def iTable2GFF(iTable, fa, contig = False):
columns = ['<STR_LIT>', '<STR_LIT:source>', '<STR_LIT>', '<STR_LIT:start>', '<STR_LIT:end>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>gff = {c:[] for c in columns}<EOL>for insertion in iTable.iterrows():<EOL><INDENT>insertion = insertion[<NUM_LIT:1>]<EOL>if insertion['<STR_LIT>'] not in fa:<EOL><INDENT>continue<EOL><DEDENT>strand = insertion['<STR_LIT>'].split('<STR_LIT>', <NUM_LIT:1>)[<NUM_LIT:1>].split()[<NUM_LIT:0>]<EOL>if contig is True:<EOL><INDENT>gene = [int(i) for i in insertion['<STR_LIT>'].split('<STR_LIT>', <NUM_LIT:1>)[<NUM_LIT:1>].split()[<NUM_LIT:0>].split('<STR_LIT:->')]<EOL>if strand == '<STR_LIT:->':<EOL><INDENT>offset = -<NUM_LIT:1> * (gene[<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>offset = gene[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>strand = '<STR_LIT:+>'<EOL>gene = [<NUM_LIT:1>, int(insertion['<STR_LIT>'].split('<STR_LIT>', <NUM_LIT:1>)[<NUM_LIT:1>].split()[<NUM_LIT:0>])]<EOL>offset = gene[<NUM_LIT:0>]<EOL><DEDENT>insertion['<STR_LIT>'] = strand<EOL>insertion['<STR_LIT>'] = offset<EOL>source = insertion['<STR_LIT>'].split('<STR_LIT>', <NUM_LIT:1>)[<NUM_LIT:0>].rsplit('<STR_LIT:U+0020>', <NUM_LIT:1>)[-<NUM_LIT:1>]<EOL>insertion['<STR_LIT:source>'] = source<EOL>geneAnnot = '<STR_LIT>' % (source.split('<STR_LIT>', <NUM_LIT:1>)[<NUM_LIT:0>])<EOL>geneNum = insertion['<STR_LIT>'].split('<STR_LIT>', <NUM_LIT:1>)[<NUM_LIT:1>].split()[<NUM_LIT:0>]<EOL>gff['<STR_LIT>'].append(insertion['<STR_LIT>'])<EOL>gff['<STR_LIT:source>'].append(source)<EOL>gff['<STR_LIT>'].append('<STR_LIT>')<EOL>gff['<STR_LIT:start>'].append(gene[<NUM_LIT:0>])<EOL>gff['<STR_LIT:end>'].append(gene[<NUM_LIT:1>])<EOL>gff['<STR_LIT>'].append('<STR_LIT:.>')<EOL>gff['<STR_LIT>'].append(strand)<EOL>gff['<STR_LIT>'].append('<STR_LIT:.>')<EOL>gff['<STR_LIT>'].append('<STR_LIT>' % (geneNum, geneAnnot))<EOL>gff = parse_rRNA(insertion, fa[insertion['<STR_LIT>']], gff)<EOL>gff = parse_insertion(insertion, gff)<EOL>gff = parse_orf(insertion, gff)<EOL>gff = parse_catalytic(insertion, gff)<EOL><DEDENT>return pd.DataFrame(gff)[columns].drop_duplicates()<EOL>
convert iTable to gff file