def __init__(self, genetic_code=None, path=None): self.genetic_code = get_genetic_code(genetic_code) self.__sequences = {} self.headers = [] self.items = [] if path: self.read(path)
def main(): """ main function """ opts = get_options() genetic_code = None if opts.aa else get_genetic_code(opts.code) sequences = parse_fasta(opts.fastafile, genetic_code) tmp_dir = dirname( opts.outfile) + ('/tmp' if '/' in opts.outfile else 'tmp') Popen('mkdir -p ' + tmp_dir, shell=True).communicate() ### if we need to align: # write sense and anti-sense translated sequences this = 'seq' if opts.aa else 'prot' write_rfasta(sequences, tmp_dir + '/prot.fasta', what=this) if opts.align == 2: write_rfasta(sequences, tmp_dir + '/torp.fasta', what=this, rev=True) # run alignment if opts.align: run_alignments(tmp_dir, opts.cpus, opts.quiet, opts.align) # merge all in one, keep only sites with score better than m_coffee cut aligners = [ali for ali in BINARIES if 'fun' in BINARIES[ali]] if len(aligners) > 1 or opts.align == 2: merge_mcoffee(tmp_dir, opts.mcoffee_cut, sequences, aa=opts.aa) else: aa_ali = parse_fasta(tmp_dir + '/prot.fasta_' + aligners[0]) for seq in sequences: sequences[seq]['aa_ali'] = aa_ali[seq]['seq'] for elt in xrange(len(sequences[seq]['aa_ali'])): if sequences[seq]['aa_ali'][elt] == '-': sequences[seq]['codon'].insert(elt, '---') continue # trimal if opts.trimseq: trim_sequences(tmp_dir, opts.outfile, sequences, opts.trimseq, quiet=opts.quiet) if opts.trimcol != 'None': trim_columns(sequences, opts, tmp_dir) # write codon sequences if opts.aa: write_fasta(sequences, opts.outfile, what='aa_ali') else: write_fasta(sequences, opts.outfile, what='codon') # print map if opts.printmap: printmap(sequences, opts.outfile + '.map', opts.pymap)
def main(): """ main function """ opts = get_options() genetic_code = None if opts.aa else get_genetic_code (opts.code) sequences = parse_fasta (opts.fastafile, genetic_code) tmp_dir = dirname(opts.outfile) + ('/tmp' if '/' in opts.outfile else 'tmp') Popen('mkdir -p ' + tmp_dir, shell=True).communicate() ### if we need to align: # write sense and anti-sense translated sequences this = 'seq' if opts.aa else 'prot' write_rfasta(sequences, tmp_dir + '/prot.fasta', what=this) if opts.align == 2: write_rfasta(sequences, tmp_dir + '/torp.fasta', what=this, rev=True) # run alignment if opts.align: run_alignments(tmp_dir, opts.cpus, opts.quiet, opts.align) # merge all in one, keep only sites with score better than m_coffee cut aligners = [ali for ali in BINARIES if 'fun' in BINARIES[ali]] if len(aligners) > 1 or opts.align == 2: merge_mcoffee(tmp_dir, opts.mcoffee_cut, sequences, aa=opts.aa) else: aa_ali = parse_fasta(tmp_dir + '/prot.fasta_' + aligners[0]) for seq in sequences: sequences[seq]['aa_ali'] = aa_ali[seq]['seq'] for elt in xrange(len(sequences[seq]['aa_ali'])): if sequences[seq]['aa_ali'][elt] == '-': sequences[seq]['codon'].insert(elt, '---') continue # trimal if opts.trimseq: trim_sequences(tmp_dir, opts.outfile, sequences, opts.trimseq, quiet=opts.quiet) if opts.trimcol != 'None': trim_columns(sequences, opts, tmp_dir) # write codon sequences if opts.aa: write_fasta(sequences, opts.outfile, what='aa_ali') else: write_fasta(sequences, opts.outfile, what='codon') # print map if opts.printmap: printmap(sequences, opts.outfile + '.map', opts.pymap)