@@ -12,7 +12,6 @@ from glob import glob
12
12
from os .path import isdir , basename , join
13
13
from shutil import copyfile
14
14
15
- from qiita_db .user import User
16
15
from qiita_db .study import Study
17
16
from qiita_db .artifact import Artifact
18
17
from qiita_db .commands import (
@@ -21,25 +20,11 @@ from qiita_db.commands import (
21
20
from qiita_db .util import get_data_types , get_mountpoint , create_nested_path
22
21
23
22
24
- SLEEP_TIME = 10
25
- EBIDIR = '/panfs/panfs1.ucsd.edu/panscratch/qiita/qebil/vertebrates/'
26
- data_types = set ([x .replace (' ' , '_' ) for x in get_data_types ()])
23
+ def load_qebil_study (folder , shared_with ):
24
+ data_types = set ([x .replace (' ' , '_' ) for x in get_data_types ()])
27
25
28
- folders = glob (f'{ EBIDIR } /*' )
29
- shared_with_emails = ['sjsong@eng.ucsd.edu' ]
30
- shared_with = [User (x ) for x in shared_with_emails ]
31
-
32
- for folder in folders :
33
26
warnings = []
34
27
extra_notes = dict ()
35
- if not isdir (folder ):
36
- print (f'Ignoring: { folder } ' )
37
- continue
38
- print (f'\n \n \n +++> Processing { folder } , you have { SLEEP_TIME } '
39
- 'seconds to ctrl-c' )
40
- # Note: this sleep is not necessary but nice for debugging so we have time
41
- # to ctrl-c
42
- sleep (10 )
43
28
44
29
files = glob (f'{ folder } /*' )
45
30
files_used = []
@@ -48,7 +33,7 @@ for folder in folders:
48
33
qebil_status = fp .readlines ()[0 ]
49
34
if 'complete' not in qebil_status :
50
35
print (f'Skipping { qebil_status_fp } , not ready: { qebil_status } ' )
51
- continue
36
+ return
52
37
files_used .append (qebil_status_fp )
53
38
54
39
title_fp = [f for f in files if f .endswith ('_study_title.txt' )][0 ]
@@ -63,11 +48,18 @@ for folder in folders:
63
48
64
49
if Study .exists (title ):
65
50
print (f'======> { folder } : { title } already loaded' )
66
- continue
51
+ return
67
52
68
53
with open (config_fp , 'r' ) as fp :
69
54
study = load_study_from_cmd ('qiita.help@gmail.com' , title , fp )
70
55
56
+ print ('===================' )
57
+ print ('===================' )
58
+ print ('===================' )
59
+ print (f'study { study .id } created' )
60
+ print ('===================' )
61
+ print ('===================' )
62
+
71
63
study .autoloaded = True
72
64
study .ebi_study_accession = study .info ['study_alias' ].split (';' )[0 ]
73
65
sample_info = load_sample_template_from_cmd (sample_fp , study .id )
@@ -201,6 +193,11 @@ for folder in folders:
201
193
202
194
artifact = Artifact .create (filepaths , 'per_sample_FASTQ' ,
203
195
prep_template = pt , move_files = False )
196
+ print (" " )
197
+ print (" " )
198
+ print (f" artifact { artifact .id } was created for { pt .id } " )
199
+ print (" " )
200
+ print (" " )
204
201
notes = ''
205
202
if warnings :
206
203
notes = '<b>Warnings</b>:<ol>%s</ol>\n ' % '' .join (
@@ -225,3 +222,23 @@ for folder in folders:
225
222
226
223
for x in shared_with :
227
224
study .share (x )
225
+
226
+
227
+ # data is a list [str, [list of Users]]
228
+ data = [
229
+ # ["folder filepath", [list of Users to add as shared_with]]
230
+ ]
231
+
232
+ for folder , shared_with in data :
233
+ SLEEP_TIME = 10
234
+
235
+ if not isdir (folder ):
236
+ print (f'Ignoring: { folder } ' )
237
+ continue
238
+ print (f'\n \n \n +++> Processing { folder } , you have { SLEEP_TIME } '
239
+ 'seconds to ctrl-c' )
240
+ # Note: this sleep is not necessary but nice for debugging so we have time
241
+ # to ctrl-c
242
+ sleep (10 )
243
+
244
+ load_qebil_study (folder , shared_with )
0 commit comments