annotate idr_download_by_ids.py @ 8:97f70f7ed077 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
author iuc
date Sun, 22 Nov 2020 13:55:01 +0000
parents f067504aa92a
children 4aed70472589
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
0
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.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
11 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
12
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
13
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
14 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
15 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
16 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
17 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
18 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
19 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
20 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
21 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
22 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
23 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
24 '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
25 .format(
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
26 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
27 message,
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
28 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
29 ),
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
30 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
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
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
34 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
35 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
36 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
37 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
38 return n
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
39 # 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48 return n
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
49 return -1
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
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
52 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
53 # 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
54 # 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
55 # 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
56 # 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
57 # 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
58 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
59 raise ValueError(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
60 '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
61 .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
62 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
63 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
64 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
65 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
66 raise ValueError(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
67 '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
68 '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
69 .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
70 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
71 # 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
72 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
73 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
74 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
75 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
76 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
77
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 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
80 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
81 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 else:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
83 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
84 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
85 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 return z
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
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
89 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
90 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
91 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 else:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
93 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
94 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
95 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 return t
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
97
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
98
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
99 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
100 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
101 try:
17b1cd0f4812 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 7d7d50f41a9da71b0f45f8b710e52696689a8d85"
iuc
parents: 1
diff changeset
102 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
103 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
104 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
105 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
106 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
107 return
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
108
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
109 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
110
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 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
113 image_ids,
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
114 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
115 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
116 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
117 ):
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
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
119 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
120 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
121 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
122 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
123 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
124 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
125 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
126 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
127
97f70f7ed077 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664"
iuc
parents: 7
diff changeset
128 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
129 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
130 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
131
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
132 # 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
133 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
134 # 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
135 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
136 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
137 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
138 ]
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
139
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
140 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
141 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
142 '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
143 .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
144 )
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 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
146 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
147 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
148 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
149 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
150 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
151 )
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 # 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
154 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
155 # 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
156 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
157 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
158 )
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
159 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
160 TemporaryDirectory()
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
161 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
162
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
163 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
164 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
165 try:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
166 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
167 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
168 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
169 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
170 try:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
171 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
172 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
173 # 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
174 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
175 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
176 continue
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
177 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
178 raise
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
179
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
180 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
181 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
182 warn(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
183 '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
184 'database.',
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
185 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
186 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
187 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
188 continue
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
189 raise ValueError(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
190 '{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
191 'database. Aborting!'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
192 .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
193 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
194
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
195 try:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
196 # 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
197 # 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
198 # 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
199 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
200 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
201 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
202 )
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
203
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
204 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
205 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
206 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
207 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
208 image,
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
209 *_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
210 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
211
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
212 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
213 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
214 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
215 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
216 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
217 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
218 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
219 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
220 # 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
221 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
222 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
223 continue
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
224 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
225 raise
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
226
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
227 # 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
228 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
229 # 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
230 # 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
231 warn(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
232 '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
233 '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
234 .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
235 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
236 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
237
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
238 # 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
239 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
240 warn(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
241 '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
242 'instead.'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
243 .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
244 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
245 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
246
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
247 # 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
248 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
249 warn(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
250 '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
251 '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
252 .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
253 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
254 )
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
255
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
256 # 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
257 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
258 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
259 warn(
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
260 '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
261 '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
262 .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
263 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
264 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
265 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
266 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
267 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
268 warn(
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
269 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
270 + ' 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
271 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
272 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
273 )
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
274 continue
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
275 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
276 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
277 '"{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
278 'Aborting!'
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
279 .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
280 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
281
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
282 # 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
283 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
284 [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
285 )
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
286 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
287 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
288 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
289
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
290 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
291
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
292 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
293
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
294 if download_tar:
6
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
295 fname = os.path.join(tempdir, fname)
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
296 try:
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
297 tiff = TIFF.open(fname, 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
298 tiff.write_image(im_array)
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
299 finally:
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
300 tiff.close()
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
301 # move image into tarball
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
302 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
303 archive.add(fname, os.path.basename(fname))
5c743356df83 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit bf331f8e60e7bc1daf1cd71d2068062d925e7ffa"
iuc
parents: 5
diff changeset
304 os.remove(fname)
3
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
305 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
306 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
307 # 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
308 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
309 continue
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
310 else:
381f248febba "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 0ae8913ec1c14caedc9836d4889650ea836a1d70"
iuc
parents: 2
diff changeset
311 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
312
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
313
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
314 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
315 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
316 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
317 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
318 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
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_x = 0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
321 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
322 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
323 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
324 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
325 else:
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
326 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
327 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
328
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
329
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
330 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
331 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
332 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
333 '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
334 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
335 '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
336 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
337 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
338 '-c', '--channel',
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
339 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
340 '(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
341 'left unspecified)'
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
342 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
343 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
344 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
345 '--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
346 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
347 '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
348 '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
349 '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
350 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
351 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
352 '--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
353 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
354 '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
355 '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
356 '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
357 '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
358 '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
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 '-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
362 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
363 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
364 '-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
365 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
366 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
367 '--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
368 )
4
11036f6197d6 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 3c3f1023af1edb4c63f59f4311cc078d9e88923f"
iuc
parents: 3
diff changeset
369 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
370 '--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
371 )
7
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
372 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
373 '-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
374 )
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
375 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
376 '--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
377 )
f067504aa92a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 6b9df5f3cf2518e48eced93a2904a89776bde02d"
iuc
parents: 6
diff changeset
378 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
379 '-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
380 )
0
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
381 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
382 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
383 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
384 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
385 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
386 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
387 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
388 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
389 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
390 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
391 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
392 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
393 )
57aa9597cd31 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit 253efabdfea3a1fecc4c0f2c54c0e97a7d7960ab"
iuc
parents:
diff changeset
394 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
395 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
396 download_image_data(**vars(args))