Skip to content

Commit 03f0731

Browse files
committed
EBI submission only uploads the samples present in the prep template - and added a test for this
1 parent 641492b commit 03f0731

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

qiita_ware/ebi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,9 @@ def add_samples_from_templates(self, sample_template, prep_template,
838838
library_construction_protocol,
839839
**prep)
840840

841-
# to_remove = set(self.samples).difference(prep_template_samples)
842-
# for sample in to_remove:
843-
# del self.samples[sample]
841+
to_remove = set(self.samples).difference(prep_template_samples)
842+
for sample in to_remove:
843+
del self.samples[sample]
844844

845845
@classmethod
846846
def from_templates_and_per_sample_fastqs(cls, preprocessed_data_id,

qiita_ware/test/test_ebi.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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\tANL\tTest Project\t2\t1\tValue for sample 2"
696715
"\tILLUMINA\texp design\tlib protocol\n")
697716

717+
EXP_PREP_TEMPLATE_FILTERED = (
718+
"sample_name\tcenter_name\tcenter_project_name\tdata_type_id\t"
719+
"temp_status_id\tstr_column\tplatform\texperiment_design_description"
720+
"\tlibrary_construction_protocol"
721+
"\nsample1\tANL\tTest Project\t2\t1\tValue for sample 3"
722+
"\tILLUMINA\texp design\tlib protocol\n"
723+
"sample2\tANL\tTest Project\t2\t1\tValue for sample 1"
724+
"\tILLUMINA\texp design\tlib protocol\n")
725+
698726
if __name__ == "__main__":
699727
main()

0 commit comments

Comments
 (0)