view 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
line wrap: on
line source

#!/usr/bin/env python
# This tool takes a gff file as input and counts the number of features in it.

from __future__ import print_function

import fileinput
import sys

from bx.intervals.io import GenomicInterval
from galaxy.datatypes.util.gff_util import GFFReaderWrapper

# 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)