root/galaxy-central/eggs/bx_python-0.5.0_dev_f74aec067563-py2.6-macosx-10.6-universal-ucs2.egg/EGG-INFO/scripts/bed_coverage.py

リビジョン 3, 0.6 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1#!/usr/bin/python2.6
2
3"""
4Print number of bases covered by all intervals in a bed file (bases covered by
5more than one interval are counted only once). Multiple bed files can be
6provided on the command line or to stdin.
7
8usage: %prog bed files ...
9"""
10
11import psyco_full
12import sys
13from bx.bitset import BinnedBitSet
14from bx.bitset_builders import *
15from itertools import *
16
17bed_filenames = sys.argv[1:]
18if bed_filenames:
19    input = chain( * imap( open, bed_filenames ) )
20else:
21    input = sys.stdin
22
23bitsets = binned_bitsets_from_file( input )
24
25total = 0
26for chrom in bitsets:
27    total += bitsets[chrom].count_range( 0, bitsets[chrom].size )
28
29print total   
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。