comparison gff_to_bed_converter.py @ 0:498748c87252 draft

planemo upload for repository https://www.encodeproject.org/software/bedgraphtobigwig/ commit fa9d44f1ca94a7522f21db6c7771764e1b8d92a5
author iuc
date Fri, 14 Jun 2024 21:23:54 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:498748c87252
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__()