Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idr download #539

Merged
merged 4 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions utils/idr-download-tool/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[bumpversion]
current_version = 0.1.0-dev0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<dev>\d+))?
serialize =
{major}.{minor}.{patch}-{release}{dev}
{major}.{minor}.{patch}

[bumpversion:part:release]
optional_value = _
first_value = dev
values =
dev
_

[bumpversion:part:dev]

[bumpversion:file:pyproject.toml]
search = version = "{current_version}"
replace = version = "{new_version}"

[bumpversion:file:plugin.json]

[bumpversion:file:VERSION]

[bumpversion:file:src/polus/images/utils/idr_download/__init__.py]
28 changes: 28 additions & 0 deletions utils/idr-download-tool/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM continuumio/miniconda3

# environment variables defined in polusai/bfio
ENV EXEC_DIR="/opt/executables"
ENV POLUS_IMG_EXT=".ome.tif"
ENV POLUS_TAB_EXT=".csv"
ENV POLUS_LOG="INFO"

ARG conda_env=myidrenv

# Work directory defined in the base container
WORKDIR ${EXEC_DIR}

COPY pyproject.toml ${EXEC_DIR}
COPY environment.yml ${EXEC_DIR}
COPY VERSION ${EXEC_DIR}
COPY README.md ${EXEC_DIR}
COPY src ${EXEC_DIR}/src

RUN conda env create -f environment.yml

ENV PATH /opt/conda/envs/myidrenv/bin:$PATH
RUN /bin/bash -c "source activate myidrenv"

RUN pip3 install ${EXEC_DIR} --no-cache-dir

ENTRYPOINT ["python3", "-m", "polus.images.utils.idr_download"]
CMD ["--help"]
41 changes: 41 additions & 0 deletions utils/idr-download-tool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Idr Download (v0.1.0-dev0)

