def run_formatdb(self, filepath): 'ATTEMPT TO BUILD BLAST DATABASE INDEXES at filepath' dirname = classutil.file_dirpath(filepath) if not os.access(dirname, os.W_OK): # check if directory is writable raise IOError('run_formatdb: directory %s is not writable!' % dirname) cmd = ['formatdb', '-i', self.filepath, '-n', filepath, '-o', 'T'] if self.seqDB._seqtype != PROTEIN_SEQTYPE: cmd += ['-p', 'F'] # special flag required for nucleotide seqs logger.info('Building index: ' + ' '.join(cmd)) if classutil.call_subprocess(cmd): # bad exit code, so command failed raise OSError('command %s failed' % ' '.join(cmd)) self.blastReady=True if filepath!=self.filepath: self.blastIndexPath = filepath
def run_formatdb(self, testpath): 'ATTEMPT TO BUILD BLAST DATABASE INDEXES at testpath' dirname = classutil.file_dirpath(testpath) if not os.access(dirname, os.W_OK): # check if directory is writable raise IOError('run_formatdb: directory %s is not writable!' % dirname) cmd = ['formatdb', '-i', self.filepath, '-n', testpath, '-o', 'T'] if self.seqDB._seqtype != PROTEIN_SEQTYPE: cmd += ['-p', 'F'] # special flag required for nucleotide seqs logger.info('Building index: ' + ' '.join(cmd)) if self.showFormatdbMessages: kwargs = {} else: # suppress formatdb messages by redirecting them kwargs = dict(stdout=classutil.PIPE, stderr=classutil.PIPE) if classutil.call_subprocess(cmd, **kwargs): # bad exit code, so command failed warn_if_whitespace(self.filepath) \ or warn_if_whitespace(testpath) # only issue one warning raise OSError('command %s failed' % ' '.join(cmd)) self.blastReady=True if testpath!=self.filepath: self.blastIndexPath = testpath