예제 #1
0
파일: blast.py 프로젝트: jamescasbon/pygr
 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
예제 #2
0
파일: blast.py 프로젝트: antonwang/pygr
 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