예제 #1
0
def _align_pairwise(s1,
                    s2,
                    mprobs,
                    psub,
                    TM,
                    local,
                    return_alignment=True,
                    return_score=False,
                    **kw):
    """Generic alignment with any substitution model and indel model"""
    [p1, p2] = [makeLikelihoodTreeLeaf(seq) for seq in [s1, s2]]
    [p1, p2] = [pairwise.AlignableSeq(leaf) for leaf in [p1, p2]]
    pair = pairwise.Pair(p1, p2)
    EP = pair.makeSimpleEmissionProbs(mprobs, [psub])
    hmm = EP.makePairHMM(TM)
    vpath = hmm.getViterbiPath(local=local, **kw)
    score = vpath.getScore()
    if return_alignment:
        alignment = vpath.getAlignment()
        if return_score:
            return (alignment, score)
        else:
            return alignment
    else:
        return score
예제 #2
0
 def countMotifs(self, alignment, include_ambiguity=False, recode_gaps=True):
     result = None
     for seq_name in alignment.getSeqNames():
         sequence = alignment.getGappedSeq(seq_name, recode_gaps)
         leaf = makeLikelihoodTreeLeaf(sequence, self.getCountedAlphabet(), 
                 seq_name)
         count = leaf.getMotifCounts(include_ambiguity=include_ambiguity)
         if result is None:
             result = count.copy()
         else:
             result += count
     return result
예제 #3
0
 def countMotifs(self, alignment, include_ambiguity=False, recode_gaps=True):
     result = None
     for seq_name in alignment.getSeqNames():
         sequence = alignment.getGappedSeq(seq_name, recode_gaps)
         leaf = makeLikelihoodTreeLeaf(sequence, self.getCountedAlphabet(), 
                 seq_name)
         count = leaf.getMotifCounts(include_ambiguity=include_ambiguity)
         if result is None:
             result = count.copy()
         else:
             result += count
     return result
예제 #4
0
def _align_pairwise(s1, s2, mprobs, psub, TM, local, return_score=False, **kw):
    """Generic alignment with any substitution model and indel model"""
    [p1, p2] = [makeLikelihoodTreeLeaf(seq) for seq in [s1, s2]]
    [p1, p2] = [pairwise.AlignableSeq(leaf) for leaf in [p1, p2]]
    pair = pairwise.Pair(p1, p2)
    EP = pair.makeSimpleEmissionProbs(mprobs, [psub])
    hmm = EP.makePairHMM(TM)
    if local:
        (score, alignment) = hmm.getLocalViterbiScoreAndAlignment(**kw)
    else:
        (score, alignment) = hmm.getViterbiScoreAndAlignment(**kw)

    if return_score:
        return alignment, score
    else:
        return alignment
예제 #5
0
def _align_pairwise(s1, s2, mprobs, psub, TM, local, return_score=False, **kw):
    """Generic alignment with any substitution model and indel model"""
    [p1, p2] = [makeLikelihoodTreeLeaf(seq) for seq in [s1, s2]]
    [p1, p2] = [pairwise.AlignableSeq(leaf) for leaf in [p1, p2]]
    pair = pairwise.Pair(p1, p2)
    EP = pair.makeSimpleEmissionProbs(mprobs, [psub])
    hmm = EP.makePairHMM(TM)
    if local:
        (score, alignment) = hmm.getLocalViterbiScoreAndAlignment(**kw)
    else:
        (score, alignment) = hmm.getViterbiScoreAndAlignment(**kw)
    
    if return_score:
        return alignment, score
    else:
        return alignment
예제 #6
0
파일: align.py 프로젝트: miklou/pycogent
def _align_pairwise(s1, s2, mprobs, psub, TM, local, return_alignment=True, return_score=False, **kw):
    """Generic alignment with any substitution model and indel model"""
    [p1, p2] = [makeLikelihoodTreeLeaf(seq) for seq in [s1, s2]]
    [p1, p2] = [pairwise.AlignableSeq(leaf) for leaf in [p1, p2]]
    pair = pairwise.Pair(p1, p2)
    EP = pair.makeSimpleEmissionProbs(mprobs, [psub])
    hmm = EP.makePairHMM(TM)
    vpath = hmm.getViterbiPath(local=local, **kw)
    score = vpath.getScore()
    if return_alignment:
        alignment = vpath.getAlignment()
        if return_score:
            return (alignment, score)
        else:
            return alignment
    else:
        return score
예제 #7
0
 def convertSequence(self, sequence, name):
     # makeLikelihoodTreeLeaf, sort of an indexed profile where duplicate
     # columns stored once, so likelihoods only calc'd once
     return makeLikelihoodTreeLeaf(sequence, self.getAlphabet(), name)
예제 #8
0
 def convertSequence(self, sequence, name):
     # makeLikelihoodTreeLeaf, sort of an indexed profile where duplicate
     # columns stored once, so likelihoods only calc'd once
     return makeLikelihoodTreeLeaf(sequence, self.getAlphabet(), name)