当前位置: 首页>>代码示例>>C++>>正文


C++ Sequence::getLength方法代码示例

本文整理汇总了C++中Sequence::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Sequence::getLength方法的具体用法?C++ Sequence::getLength怎么用?C++ Sequence::getLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sequence的用法示例。


在下文中一共展示了Sequence::getLength方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateCounts

void Application::updateCounts(Sequence &S1,Sequence &S2)
{
  // First, infer state sequence
  int L=S1.getLength();
  if(S2.getLength()!=L) throw "unequal sequence lengths";
  Array1D<STATE> path(L);
  for(int i=0 ; i<L ; ++i)
    if(S1[i]==gapSymbol) path[i]=INSERTION_STATE;
    else if(S2[i]==gapSymbol) path[i]=DELETION_STATE;
    else path[i]=MATCH_STATE;
  
  // Now count state transitions
  for(int i=0 ; i<L-1 ; ++i)
    ++transCounts[path[i]][path[i+1]];
  ++transCounts[0][path[0]];
  ++transCounts[path[L-1]][0];

  // Make sure there are no ambiguity codes
  S1.replaceAll(INVALID_SYMBOL,gapSymbol);
  S2.replaceAll(INVALID_SYMBOL,gapSymbol);

  // Now count state emissions
  for(int i=0 ; i<L ; ++i)
    ++emitCounts(path[i],S1[i],S2[i]);
}
开发者ID:bmajoros,项目名称:alignment,代码行数:25,代码来源:train-3state.C

示例2: NoSuchElementException

// XUIElementFactory
Reference< XUIElement > SAL_CALL WWUIElementFactory::createUIElement(
            const OUString & rResourceURL, 
            const Sequence< PropertyValue > & aArgs) 
            throw (RuntimeException, NoSuchElementException, IllegalArgumentException)
{
    ::osl::MutexGuard const g( m_aMutex );
    
    if ( !rResourceURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( RESOURCE_NAME ) ) )
        throw NoSuchElementException();
    
    Reference< XFrame > xFrame;
    Reference< XWindow > xParentWindow;
    
    const PropertyValue * pArgs = aArgs.getConstArray();
    const PropertyValue * pEndArgs = aArgs.getConstArray() + aArgs.getLength();
    for ( ; pArgs < pEndArgs; ++pArgs )
    {
        if ( pArgs->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Frame" ) ) )
            xFrame.set( pArgs->Value, UNO_QUERY );
        else if ( pArgs->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ParentWindow" ) ) )
            xParentWindow.set( pArgs->Value, UNO_QUERY );
    }
    if ( !xFrame.is() )
        throw IllegalArgumentException();
    if ( !xParentWindow.is() )
        throw IllegalArgumentException();
    Reference< XUIElement > xElement( new WWUIElement( m_xContext, xFrame, xParentWindow ) );
    return xElement;
}
开发者ID:hanya,项目名称:ww,代码行数:30,代码来源:efac.cpp

示例3: countDifferences

int NmerRateMatrix::countDifferences(const Sequence &seq1,
				     const Sequence &seq2)
{
  int length=seq1.getLength(), diffs=0;
  for(int i=0 ; i<length ; ++i)
    if(seq1[i]!=seq2[i])
      ++diffs;
  return diffs;
}
开发者ID:bmajoros,项目名称:PhyLib,代码行数:9,代码来源:NmerRateMatrix.C

示例4: getSummationSeq

Sequence* getSummationSeq(Sequence * seq)
{
	Sequence * res = new Sequence(seq->getLength());
	res->set(1, seq->get(1));
	for(int i = 2; i <= res->getLength(); i++)
	{
		res->set(i, res->get(i-1) + seq->get(i));
	}

	return res;
}
开发者ID:kalngyk,项目名称:codes,代码行数:11,代码来源:AlcsRmsdSolver.cpp

示例5: sort

Sequence CollationImpl::sort(Sequence data, const DynamicContext* context) const
{
  // build a sequence made of strings
  Sequence stringSeq = Sequence(data.getLength(), context->getMemoryManager());
  for(Sequence::iterator it=data.begin(); it!=data.end(); ++it) {
    const XMLCh *str = (*it)->asString(context);
    stringSeq.addItem(context->getItemFactory()->createString(str, context).get());
  }

  stringSeq.sortWithCollation(this, context);

  return stringSeq;
}
开发者ID:xubingyue,项目名称:xqilla,代码行数:13,代码来源:CollationImpl.cpp

示例6: convertNmerCode

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());
}
开发者ID:bmajoros,项目名称:PhyLib,代码行数:13,代码来源:NmerRateMatrix.C

