def test_silva_taxidmap_format_validate_negative_nonnumeric_values(self):
     filepath = self.get_data_path('silva_taxamap.tsv')
     badtax = pd.read_csv(filepath, sep='\t', index_col=0, header=0)
     # turn the taxids to a non-numeric column
     badtax['taxid'] = 'peanuts'
     junkpath = os.path.join(self.temp_dir.name, 'junk.tsv')
     badtax.to_csv(junkpath, sep='\t', header=True)
     format = SILVATaxidMapFormat(junkpath, mode='r')
     with self.assertRaisesRegex(ValidationError, 'non-numeric value'):
         format.validate()
 def test_silva_taxidmap_format_validate_negative_invalid_taxonomy(self):
     filepath = self.get_data_path('silva_taxamap.tsv')
     badtax = pd.read_csv(filepath, sep='\t', index_col=0, header=0)
     # replace the taxonomy with non-semicolon-delimited strings
     badtax['path'] = 'foobar'
     junkpath = os.path.join(self.temp_dir.name, 'junk.tsv')
     badtax.to_csv(junkpath, sep='\t', header=True)
     format = SILVATaxidMapFormat(junkpath, mode='r')
     with self.assertRaisesRegex(ValidationError,
                                 'not in SILVA taxonomy format'):
         format.validate()
 def test_silva_taxidmap_format_validate_negative_bad_header(self):
     filepath = self.get_data_path('silva_taxa.tsv')
     format = SILVATaxidMapFormat(filepath, mode='r')
     with self.assertRaisesRegex(ValidationError,
                                 'Header line does not match SILVA format'):
         format.validate()
 def test_silva_taxidmap_format_validate_positive_version132(self):
     filepath = self.get_data_path('silva_taxamap_v132.tsv')
     format = SILVATaxidMapFormat(filepath, mode='r')
     # These should both just succeed
     format.validate('min')
     format.validate('max')
 def test_silva_taxidmap_format_validate_negative_empty_file(self):
     filepath = self.get_data_path('empty_with_header.tsv')
     format = SILVATaxidMapFormat(filepath, mode='r')
     with self.assertRaisesRegex(ValidationError,
                                 'must be at least one.*record'):
         format.validate()
 def test_silva_taxidmap_format_validate_negative_row_count(self):
     filepath = self.get_data_path('trash_taxamap.tsv')
     format = SILVATaxidMapFormat(filepath, mode='r')
     with self.assertRaisesRegex(ValidationError, 'Expected.*6 fields'):
         format.validate()