コード例 #1
0
 def test_silva_taxonomy_format_validate_negative_nonnumeric_values(self):
     filepath = self.get_data_path('silva_taxa.tsv')
     badtax = pd.read_csv(filepath, sep='\t', index_col=0, header=None)
     # turn the taxids to a non-numeric column
     badtax[1] = 'blarg'
     junkpath = os.path.join(self.temp_dir.name, 'junk.tsv')
     badtax.to_csv(junkpath, sep='\t', header=False)
     format = SILVATaxonomyFormat(junkpath, mode='r')
     with self.assertRaisesRegex(ValidationError, 'non-numeric value'):
         format.validate()
コード例 #2
0
 def test_silva_taxonomy_format_validate_negative_invalid_taxonomy(self):
     filepath = self.get_data_path('silva_taxa.tsv')
     # index_col=1 sets the wrong index, creating an invalid taxonomy
     badtax = pd.read_csv(filepath, sep='\t', index_col=1, header=None)
     junkpath = os.path.join(self.temp_dir.name, 'junk.tsv')
     badtax.to_csv(junkpath, sep='\t', header=False)
     format = SILVATaxonomyFormat(junkpath, mode='r')
     with self.assertRaisesRegex(ValidationError,
                                 'not in SILVA taxonomy format'):
         format.validate()
コード例 #3
0
 def test_silva_taxonomy_format_validate_negative_empty_file(self):
     filepath = self.get_data_path('empty.tsv')
     format = SILVATaxonomyFormat(filepath, mode='r')
     with self.assertRaisesRegex(ValidationError,
                                 'must be at least one.*record'):
         format.validate()
コード例 #4
0
 def test_silva_taxonomy_format_validate_negative_incorrect_row_count(self):
     filepath = self.get_data_path('silva_taxamap.tsv')
     format = SILVATaxonomyFormat(filepath, mode='r')
     with self.assertRaisesRegex(ValidationError, 'Expected.*5 fields'):
         format.validate()
コード例 #5
0
 def test_silva_taxonomy_format_validate_positive(self):
     filepath = self.get_data_path('silva_taxa.tsv')
     format = SILVATaxonomyFormat(filepath, mode='r')
     # These should both just succeed
     format.validate('min')
     format.validate('max')