示例7:

	~PrecomputeRes()
	{
		int n = A->getLength();
		A->release();
		B->release();
		delete [] aSquare;
		delete [] bSquare;
		for(int i=0; i<=n; i++)
		{
			for(int j=0; j<3; j++)
				delete [] s[i][j];
			delete [] s[i];
		}
		delete [] s;
	}
开发者ID:kalngyk,项目名称:codes,代码行数:15,代码来源:AlcsRmsdSolver.cpp

示例8: getContext

  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());
  }
开发者ID:bmajoros,项目名称:PhyLib,代码行数:21,代码来源:LCO_Felsenstein.C

示例9: computePDS

float Application::computePDS(const Sequence &refSeq,const Sequence &altSeq)
{
  // Compute raw alignment score
  BandedSmithWaterman<float> aligner(AminoAlphabet::global(),refSeq,altSeq,*M,
				     gapOpen,gapExtend,bandWidth);
  Alignment *alignment=aligner.fullAlignment();
  double score=alignment->getScore();
  delete alignment;
  if(score<0) score=0;

  // Normalize by maximal possible score
  float maxScore=0;
  int L=refSeq.getLength();
  for(int i=0 ; i<L ; ++i) maxScore+=(*M)(refSeq[i],refSeq[i]);
  //score-=maxScore;
  score/=maxScore;

  // Convert from a similarity score to a dissimilarity score
  //return -score;
  //cout<<1-score<<endl;
  return 1-score;
}
开发者ID:ReddyLab,项目名称:FBI,代码行数:22,代码来源:simulate-cryptic-sites.C

示例10: operator

 bool operator()(const uint & w1, const uint & w2) {
     return Seq->rank(w1,Seq->getLength()-1) < Seq->rank(w2,Seq->getLength()-1);
 }
开发者ID:rkonow,项目名称:topk-final,代码行数:3,代码来源:intersection.cpp

示例11: main

