From 3636c4bd40d5964a2b26d6ccd66226ba2c263a5b Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Mon, 19 Sep 2011 16:24:25 -0700 Subject: [PATCH] Output samples that don't have index sequence as well. Also use writerow to handle the header so there's a consistent EOL mark on the header. --- htsworkflow/pipelines/retrieve_config.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htsworkflow/pipelines/retrieve_config.py b/htsworkflow/pipelines/retrieve_config.py index 7427924..2292cb9 100644 --- a/htsworkflow/pipelines/retrieve_config.py +++ b/htsworkflow/pipelines/retrieve_config.py @@ -352,7 +352,7 @@ def save_sample_sheet(outstream, options, flowcell_info): 'Recipe': format_recipe_name, 'Operator': format_operator_name} out = csv.DictWriter(outstream, sample_sheet_fields) - outstream.write(','.join(sample_sheet_fields)) + out.writerow(dict(((x,x) for x in sample_sheet_fields))) for lane_number in LANE_LIST: lane_contents = flowcell_info['lane_set'][str(lane_number)] @@ -373,9 +373,8 @@ def save_sample_sheet(outstream, options, flowcell_info): pooled_lane_contents.extend(format_pooled_libraries(renamed, library)) - if len(pooled_lane_contents) > 1: - for row in pooled_lane_contents: - out.writerow(row) + for row in pooled_lane_contents: + out.writerow(row) def format_sampleref(options, flowcell_info, sample): @@ -401,11 +400,12 @@ def format_pooled_libraries(shared, library): sequences = library.get('index_sequence', None) if sequences is None: return [] - elif type(sequences) in types.StringTypes: - shared['Index'] = sequences + elif (type(sequences) in types.StringTypes and + sequences.lower().startswith('err')): + shared['Index'] = '' shared['SampleProject'] = library['library_id'] return [shared] - else: + elif (type(sequences) == types.DictType): pooled = [] multiplex_ids = sequences.keys() multiplex_ids.sort(key=int) @@ -417,6 +417,9 @@ def format_pooled_libraries(shared, library): multiplex_id) pooled.append(sample) return pooled + else: + raise RuntimeError("Unrecognized index type") + def format_project_name(library, multiplex_id): -- 2.30.2