changeset 7:f067504aa92a draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
author iuc
date Thu, 05 Nov 2020 23:29:40 +0000
parents 5c743356df83
children 97f70f7ed077
files README.md idr_download_by_ids.py idr_download_by_ids.xml test-data/test0.tiff
diffstat 4 files changed, 113 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Thu Nov 05 23:29:40 2020 +0000
@@ -0,0 +1,18 @@
+## Set up user credentials on Galaxy to connect to other omero instance
+
+To enable users to set their credentials for this tool,
+make sure the file `config/user_preferences_extra.yml` has the following section:
+
+```
+    omero_account:
+        description: Your OMERO instance connection credentials
+        inputs:
+            - name: username
+              label: Username
+              type: text
+              required: False
+            - name: password
+              label: Password
+              type:  password
+              required: False
+```
--- a/idr_download_by_ids.py	Mon Jul 06 19:33:59 2020 -0400
+++ b/idr_download_by_ids.py	Thu Nov 05 23:29:40 2020 +0000
@@ -112,7 +112,7 @@
     image_ids,
     channel=None, z_stack=0, frame=0,
     coord=(0, 0), width=0, height=0, region_spec='rectangle',
-    skip_failed=False, download_tar=False
+    skip_failed=False, download_tar=False, omero_host='idr.openmicroscopy.org', omero_secured=True, omero_username='public', omero_password='public'
 ):
     # basic argument sanity checks and adjustments
     prefix = 'image-'
@@ -127,14 +127,12 @@
             'Got unknown value "{0}" as region_spec argument'
             .format(region_spec)
         )
-
     with ExitStack() as exit_stack:
-        # connect to idr
         conn = exit_stack.enter_context(
             BlitzGateway(
-                'public', 'public',
-                host='idr.openmicroscopy.org',
-                secure=True
+                omero_username, omero_password,
+                host=omero_host,
+                secure=omero_secured
             )
         )
         # exit_stack.callback(conn.connect().close)
@@ -356,6 +354,18 @@
     p.add_argument(
         '--download-tar', action='store_true'
     )
+    p.add_argument(
+        '-oh', '--omero-host', type=str, default="idr.openmicroscopy.org"
+    )
+    p.add_argument(
+        '--omero-secured', action='store_false'
+    )
+    p.add_argument(
+        '-u', '--omero-username', type=str, default="public"
+    )
+    p.add_argument(
+        '-p', '--omero-password', type=str, default="public"
+    )
     args = p.parse_args()
     if not args.image_ids:
         args.image_ids = sys.stdin.read().split()
--- a/idr_download_by_ids.xml	Mon Jul 06 19:33:59 2020 -0400
+++ b/idr_download_by_ids.xml	Thu Nov 05 23:29:40 2020 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<tool id="idr_download_by_ids" name="IDR Download" version="0.42" profile="18.09">
+<tool id="idr_download_by_ids" name="IDR Download" version="0.43" profile="18.09">
     <description>- download images from the Image Data Resource using image IDs</description>
     <macros>
         <xml name="region_spec" token_pos="upper-left corner">
@@ -16,10 +16,21 @@
         </xml>
     </macros>
     <requirements>
-        <requirement type="package" version="5.6.0">python-omero</requirement>
+        <requirement type="package" version="5.7.1">python-omero</requirement>
         <requirement type="package" version="0.4.2">pylibtiff</requirement>
     </requirements>
     <command detect_errors="exit_code"><![CDATA[
+        
+        #if $omero_instance_type.omero_instance == "priv":
+            #set $username = $__user__.extra_preferences.get('omero_account|username', "")
+            #set $password = $__user__.extra_preferences.get('omero_account|password', "")
+
+            #if $username == "" or $password =="":
+                echo "OMERO connection credentials are empty. Set your credentials via: User -> Preferences -> Manage Information"  &&
+                exit 1
+            #end if
+        #end if
+        
         mkdir downloads && cd downloads &&
         #if str($image_ids.source) == 'link':
             python -c 'print("${image_ids.id_spec}".replace(",", "|").split("?show=")[-1].replace("|", "\n"))'
@@ -39,10 +50,35 @@
         #end if
         $skip_failed
         $download_tar
-
+        #if $omero_instance_type.omero_instance =='priv':
+            -h '$omero_host'
+            $omero_secured
+            -u '$username'
+            -p '$password'
+        #end if
         2> >(tee -a $out_log >&2)
     ]]></command>
 <inputs>
