@@ -386,6 +386,25 @@ def test_add_samples_from_templates(self):
386386 with self .assertRaises (KeyError ):
387387 submission .samples ['nothere' ]
388388
389+ def test_add_samples_from_templates_filter_samples (self ):
390+ sample_template = StringIO (EXP_SAMPLE_TEMPLATE )
391+ prep_template = StringIO (EXP_PREP_TEMPLATE_FILTERED )
392+ submission = EBISubmission ('001' , 'teststudy' , 'test asbstract' ,
393+ investigation_type = 'Other' ,
394+ new_investigation_type = 'metagenome' )
395+ submission .add_samples_from_templates (sample_template , prep_template ,
396+ self .path )
397+ self .assertTrue ('sample1' in submission .samples )
398+ self .assertTrue ('sample2' in submission .samples )
399+ self .assertFalse ('sample3' in submission .samples )
400+ self .assertEqual (submission .samples ['sample2' ]['prep' ]['platform' ],
401+ 'ILLUMINA' )
402+ self .assertEqual (
403+ submission .samples ['sample2' ]['prep' ]['file_path' ],
404+ self .sample2_fp )
405+ with self .assertRaises (KeyError ):
406+ submission .samples ['nothere' ]
407+
389408 def test_add_samples_from_templates_error (self ):
390409 sample_template = StringIO (SAMPLE_TEMPLATE_ERROR )
391410 prep_template = StringIO (EXP_PREP_TEMPLATE )
@@ -695,5 +714,14 @@ def test_generate_curl_command(self):
695714 "sample3\t ANL\t Test Project\t 2\t 1\t Value for sample 2"
696715 "\t ILLUMINA\t exp design\t lib protocol\n " )
697716
717+ EXP_PREP_TEMPLATE_FILTERED = (
718+ "sample_name\t center_name\t center_project_name\t data_type_id\t "
719+ "temp_status_id\t str_column\t platform\t experiment_design_description"
720+ "\t library_construction_protocol"
721+ "\n sample1\t ANL\t Test Project\t 2\t 1\t Value for sample 3"
722+ "\t ILLUMINA\t exp design\t lib protocol\n "
723+ "sample2\t ANL\t Test Project\t 2\t 1\t Value for sample 1"
724+ "\t ILLUMINA\t exp design\t lib protocol\n " )
725+
698726if __name__ == "__main__" :
699727 main ()
0 commit comments