def test_template_attribute_reading_first_mapping():
    infile = gt.InputFile(testfiles["test.map"])
    for tmpl in infile:
        print "Template"
        assert tmpl.tag == "HWI-ST661:153:D0FTJACXX:2:1102:13924:124292", tmpl.tag
        assert tmpl.blocks == 1, tmpl.blocks
        assert tmpl.counters == 3, tmpl.counters
        assert tmpl.mcs == 2, tmpl.mcs
        assert tmpl.level() == -1, tmpl.level()
        break
def test_open_raw_stream_from_stream():
    p = subprocess.Popen(["cat", testfiles["bedconvert.map"]],
                         stdout=subprocess.PIPE)
    infile = gt.InputFile(p.stdout)
    p.wait()
    count = 0
    for line in infile.raw_stream():
        count += 1
        assert line.startswith("WI-ST472_0084:6:1101:1179:2208#CTTGTA")
    assert count == 1
def test_open_stream():
    p = subprocess.Popen(["cat", testfiles["bedconvert.map"]],
                         stdout=subprocess.PIPE)
    infile = gt.InputFile(p.stdout)
    p.wait()
    count = 0
    for tmpl in infile:
        count += 1
        assert tmpl.tag == "WI-ST472_0084:6:1101:1179:2208#CTTGTA", tmpl.tag
        assert tmpl.blocks == 2, tmpl.blocks
    assert count == 1
Example #4
0
def test_pipeline_fastaq_input():
    ff = gt.InputFile(test_mapping)
    p = gu.run_tools([["cat", "-"]], input=ff, force_debug=True)
    lines = 0
    while (True):
        s = p.stdout.readline()
        if s is None or len(s) == 0:
            break
        lines += 1
    assert p.wait() == 0
    assert lines == 40
def test_template_unmapped_filter_length():
    infile = gt.InputFile(testfiles["test.map.gz"])
    assert 1 == len([x for x in gt.unmapped(infile, 1)
                     ]), len([x for x in gt.unmapped(infile, 1)])
    assert 5 == len([x for x in gt.unmapped(infile, 0)
                     ]), len([x for x in gt.unmapped(infile, 0)])
    assert 1 == len([x for x in gt.unmapped(infile, 2)
                     ]), len([x for x in gt.unmapped(infile, 2)])
    assert 0 == len([x for x in gt.unmapped(infile, 3)
                     ]), len([x for x in gt.unmapped(infile, 3)])
    assert 0 == len([x for x in gt.unmapped(infile, 4)
                     ]), len([x for x in gt.unmapped(infile, 4)])
def test_template_unique_filter_level():
    infile = gt.InputFile(testfiles["test.map.gz"])
    assert 1 == len([x for x in gt.unique(infile, 20)
                     ]), "Should be length 1 buyt is: " + str(
                         [x.level() for x in gt.unique(infile, 20)])
def test_template_uniqness_level():
    infile = gt.InputFile(testfiles["test.map"])
    levels = [t.level() for t in infile]
    assert levels == [-1, 37, 0, -1, 0, 0, 0, 0, 0, 0], levels
def test_iterating_input_file():
    infile = gt.InputFile(testfiles["reads_1.fastq"])
    count = 0
    for line in infile:
        count += 1
    assert count == 10000, count