@@ -621,6 +621,89 @@ def test_add_common_creation_steps_to_queue(self):
621
621
622
622
self .assertEqual (conn_handler .queues [queue_name ], exp )
623
623
624
+ def test_clean_validate_template_error_bad_chars (self ):
625
+ """Raises an error if there are invalid characters in the sample names
626
+ """
627
+ conn_handler = SQLConnectionHandler ()
628
+ self .metadata .index = ['o()xxxx[{::::::::>' , 'sample.1' , 'sample.3' ]
629
+ with self .assertRaises (QiitaDBColumnError ):
630
+ PrepTemplate ._clean_validate_template (self .metadata , 2 , "16S" ,
631
+ conn_handler )
632
+
633
+ def test_clean_validate_template_error_duplicate_cols (self ):
634
+ """Raises an error if there are duplicated columns in the template"""
635
+ conn_handler = SQLConnectionHandler ()
636
+ self .metadata ['STR_COLUMN' ] = pd .Series (['' , '' , '' ],
637
+ index = self .metadata .index )
638
+ with self .assertRaises (QiitaDBDuplicateHeaderError ):
639
+ PrepTemplate ._clean_validate_template (self .metadata , 2 , "16S" ,
640
+ conn_handler )
641
+
642
+ def test_clean_validate_template_error_missing (self ):
643
+ """Raises an error if the template is missing a required column"""
644
+ conn_handler = SQLConnectionHandler ()
645
+ metadata_dict = {
646
+ 'SKB8.640193' : {'center_name' : 'ANL' ,
647
+ 'center_project_name' : 'Test Project' ,
648
+ 'ebi_submission_accession' : None ,
649
+ 'linkerprimersequence' : 'GTGCCAGCMGCCGCGGTAA' ,
650
+ 'barcodesequence' : 'GTCCGCAAGTTA' ,
651
+ 'run_prefix' : "s_G1_L001_sequences" ,
652
+ 'platform' : 'ILLUMINA' ,
653
+ 'library_construction_protocol' : 'AAAA' ,
654
+ 'experiment_design_description' : 'BBBB' }
655
+ }
656
+ metadata = pd .DataFrame .from_dict (metadata_dict , orient = 'index' )
657
+ with self .assertRaises (QiitaDBColumnError ):
658
+ PrepTemplate ._clean_validate_template (metadata , 2 , "16S" ,
659
+ conn_handler )
660
+
661
+ def test_clean_validate_template (self ):
662
+ conn_handler = SQLConnectionHandler ()
663
+ obs = PrepTemplate ._clean_validate_template (self .metadata , 2 , "16S" ,
664
+ conn_handler )
665
+ metadata_dict = {
666
+ '2.SKB8.640193' : {'center_name' : 'ANL' ,
667
+ 'center_project_name' : 'Test Project' ,
668
+ 'ebi_submission_accession' : None ,
669
+ 'emp_status_id' : 1 ,
670
+ 'str_column' : 'Value for sample 1' ,
671
+ 'linkerprimersequence' : 'GTGCCAGCMGCCGCGGTAA' ,
672
+ 'barcodesequence' : 'GTCCGCAAGTTA' ,
673
+ 'run_prefix' : "s_G1_L001_sequences" ,
674
+ 'platform' : 'ILLUMINA' ,
675
+ 'library_construction_protocol' : 'AAAA' ,
676
+ 'experiment_design_description' : 'BBBB' },
677
+ '2.SKD8.640184' : {'center_name' : 'ANL' ,
678
+ 'center_project_name' : 'Test Project' ,
679
+ 'ebi_submission_accession' : None ,
680
+ 'emp_status_id' : 1 ,
681
+ 'str_column' : 'Value for sample 2' ,
682
+ 'linkerprimersequence' : 'GTGCCAGCMGCCGCGGTAA' ,
683
+ 'barcodesequence' : 'CGTAGAGCTCTC' ,
684
+ 'run_prefix' : "s_G1_L001_sequences" ,
685
+ 'platform' : 'ILLUMINA' ,
686
+ 'library_construction_protocol' : 'AAAA' ,
687
+ 'experiment_design_description' : 'BBBB' },
688
+ '2.SKB7.640196' : {'center_name' : 'ANL' ,
689
+ 'center_project_name' : 'Test Project' ,
690
+ 'ebi_submission_accession' : None ,
691
+ 'emp_status_id' : 1 ,
692
+ 'str_column' : 'Value for sample 3' ,
693
+ 'linkerprimersequence' : 'GTGCCAGCMGCCGCGGTAA' ,
694
+ 'barcodesequence' : 'CCTCTGAGAGCT' ,
695
+ 'run_prefix' : "s_G1_L002_sequences" ,
696
+ 'platform' : 'ILLUMINA' ,
697
+ 'library_construction_protocol' : 'AAAA' ,
698
+ 'experiment_design_description' : 'BBBB' }
699
+ }
700
+ exp = pd .DataFrame .from_dict (metadata_dict , orient = 'index' )
701
+ obs .sort_index (axis = 0 , inplace = True )
702
+ obs .sort_index (axis = 1 , inplace = True )
703
+ exp .sort_index (axis = 0 , inplace = True )
704
+ exp .sort_index (axis = 1 , inplace = True )
705
+ assert_frame_equal (obs , exp )
706
+
624
707
625
708
@qiita_test_checker ()
626
709
class TestPrepTemplateReadWrite (BaseTestPrepTemplate ):
0 commit comments