annotate reformat.py @ 1:222b7f7b8432 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/crt commit 4241c1d4b05a177bd2c74f5a139f51d4f65e0b55
author bgruening
date Tue, 13 Jun 2017 08:25:06 -0400
parents db0f5c1cb227
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
1 #!/usr/bin/env python
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
2
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
3 """
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
4 Extract importent information from the standard output file and put it in some standard format, like BED and tabular.
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
5 """
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
6
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
7 import sys
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
8
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
9 bed = open(sys.argv[2], 'w+')
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
10 tabular = open(sys.argv[3], 'w+')
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
11
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
12 for line in open(sys.argv[1]):
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
13 # ORGANISM: gi|21226102|ref|NC_003901.1| Methanosarcina mazei Go1 chromosome, complete genome
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
14 if line.startswith('ORGANISM:'):
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
15 organism = line.lstrip('ORGANISM:').strip()
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
16 # CRISPR 1 Range: 679197 - 682529
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
17 if line.startswith('CRISPR '):
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
18 start,end = line.split('Range:')[1].strip().split('-')
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
19 start = start.strip()
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
20 end = end.strip()
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
21 bed.write('%s\t%s\t%s\n' % (organism, start, end))
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
22 if line.rstrip().endswith(']'):
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
23 cols = line.split()
db0f5c1cb227 Imported from capsule None
bgruening
parents:
diff changeset
24 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]))