annotate sanitize_bed.py @ 7:43aac8d29685 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 80ad6146e8852fb04fbdbe7b14ab120eee605e3a"
author iuc
date Fri, 11 Jun 2021 15:41:24 +0000
parents ee2beb764a7b
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)