diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gff_to_bed_converter.py	Fri Jun 14 06:47:20 2024 +0000
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+
+import sys
+
+assert sys.version_info[:2] >= (2, 6)
+
+
+def __main__():
+    skipped_lines = 0
+    first_skipped_line = None
+    # was sys.argv[2] but we need stdout for a pipe in bam_bed_gff_to_bigwig.xml
+    for i, line in enumerate(sys.stdin):
+        line = line.rstrip("\r\n")
+        if line and not line.startswith("#"):
+            try:
+                elems = line.split("\t")
+                start = str(int(elems[3]) - 1)
+                endoff = str(int(elems[4]) - 1)
+                # GFF format: chrom, source, name, chromStart, chromEnd, score, strand
+                # bedtools puts out only 4 fields: chrom, chromStart, chromEnd, score
+                sys.stdout.write(f"{elems[0]}\t{start}\t{endoff}\t0\n")
+            except Exception:
+                skipped_lines += 1
+                if not first_skipped_line:
+                    first_skipped_line = i + 1
+        else:
+            skipped_lines += 1
+            if not first_skipped_line:
+                first_skipped_line = i + 1
+
+
+if __name__ == "__main__":
+    __main__()