annotate idr_download_by_ids.py @ 12:4b794652dcdc draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 18d21cc8fc24236c514ffe31332bfa13cd08d1e9
author iuc
date Wed, 08 Nov 2023 12:57:25 +0000
parents cbd605a24336
children f92941d1a85e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
1 import argparse
8
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
2 import json
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
3 import os
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
4 import sys
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
5 import tarfile
6
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
6 from contextlib import ExitStack
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
7 from tempfile import TemporaryDirectory
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
8
2
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
9 from libtiff import TIFF
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
10 from omero.cli import cli_login
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
11 from omero.gateway import BlitzGateway # noqa
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
12 from omero.constants.namespaces import NSBULKANNOTATIONS # noqa
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
13
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
14
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
15 def warn(message, image_identifier, warn_skip=False):
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
16 message = message.rstrip()
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
17 if warn_skip:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
18 if message[-1] in ['.', '!', '?']:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
19 skip_msg = ' Skipping download!'
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
20 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
21 skip_msg = '. Skipping download!'
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
22 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
23 skip_msg = ''
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
24 print(
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
25 'ImageSpecWarning for {0}: {1}{2}'
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
26 .format(
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
27 image_identifier,
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
28 message,
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
29 skip_msg
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
30 ),
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
31 file=sys.stderr
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
32 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
33
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
34
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
35 def find_channel_index(image, channel_name):
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
36 channel_name = channel_name.lower()
2
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
37 for n, channel in enumerate(image.getChannelLabels()):
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
38 if channel_name == channel.lower():
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
39 return n
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
40 # Check map annotation for information (this is necessary for some images)
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
41 for ann in image.listAnnotations(NSBULKANNOTATIONS):
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
42 pairs = ann.getValue()
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
43 for p in pairs:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
44 if p[0] == "Channels":
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
45 channels = p[1].replace(" ", "").split(";")
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
46 for n, c in enumerate(channels):
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
47 for value in c.split(':'):
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
48 if channel_name == value.lower():
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
49 return n
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
50 return -1
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
51
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
52
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
53 def get_clipping_region(image, x, y, w, h):
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
54 # If the (x, y) coordinate falls outside the image boundaries, we
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
55 # cannot just shift it because that would render the meaning of
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
56 # w and h undefined (should width and height be decreased or the whole
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
57 # region be shifted to keep them fixed?).
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
58 # It may be better to abort in this situation.
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
59 if x < 0 or y < 0:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
60 raise ValueError(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
61 'Too small upper left coordinate ({0}, {1}) for clipping region.'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
62 .format(x, y)
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
63 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
64 size_x = image.getSizeX()
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
65 size_y = image.getSizeY()
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
66 if x >= size_x or y >= size_y:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
67 raise ValueError(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
68 'Upper left coordinate ({0}, {1}) of clipping region lies '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
69 'outside of image.'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
70 .format(x, y)
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
71 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
72 # adjust width and height to the image dimensions
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
73 if w <= 0 or x + w > size_x:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
74 w = size_x - x
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
75 if h <= 0 or y + h > size_y:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
76 h = size_y - y
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
77 return [x, y, w, h]
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
78
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
79
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
80 def confine_plane(image, z):
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
81 if z < 0:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
82 z = 0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
83 else:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
84 max_z = image.getSizeZ() - 1
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
85 if z > max_z:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
86 z = max_z
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
87 return z
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
88
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
89
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
90 def confine_frame(image, t):
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
91 if t < 0:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
92 t = 0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
93 else:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
94 max_t = image.getSizeT() - 1
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
95 if t > max_t:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
96 t = max_t
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
97 return t
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
98
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
99
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
100 def get_image_array(image, tile, z, c, t):
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
101 pixels = image.getPrimaryPixels()
2
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
102 try:
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
103 selection = pixels.getTile(theZ=z, theT=t, theC=c, tile=tile)
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
104 except Exception:
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
105 warning = '{0} (ID: {1})'.format(image.getName(),
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
106 image.getId())
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
107 warn('Could not download the requested region', warning)
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
108 return
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
109
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
110 return selection
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
111
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
112
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
113 def download_image_data(
10
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
114 image_ids_or_dataset_id, dataset=False,
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
115 download_original=False,
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
116 channel=None, z_stack=0, frame=0,
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
117 coord=(0, 0), width=0, height=0, region_spec='rectangle',
8
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
118 skip_failed=False, download_tar=False, omero_host='idr.openmicroscopy.org', omero_secured=False, config_file=None
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
119 ):
8
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
120
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
121 if config_file is None: # IDR connection
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
122 omero_username = 'public'
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
123 omero_password = 'public'
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
124 else: # other omero instance
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
125 with open(config_file) as f:
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
126 cfg = json.load(f)
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
127 omero_username = cfg['username']
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
128 omero_password = cfg['password']
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
129
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
130 if omero_username == "" or omero_password == "":
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
131 omero_username = 'public'
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
132 omero_password = 'public'
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
133
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
134 if not download_original and region_spec not in ['rectangle', 'center']:
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
135 raise ValueError(
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
136 'Got unknown value "{0}" as region_spec argument'
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
137 .format(region_spec)
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
138 )
6
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
139 with ExitStack() as exit_stack:
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
140 conn = exit_stack.enter_context(
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
141 BlitzGateway(
7
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
142 omero_username, omero_password,
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
143 host=omero_host,
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
144 secure=omero_secured
6
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
145 )
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
146 )
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
147 # exit_stack.callback(conn.connect().close)
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
148 if download_tar:
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
149 # create an archive file to write images to
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
150 archive = exit_stack.enter_context(
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
151 tarfile.open('images.tar', mode='w')
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
152 )
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
153 tempdir = exit_stack.enter_context(
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
154 TemporaryDirectory()
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
155 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
156
10
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
157 if dataset:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
158 dataset_warning_id = 'Dataset-ID: {0}'.format(image_ids_or_dataset_id[0])
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
159 try:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
160 dataset_id = int(image_ids_or_dataset_id[0])
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
161 except ValueError:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
162 image_ids = None
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
163 else:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
164 try:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
165 dataset = conn.getObject("Dataset", dataset_id)
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
166 except Exception as e:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
167 # respect skip_failed on unexpected errors
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
168 if skip_failed:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
169 warn(str(e), dataset_warning_id, warn_skip=True)
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
170 else:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
171 raise
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
172 else:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
173 image_ids = [image.id for image in dataset.listChildren()]
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
174
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
175 if image_ids is None:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
176 if skip_failed:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
177 warn(
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
178 'Unable to find a dataset with this ID in the '
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
179 'database.',
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
180 dataset_warning_id,
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
181 warn_skip=True
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
182 )
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
183 else:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
184 raise ValueError(
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
185 '{0}: Unable to find a dataset with this ID in the '
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
186 'database. Aborting!'
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
187 .format(dataset_warning_id)
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
188 )
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
189
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
190 else:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
191 # basic argument sanity checks and adjustments
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
192 prefix = 'image-'
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
193 # normalize image ids by stripping off prefix if it exists
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
194 image_ids = [
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
195 iid[len(prefix):] if iid[:len(prefix)] == prefix else iid
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
196 for iid in image_ids_or_dataset_id
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
197 ]
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
198 for image_id in image_ids:
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
199 image_warning_id = 'Image-ID: {0}'.format(image_id)
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
200 try:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
201 image_id = int(image_id)
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
202 except ValueError:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
203 image = None
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
204 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
205 try:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
206 image = conn.getObject("Image", image_id)
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
207 except Exception as e:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
208 # respect skip_failed on unexpected errors
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
209 if skip_failed:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
210 warn(str(e), image_warning_id, warn_skip=True)
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
211 continue
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
212 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
213 raise
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
214
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
215 if image is None:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
216 if skip_failed:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
217 warn(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
218 'Unable to find an image with this ID in the '
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
219 'database.',
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
220 image_warning_id,
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
221 warn_skip=True
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
222 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
223 continue
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
224 raise ValueError(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
225 '{0}: Unable to find an image with this ID in the '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
226 'database. Aborting!'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
227 .format(image_warning_id)
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
228 )
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
229 if not download_original:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
230 try:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
231 # try to extract image properties
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
232 # if anything goes wrong here skip the image
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
233 # or abort.
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
234 image_name = os.path.splitext(image.getName())[0]
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
235 image_warning_id = '{0} (ID: {1})'.format(
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
236 image_name, image_id
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
237 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
238
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
239 if region_spec == 'rectangle':
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
240 tile = get_clipping_region(image, *coord, width, height)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
241 elif region_spec == 'center':
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
242 tile = get_clipping_region(
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
243 image,
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
244 *_center_to_ul(*coord, width, height)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
245 )
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
246
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
247 ori_z, z_stack = z_stack, confine_plane(image, z_stack)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
248 ori_frame, frame = frame, confine_frame(image, frame)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
249 num_channels = image.getSizeC()
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
250 if channel is None:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
251 channel_index = 0
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
252 else:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
253 channel_index = find_channel_index(image, channel)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
254 except Exception as e:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
255 # respect skip_failed on unexpected errors
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
256 if skip_failed:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
257 warn(str(e), image_warning_id, warn_skip=True)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
258 continue
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
259 else:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
260 raise
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
261
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
262 # region sanity checks and warnings
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
263 if tile[2] < width or tile[3] < height:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
264 # The downloaded image region will have smaller dimensions
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
265 # than the specified width x height.
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
266 warn(
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
267 'Downloaded image dimensions ({0} x {1}) will be smaller '
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
268 'than the specified width and height ({2} x {3}).'
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
269 .format(tile[2], tile[3], width, height),
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
270 image_warning_id
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
271 )
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
272
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
273 # z-stack sanity checks and warnings
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
274 if z_stack != ori_z:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
275 warn(
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
276 'Specified image plane ({0}) is out of bounds. Using {1} '
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
277 'instead.'
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
278 .format(ori_z, z_stack),
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
279 image_warning_id
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
280 )
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
281
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
282 # frame sanity checks and warnings
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
283 if frame != ori_frame:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
284 warn(
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
285 'Specified image frame ({0}) is out of bounds. Using '
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
286 'frame {1} instead.'
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
287 .format(ori_frame, frame),
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
288 image_warning_id
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
289 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
290
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
291 # channel index sanity checks and warnings
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
292 if channel is None:
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
293 if num_channels > 1:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
294 warn(
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
295 'No specific channel selected for multi-channel '
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
296 'image. Using first of {0} channels.'
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
297 .format(num_channels),
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
298 image_warning_id
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
299 )
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
300 else:
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
301 if channel_index == -1 or channel_index >= num_channels:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
302 if skip_failed:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
303 warn(
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
304 str(channel)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
305 + ' is not a known channel name for this image.',
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
306 image_warning_id,
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
307 warn_skip=True
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
308 )
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
309 continue
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
310 else:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
311 raise ValueError(
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
312 '"{0}" is not a known channel name for image {1}. '
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
313 'Aborting!'
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
314 .format(channel, image_warning_id)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
315 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
316
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
317 # download and save the region as TIFF
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
318 fname = '__'.join(
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
319 [image_name, str(image_id)] + [str(x) for x in tile]
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
320 )
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
321 try:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
322 if fname[-5:] != '.tiff':
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
323 fname += '.tiff'
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
324
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
325 fname = fname.replace(' ', '_')
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
326
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
327 im_array = get_image_array(image, tile, z_stack, channel_index, frame)
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
328
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
329 if download_tar:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
330 fname = os.path.join(tempdir, fname)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
331 try:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
332 tiff = TIFF.open(fname, mode='w')
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
333 tiff.write_image(im_array)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
334 finally:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
335 tiff.close()
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
336 # move image into tarball
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
337 if download_tar:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
338 archive.add(fname, os.path.basename(fname))
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
339 os.remove(fname)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
340 except Exception as e:
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
341 if skip_failed:
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
342 # respect skip_failed on unexpected errors
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
343 warn(str(e), image_warning_id, warn_skip=True)
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
344 continue
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
345 else:
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
346 raise
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
347 else:
6
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
348 try:
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
349 # try to extract image properties
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
350 # if anything goes wrong here skip the image
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
351 # or abort.
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
352 image_name = os.path.splitext(image.getName())[0]
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
353 image_warning_id = '{0} (ID: {1})'.format(
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
354 image_name, image_id
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
355 )
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
356 original_image_name = image.getFileset().listFiles()[0].getName()
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
357 fname = image_name + "__" + str(image_id) + os.path.splitext(original_image_name)[1]
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
358 fname = fname.replace(' ', '_')
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
359 fname = fname.replace('/', '_')
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
360 download_directory = "./"
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
361 if download_tar:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
362 download_directory = tempdir
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
363 with cli_login("-u", omero_username, "-s", omero_host, "-w", omero_password) as cli:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
364 cli.invoke(["download", f"Image:{image_id}", download_directory])
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
365 if cli.rv != 0:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
366 raise Exception("Download failed.")
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
367 # This will download to download_directory/original_image_name
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
368 os.rename(os.path.join(download_directory, original_image_name),
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
369 os.path.join(download_directory, fname))
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
370 # move image into tarball
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
371 if download_tar:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
372 archive.add(os.path.join(download_directory, fname),
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
373 os.path.basename(fname))
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
374 os.remove(os.path.join(download_directory, fname))
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
375 except Exception as e:
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
376 # respect skip_failed on unexpected errors
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
377 if skip_failed:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
378 warn(str(e), image_warning_id, warn_skip=True)
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
379 continue
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
380 else:
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
381 raise
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
382
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
383
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
384 def _center_to_ul(center_x, center_y, width, height):
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
385 if width > 0:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
386 ext_x = (width - 1) // 2
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
387 ul_x = max([center_x - ext_x, 0])
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
388 width = center_x + ext_x + 1 - ul_x
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
389 else:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
390 ul_x = 0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
391 if height > 0:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
392 ext_y = (height - 1) // 2
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
393 ul_y = max([center_y - ext_y, 0])
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
394 height = center_y + ext_y + 1 - ul_y
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
395 else:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
396 ul_y = 0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
397 return ul_x, ul_y, width, height
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
398
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
399
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
400 if __name__ == "__main__":
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
401 p = argparse.ArgumentParser()
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
402 p.add_argument(
10
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
403 'image_ids_or_dataset_id', nargs='*', default=[],
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
404 help='one or more IDR image ids or a single dataset id'
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
405 'for which to retrieve data (default: '
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
406 'read ids from stdin).'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
407 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
408 p.add_argument(
11
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
409 '--download-original', dest='download_original', action='store_true',
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
410 help="download the original file uploaded to omero"
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
411 )
cbd605a24336 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit b68715960d1107593db13dd9e1dbd8d4b905cc6f"
iuc
parents: 10
diff changeset
412 p.add_argument(
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
413 '-c', '--channel',
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
414 help='name of the channel to retrieve data for '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
415 '(note: the first channel of each image will be downloaded if '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
416 'left unspecified)'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
417 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
418 region = p.add_mutually_exclusive_group()
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
419 region.add_argument(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
420 '--rectangle', nargs=4, type=int, default=argparse.SUPPRESS,
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
421 help='specify a clipping region for the image as x y width height, '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
422 'where x and y give the upper left coordinate of the rectangle '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
423 'to clip to. Set width and height to 0 to extend the rectangle '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
424 'to the actual size of the image.'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
425 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
426 region.add_argument(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
427 '--center', nargs=4, type=int, default=argparse.SUPPRESS,
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
428 help='specify a clipping region for the image as x y width height, '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
429 'where x and y define the center of a width x height rectangle. '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
430 'Set either width or height to 0 to extend the region to the '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
431 'actual size of the image along the x- or y-axis.\n'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
432 'Note: Even values for width and height will be rounded down to '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
433 'the nearest odd number.'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
434 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
435 p.add_argument(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
436 '-f', '--frame', type=int, default=0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
437 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
438 p.add_argument(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
439 '-z', '--z-stack', type=int, default=0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
440 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
441 p.add_argument(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
442 '--skip-failed', action='store_true'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
443 )
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
444 p.add_argument(
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
445 '--download-tar', action='store_true'
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
446 )
7
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
447 p.add_argument(
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
448 '-oh', '--omero-host', type=str, default="idr.openmicroscopy.org"
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
449 )
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
450 p.add_argument(
8
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
451 '--omero-secured', action='store_true', default=True
7
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
452 )
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
453 p.add_argument(
8
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
454 '-cf', '--config-file', dest='config_file', default=None
7
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
455 )
10
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
456 p.add_argument(
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
457 '--dataset', action='store_true'
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
458 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
459 args = p.parse_args()
10
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
460 if not args.image_ids_or_dataset_id:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
461 args.image_ids_or_dataset_id = sys.stdin.read().split()
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
462 if args.dataset and len(args.image_ids_or_dataset_id) > 1:
4aed70472589 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bb22e94226d3bcf241a6fe27e426b541a36a0815"
iuc
parents: 8
diff changeset
463 warn("Multiple dataset ids provided. Only the first one will be used.")
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
464 if 'center' in args:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
465 args.coord, args.width, args.height = (
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
466 args.center[:2], args.center[2], args.center[3]
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
467 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
468 args.region_spec = 'center'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
469 del args.center
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
470 elif 'rectangle' in args:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
471 args.coord, args.width, args.height = (
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
472 args.rectangle[:2], args.rectangle[2], args.rectangle[3]
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
473 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
474 args.region_spec = 'rectangle'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
475 del args.rectangle
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
476 download_image_data(**vars(args))