示例#1
0
def run_fsa(sequences, path=''):
    command = ['fsa', 'tmp.fasta']
    dna.write_fasta(sequences, 'tmp.fasta')
    fsa = subprocess.Popen(command, stdout=subprocess.PIPE)
    fsa_out, fsa_err = fsa.communicate()
    fsa_file = open('tmp.aln', 'w')
    fsa_file.write(fsa_out)
    fsa_results = dna.read_fasta('tmp.aln')
    os.remove('tmp.fasta')
    os.remove('tmp.aln')
    return fsa_results
示例#2
0
def run_prank(sequences, path='', tree='', codon=False, translate=False):
    command = [path + 'prank',
               '-d=tmp.fasta',
               '-o=tmp',
               '-F']
    if tree != '':
        command += ['t=' + tree]
    if codon:
        command += ['-codon']
    if translate:
        command += ['-translate']
    dna.write_fasta(sequences, 'tmp.fasta')
    prank = subprocess.Popen(command, stdout=subprocess.PIPE)
    prank_out, prank_err = prank.communicate()
    prank_results = dna.read_fasta('tmp.best.fas')
    os.remove('tmp.fasta')
    os.remove('tmp.best.fas')
    return prank_results
示例#3
0
def convert_prank(sequences, path='', dna_input='', input_format=''):
    command = [path + 'prank',
               '-convert',
               '-d=tmp.fasta',
               '-o=tmp',
               '-keep']
    formats = ['fasta','phylipi','phylips','paml','nexus','raxml']
    if input_format != '':
        if input_format in format:
            command += ['-f=' + input_format]
        else:
            sys.exit('Specify one of the following: %s' % (', '.join(formats)))
    if dna_input != '':
        command += ['dna=' + dna_input]
    else:
        command += ['-translate']
    dna.write_fasta(sequences, 'tmp.fasta')
    prank = subprocess.Popen(command, stdout=subprocess.PIPE)
    prank_out, prank_err = prank.communicate()
    prank_results = dna.read_fasta('tmp.fas')
    os.remove('tmp.fasta')
    os.remove('tmp.fas')
    return prank_results