コード例 #1
0
ファイル: test_pw.py プロジェクト: amirkdv/biseqt
def test_alignment_std_local(err):
    A = Alphabet('ACGT')
    M = MutationProcess(A, subst_probs=err, go_prob=err, ge_prob=err)
    subst_scores, (go_score, ge_score) = M.log_odds_scores()

    S = rand_seq(A, 100)
    T, tx = M.mutate(S)
    T = A.parse('A' * 100) + T + A.parse('G' * 100)
    mutation_aln = Alignment(S, T, tx)
    mutation_score = mutation_aln.calculate_score(subst_scores, go_score,
                                                  ge_score)

    aligner = Aligner(S, T, subst_scores=subst_scores, go_score=go_score,
                      ge_score=ge_score, alnmode=STD_MODE, alntype=LOCAL)
    with aligner:
        reported_score = aligner.solve()
        assert round(reported_score, 3) >= round(mutation_score, 3), \
            'optimal alignment scores better than the known transcript'
        alignment = aligner.traceback()
        aln_score = alignment.calculate_score(subst_scores, go_score, ge_score)
        assert round(aln_score, 3) == round(reported_score, 3), \
            'The alignment score should be calculated correctly'

        ori_len = Alignment.projected_len(alignment.transcript, on='origin')
        mut_len = Alignment.projected_len(alignment.transcript, on='mutant')
        assert ori_len <= len(S) and mut_len < len(T), \
            'Local alignments do not cover the entirety of both sequences'
コード例 #2
0
ファイル: test_pw.py プロジェクト: amirkdv/biseqt
def test_projected_aln_len():
    assert Alignment.projected_len('MMM', on='origin') == 3
    assert Alignment.projected_len('MMM', on='mutant') == 3
    assert Alignment.projected_len('SMS', on='origin') == 3
    assert Alignment.projected_len('SMS', on='mutant') == 3
    assert Alignment.projected_len('DMS', on='origin') == 3
    assert Alignment.projected_len('DMS', on='mutant') == 2
    assert Alignment.projected_len('IMS', on='origin') == 2
    assert Alignment.projected_len('IMS', on='mutant') == 3