Skip to content
Snippets Groups Projects
Commit 5f7d6530 authored by Gabriel Studer's avatar Gabriel Studer
Browse files

some finetuning, especially in CreateDB function

parent a12356ba
No related branches found
No related tags found
No related merge requests found
...@@ -130,33 +130,41 @@ class BlastError(RuntimeError): ...@@ -130,33 +130,41 @@ class BlastError(RuntimeError):
else: else:
return self.brief return self.brief
def CreateDB(infasta, dbout, mkdb_cmd='makeblastdb'): def CreateDB(infasta, dbout, mkdb_cmd=None):
""" """
Create a blast DB from a fasta file Create a blast DB from a fasta file
:param infasta: the pdb fasta from which the database will be created :param infasta: the pdb fasta from which the database will be created
:type infasta: :class:`string` :type infasta: :class:`string`
:param dbout: output location for blatDB file :param dbout: output location for blastDB file
:type infasta: :class:`string` :type infasta: :class:`string`
""" """
try: if mkdb_cmd==None:
exe=settings.Locate('makeblastdb')
args=[exe, '-in', infasta, ' -max_file_sz 10GB -out', dbout,'-dbtype','prot']
except:
try: try:
exe=settings.Locate('formatdb') exe=settings.Locate('makeblastdb')
args=[exe, '-i', infasta, '-v',str(10000),'-n',dbout] args=[exe, '-in', infasta, ' -max_file_sz 10GB -out', dbout,'-dbtype','prot']
except: except:
raise BlastError('could not find makeblastdb/formatdb executable') try:
exe=settings.Locate('formatdb')
args=[exe, '-i', infasta, '-v',str(10000),'-n',dbout]
except:
raise RuntimeError('could not find makeblastdb/formatdb executable')
else:
if os.path.basename(mkdb_cmd)=='makeblastdb':
exe=settings.Locate('makeblastdb',explicit_file_name=mkdb_cmd)
args=[exe, '-in', infasta, ' -max_file_sz 10GB -out', dbout,'-dbtype','prot']
elif os.path.basename(mkdb_cmd)=='formatdb':
exe=settings.Locate('formatdb',explicit_filename=mkdb_cmd)
args=[exe, '-i', infasta, '-v',str(10000),'-n',dbout]
else:
raise IOError('mkdb command must either be the path to formatdb or makeblastdb!')
cmd=' '.join(args) cmd=' '.join(args)
ost.LogInfo('creating blast DB (%s)' % cmd) ost.LogInfo('creating blast DB (%s)' % cmd)
stderr=os.system(cmd) os.system(cmd)
print stderr
print "finished creating blast DB"
def BlastVersion(blast_location=None): def BlastVersion(blast_location=None):
""" """
...@@ -169,7 +177,7 @@ def BlastVersion(blast_location=None): ...@@ -169,7 +177,7 @@ def BlastVersion(blast_location=None):
try: try:
blast_exe=settings.Locate('blastall', explicit_file_name=blast_location) blast_exe=settings.Locate('blastall', explicit_file_name=blast_location)
except: except:
raise BlastError('could not find blast executable') raise RuntimeError('could not find blast executable')
if os.path.basename(blast_exe)=='blastall': if os.path.basename(blast_exe)=='blastall':
args=[blast_exe] args=[blast_exe]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment