annotate sanitize_bed.py @ 4:ee2beb764a7b draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
author iuc
date Mon, 22 Jun 2020 07:29:10 -0400
parents
children ee29337f905c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
1 #!/usr/bin/env python
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
2
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
3 import sys
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
4
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
5
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
6 with open(sys.argv[1]) as i:
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
7 bed_data = i.readlines()
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
8
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
9 sanitized_data = []
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
10 try:
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
11 for record in bed_data:
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
12 fields = record.split('\t')
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
13 sanitized_data.append(
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
14 '\t'.join(fields[:4] + ['60'] + fields[5:])
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
15 )
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
16 except IndexError:
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
17 pass # leave column number issue to getmasked
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
18 else:
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
19 with open(sys.argv[1], 'w') as o:
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
20 o.writelines(sanitized_data)