Пример #1
0
def test_cumsum__integers():
    assert list(utils.cumsum(list(range(-4, 5)))) == [
        -4,
        -7,
        -9,
        -10,
        -10,
        -9,
        -7,
        -4,
        0,
    ]
Пример #2
0
    def __init__(self, bamfile, desc = None, step = 1e6, out = sys.stderr):
        self._bam   = None
        self._out   = out
        self._desc  = desc
        self._step  = int(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._bam_references = None

        self._total  = 0.0
        self._counts = []
        if bamfile and bamfile.header.get("HD", {}).get("SO", "NA") == "coordinate":
            self._bam   = bamfile
            self._bam_references = self._bam.references

            lengths = bamfile.lengths
            self._total = float(sum(lengths)) or 1.0
            self._counts.append(0)
            self._counts.extend(cumsum(lengths))
Пример #3
0
    def __init__(self, bamfile, desc=None, step=1e6, out=sys.stderr):
        self._bam = None
        self._out = out
        self._desc = desc
        self._step = int(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._bam_references = None

        self._total = 0.0
        self._counts = []
        if bamfile and bamfile.header.get("HD", {}).get("SO",
                                                        "NA") == "coordinate":
            self._bam = bamfile
            self._bam_references = self._bam.references

            lengths = bamfile.lengths
            self._total = float(sum(lengths)) or 1.0
            self._counts.append(0)
            self._counts.extend(cumsum(lengths))
Пример #4
0
def test_cumsum__initial():
    assert_equal(list(utils.cumsum(range(5), -10)), [-10, -9, -7, -4, 0])
Пример #5
0
def test_cumsum__float():
    assert_equal(list(utils.cumsum((1.0, 2.0, 3.0))), [1.0, 3.0, 6.0])
Пример #6
0
def test_cumsum__integers():
    assert_equal(list(utils.cumsum(range(-4, 5))),
                 [-4, -7, -9, -10, -10, -9, -7, -4, 0])
Пример #7
0
def test_cumsum__empty():
    assert_equal(list(utils.cumsum([])), [])
Пример #8
0
def test_cumsum__initial():
    assert list(utils.cumsum(list(range(5)), -10)) == [-10, -9, -7, -4, 0]
Пример #9
0
def test_cumsum__float():
    assert list(utils.cumsum((1.0, 2.0, 3.0))) == [1.0, 3.0, 6.0]
Пример #10
0
def test_cumsum__empty():
    assert list(utils.cumsum([])) == []