Exemple #1
0
 def _assign_single(self,blast,db_file,best):
     self.logger.info("\n# [BASTA STATUS] Assigning taxonomies ...")
     (tax_lookup, map_lookup) = self._get_lookups(db_file)
     taxa = []
     nofo_map = []
     out_fh = open(self.output, "w")
     for seq_hits in futils.hit_gen(blast,self.alen,self.evalue,self.identity,self.config,self.num):
         for seq in seq_hits:
             self._get_tax_list(seq_hits[seq],map_lookup,tax_lookup,taxa,nofo_map)
     lca = self._getLCS([x for x in taxa if x])
     if self.info_file:
         self._print_info(taxa,"Sequence")
     self._print(out_fh,"Sequence",lca,best,taxa)
     return lca
Exemple #2
0
 def _assign_sequence(self,blast,db_file,best):
     self.logger.info("\n# [BASTA STATUS] Assigning taxonomies ...")
     (tax_lookup, map_lookup) = self._get_lookups(db_file)
     nofo_map = []
     out_fh = open(self.output,"w")
     print(self.info_file)
     for seq_hits in futils.hit_gen(blast,self.alen,self.evalue,self.identity,self.config,self.num):
         for seq in seq_hits:
             taxa = []
             self._get_tax_list(seq_hits[seq],map_lookup,tax_lookup,taxa,nofo_map)
             lca = self._getLCS(taxa)
             if self.info_file:
                 self._print_info(taxa,seq)
             self._print(out_fh,seq,lca,best,taxa)
     out_fh.close()
Exemple #3
0
 def test_hit_hash(self):
     hh = fu._hit_hash(['bli',10,20,1e-7,'bla'],self.config)
     self.assertEqual(hh['evalue'],1e-7)
     self.assertEqual(hh['identity'],10)
     self.assertEqual(hh['id'],'bla')
     self.assertEqual(hh['alen'],20)
Exemple #4
0
 def test_get_hit_name(self):
     self.assertEqual(fu._get_hit_name("something|acc.1|me myself and I"),"acc")
     self.assertEqual(fu._get_hit_name("acc.1 me, myself and I"),"acc")
     self.assertEqual(fu._get_hit_name("gi|123145|ref|acc.1"),"acc")
     self.assertEqual(fu._get_hit_name("acc.1"),"acc")
Exemple #5
0
 def test_check_hit(self):
     self.assertTrue(fu._check_hit(['bli',10,20,1e-7,'bla'],5,0.05,5,self.config))
     self.assertFalse(fu._check_hit(['bli',4,20,1e-7,'bla'],5,0.05,5,self.config))
     self.assertFalse(fu._check_hit(['bli',10,4,1e-7,'bla'],5,0.05,5,self.config))
     self.assertFalse(fu._check_hit(['bli',10,20,2,'bla'],5,0.05,5,self.config))