Ejemplo n.º 1
0
def foun(file: str):
    """The Founder Effect and Genetic Drift"""
    l1, l2 = Parser(file).lines()
    n, m = [int(x) for x in l1.split()]
    a = [int(x) for x in l2.split()]
    for x in pr.foun(n, m, a):
        print(*[round(f, 8) for f in x])
Ejemplo n.º 2
0
def conv(file: str):
    """Comparing Spectra with the Spectral Convolution"""
    l1, l2 = Parser(file).lines()
    s1 = list(map(float, l1.split()))
    s2 = list(map(float, l2.split()))
    res = mass.conv(s1, s2)
    print(res[1], res[0], sep="\n")
Ejemplo n.º 3
0
def rstr(file: str):
    """Matching Random Motifs"""
    l1, seq = Parser(file).lines()
    n, x = map(float, l1.split(" "))
    gc = sum([seq.count(x) for x in "GC"])
    lam = ((1 - x) / 2) ** (len(seq) - gc) * (x / 2) ** gc * n
    print(1 - math.exp(-lam))
Ejemplo n.º 4
0
def lexf(file: str):
    """Enumerating k-mers Lexicographically"""

    l1, l2 = Parser(file).lines()
    set = l1.split(" ")
    n = int(l2)
    perm = ["".join(x) for x in product(set, repeat=n)]
    print(*sorted(perm), sep="\n")
Ejemplo n.º 5
0
def lgis(file: str):
    """Longest Increasing Subsequence"""
    data = Parser(file).lines()[1]
    data = [int(x) for x in data.split(" ")]
    s1 = ros.lgis(data)
    print(*s1)

    s2 = ros.lgis([-x for x in data])
    s2 = [-x for x in s2]
    print(*s2)
Ejemplo n.º 6
0
def lexv(file: str):
    """Ordering Strings of Varying Length Lexicographically"""
    l1, l2 = Parser(file).lines()
    print(*ros.lexv(l1.split(), int(l2)), sep="\n")