def test_taxadumpparser_taxdump_noargs(self): """Check method runs ok""" # Need connection to db. We use an empty db to fill list returned by # parsing method db = TaxaDB(dbtype='sqlite', dbname=self.testdb) db.db.create_table(Taxa, safe=True) dp = TaxaDumpParser(verbose=True, nodes_file=self.nodes, names_file=self.names) l = dp.taxdump() self.assertEqual(len(l), 14)
def test_accessionparser_accession2taxid(self): """Check method yield correct number of entries read from accession file""" # Need connection to db. We use an empty db to fill list returned by # parsing method db = TaxaDB(dbtype='sqlite', dbname=self.testdb) db.db.create_table(Taxa, safe=True) db.db.create_table(Accession, safe=True) # We need to load names.dmp and nodes.dmp tp = TaxaDumpParser(nodes_file=self.nodes, names_file=self.names, verbose=True) taxa_info = tp.taxdump() with db.db.atomic(): for i in range(0, len(taxa_info), self.chunk): Taxa.insert_many(taxa_info[i:i + self.chunk]).execute() ap = Accession2TaxidParser(acc_file=self.acc, chunk=self.chunk, verbose=True) acc_list = ap.accession2taxid() total_entrires = 0 for accs in acc_list: total_entrires += len(accs) self.assertEqual(total_entrires, 55211)
def test_wrong_dbtype(self): """Check wrong dbtype raises an exception""" with self.assertRaises(SystemExit): TaxaDB(dbtype='fake')
def test_max_limit_ok(self): ids = [i for i in range(1, 90)] self.assertTrue(TaxaDB.check_list_ids(ids))
def test_max_limit_exceeded(self): """Check max length of ids raises an exception""" ids = [i for i in range(1, 1001)] with self.assertRaises(SystemExit): TaxaDB.check_list_ids(ids)