Attempt to be robust to not having an alignment in our RunXml file
[htsworkflow.git] / docs / conv_caltech_v0.1_made_for.py
1 """
2 Read the made-for field and split them up into different affiliations
3 while fixing the different spellings for some of our users
4 """
5 import os
6
7 script_dir = os.path.split(__file__)[0]
8 settings_path = os.path.join(script_dir, 'htsworkflow','frontend')
9 os.environ['DJANGO_SETTINGS_MODULE'] = 'htsworkflow.frontend.settings'
10
11 from htsworkflow.frontend.samples import models as samples
12
13 def main():
14     # names  ( {'target name': ('current name', 'current name') )
15     names = [
16       'Unknown',
17       'Adam Rosenthal',
18       'Adler Dillman',
19       'Ali',
20       'Ali/EHD',
21       'Ali/PWS',
22       'Andrew Medina-Marino',
23       'Brian Williams',
24       'Davidson',
25       'Elowitz',
26       'Erich Schwarz',
27       'Georgi Warinov',
28       'Gilberto Desalvo',
29       'Gilberto Hernandez',
30       'Gordon Kwan',
31       'Hudson-Alpha',
32       'James Puckett',
33       'Jingli Zhang',
34       'Ellen Rothenberg',
35       'Jose Luis',
36       'Katherine Fisher',
37       'Meyerowitz',
38       'Ryan',
39       'Demo',
40       'Angela Stathopoulos',
41       'Steven Kuntz',
42       'Tony',
43       'Tristan',
44       'Yuling Jiao',
45       u'Anil Ozdemir',
46     ]
47
48     name_map = {
49       '': ('Unknown',) ,
50       'Adam Rosenthal': ('Adam Rosenthal',),
51       'Adler Dillman': ('Adler Dillman',),
52       'Ali': ('Ali',),
53       'Ali/EHD': ('Ali/EHD',),
54       'Ali/PWS': ('Ali/PWS',),
55       'Andrew Medina-Marina': ('Andrew Medina-Marino',),
56       'Andrew Medina-Marino': ('Andrew Medina-Marino',),
57       'Brian': ('Brian Williams',),
58       'Brian Williams': ('Brian Williams',),
59       'Davidson': ('Davidson',),
60       'Elowitz': ('Elowitz',),
61       'Erich Schwarz': ('Erich Schwarz',),
62       'Erich Schwartz': ('Erich Schwarz',),
63       'Georgi Warinov': ('Georgi Warinov',),
64       'Gilberto Desalvo': ('Gilberto Desalvo',),
65       'Gilberto Hernandez': ('Gilberto Hernandez',),
66       'Gordon Kwan': ('Gordon Kwan',),
67       'Gordon': ('Gordon Kwan',),
68       'Alpha-Hudson': ('Hudson-Alpha',),
69       'Hudson-Alpha': ('Hudson-Alpha',),
70       'James Puckett': ('James Puckett',),
71       'Jingli Zhang, Rothenberg': ('Jingli Zhang', 'Ellen Rothenberg',),
72       'Jingli Zhang': ('Jingli Zhang',),
73       'Jose Luis': ('Jose Luis',),
74       'Katherine Fisher': ('Katherine Fisher',),
75       'Katherine, Gigio': ('Katherine Fisher', 'Gilberto Desalvo',),
76       'Meyerowitz': ('Meyerowitz',),
77       'Ryan, Demo': ('Ryan', 'Demo',),
78       'Stathopoulos': ('Angela Stathopoulos',),
79       'Steve Kuntz': ('Steven Kuntz',),
80       'Steven Kuntz': ('Steven Kuntz',),
81       'Tony': ('Tony',),
82       'Tristan': ('Tristan',),
83       'Yuling Jiao': ('Yuling Jiao',),
84       u'Anil Ozdemir': (u'Anil Ozdemir',),
85     }
86
87     affiliations = {}
88     for name in names:
89       aff = samples.Affiliation(name=name)
90       affiliations[name] = aff
91       aff.save()
92
93     for lib in samples.Library.objects.all():
94       made_list = name_map[lib.made_for]
95       assert type(made_list) == type((None,))
96       affiliation_list = []
97       for n in made_list:
98         lib.affiliations.add(affiliations[n])
99       lib.save()
100
101 if __name__ == "__main__":
102   print "don't run this unless you know what its for"
103   print "it converts the caltech 'made_for' field into a set of"
104   print "affiliations."
105   print ""
106   print "The user lists are hard coded and exist mostly for my"
107   print "convienence."
108   main()