def testRunBlastX(self): """ test running blastx """ ## run the blast self.blast = Blast(self.queryFile) outFile = "adh-0-2.xml" targetDB = os.path.join(self.BLASTDB, "uniprot_sprot") start, stop = 0, 2 self.blast.run_blast(targetDB, evalue=0.1, start=start, stop=stop, cmd='blastx') ## read the blast parser = ParseBlast(outFile) parser.run() ## clean up for fn in [ "adh-0-2_parsed.csv", "adh-0-2_parsed.log", "adh-0-2.fasta", "adh-0-2.xml" ]: self.assertTrue(os.path.exists(fn)) os.remove(fn)
def testGetQueryFile(self): """ test the function breaks the fasta file in to chunks """ self.blast = Blast(self.queryFile) ## index 0 to 2 should return 2 results [0,1] start, stop = 0, 2 newQueryFile = self.blast.get_query_file(".", start, stop) queryFileName = os.path.split(self.queryFile)[-1] queryFilePath = os.path.join( ".", re.sub("\.\w+", "", queryFileName, flags=re.IGNORECASE) + "-%s-%s.fasta" % (start, stop)) self.assertTrue(os.path.exists(queryFilePath)) handleIn = open(newQueryFile, "r") total = 0 for record in SeqIO.parse(handleIn, "fasta"): total += 1 self.assertEqual(total, 2) handleIn.close() os.remove(queryFilePath)