コード例 #1
0
ファイル: seq.py プロジェクト: emmaavera/stuy-girls
def percent_match(seq1, seq2):
    # list formatted as [max-number-complementary, index, index, index]
    # print "percent_match \nreturns the percentage of complementarity between two strings of bases\n"
    # assume both strings are passed '3 --> '5'
    # reverse one string for binding
    seq_helpers.reverse(seq1)
    len1 = len(seq1)
    len2 = len(seq2)
    num_matches = 0
    num_comped = 0
    p1 = len1 - 1
    p2 = 0
    while p2 < len2:
        num_matches += substring_match(seq1[p1:], seq2[p2:])
        num_comped += len(seq1[p1:])
        if p1 > 0:
            p1 = -1
        else:
            p2 += 1
    return (num_matches * 1.0) / num_comped
コード例 #2
0
ファイル: seq.py プロジェクト: emmaavera/stuy-girls
def find_binding_sites(seq1, seq2):
    seq_helpers.reverse(seq1)
    len1 = len(seq1)
    len2 = len(seq2)
    max_val = 0
    num_matches = {}
    p1 = len1 - 1
    p2 = 0
    matches = 0
    while p2 < len2:
        matches = substring_match(seq1[p1:], seq2[p2:])
        if matches in num_matches:
            num_matches[matches] += (p1, p2)
        else:
            num_matches[matches] = (p1, p2)
        if p1 > 0:
            p1 -= 1
        else:
            p2 += 1
    max_val = max(num_matches.keys())
    return [max_val, num_matches[max_val]]