comparison idr_download_by_ids.py @ 8:97f70f7ed077 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
author iuc
date Sun, 22 Nov 2020 13:55:01 +0000
parents f067504aa92a
children 4aed70472589
comparison
equal deleted inserted replaced
7:f067504aa92a 8:97f70f7ed077
1 import argparse 1 import argparse
2 import json
2 import os 3 import os
3 import sys 4 import sys
4 import tarfile 5 import tarfile
5 from contextlib import ExitStack 6 from contextlib import ExitStack
6 from tempfile import TemporaryDirectory 7 from tempfile import TemporaryDirectory
110 111
111 def download_image_data( 112 def download_image_data(
112 image_ids, 113 image_ids,
113 channel=None, z_stack=0, frame=0, 114 channel=None, z_stack=0, frame=0,
114 coord=(0, 0), width=0, height=0, region_spec='rectangle', 115 coord=(0, 0), width=0, height=0, region_spec='rectangle',
115 skip_failed=False, download_tar=False, omero_host='idr.openmicroscopy.org', omero_secured=True, omero_username='public', omero_password='public' 116 skip_failed=False, download_tar=False, omero_host='idr.openmicroscopy.org', omero_secured=False, config_file=None
116 ): 117 ):
118
119 if config_file is None: # IDR connection
120 omero_username = 'public'
121 omero_password = 'public'
122 else: # other omero instance
123 with open(config_file) as f:
124 cfg = json.load(f)
125 omero_username = cfg['username']
126 omero_password = cfg['password']
127
128 if omero_username == "" or omero_password == "":
129 omero_username = 'public'
130 omero_password = 'public'
131
117 # basic argument sanity checks and adjustments 132 # basic argument sanity checks and adjustments
118 prefix = 'image-' 133 prefix = 'image-'
119 # normalize image ids by stripping off prefix if it exists 134 # normalize image ids by stripping off prefix if it exists
120 image_ids = [ 135 image_ids = [
121 iid[len(prefix):] if iid[:len(prefix)] == prefix else iid 136 iid[len(prefix):] if iid[:len(prefix)] == prefix else iid
356 ) 371 )
357 p.add_argument( 372 p.add_argument(
358 '-oh', '--omero-host', type=str, default="idr.openmicroscopy.org" 373 '-oh', '--omero-host', type=str, default="idr.openmicroscopy.org"
359 ) 374 )
360 p.add_argument( 375 p.add_argument(
361 '--omero-secured', action='store_false' 376 '--omero-secured', action='store_true', default=True
362 ) 377 )
363 p.add_argument( 378 p.add_argument(
364 '-u', '--omero-username', type=str, default="public" 379 '-cf', '--config-file', dest='config_file', default=None
365 )
366 p.add_argument(
367 '-p', '--omero-password', type=str, default="public"
368 ) 380 )
369 args = p.parse_args() 381 args = p.parse_args()
370 if not args.image_ids: 382 if not args.image_ids:
371 args.image_ids = sys.stdin.read().split() 383 args.image_ids = sys.stdin.read().split()
372 if 'center' in args: 384 if 'center' in args: