def getnib( nibdir ): seqs = {} for nibf in os.listdir( nibdir ): if not nibf.endswith('.nib'): continue chr = nibf.replace('.nib','') file = os.path.join( nibdir, nibf ) seqs[chr] = nib.NibFile( open(file) ) return seqs
#!/afs/bx.psu.edu/project/pythons/py2.7-linux-x86_64-ucs4/bin/python2.7 """ Print the number of bases in a nib file. usage: %prog nib_file """ from bx.seq import nib as seq_nib import sys nib = seq_nib.NibFile(file(sys.argv[1])) print nib.length
#!/usr/bin/env python """ Print the number of bases in a nib file. usage: %prog nib_file """ from __future__ import print_function import sys from bx.seq import nib as seq_nib with open(sys.argv[1]) as f: nib = seq_nib.NibFile(f) print(nib.length)