annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
1 #!/usr/bin/env python
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
2 # This tool takes a gff file as input and counts the number of features in it.
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
3
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
4 import sys, fileinput
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
5 from galaxy import eggs
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
6 from galaxy.datatypes.util.gff_util import GFFReaderWrapper
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
7 from bx.intervals.io import GenomicInterval
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
8
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
9 # Get args.
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
10 input_file = sys.argv[1:]
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
11
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
12 # Count features.
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
13 count = 0
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
14 for feature in GFFReaderWrapper( fileinput.FileInput( input_file ), fix_strand=True ):
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
15 if isinstance( feature, GenomicInterval ):
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
16 count += 1
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
17
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
18 print count