1 from __future__ import unicode_literals
3 from django.conf import settings
9 s_paren = re.compile("^\w+")
11 def get_flowcell_result_dict(flowcell_id):
13 returns a dictionary following the following pattern for
17 d['C1-33']['summary'] # Summary.htm file path
18 d['C1-33']['eland_results'][5] # C1-33 lane 5 file eland results file path
19 d['C1-33']['run_xml'] # run_*.xml file path
20 d['C1-33']['scores'] # scores.tar.gz file path
22 flowcell_id = flowcell_id.strip()
26 ################################
28 fc_dir = glob.glob(os.path.join(settings.RESULT_HOME_DIR, flowcell_id))
35 assert len(fc_dir) <= 1
40 ################################
42 c_dir_list = glob.glob(os.path.join(fc_dir, 'C*'))
45 if len(c_dir_list) == 0:
48 for c_dir_path in c_dir_list:
49 summary_file = glob.glob(os.path.join(c_dir_path, 'Summary.htm'))
50 pathdir, c_dir = os.path.split(c_dir_path)
52 # Create sub-dictionary
56 ###############################
60 if len(summary_file) == 0:
61 d[c_dir]['summary'] = None
66 assert len(summary_file) == 1
68 summary_file = summary_file[0]
69 d[c_dir]['summary'] = summary_file
71 ###############################
74 d[c_dir]['eland_results'] = {}
76 result_filepaths = glob.glob(os.path.join(c_dir_path, 's_*_eland_*'))
78 for filepath in result_filepaths:
80 junk, result_name = os.path.split(filepath)
82 #lanes 1-8, single digit, therefore s_#; # == index 2
83 lane = int(result_name[2])
84 d[c_dir]['eland_results'][lane] = filepath
86 ###############################
88 run_xml_filepath = glob.glob(os.path.join(c_dir_path, 'run_*.xml'))
90 if len(run_xml_filepath) == 0:
91 d[c_dir]['run_xml'] = None
94 assert len(run_xml_filepath) == 1
96 d[c_dir]['run_xml'] = run_xml_filepath[0]
98 ###############################
100 # restrict to only compressed files, so in case there are *.md5 files
101 # we don't get confused.
103 for pattern in ['scores*.tar.bz2', 'scores*.tar.gz', 'scores*.tgz']:
104 scores_filepath += glob.glob(os.path.join(c_dir_path, pattern))
106 if len(scores_filepath) == 0:
107 d[c_dir]['scores'] = None
110 assert len(scores_filepath) == 1
112 d[c_dir]['scores'] = scores_filepath[0]
119 Converts CN-M (i.e. C1-33, C1-26, C4-28) cycle information into
120 number of base pairs.