forked from IDR/idr-metadata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen_import.py
executable file
·71 lines (59 loc) · 1.57 KB
/
screen_import.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
from argparse import ArgumentParser
from glob import glob
from os.path import basename
from os.path import dirname
from os.path import expanduser
from os.path import exists
from os.path import join
from subprocess import call
bin = expanduser("~/OMERO.server/bin/omero")
assert exists(bin)
parser = ArgumentParser()
parser.add_argument("screen")
parser.add_argument(
"--force",
action="store_true",
default=False,
help="Re-import if necessary"
)
ns = parser.parse_args()
command = [
bin, "import", "--",
"--checksum-algorithm=File-Size-64",
"--transfer=ln_s"
]
if not ns.force:
command += ["--exclude=clientpath"]
if ns.screen[-1] == "/":
ns.screen = ns.screen[0:-1]
if "plates" in ns.screen:
base, ignore = ns.screen.split("/plates/")
plates = ns.screen
else:
base = ns.screen
plates = join(ns.screen, "plates", "*")
screen = basename(base)
study = basename(dirname(base))
print "Study: ", study
print "Screen: ", screen
print "Plate count:", len(glob(plates))
assert exists(ns.screen)
for plate in sorted(glob(plates)):
if plate.endswith(".log"):
continue
if exists(plate + ".log"):
print "Skipping due to %s.log" % plate
continue
name = basename(plate)
with open(plate, "r") as f:
target = f.read().strip()
print name, "-->", target
if call(command + [
"--name=%s" % name,
"--target=Screen:name:%s/%s" % (study, screen),
"--transfer=ln_s", target]):
print "FAILED",
else:
print "PASSED",
print "=" * 40