def parse_fasta_annotations(fastas, annot_tables, trans_table):
if annot_tables is not False:<EOL><INDENT>annots = {}<EOL>for table in annot_tables:<EOL><INDENT>for cds in open(table):<EOL><INDENT>ID, start, end, strand = cds.strip().split()<EOL>annots[ID] = [start, end, int(strand)]<EOL><DEDENT><DEDENT><DEDENT>for fasta in fastas:<EOL><INDENT>for seq in parse_fasta(fasta):<EOL><INDENT>if ('<STR_LIT>' not in seq[<NUM_LIT:0>] and '<STR_LIT>' not in seq[<NUM_LIT:0>]) and annot_tables is False:<EOL><INDENT>print('<STR_LIT>', file=sys.stderr)<EOL>exit()<EOL><DEDENT>if '<STR_LIT>' in seq[<NUM_LIT:0>]:<EOL><INDENT>ID = seq[<NUM_LIT:0>].rsplit('<STR_LIT>', <NUM_LIT:1>)[<NUM_LIT:1>].split('<STR_LIT:;>', <NUM_LIT:1>)[<NUM_LIT:0>]<EOL>contig = seq[<NUM_LIT:0>].split()[<NUM_LIT:0>].split('<STR_LIT:>>')[<NUM_LIT:1>].rsplit('<STR_LIT>' % (ID), <NUM_LIT:1>)[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>contig = seq[<NUM_LIT:0>].split()[<NUM_LIT:0>].split('<STR_LIT:>>')[<NUM_LIT:1>].rsplit('<STR_LIT:_>', <NUM_LIT:1>)[<NUM_LIT:0>]<EOL><DEDENT>locus = seq[<NUM_LIT:0>].split()[<NUM_LIT:0>].split('<STR_LIT:>>')[<NUM_LIT:1>]<EOL>if ('<STR_LIT>' in seq[<NUM_LIT:0>] or '<STR_LIT>' in seq[<NUM_LIT:0>]):<EOL><INDENT>info = seq[<NUM_LIT:0>].split('<STR_LIT>')<EOL>start, end, strand = int(info[<NUM_LIT:1>]), int(info[<NUM_LIT:2>]), info[<NUM_LIT:3>]<EOL>if strand == '<STR_LIT:1>':<EOL><INDENT>strand = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>strand = -<NUM_LIT:1><EOL><DEDENT>product = ['<STR_LIT>'.join(info[<NUM_LIT:4>].split()[<NUM_LIT:1>:])]<EOL><DEDENT>else:<EOL><INDENT>start, end, strand = annots[locus]<EOL>product = seq[<NUM_LIT:0>].split('<STR_LIT:U+0020>', <NUM_LIT:1>)[<NUM_LIT:1>]<EOL><DEDENT>info = {'<STR_LIT>':[trans_table],'<STR_LIT>':[seq[<NUM_LIT:1>]],'<STR_LIT>':product}<EOL>yield contig, [locus, [start, end, strand], info]<EOL><DEDENT><DEDENT>
parse gene call information from Prodigal fasta output