int main(int argc, char **argv) {
    if(argc!=5) {
        cout << "usage: " << argv[0] << " <text> <offsets> <queries> <seq>" << endl;
        cout << " seq=1: Wavelet Tree Noptrs RG5" << endl;
        cout << " seq=2: Wavelet Tree Noptrs RG10" << endl;
        cout << " seq=3: Wavelet Tree Noptrs RG20" << endl;
        cout << " seq=4: Wavelet Tree Noptrs RRR16" << endl;
        cout << " seq=5: Wavelet Tree Noptrs RRR32" << endl;
        cout << " seq=6: Wavelet Tree Noptrs RRR64" << endl;
        cout << " seq=7: GMR B=RG20 X=RG20 PS=16" << endl;
        return 0;
    }

    uint seq = transform(string(argv[4]));

    ifstream input_seq(argv[1]);
    Array * A = new Array(input_seq);
    input_seq.close();

    SequenceBuilder * sb,*sb1,*sb2,*sb3;
    Sequence * S;
    switch(seq) {
    case 1:
        S = new WaveletTreeNoptrs(*A, new BitSequenceBuilderRG(5),new MapperNone());
        break;
    case 2:
        S = new WaveletTreeNoptrs(*A, new BitSequenceBuilderRG(10),new MapperNone());
        break;
    case 3:
        S = new WaveletTreeNoptrs(*A, new BitSequenceBuilderRG(20),new MapperNone());
        break;
    case 4:
        S = new WaveletTreeNoptrs(*A, new BitSequenceBuilderRRR(16),new MapperNone());
        break;
    case 5:
        S = new WaveletTreeNoptrs(*A, new BitSequenceBuilderRRR(32),new MapperNone());
        break;
    case 6:
        S = new WaveletTreeNoptrs(*A, new BitSequenceBuilderRRR(64),new MapperNone());
        break;
    case 7:
        sb = new SequenceBuilderGMRChunk(new BitSequenceBuilderRG(20),new PermutationBuilderMRRR(16, new BitSequenceBuilderRG(20)));
        S = new SequenceGMR(*A, 2*A->getMax(), new BitSequenceBuilderRG(20), sb);
        break;
    case 8:
        sb1 = new SequenceBuilderWaveletTree(new BitSequenceBuilderRG(20), new MapperNone());
        sb2 = new SequenceBuilderGMRChunk(new BitSequenceBuilderRG(20),new PermutationBuilderMRRR(16, new BitSequenceBuilderRG(20)));
        sb3 = new SequenceBuilderGMR(new BitSequenceBuilderRG(20),sb2);
        S = new SequenceAlphPart(*A, 10, sb1, sb3);
        break;
    }
    cout << "Sequence size: " << S->getSize() << endl;

    ifstream input_offs(argv[2]);
    uint of;
    vector<uint> offsets;
    while((input_offs>>of)) offsets.push_back(of);
    offsets.push_back(S->getLength());
    input_offs.close();

    cout << "Structure size: " << S->getSize()+offsets.size()*sizeof(uint) << endl;

    cout << "No of documents: " << offsets.size() << endl;
    cout << "No of words: " << A->getMax() << endl;

    ifstream input(argv[3]);
    vector<vector<uint> > queries;
    uint qs;
    while((input >> qs)) {
        vector<uint> query;
        for(uint i=0; i<qs; i++) {
            uint tmp;
            input >> tmp;
            query.push_back(tmp);
        }
        queries.push_back(query);
    }
    input.close();

#define ERROUT 0

    uint acc = 0;
    start_timing();
    vector<uint> aux;
    for(uint i=0; i<queries.size(); i++) {
        aux.clear();
        intersect2(queries[i],S,offsets,aux);
#if ERROUT
        for(uint j=0; j<aux.size(); j++) {
            cerr << " " << aux[j];
            acc += aux[j];
        }
        cerr << endl;
#else
        acc += aux.size();
#endif
    }
    double t=get_timing();
    cout << "acc: " << acc << endl;
    cout << "Total time: " << t << " ms" << endl;
//.........这里部分代码省略.........
开发者ID:rkonow,项目名称:topk-final,代码行数:101,代码来源:intersection.cpp

示例12: getTransformed

Sequence * getTransformed(Sequence *a, 
		Sequence * b, int begin, int end, PrecomputeRes &precomp)
{
	if(begin == end) return 0;
	Sequence * res = new Sequence(a->getLength());
	for(int i=1; i<=res->getLength(); i++)
		res->set(i, a->get(i));
//	Point tempPt = precomp.A->get(end) - precomp.A->get(begin-1);
	// centroids
	Point aCenter = (precomp.A->get(end) - precomp.A->get(begin-1))/(end-begin+1);
	
	Point bCenter = (precomp.B->get(end) - precomp.B->get(begin-1))/(end-begin+1);
	
	
	//cout<<precomp.B->get(1)[0]<<endl;
	/*
	for(int i=0; i<a->getLength()+1; i++)
	{
		for(int j=0; j<3; j++)
		{
			for(int k=0; k<3; k++)
				cout<<precomp.s[i][j][k]<<" ";
			cout<<endl;
		}
		cout<<endl;
	}
	*/
	// a' (transpose) b'
	double  C[3][3];
	for(int u=0; u<3; u++)
		for(int v=0; v<3; v++)
		{
			C[u][v] = precomp.s[end][u][v] - precomp.s[begin-1][u][v]
					-aCenter[u]*(precomp.B->get(end)[v] - precomp.B->get(begin-1)[v])
					-bCenter[v]*(precomp.A->get(end)[u] - precomp.A->get(begin-1)[u])
					+(end - begin + 1)*aCenter[u]*bCenter[v];
		}

	SVDRes svdRes = calcSVD2(C);
	double d[3][3];
	for(int i=0; i<3; i++)
		for(int j=0; j<3; j++)
			d[i][j] = 0;
	d[0][0] = 1; d[1][1] = 1;
	d[2][2] = 1;
	
	if(determinant(C)<0)
		d[2][2] = -1;
	transpose(svdRes.U);
	transpose(svdRes.VT);
	double tempMat[3][3];
	matrixMul(svdRes.VT, d,tempMat);
	double U[3][3];
	matrixMul(tempMat, svdRes.U,U);
	for(int i= begin; i<=end; i++)
	{
		res->set(i, mul(a->get(i)-aCenter, U)+bCenter);
	}
	return res;

}
开发者ID:kalngyk,项目名称:codes,代码行数:61,代码来源:AlcsRmsdSolver.cpp

示例13: evaluate

/*** Evaluate this object ***/
Object* SpecialFunction::evaluate()
{
	if(args.size() == 0)
		throw Excep(getLineNumber(), getColumnNumber(), "Expected argument to special function!");

	std::auto_ptr<Object> arg1(args.at(0)->evaluate());

	if(id == SPF_INDEX)
	{
		if(args.size() != 2)
			throw Excep(getLineNumber(), getColumnNumber(), "Invalid number of arguments passed to special function!");

		std::auto_ptr<Object> arg2(args.at(1)->evaluate());

		if(arg2->getType() == OBJ_TEXT)
		{
			if(arg1->getType() != OBJ_TEXT)
				throw InvalidTypeException(getLineNumber(), getColumnNumber(), OBJ_TEXT, arg1->getType(), 1);

			Text* cast1 = static_cast<Text*>(arg1.get());
			Text* cast2 = static_cast<Text*>(arg2.get());

			size_t index = cast2->getValue().find(cast1->getValue());

			if(index != std::string::npos)
				return new Integer(index + 1);

			return new Integer(0);
		}

		if(arg2->getType() == OBJ_SEQUENCE)
		{
				Sequence* cast = dynamic_cast<Sequence*>(arg2.get());

				for(unsigned int i = 0; i < cast->getLength(); i++)
				{
					std::auto_ptr<Logical> eqOp(static_cast<Logical*>(Equal(arg1->clone(), cast->getObject(i)->clone()).evaluate()));
					if(eqOp->getValue() == true)
						return new Integer(i + 1);
				}

				return new Integer(0);
		}

		throw InvalidTypeException(getLineNumber(), getColumnNumber(), OBJ_TEXT | OBJ_SEQUENCE, arg2->getType(), 2);
	}

	if(args.size() > 1)
		throw Excep(getLineNumber(), getColumnNumber(), "Invalid number of arguments passed to special function!");

	if(id == SPF_ABS)
	{
		if(arg1->getType() == OBJ_INTEGER)
		{
			Integer* cast = static_cast<Integer*>(arg1.get());
			if(cast->getValue() < 0)
				return new Integer(-cast->getValue());
			return new Integer(cast->getValue());
		}

		if(arg1->getType() == OBJ_REAL)
		{
			Real* cast = static_cast<Real*>(arg1.get());
			if(cast->getValue() < 0)
				return new Real(-cast->getValue());
			return new Real(cast->getValue());
		}

		throw InvalidTypeException(getLineNumber(), getColumnNumber(), OBJ_INTEGER | OBJ_REAL, arg1->getType(), 1);
	}

	if(id == SPF_SIGN)
	{
		if(arg1->getType() == OBJ_INTEGER)
		{
			Integer* cast = static_cast<Integer*>(arg1.get());
			if(cast->getValue() < 0)
				return new Integer(-1);
			if(cast->getValue() > 0)
				return new Integer(1);
			return new Integer(0);
		}

		if(arg1->getType() == OBJ_REAL)
		{
			Real* cast = static_cast<Real*>(arg1.get());
			if(cast->getValue() < 0)
				return new Integer(-1);
			if(cast->getValue() > 0)
				return new Integer(1);
			return new Integer(0);
		}

		throw InvalidTypeException(getLineNumber(), getColumnNumber(), OBJ_INTEGER | OBJ_REAL, arg1->getType(), 1);
	}

	if(id == SPF_SQRT)
	{
		if(arg1->getType() == OBJ_INTEGER)
//.........这里部分代码省略.........
开发者ID:denrusio,项目名称:vak-opensource,代码行数:101,代码来源:specialfunction.cpp


注:本文中的Sequence::getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。