Exemple #1
0
  double processInternalChild(Symbol parentSymbol,int parentID,int child,
			      NthOrdSubstMatrix &noPt) {
    AlignmentSeq &track=A.getIthTrack(parentID);
    AlignmentSeq &childTrack=A.getIthTrack(child);
    int contextBegin=column-order;
    if(contextBegin<0) contextBegin=0;
    int contextLen=column-contextBegin;
    Sequence context;
    track.getSeq().getSubsequence(contextBegin,contextLen,context);//ACO
    //A.getIthTrack(root->getID()).getSeq().getSubsequence(contextBegin,contextLen,context);//TRCO
    int pos=MultSeqAlignment::rightmostGapPos(context,gapSymbols);
    if(pos>=0) {
      throw "this should not happen (FitchFelsenstein)::processInternalChild";
      Sequence temp;
      context.getSubsequence(pos+1,contextLen-pos-1,temp);
      context=temp;
    }
    SubstitutionMatrix &Pt=*noPt.lookup(context,0,-1);
    Array2D<double>::RowIn2DArray<double> row=L[child];
    Symbol childSym=childTrack.getSeq()[column];
    double ll;
    if(gapSymbols.isMember(childSym)){
      V.setAllTo(NEGATIVE_INFINITY);
      for(Symbol a=0 ; a<numAlpha ; ++a) {
	if(!gapSymbols.isMember(a)) {
	  V[(int)a]=safeAdd(row[a],Pt(parentSymbol,a));
	}
      }
      ll=sumLogProbs(V);
    }
    else {
      ll=safeAdd(row[childSym],Pt(parentSymbol,childSym));
    }
    return ll;
  }
Exemple #2
0
  FitchLikelihooder(int numNodes,int numAlpha,Alphabet &alpha,
		    MultSeqAlignment &A,int column,RootNode *root,int order)
    : A(A), numNodes(numNodes), numAlpha(numAlpha),
      alpha(alpha), L(numNodes,numAlpha), column(column),
      order(order), root(root), likelihood(NEGATIVE_INFINITY),
      gapSymbols(A.getGapSymbols()), V(numAlpha)
  {
    L.setAllTo(NEGATIVE_INFINITY);
    V.setAllTo(NEGATIVE_INFINITY);
  }