annotate sanitize_bed.py @ 18:3a72fede57ce draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 32fbe8a14173afe0b39f1483afaba958dc6cd027
author iuc
date Fri, 21 Jun 2024 15:19:15 +0000
parents e319b5b65879
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
78bbd17d0703 "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
78bbd17d0703 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
2
78bbd17d0703 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
3 import sys
78bbd17d0703 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
4
78bbd17d0703 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
5
78bbd17d0703 "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:
78bbd17d0703 "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()
78bbd17d0703 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
8
78bbd17d0703 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
9 sanitized_data = []
78bbd17d0703 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
10 try:
78bbd17d0703 "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
e319b5b65879 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():
e319b5b65879 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')
e319b5b65879 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(
e319b5b65879 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:])
e319b5b65879 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 8ce6fd9aee543d9e62db33a9c95f79d8dc4e6dea
iuc
parents: 4
diff changeset
16 )
4
78bbd17d0703 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
17 except IndexError:
78bbd17d0703 "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
78bbd17d0703 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ivar/ commit 693df287d23b0fd9dfd134b41d401a438c3f5ad6"
iuc
parents:
diff changeset
19 else:
78bbd17d0703 "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:
78bbd17d0703 "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)