Add another username to manage for our made_for to affiliation script
[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       'Gigio',
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       'Gordon Kwan': ('Gordon Kwan',),
66       'Gordon': ('Gordon Kwan',),
67       'Alpha-Hudson': ('Hudson-Alpha',),
68       'Hudson-Alpha': ('Hudson-Alpha',),
69       'James Puckett': ('James Puckett',),
70       'Jingli Zhang, Rothenberg': ('Jingli Zhang', 'Ellen Rothenberg',),
71       'Jingli Zhang': ('Jingli Zhang',),
72       'Jose Luis': ('Jose Luis',),
73       'Katherine Fisher': ('Katherine Fisher',),
74       'Katherine, Gigio': ('Katherine Fisher', 'Gigio',),
75       'Meyerowitz': ('Meyerowitz',),
76       'Ryan, Demo': ('Ryan', 'Demo',),
77       'Stathopoulos': ('Angela Stathopoulos',),
78       'Steve Kuntz': ('Steven Kuntz',),
79       'Steven Kuntz': ('Steven Kuntz',),
80       'Tony': ('Tony',),
81       'Tristan': ('Tristan',),
82       'Yuling Jiao': ('Yuling Jiao',),
83       u'Anil Ozdemir': (u'Anil Ozdemir',),
84     }
85
86     affiliations = {}
87     for name in names:
88       aff = samples.Affiliation(name=name)
89       affiliations[name] = aff
90       aff.save()
91
92     for lib in samples.Library.objects.all():
93       made_list = name_map[lib.made_for]
94       assert type(made_list) == type((None,))
95       affiliation_list = []
96       for n in made_list:
97         lib.affiliations.add(affiliations[n])
98       lib.save()
99
100 if __name__ == "__main__":
101   print "don't run this unless you know what its for"
102   print "it converts the caltech 'made_for' field into a set of"
103   print "affiliations."
104   print ""
105   print "The user lists are hard coded and exist mostly for my"
106   print "convienence."
107   #main()