annotate sanitize_bed.py @ 16:a1c2aecd7a0d draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit dab395b37976a99a62334c3188073ee8b97f451f
author iuc
date Mon, 11 Mar 2024 15:48:15 +0000
parents ee29337f905c
children
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:
10
ee29337f905c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 8ce6fd9aee543d9e62db33a9c95f79d8dc4e6dea
iuc
parents: 4
diff changeset
12 if record.strip():
ee29337f905c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 8ce6fd9aee543d9e62db33a9c95f79d8dc4e6dea
iuc
parents: 4
diff changeset
13 fields = record.split('\t')
ee29337f905c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 8ce6fd9aee543d9e62db33a9c95f79d8dc4e6dea
iuc
parents: 4
diff changeset
14 sanitized_data.append(
ee29337f905c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 8ce6fd9aee543d9e62db33a9c95f79d8dc4e6dea
iuc
parents: 4
diff changeset
15 '\t'.join(fields[:4] + ['60'] + fields[5:])
ee29337f905c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 8ce6fd9aee543d9e62db33a9c95f79d8dc4e6dea
iuc
parents: 4
diff changeset
16 )
4
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
17 except IndexError:
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
18 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
19 else:
ee2beb764a7b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
20 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
21 o.writelines(sanitized_data)