diff count_gff_features.py @ 0:fabda887a71f draft

Imported from capsule None
author devteam
date Mon, 28 Jul 2014 11:56:10 -0400
parents
children 188392a0d0a8
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/count_gff_features.py	Mon Jul 28 11:56:10 2014 -0400
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+# This tool takes a gff file as input and counts the number of features in it.
+
+import sys, fileinput
+from galaxy import eggs
+from galaxy.datatypes.util.gff_util import GFFReaderWrapper
+from bx.intervals.io import GenomicInterval
+
+# Get args.
+input_file = sys.argv[1:]
+
+# Count features.
+count = 0
+for feature in GFFReaderWrapper( fileinput.FileInput( input_file ), fix_strand=True ):
+    if isinstance( feature, GenomicInterval ):
+        count += 1
+
+print count
\ No newline at end of file