Exemple #1
0
  RCO_Likelihooder(int numNodes,int numAlpha,Alphabet &alpha,
		   MultSeqAlignment &A,int column,
		   RootNode *root,int order,AlphabetMap &alphabetMap,
		   const BitSet &gapSymbols)
    : A(A), numNodes(numNodes), numAlpha(numAlpha),
      alpha(alpha), L(numNodes,numAlpha), column(column),
      alphabetMap(alphabetMap), gapSymbols(gapSymbols)
  {
    // ctor
    
    // Get the root's left-context for this column (for RCO)
    int rootID=root->getID();
    AlignmentSeq &rootTrack=A.getIthTrack(rootID);
    int contextBegin=column-order;
    if(contextBegin<0) contextBegin=0;
    int contextLen=column-contextBegin;
    rootTrack.getSeq().getSubsequence(contextBegin,contextLen,
				      rootContext);
    int pos=MultSeqAlignment::rightmostGapPos(rootContext,gapSymbols);
    if(pos>=0) {
      Sequence temp;
      rootContext.getSubsequence(pos+1,contextLen-pos-1,temp);
      rootContext=temp;
    }
    rootContextCode=rootContext.asInt(alphabetMap);
    rootContextLength=contextLen;
  }
Exemple #2
0
unsigned convertNmerCode(unsigned rawCode,int seqLength,const Alphabet &alphabet)
{
  Sequence S;
  S.resize(seqLength);
  unsigned base=alphabet.size();
  for(int i=seqLength-1 ; i>=0 ; --i) {
    unsigned digit=rawCode%base;
    Symbol s=(int)digit;
    S[i]=s;
    rawCode/=base;
  }	
  return S.asInt(alphabet,0,S.getLength());
}
Exemple #3
0
  void getContext(PhylogenyNode *node,int &contextCode,int &contextLength)
  {
    int ID=node->getID();
    AlignmentSeq &track=A.getIthTrack(ID);
    int contextBegin=column-order;
    if(contextBegin<0) contextBegin=0;
    contextLength=column-contextBegin;
    if(contextLength==0) {contextCode=0;return;}
    Sequence context;
    track.getSeq().getSubsequence(contextBegin,contextLength,context);
    int pos=MultSeqAlignment::rightmostGapPos(context,gapSymbols);
    if(pos>=0) {
      Sequence temp;
      int begin=pos+1, len=contextLength-pos-1;
      if(begin<order && len>0)
	context.getSubsequence(pos+1,contextLength-pos-1,temp);
      context=temp;
      contextLength=context.getLength();
    }
    contextCode=context.asInt(*alphabetMap.getRange());
  }
Exemple #4
0
void NmerRateMatrix::setNmerEqFreq(const Sequence &nmer,double nmerFreq)
{
  int index=nmer.asInt(alphabetMap);
  eq[index]=nmerFreq;
}