@@ -56,57 +56,61 @@ workflow demux_metadata_only {
5656 }
5757 }
5858
59- #### merge biosample attribute tsvs (iff provided with more than one)
60- if (length (biosample_map_tsvs ) > 1 ) {
61- call utils .tsv_join as biosample_map_tsv_join {
62- input :
63- input_tsvs = biosample_map_tsvs ,
64- id_col = 'accession' ,
65- out_suffix = ".tsv" ,
66- out_basename = "biosample-attributes-merged"
59+ if (length (biosample_map_tsvs ) > 0 ) {
60+ # NCBI biosample metadata is available
61+
62+ #### merge biosample attribute tsvs (iff provided with more than one)
63+ if (length (biosample_map_tsvs ) > 1 ) {
64+ call utils .tsv_join as biosample_map_tsv_join {
65+ input :
66+ input_tsvs = biosample_map_tsvs ,
67+ id_col = 'accession' ,
68+ out_suffix = ".tsv" ,
69+ out_basename = "biosample-attributes-merged"
70+ }
6771 }
68- }
69- File biosample_map_tsv = select_first (flatten ([[biosample_map_tsv_join .out_tsv ], biosample_map_tsvs ]))
70-
71- #### biosample metadata mapping
72- call ncbi .biosample_to_table {
73- input :
74- biosample_attributes_tsv = biosample_map_tsv ,
75- raw_bam_filepaths = raw_reads_unaligned_bams ,
76- demux_meta_json = meta_by_filename_json
77- }
72+ File biosample_map_tsv = select_first (flatten ([[biosample_map_tsv_join .out_tsv ], biosample_map_tsvs ]))
7873
79- #### SRA submission prep
80- call ncbi .sra_meta_prep {
81- input :
82- cleaned_bam_filepaths = cleaned_reads_unaligned_bams ,
83- biosample_map = biosample_map_tsv ,
84- library_metadata = samplesheet_rename_ids .new_sheet ,
85- platform = "ILLUMINA" ,
86- paired = (run_info ['indexes' ] == '2' ),
87-
88- out_name = "sra_metadata-~{run_info ['run_id' ]}.tsv" ,
89- instrument_model = select_first (flatten ([[instrument_model_user_specified ],[run_info ['sequencer_model' ]]])),
90- title = sra_title
91- }
74+ #### biosample metadata mapping
75+ call ncbi .biosample_to_table {
76+ input :
77+ biosample_attributes_tsv = biosample_map_tsv ,
78+ raw_bam_filepaths = raw_reads_unaligned_bams ,
79+ demux_meta_json = meta_by_filename_json
80+ }
9281
93- if ( insert_demux_outputs_into_terra_tables && select_first ([ check_terra_env . is_running_on_terra ])) {
94- call terra . upload_entities_tsv as terra_load_biosample_data {
82+ ## ## SRA submission prep
83+ call ncbi . sra_meta_prep {
9584 input :
96- workspace_name = select_first ([check_terra_env .workspace_name ]),
97- terra_project = select_first ([check_terra_env .workspace_namespace ]),
98- tsv_file = biosample_to_table .sample_meta_tsv
85+ cleaned_bam_filepaths = cleaned_reads_unaligned_bams ,
86+ biosample_map = biosample_map_tsv ,
87+ library_metadata = samplesheet_rename_ids .new_sheet ,
88+ platform = "ILLUMINA" ,
89+ paired = (run_info ['indexes' ] == '2' ),
90+
91+ out_name = "sra_metadata-~{run_info ['run_id' ]}.tsv" ,
92+ instrument_model = select_first (flatten ([[instrument_model_user_specified ],[run_info ['sequencer_model' ]]])),
93+ title = sra_title
94+ }
95+
96+ if (insert_demux_outputs_into_terra_tables && select_first ([check_terra_env .is_running_on_terra ])) {
97+ call terra .upload_entities_tsv as terra_load_biosample_data {
98+ input :
99+ workspace_name = select_first ([check_terra_env .workspace_name ]),
100+ terra_project = select_first ([check_terra_env .workspace_namespace ]),
101+ tsv_file = biosample_to_table .sample_meta_tsv
102+ }
99103 }
100104 }
101105
102106
103107 output {
104- File sra_metadata = sra_meta_prep .sra_metadata
108+ File ? sra_metadata = sra_meta_prep .sra_metadata
105109
106110 String instrument_model_inferred = select_first (flatten ([[instrument_model_user_specified ],[run_info ['sequencer_model' ]]]))
107111
108112 File ? terra_library_table = create_or_update_sample_tables .library_metadata_tsv
109113 File ? terra_sample_library_map = create_or_update_sample_tables .sample_membership_tsv
110- File terra_sample_metadata = biosample_to_table .sample_meta_tsv
114+ File ? terra_sample_metadata = biosample_to_table .sample_meta_tsv
111115 }
112116}
0 commit comments