Skip to content
Snippets Groups Projects
Commit faac2923 authored by Marco Biasini's avatar Marco Biasini
Browse files

cater for specific needs of blast 2.2.16

parent 3513af4b
No related branches found
No related tags found
No related merge requests found
...@@ -125,6 +125,20 @@ def ParseBlastOutput(string): ...@@ -125,6 +125,20 @@ def ParseBlastOutput(string):
hits.append(BlastHit(hit_id, aligned_patches)) hits.append(BlastHit(hit_id, aligned_patches))
return hits return hits
def BlastVersion(blast_location=None):
"""
Returns the version of the BLAST executable, e.g. 2.2.24 as a string
"""
blastall_exe=settings.Locate('blastall', explicit_file_name=blast_location)
blast_pipe=subprocess.Popen(blastall_exe, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
lines=blast_pipe.stdout.readlines()
pattern=re.compile(r'blastall (\d+\.\d+\.\d+)\s+arguments:\s*')
for line in lines:
m=pattern.match(line)
if m:
return m.group(1)
raise IOError("could not determine blast version for '%s'" % blastall_exe)
def Blast(query, database, gap_open=11, gap_ext=1, matrix='BLOSUM62', def Blast(query, database, gap_open=11, gap_ext=1, matrix='BLOSUM62',
blast_location=None): blast_location=None):
......
...@@ -26,11 +26,20 @@ class TestBlastBindings(unittest.TestCase): ...@@ -26,11 +26,20 @@ class TestBlastBindings(unittest.TestCase):
def testParseBlastOutput(self): def testParseBlastOutput(self):
hits=blast.Blast(self.query, 'testfiles/seqdb') hits=blast.Blast(self.query, 'testfiles/seqdb')
expected_output=[{'evalue':2.366130E-59,'bitscore':211.460,'score':537}, blast_version=blast.BlastVersion()
{'evalue':4.808930E-59,'bitscore':210.305,'score':534}, if blast_version=='2.2.16':
{'evalue':5.361450E-58,'bitscore':206.838,'score':525}, expected_output=[{'evalue':4.808930E-59,'bitscore':210.305,'score':534},
{'evalue':3.277500E+00,'bitscore':15.0086,'score':27}, {'evalue':2.366130E-59,'bitscore':210.305,'score':534},
{'evalue':9.696520E+00,'bitscore':13.4678,'score':23}] {'evalue':5.361450E-58,'bitscore':206.068,'score':523},
{'evalue':2.965230E+00,'bitscore':15.0086,'score':27},
{'evalue':9.696520E+00,'bitscore':13.4678,'score':23}]
else:
expected_output=[{'evalue':2.366130E-59,'bitscore':211.460,'score':537},
{'evalue':4.808930E-59,'bitscore':210.305,'score':534},
{'evalue':5.361450E-58,'bitscore':206.838,'score':525},
{'evalue':3.277500E+00,'bitscore':15.0086,'score':27},
{'evalue':9.696520E+00,'bitscore':13.4678,'score':23}]
self.assertEqual(len(hits), 4) self.assertEqual(len(hits), 4)
for expected, hit in zip(expected_output, hits): for expected, hit in zip(expected_output, hits):
patch=hit.aligned_patches[0] patch=hit.aligned_patches[0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment