annotate idr_download_by_ids.py @ 4:11036f6197d6 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
author iuc
date Fri, 15 May 2020 14:54:02 -0400
parents 381f248febba
children e08b1dc0480c
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
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
2 import os
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
3 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
4 import tarfile
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
5
2
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
6 from libtiff import TIFF
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
7 from PIL import Image
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
8 from tempfile import TemporaryFile
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
9 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
10 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
11
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
12
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
13 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
14 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
15 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
16 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
17 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
18 else:
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 = ''
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
22 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
23 '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
24 .format(
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
25 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
26 message,
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
27 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
28 ),
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
29 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
30 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
31
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 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
34 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
35 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
36 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
37 return n
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
38 # 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 return n
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
48 return -1
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
49
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
50
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
51 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
52 # 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
53 # 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
54 # 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
55 # 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
56 # 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
57 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
58 raise ValueError(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
59 '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
60 .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
61 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
62 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
63 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
64 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
65 raise ValueError(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
66 '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
67 '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
68 .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
69 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
70 # 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
71 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
72 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
73 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
74 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
75 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
76
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
77
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
78 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
79 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
80 z = 0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
81 else:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
82 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
83 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
84 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
85 return z
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
86
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
87
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
88 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
89 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
90 t = 0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
91 else:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
92 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
93 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
94 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
95 return t
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
96
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
97
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
98 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
99 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
100 try:
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
101 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
102 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
103 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
104 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
105 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
106 return
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
107
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
108 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
109
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
110
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
111 def download_image_data(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
112 image_ids,
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
113 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
114 coord=(0, 0), width=0, height=0, region_spec='rectangle',
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
115 skip_failed=False, download_tar=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 ):
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
117 # basic argument sanity checks and adjustments
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
118 prefix = 'image-'
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
119 # normalize image ids by stripping off prefix if it exists
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
120 image_ids = [
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
121 iid[len(prefix):] if iid[:len(prefix)] == prefix else iid
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
122 for iid in image_ids
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
123 ]
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
124
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
125 if region_spec not in ['rectangle', 'center']:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
126 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
127 '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
128 .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
129 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
130
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
131 # connect to idr
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
132 conn = BlitzGateway('public', 'public',
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
133 host='idr.openmicroscopy.org',
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
134 secure=True)
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
135 conn.connect()
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
136
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
137 if download_tar:
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
138 # create an archive file to write images to
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
139 archive = tarfile.open('images.tar', mode='w')
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
140
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
141 try:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
142 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
143 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
144 try:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
145 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
146 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
147 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
148 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
149 try:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
150 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
151 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
152 # 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
153 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
154 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
155 continue
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
156 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
157 raise
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
158
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
159 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
160 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
161 warn(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
162 '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
163 'database.',
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
164 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
165 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
166 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
167 continue
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
168 raise ValueError(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
169 '{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
170 'database. Aborting!'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
171 .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
172 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
173
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
174 try:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
175 # try to extract image properties
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
176 # if anything goes wrong here skip the image
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
177 # or abort.
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
178 image_name = os.path.splitext(image.getName())[0]
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
179 image_warning_id = '{0} (ID: {1})'.format(
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
180 image_name, 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
181 )
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
182
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
183 if region_spec == 'rectangle':
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
184 tile = get_clipping_region(image, *coord, width, height)
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
185 elif region_spec == 'center':
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
186 tile = get_clipping_region(
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
187 image,
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
188 *_center_to_ul(*coord, width, height)
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
189 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
190
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
191 ori_z, z_stack = z_stack, confine_plane(image, z_stack)
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
192 ori_frame, frame = frame, confine_frame(image, frame)
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
193 num_channels = image.getSizeC()
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
194 if channel is None:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
195 channel_index = 0
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
196 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
197 channel_index = find_channel_index(image, channel)
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
198 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
199 # 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
200 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
201 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
202 continue
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
203 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
204 raise
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
205
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
206 # region sanity checks and warnings
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
207 if tile[2] < width or tile[3] < height:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
208 # The downloaded image region will have smaller dimensions
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
209 # than the specified width x height.
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
210 warn(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
211 'Downloaded image dimensions ({0} x {1}) will be smaller '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
212 'than the specified width and height ({2} x {3}).'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
213 .format(tile[2], tile[3], width, height),
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
214 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
215 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
216
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
217 # z-stack sanity checks and warnings
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
218 if z_stack != ori_z:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
219 warn(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
220 'Specified image plane ({0}) is out of bounds. Using {1} '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
221 'instead.'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
222 .format(ori_z, z_stack),
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
223 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
224 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
225
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
226 # frame sanity checks and warnings
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
227 if frame != ori_frame:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
228 warn(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
229 'Specified image frame ({0}) is out of bounds. Using '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
230 'frame {1} instead.'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
231 .format(ori_frame, frame),
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
232 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
233 )
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
234
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
235 # channel index sanity checks and warnings
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
236 if channel is None:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
237 if num_channels > 1:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
238 warn(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
239 'No specific channel selected for multi-channel '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
240 'image. Using first of {0} channels.'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
241 .format(num_channels),
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
242 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
243 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
244 else:
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
245 if channel_index == -1 or channel_index >= num_channels:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
246 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
247 warn(
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
248 str(channel)
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
249 + ' is not a known channel name for this image.',
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
250 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
251 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
252 )
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
253 continue
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
254 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
255 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
256 '"{0}" is not a known channel name for image {1}. '
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
257 'Aborting!'
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
258 .format(channel, 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
259 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
260
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
261 # download and save the region as TIFF
1
9340cbc7796c "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit c496b34c7f6265cccd9326fd239542d9e625c1a4"
iuc
parents: 0
diff changeset
262 fname = '__'.join(
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
263 [image_name, str(image_id)] + [str(x) for x in tile]
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
264 )
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
265 try:
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
266 if fname[-5:] != '.tiff':
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
267 fname += '.tiff'
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
268
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
269 fname = fname.replace(' ', '_')
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
270
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
271 im_array = get_image_array(image, tile, z_stack, channel_index, frame)
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
272
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
273 # pack images into tarball
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
274 if download_tar:
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
275 tar_img = Image.fromarray(im_array)
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
276 # Use TemporaryFile() for intermediate storage of images.
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
277 # TO DO: could this be improved by using
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
278 # SpooledTemporaryFile with a suitable max_size?
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
279 with TemporaryFile() as buf:
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
280 tar_img.save(buf, format='TIFF')
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
281 tarinfo = tarfile.TarInfo(name=fname)
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
282 buf.seek(0, 2)
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
283 tarinfo.size = buf.tell()
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
284 buf.seek(0)
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
285 archive.addfile(tarinfo=tarinfo, fileobj=buf)
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
286 else: # save image as individual file
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
287 try:
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
288 tiff = TIFF.open(fname, mode='w')
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
289 tiff.write_image(im_array)
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
290 finally:
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
291 tiff.close()
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 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
293 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
294 # 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
295 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
296 continue
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
297 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
298 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
299
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
300 finally:
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
301 # close the archive file,if it is created
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
302 if download_tar:
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
303 archive.close()
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
304 # Close the connection
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
305 conn.close()
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
306
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
307
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
308 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
309 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
310 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
311 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
312 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
313 else:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
314 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
315 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
316 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
317 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
318 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
319 else:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
320 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
321 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
322
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
323
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
324 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
325 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
326 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
327 'image_ids', nargs='*', default=[],
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
328 help='one or more IDR image ids for which to retrieve data (default: '
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
329 '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
330 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
331 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
332 '-c', '--channel',
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
333 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
334 '(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
335 'left unspecified)'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
336 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
337 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
338 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
339 '--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
340 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
341 '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
342 '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
343 '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
344 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
345 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
346 '--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
347 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
348 '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
349 '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
350 '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
351 '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
352 '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
353 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
354 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
355 '-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
356 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
357 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
358 '-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
359 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
360 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
361 '--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
362 )
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
363 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
364 '--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
365 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
366 args = p.parse_args()
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
367 if not args.image_ids:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
368 args.image_ids = sys.stdin.read().split()
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
369 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
370 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
371 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
372 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
373 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
374 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
375 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
376 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
377 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
378 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
379 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
380 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
381 download_image_data(**vars(args))