annotate sanitize_bed.py @ 8:28a6f1908fcc draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 6dae6f97a45a61b1f10be4227d978584624c3b3d"
author iuc
date Thu, 05 Aug 2021 12:44:59 +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)