Created
June 2, 2014 08:13
-
-
Save davmlaw/b9bd7eb729a6eb240d99 to your computer and use it in GitHub Desktop.
chrosome sizes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
if len(sys.argv) != 2: | |
print "Usage %s: samtools_index" % os.path.basename(sys.argv[0]) | |
sys.exit(1) | |
samtools_index = sys.argv[1] | |
with open(samtools_index) as f: | |
prev_chrom = None | |
prev_size = 0 | |
for line in f: | |
cols = line.split('\t') | |
chrom = cols[0] | |
chrom_size = int(cols[1]) | |
if chrom[-1].isdigit(): | |
if prev_size: | |
length_diff = prev_size - chrom_size | |
if length_diff < 0: | |
print "%s longer than %s by %d bases!" % (chrom, prev_chrom, -length_diff) | |
prev_chrom = chrom | |
prev_size = chrom_size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment