comparison gff_to_bed_converter.py @ 1:49c6f715bc82 draft

planemo upload for repository https://www.encodeproject.org/software/bedgraphtobigwig/
author fubar
date Fri, 14 Jun 2024 06:47:20 +0000
parents
children
comparison
equal deleted inserted replaced
0:4eadb56fa314 1:49c6f715bc82
1 #!/usr/bin/env python
2
3 import sys
4
5 assert sys.version_info[:2] >= (2, 6)
6
7
8 def __main__():
9 skipped_lines = 0
10 first_skipped_line = None
11 # was sys.argv[2] but we need stdout for a pipe in bam_bed_gff_to_bigwig.xml
12 for i, line in enumerate(sys.stdin):
13 line = line.rstrip("\r\n")
14 if line and not line.startswith("#"):
15 try:
16 elems = line.split("\t")
17 start = str(int(elems[3]) - 1)
18 endoff = str(int(elems[4]) - 1)
19 # GFF format: chrom, source, name, chromStart, chromEnd, score, strand
20 # bedtools puts out only 4 fields: chrom, chromStart, chromEnd, score
21 sys.stdout.write(f"{elems[0]}\t{start}\t{endoff}\t0\n")
22 except Exception:
23 skipped_lines += 1
24 if not first_skipped_line:
25 first_skipped_line = i + 1
26 else:
27 skipped_lines += 1
28 if not first_skipped_line:
29 first_skipped_line = i + 1
30
31
32 if __name__ == "__main__":
33 __main__()