File: snp_file.py

package info (click to toggle)
python-pymummer 0.11.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 320 kB
  • sloc: python: 1,074; sh: 55; makefile: 6
file content (24 lines) | stat: -rw-r--r-- 522 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pyfastaq
from pymummer import snp, variant

def reader(fname):
    f = pyfastaq.utils.open_file_read(fname)

    for line in f:
        if line.startswith('[') or (not '\t' in line):
            continue

        yield snp.Snp(line)

    pyfastaq.utils.close(f)


def get_all_variants(fname):
    variants = []
    fr = reader(fname)
    for nucmer_snp in fr:
        if len(variants) == 0 or not variants[-1].update_indel(nucmer_snp):
            variants.append(variant.Variant(nucmer_snp))

    return variants