Mercurial > repos > iuc > bbgbigwig
annotate gff_to_bed_converter.py @ 0:65a296d558e7 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
| author | iuc |
|---|---|
| date | Fri, 12 Dec 2025 21:28:28 +0000 |
| parents | |
| children |
| rev | line source |
|---|---|
|
0
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
2 |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
3 import sys |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
4 |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
5 assert sys.version_info[:2] >= (2, 6) |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
6 |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
7 |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
8 def __main__(): |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
9 skipped_lines = 0 |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
10 first_skipped_line = None |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
11 # was sys.argv[2] but we need stdout for a pipe in bam_bed_gff_to_bigwig.xml |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
12 for i, line in enumerate(sys.stdin): |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
13 line = line.rstrip("\r\n") |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
14 if line and not line.startswith("#"): |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
15 try: |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
16 elems = line.split("\t") |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
17 start = str(int(elems[3]) - 1) |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
18 endoff = str(int(elems[4]) - 1) |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
19 # GFF format: chrom, source, name, chromStart, chromEnd, score, strand |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
20 # bedtools puts out only 4 fields: chrom, chromStart, chromEnd, score |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
21 sys.stdout.write(f"{elems[0]}\t{start}\t{endoff}\t0\n") |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
22 except Exception: |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
23 skipped_lines += 1 |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
24 if not first_skipped_line: |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
25 first_skipped_line = i + 1 |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
26 else: |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
27 skipped_lines += 1 |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
28 if not first_skipped_line: |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
29 first_skipped_line = i + 1 |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
30 |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
31 |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
32 if __name__ == "__main__": |
|
65a296d558e7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/bbgbigwig commit decf6daa4769664f779bc088b83b0f89ac1df147
iuc
parents:
diff
changeset
|
33 __main__() |
