view reformat.py @ 4:08e4ca411ea6 draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/minced commit edee3afc7d729be9a224d21729bb7490a3761a0e-dirty
author bgruening
date Sun, 18 Sep 2016 06:18:17 -0400
parents 5ead4a4f46bd
children
line wrap: on
line source

#!/usr/bin/env python

"""
    Extract importent information from the standard output file and put it in some standard format, like BED and tabular.
"""

import sys

bed = open(sys.argv[2], 'w+')
tabular = open(sys.argv[3], 'w+')

for line in open(sys.argv[1]):
    # Sequence 'CRISPRs' (10798 bp)
    if line.startswith('Sequence '):
        organism = line.split("'")[1]
    # CRISPR 1   Range: 679197 - 682529
    if line.startswith('CRISPR '):
        start,end = line.split('Range:')[1].strip().split('-')
        start = start.strip()
        end = end.strip()
        bed.write('%s\t%s\t%s\n' % (organism, start, end))
    if line.rstrip().endswith(']'):
        cols = line.split()
        tabular.write("%s\t%s\t%s\t%s\t%s\t%s\n" % (organism, cols[0], cols[1], cols[2], cols[4].rstrip(','), cols[5]))