This tool enables the retrieval of data from the [idr](https://idr.openmicroscopy.org/) using the IDR web API.

## Note
In order to retrieve data from the IDR web server, users need to establish a VPN connection


Conda is employed to install all dependencies because one of the critical packages, `omero-py`, encountered installation issues with pip

Currently, the supported object types in a tool include: `project`, `dataset`, `screen`, `plate`, `well`


## Building

To build the Docker image for the download plugin, run
`bash build-docker.sh`.

## Run the Docker image

To execute the built docker image for the download plugin, run
`bash run-plugin.sh`.

## Options

This plugin takes 4 input arguments and
1 output argument:

| Name | Description | I/O | Type |
| --------------- | ------------------------------------------------------------ | ------ | ----------- |
| `--dataType` | Object types to be retreived from Idr Server | Input | String |
| `--name ` | Name of an object | Input | String |
| `--objectId ` | Identification of an object of an object | Input | Integer |
| `--outDir` | Directory to store the downloaded data | Output | genericData |
| `--preview` | Generate a JSON file with outputs | Output | JSON |



## Sample docker command:
```bash
docker run -v /home/ec2-user/data/:/home/ec2-user/data/ polusai/idr-download-tool:0.1.0-dev0 --dataType="plate" --name='plate1_1_013' --outDir=/home/ec2-user/data/output```
1 change: 1 addition & 0 deletions utils/idr-download-tool/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0-dev0
4 changes: 4 additions & 0 deletions utils/idr-download-tool/build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

version=$(<VERSION)
docker build . -t polusai/idr-download-tool:${version}
13 changes: 13 additions & 0 deletions utils/idr-download-tool/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: myidrenv
channels:
- defaults
- conda-forge
dependencies:
- python==3.9.18
- numpy==1.21.0
- bfio=*
- ome:omero-py
- pydantic=*
- pip
- pip:
- preadator==0.4.0-dev2
67 changes: 67 additions & 0 deletions utils/idr-download-tool/ict.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
author:
- Hamdah Shafqat
contact: hamdahshafqat.abbasi@nih.gov
container: polusai/idr-download-tool:0.1.0-dev0
description: This plugin allows to retrieve the microscopy image data from the https://idr.openmicroscopy.org.
entrypoint: python3 -m polus.images.utils.idr_download
inputs:
- description: The supported object types to be retreived.
format:
- dataType
name: dataType
required: true
type: string
- description: Name of the object to be downloaded.
format:
- name
name: name
required: false
type: string
- description: Identifier of the object to be downloaded.
format:
- objectId
name: objectId
required: false
type: number
- description: Generate an output preview.
format:
- preview
name: preview
required: false
type: boolean
name: polusai/IdrDownload
outputs:
- description: Output collection.
format:
- outDir
name: outDir
required: true
type: path
repository: https://github.com/PolusAI/image-tools
specVersion: 1.0.0
title: Idr Download
ui:
- description: The supported object types to be retreived.
fields:
- project
- dataset
- screen
- plate
- well
- default
key: inputs.dataType
title: dataType
type: select
- description: Name of the object to be downloaded.
key: inputs.name
title: name
type: text
- description: Identifier of the object to be downloaded.
key: inputs.objectId
title: objectId
type: number
- description: Generate an output preview.
key: inputs.preview
title: Preview example output of this plugin
type: checkbox
version: 0.1.0-dev0
36 changes: 36 additions & 0 deletions utils/idr-download-tool/idrdownload.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class: CommandLineTool
cwlVersion: v1.2
inputs:
dataType:
inputBinding:
prefix: --dataType
type: string
name:
inputBinding:
prefix: --name
type: string?
objectId:
inputBinding:
prefix: --objectId
type: double?
outDir:
inputBinding:
prefix: --outDir
type: Directory
preview:
inputBinding:
prefix: --preview
type: boolean?
outputs:
outDir:
outputBinding:
glob: $(inputs.outDir.basename)
type: Directory
requirements:
DockerRequirement:
dockerPull: polusai/idr-download-tool:0.1.0-dev0
InitialWorkDirRequirement:
listing:
- entry: $(inputs.outDir)
writable: true
InlineJavascriptRequirement: {}
96 changes: 96 additions & 0 deletions utils/idr-download-tool/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"name": "Idr Download",
"version": "0.1.0-dev0",
"containerId": "polusai/idr-download-tool:0.1.0-dev0",
"title": "Omero Download",
"description": "This plugin allows to retrieve the microscopy image data from the https://idr.openmicroscopy.org.",
"author": "Hamdah Shafqat Abbasi (hamdahshafqat.abbasi@nih.gov)",
"institution": "National Center for Advancing Translational Sciences, National Institutes of Health",
"repository": "https://github.com/PolusAI/image-tools",
"website": "https://ncats.nih.gov/preclinical/core/informatics",
"citation": "",
"baseCommand": [
"python3",
"-m",
"polus.images.utils.idr_download"
],
"inputs": [
{
"name": "dataType",
"type": "enum",
"title": "dataType",
"description": "The supported object types to be retreived.",
"default": "default",
"options": {
"values": [
"project",
"dataset",
"screen",
"plate",
"well",
"default"
]
},
"required": true
},
{
"name": "name",
"type": "string",
"title": "name",
"description": "Name of the object to be downloaded.",
"required": "False"
},
{
"name": "objectId",
"type": "integer",
"title": "objectId",
"description": "Identifier of the object to be downloaded.",
"required": "False"
},
{
"name": "preview",
"type": "boolean",
"title": "Preview",
"description": "Generate an output preview.",
"required": "False"
}
],
"outputs": [
{
"name": "outDir",
"type": "genericData",
"description": "Output collection."
}
],
"ui": [
{
"key": "inputs.dataType",
"type": "enum",
"title": "dataType",
"description": "The supported object types to be retreived.",
"default": "dataset",
"required": "True"
},
{
"key": "inputs.name",
"type": "string",
"title": "name",
"description": "Name of the object to be downloaded.",
"required": "False"
},
{
"key": "inputs.objectId",
"type": "integer",
"title": "objectId",
"description": "Identifier of the object to be downloaded.",
"required": "False"
},
{
"key": "inputs.preview",
"type": "boolean",
"title": "Preview example output of this plugin",
"description": "Generate an output preview.",
"required": "False"
}
]
}
43 changes: 43 additions & 0 deletions utils/idr-download-tool/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[tool.poetry]
name = "polus-images-utils-idr-download"
version = "0.1.0-dev0"
description = "Retrieve the microscopy image data from the idr server"
authors = [
"Hamdah Shafqat abbasi <hamdahshafqat.abbasi@nih.gov>"
]
readme = "README.md"
packages = [{include = "polus", from = "src"}]

[tool.poetry.dependencies]
python = "3.9.18"
bfio = {version = "^2.3.6", extras = ["all"]}
typer = "^0.7.0"
pydantic = "^2.5.3"
pandas = "2.2.2"
preadator = "0.4.0-dev2"
tqdm = "^4.66.2"

[[tool.poetry.source]]
name = "test"
url = "https://test.pypi.org/simple/"
default = false
secondary = true

[tool.poetry.group.dev.dependencies]
bump2version = "^1.0.1"
flake8 = "^6.0.0"
pre-commit = "^3.2.1"
flake8-docstrings = "^1.7.0"
black = "^23.3.0"
mypy = "^1.1.1"
pytest = "^7.2.2"
ruff = "^0.0.270"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.pytest.ini_options]
pythonpath = [
"."
]
21 changes: 21 additions & 0 deletions utils/idr-download-tool/run-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

version=$(<VERSION)
datapath=$(readlink --canonicalize data)
echo ${datapath}

# Inputs
out_dir=${datapath}/out
data_type="plate"
object_id=3139


# #Show the help options
# #docker run polusai/polusai/idr_download-tool:${version}

docker run -v ${datapath}:${datapath} \
polusai/idr_download-tool:${version} \
--dataType ${data_type} \
--name ${name} \
--objectId ${object_id} \
--outDir ${out_dir}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Idr Download Package."""

__version__ = "0.1.0-dev0"
Loading
Loading