root/galaxy-central/eggs/bx_python-0.5.0_dev_f74aec067563-py2.6-macosx-10.6-universal-ucs2.egg/bx/intervals/operations/base_coverage.py

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

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

行番号 
1"""
2Determine the number of bases covered by a set of intervals.
3"""
4
5import psyco_full
6
7import traceback
8import fileinput
9from warnings import warn
10
11from bx.intervals.io import *
12from bx.intervals.operations import *
13
14def base_coverage( reader ):
15    # Handle any ValueError, IndexError and OverflowError exceptions that may be thrown when
16    # the bitsets are being created by skipping the problem lines
17    base_reader = BitsetSafeReaderWrapper( reader, lens={} )
18    bitsets = base_reader.binned_bitsets()
19    coverage = 0
20    for chrom in bitsets:
21        try:
22            coverage += bitsets[chrom].count_range(0, MAX_END)
23        except IndexError, e:
24            base_reader.skipped += 1
25            # no reason to stuff an entire bad file into memmory
26            if base_reader.skipped < 10:
27                base_reader.skipped_lines.append( ( base_reader.linenum, base_reader.current_line, str( e ) ) )
28            continue
29    return coverage
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。