Mercurial > repos > bgruening > augustus
diff extract_features.py @ 10:cb47e789ccaa draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/augustus commit 4a8f640dec78899be470ddd1c436fc0d158c80f3
| author | bgruening |
|---|---|
| date | Fri, 10 May 2019 08:25:57 -0400 |
| parents | bcfe8e0731f8 |
| children | 66c8e9d8d1c4 |
line wrap: on
line diff
--- a/extract_features.py Fri May 22 04:51:46 2015 -0400 +++ b/extract_features.py Fri May 10 08:25:57 2019 -0400 @@ -1,10 +1,10 @@ #!/usr/bin/env python -import os +import argparse import sys -import argparse import textwrap + def main( args ): """ Extract the protein and coding section from an augustus gff, gtf file @@ -45,6 +45,22 @@ if line.startswith('start gene'): gene_name = line[11:].strip() + if protein_seq: + if line.endswith(']'): + protein_seq += line[:-1] + po.write( '>%s\n%s\n' % (gene_name, '\n'.join( textwrap.wrap( protein_seq, 80 ) ) ) ) + protein_seq = '' + else: + protein_seq += line + + if coding_seq: + if line.endswith(']'): + coding_seq += line[:-1] + co.write( '>%s\n%s\n' % (gene_name, '\n'.join( textwrap.wrap( coding_seq, 80 ) ) ) ) + coding_seq = '' + else: + coding_seq += line + if args.protein and line.startswith('protein sequence = ['): if line.endswith(']'): protein_seq = line[20:-1] @@ -63,26 +79,12 @@ line = line[19:] coding_seq = line - if protein_seq: - if line.endswith(']'): - protein_seq += line[:-1] - po.write( '>%s\n%s\n' % (gene_name, '\n'.join( textwrap.wrap( protein_seq, 80 ) ) ) ) - protein_seq = '' - else: - protein_seq += line - - if coding_seq: - if line.endswith(']'): - coding_seq += line[:-1] - co.write( '>%s\n%s\n' % (gene_name, '\n'.join( textwrap.wrap( coding_seq, 80 ) ) ) ) - coding_seq = '' - else: - coding_seq += line if args.codingseq: co.close() if args.protein: po.close() + if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('-p', '--protein', help='Path to the protein file.') @@ -90,4 +92,3 @@ args = parser.parse_args() main( args ) -
