Mercurial > repos > bgruening > augustus
diff extract_features.py @ 4:4de31938431b draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/augustus commit 2896dcfd180800d00ea413a59264ef8b11788b8e
author | iuc |
---|---|
date | Fri, 20 Oct 2017 03:48:57 -0400 |
parents | af307d3285c5 |
children | 09855551d713 |
line wrap: on
line diff
--- a/extract_features.py Fri May 22 04:55:25 2015 -0400 +++ b/extract_features.py Fri Oct 20 03:48:57 2017 -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 ) -