Пример #1
0
def main(bam, config):

    actg = set("ATGC")
    for pos in range(10000, 200011000):
        h = chileup.pileup(bam, "1", pos, config)
        #print(pos, h.bases, len(h.bqs), len(h.deletions), len(h.insertions))
        if set(h.bases.decode()) - actg:
            print(pos, h.bases, set(h.bases.decode()) - actg)
            break
        h.rbp(h)
Пример #2
0
def test_insertion():
    bam = pysam.AlignmentFile("tests/three.bam", "rb")
    pos = 1585270
    h = chileup.pileup(bam, "1", pos, config)
    assert h.bases == 'tt', h.bases
    assert len(h.deletions) == 2
Пример #3
0
def test_off_by_one():
    bam = pysam.AlignmentFile("tests/soft.bam", "rb")
    pos = 10080
    h = chileup.pileup(bam, "1", pos, config)
    assert h.bases == "", h.bases
Пример #4
0
    actg = set("ATGCatgc")
    for pos in range(10000, 200011000):
        h = chileup.pileup(bam, "1", pos, config)
        if len(h.insertions) > 0:
            print(pos, len(h.bases), h.insertions)
        #print(pos, h.bases, len(h.bqs), len(h.deletions), len(h.insertions))
        if set(h.bases) - actg:
            print(pos, h.bases, set(h.bases) - actg)
            break
        h.rbp(h)

if __name__ == "__main__":
    bam = pysam.AlignmentFile("/data/human/hg002.cram", "rc",
                reference_filename="/data/human/g1k_v37_decoy.fa")

    config = chileup.Config(tags=[], track_read_names=True,
            track_base_qualities=True, track_mapping_qualities=True,
            exclude_flags=pysam.FQCFAIL | pysam.FSECONDARY | pysam.FSUPPLEMENTARY | pysam.FDUP,
            min_base_quality=10, min_mapping_quality=10)

    pos = 10080
    h = chileup.pileup(bam, "1", pos, config)
    print(h)
    #print(pos, h.bases)
    test_off_by_one()
    print("off by one")
    test_insertion()
    print("insertion")

    main(bam, config)
Пример #5
0
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

import pysam
import cyvcf2
import chileup
import time

config = chileup.Config(tags=[], track_read_names=False,
            track_base_qualities=False, track_mapping_qualities=False,
            exclude_flags=pysam.FQCFAIL | pysam.FSECONDARY | pysam.FSUPPLEMENTARY | pysam.FDUP,
            min_base_quality=10, min_mapping_quality=10)

bam = pysam.AlignmentFile(sys.argv[1], "rb",
                          reference_filename="/data/human/g1k_v37_decoy.fa")

vcf = cyvcf2.VCF(sys.argv[2])

t0 = time.time()

for v in vcf("1"):
    h = chileup.pileup(bam, v.CHROM, v.start, config)
    print(repr(v).strip(), h.bases)

print("hileup time: %.2f", time.time() - t0)

# now do pysam pileup.