示例#1
0
    def __init__(self, bamfile, desc = None, step = 1e6, out = sys.stderr):
        self._bam   = None
        self._out   = out
        self._desc  = desc
        self._step  = step
        self._count = 0
        self._last_count = 0
        self._last_time  = time.time()
        self._start_time = self._last_time
        self._last_fract = -1.0

        self._total  = 0.0
        self._counts = []
        if bamfile and bamfile.header.get("HD", {}).get("SO", "NA") == "coordinate":
            self._bam   = bamfile
            self._total = float(sum(bamfile.lengths)) or 1.0
            self._counts.append(0)
            self._counts.extend(cumsum(bamfile.lengths))
示例#2
0
    def __init__(self, bamfile, desc=None, step=1e6, out=sys.stderr):
        self._bam = None
        self._out = out
        self._desc = desc
        self._step = step
        self._count = 0
        self._last_count = 0
        self._last_time = time.time()
        self._start_time = self._last_time
        self._last_fract = -1.0

        self._total = 0.0
        self._counts = []
        if bamfile and bamfile.header.get("HD", {}).get("SO",
                                                        "NA") == "coordinate":
            self._bam = bamfile
            self._total = float(sum(bamfile.lengths)) or 1.0
            self._counts.append(0)
            self._counts.extend(cumsum(bamfile.lengths))
示例#3
0
def test_cumsum__initial():
    assert_equal(list(utils.cumsum(range(5), -10)), [-10, -9, -7, -4, 0])
示例#4
0
def test_cumsum__float():
    assert_equal(list(utils.cumsum((1.0, 2.0, 3.0))), [1.0, 3.0, 6.0])
示例#5
0
def test_cumsum__integers():
    assert_equal(list(utils.cumsum(range(-4, 5))),
                 [-4, -7, -9, -10, -10, -9, -7, -4, 0])
示例#6
0
def test_cumsum__empty():
    assert_equal(list(utils.cumsum([])), [])
示例#7
0
def test_cumsum__initial():
    assert_equal(list(utils.cumsum(range(5), -10)), [-10, -9, -7, -4, 0])
示例#8
0
def test_cumsum__float():
    assert_equal(list(utils.cumsum((1.0, 2.0, 3.0))), [1.0, 3.0, 6.0])
示例#9
0
def test_cumsum__integers():
    assert_equal(list(utils.cumsum(range(-4, 5))), [-4, -7, -9, -10, -10, -9, -7, -4, 0])
示例#10
0
def test_cumsum__empty():
    assert_equal(list(utils.cumsum([])), [])