annotate count_gff_features.py @ 1:188392a0d0a8 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
author devteam
date Tue, 06 Jun 2017 18:37:53 -0400
parents fabda887a71f
children
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
1
188392a0d0a8 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
devteam
parents: 0
diff changeset
4 from __future__ import print_function
188392a0d0a8 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
devteam
parents: 0
diff changeset
5
188392a0d0a8 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
devteam
parents: 0
diff changeset
6 import fileinput
188392a0d0a8 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
devteam
parents: 0
diff changeset
7 import sys
188392a0d0a8 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
devteam
parents: 0
diff changeset
8
188392a0d0a8 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
devteam
parents: 0
diff changeset
9 from bx.intervals.io import GenomicInterval
0
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
10 from galaxy.datatypes.util.gff_util import GFFReaderWrapper
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
11
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
12 # Get args.
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
13 input_file = sys.argv[1:]
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
14
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
15 # Count features.
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
16 count = 0
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
17 for feature in GFFReaderWrapper( fileinput.FileInput( input_file ), fix_strand=True ):
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
18 if isinstance( feature, GenomicInterval ):
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
19 count += 1
fabda887a71f Imported from capsule None
devteam
parents:
diff changeset
20
1
188392a0d0a8 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
devteam
parents: 0
diff changeset
21 print(count)