+        <conditional name="omero_instance_type">
+            <param name="omero_instance" type="select" label="Which OMERO instance to connect?"
+                   help="By default, the tool will download a tarball containing individual images from IDR into your Galaxy history. If you 
+                   need to connect to your own instance, set your connection username and password from User->Preference->Manage Information" >
+                <option value="idr">IDR</option>
+                <option value="priv">other OMERO instance</option>
+            </param>
+            <when value="priv">
+                <param name="omero_host" type="text" label="OMERO host URL">
+                    <validator type="regex" message="Enter a valid host location, for example, your.omero.server">
+                        [.A-Za-z0-9_-]
+                    </validator>
+                </param>
+                <param name="omero_secured" type="boolean" label="Seured connection?" checked="true" truevalue="--omero-secured" falsevalue=""
+                        help="Select Yes if your OMERO instance is running with SSL, otherwise select No">
+                </param>
+            </when>
+            <when value="idr" />
+        </conditional>
+
         <conditional name="image_ids">
             <param name="source" type="select" label="How would you like to specify the IDs of images to download?">
                 <option value="link">As text (comma-separated list of IDs or a valid IDR link)</option>
@@ -104,9 +140,32 @@
     </outputs>
     <tests>
         <test>
+            <conditional name="omero_instance_type">
+                 <param name="omero_instance" value="idr" />
+            </conditional>
             <param name="source" value="dataset" />
             <param name="id_spec" value="ids.txt" />
-            <param name="channel" value="615.0" />
+            <param name="channel" value="PCNT" />
+            <conditional name="clip_image">
+                <param name="select" value="--rectangle" />
+                <param name="x_coord" value="3" />
+                <param name="y_coord" value="3" />
+                <param name="width" value="5" />
+                <param name="height" value="5" />
+            </conditional>
+            <param name="frame" value="0" />
+            <param name="download_tar" value="false" />
+            <output_collection name="output_file" type="list">
+                <element name="Centrin_PCNT_Cep215_20110506_Fri-1545_0_SIR_PRJ__1884807__3__3__5__5" file="test0.tiff"/>
+            </output_collection>
+        </test>
+        <test>
+            <conditional name="omero_instance_type">
+                 <param name="omero_instance" value="idr" />
+            </conditional>
+            <param name="source" value="link" />
+            <param name="id_spec" value="1884807" />
+            <param name="channel" value="PCNT" />
             <conditional name="clip_image">
                 <param name="select" value="--rectangle" />
                 <param name="x_coord" value="3" />
@@ -121,26 +180,12 @@
             </output_collection>
         </test>
         <test>
+            <conditional name="omero_instance_type">
+                 <param name="omero_instance" value="idr" />
+            </conditional>
             <param name="source" value="link" />
             <param name="id_spec" value="1884807" />
-            <param name="channel" value="615.0" />
-            <conditional name="clip_image">
-                <param name="select" value="--rectangle" />
-                <param name="x_coord" value="3" />
-                <param name="y_coord" value="3" />
-                <param name="width" value="5" />
-                <param name="height" value="5" />
-            </conditional>
-            <param name="frame" value="2" />
-            <param name="download_tar" value="false" />
-            <output_collection name="output_file" type="list">
-                <element name="Centrin_PCNT_Cep215_20110506_Fri-1545_0_SIR_PRJ__1884807__3__3__5__5" file="test1.tiff"/>
-            </output_collection>
-        </test>
-        <test>
-            <param name="source" value="link" />
-            <param name="id_spec" value="1884807" />
-            <param name="channel" value="615.0" />
+            <param name="channel" value="PCNT" />
             <conditional name="clip_image">
                 <param name="select" value="--center" />
                 <param name="x_coord" value="5" />
@@ -155,6 +200,9 @@
             </output_collection>
         </test>
         <test>
+            <conditional name="omero_instance_type">
+                 <param name="omero_instance" value="idr" />
+            </conditional>
             <param name="source" value="link" />
             <param name="id_spec" value="https://idr.openmicroscopy.org/webclient/?show=image-9036708|image-9036710|image-9036711" />
             <param name="channel" value="Spo20(51-91)" />
@@ -179,6 +227,9 @@
             </output>
         </test>
         <test expect_failure="true">
+            <conditional name="omero_instance_type">
+                 <param name="omero_instance" value="idr" />
+            </conditional>
             <!-- Test behavior with non-existing image-ID 9036708999 -->
             <param name="source" value="link" />
             <param name="id_spec" value="https://idr.openmicroscopy.org/webclient/?show=image-9036708999|image-9036710|image-9036711" />
@@ -193,6 +244,9 @@
         <test>
             <!-- Repeat test with non-existing image-ID 9036708999,
             but use skip-failed option -->
+            <conditional name="omero_instance_type">
+                 <param name="omero_instance" value="idr" />
+            </conditional>
             <param name="source" value="link" />
             <param name="id_spec" value="https://idr.openmicroscopy.org/webclient/?show=image-9036708999|image-9036710|image-9036711" />
             <param name="channel" value="Spo20(51-91)" />
@@ -219,6 +273,9 @@
             </output>
         </test>
         <test>
+            <conditional name="omero_instance_type">
+                 <param name="omero_instance" value="idr" />
+            </conditional>
             <!-- Test for download images in a tarball -->
             <param name="source" value="dataset" />
             <param name="id_spec" value="ids_tar.txt" />
Binary file test-data/test0.tiff has changed