3

How can I do this? I use Biopython and saw manual already. Of course I can make blastdb from FASTA using "makeblastdb" in standalone NCBI BLAST+, but I want to whole process in one program.

It seems there are two possible solutions.

  1. Find a function which perform this job.

    I cannot find this. I've spent whole day.

  2. Run "makeblastdb" in python.

    I input os.system("C:\blast-2.2.25+\bin\makeblastdb.exe") in my python shell, but I couldn't give any parameters.

How can I solve this? Thank you for your helping.

1 Answers1

2

This is classic Blast, but I think the idea stays the same. Code is extracted from my application KimBlast. I think it is self-explaining:

def on_execute_setup(self, evt):
    """on pressing execute button"""
    FORMAT_EXE = os.path.join(self.blastpath, 'bin', 'formatdb')
    fasta = os.path.join(self.dbpath, self.fasta)
    format_filename = self.format_file.rsplit('.', 1)[0] 
    format_filepath = os.path.join(self.dbpath, format_filename)
    format_type = 'T' if self.format_type == 'protein' else 'F' 

    format_cmd = '%s -i %s -p %s -n %s' % (FORMAT_EXE, fasta, 
                                           format_type, format_filepath)
    process = subprocess.Popen(format_cmd,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE,
                                shell=False)

    (out, err) = process.communicate()
joaquin
  • 82,968
  • 29
  • 138
  • 152