-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_bioinforesponsible.py
executable file
·84 lines (75 loc) · 3.22 KB
/
set_bioinforesponsible.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
72
73
74
75
76
77
78
79
80
81
82
83
84
""" Calls up the genologics LIMS directly in order to more quickly
set a bioinformatics responsible. Script can easily be altered
to be used to set other values."""
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from genologics.lims import Lims
from genologics.config import BASEURI, USERNAME, PASSWORD
from genologics.entities import Udfconfig
def namesetter(PID):
lims = Lims(BASEURI, USERNAME, PASSWORD)
lims.check_version()
#Find LIMS entry with same PID
allProjects = lims.get_projects()
for proj in allProjects:
if proj.id == PID:
limsproject = proj.name
break
#Error handling
if not 'limsproject' in locals():
print "{} not available in LIMS.".format(PID)
return None
#Enter project summary process
stepname=['Project Summary 1.3']
process=lims.get_processes(type=stepname, projectname=limsproject)
#Error handling
if process == []:
print "{} for {} is not available in LIMS.".format(stepname, limsproject)
return None
loop = True
while loop:
if "Bioinfo responsible" in process[0].udf:
response = process[0].udf["Bioinfo responsible"]
else:
response = "Unassigned"
print "Existing Bioinfo responsible for project {} aka {} is: {}".format(limsproject, PID, response.encode('utf-8'))
#Checks for valid name
in_responsibles = False
config_responsibles =Udfconfig(lims, id="1128")
while not in_responsibles:
newname = raw_input("Enter name of new Bioinfo responsible: ")
for names in config_responsibles.presets:
if newname in names:
in_responsibles = True
newname = names
if not in_responsibles:
print "Subset {} not found in accepted Bioinfo responsible list.".format(newname)
else:
print "Suggested name is {}".format(newname)
confirmation = raw_input("Project {} aka {} will have {} as new Bioinfo responsible, is this correct (Y/N)? ".format(limsproject, PID, newname))
if confirmation == 'Y' or confirmation == 'y':
try:
newname.decode('ascii')
process[0].udf["Bioinfo responsible"] = unicode(newname)
process[0].put()
print "Project {} aka {} assigned to {}".format(limsproject, PID, newname)
return None
except UnicodeDecodeError:
#Weird solution due to put function
process[0].udf["Bioinfo responsible"] = response
print "ERROR: You tried to use a special character, didn't you? Don't do that. New standards and stuff..."
elif confirmation == 'N' or confirmation == 'n':
loop = False
else:
print "Invalid answer."
looping = True
print "---- Bioinformatical (re)assignment application ----"
print "Connected to", BASEURI
while looping:
print ("---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ")
pid = raw_input("Enter the PID of the project you'd wish to (re)assign or Q to quit: ")
if pid != 'q' and pid != 'Q':
namesetter(pid)
else:
looping = False