Mercurial > repos > devteam > count_gff_features
annotate count_gff_features.py @ 1:115bba486116 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:39 -0400 | 
| parents | 002a1e6ef8d9 | 
| children | 
| rev | line source | 
|---|---|
| 0 | 1 #!/usr/bin/env python | 
| 2 # This tool takes a gff file as input and counts the number of features in it. | |
| 3 | |
| 1 
115bba486116
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
 devteam parents: 
0diff
changeset | 4 from __future__ import print_function | 
| 
115bba486116
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
 devteam parents: 
0diff
changeset | 5 | 
| 
115bba486116
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
 devteam parents: 
0diff
changeset | 6 import fileinput | 
| 
115bba486116
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
 devteam parents: 
0diff
changeset | 7 import sys | 
| 
115bba486116
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
 devteam parents: 
0diff
changeset | 8 | 
| 
115bba486116
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
 devteam parents: 
0diff
changeset | 9 from bx.intervals.io import GenomicInterval | 
| 0 | 10 from galaxy.datatypes.util.gff_util import GFFReaderWrapper | 
| 11 | |
| 12 # Get args. | |
| 13 input_file = sys.argv[1:] | |
| 14 | |
| 15 # Count features. | |
| 16 count = 0 | |
| 17 for feature in GFFReaderWrapper( fileinput.FileInput( input_file ), fix_strand=True ): | |
| 18 if isinstance( feature, GenomicInterval ): | |
| 19 count += 1 | |
| 20 | |
| 1 
115bba486116
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/count_gff_features commit d242cab2b4e86bc8a16eeaee7e5dc0264e617170
 devteam parents: 
0diff
changeset | 21 print(count) | 
