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


C++ Algebra::worst_score方法代码示例

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


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

示例1: getMtrxVal

void Alignment<R,L,AL>::calculateGlobal(const PPForest<L> *ppfx, const PPForest<L> *ppfy, const Algebra<R,L> &alg, bool noSpeedup)
{
	assert(ppfx != NULL);
	assert(ppfy != NULL);

	Ulong m,n,h,cols;
	long i,k;
	Uint j,l,r;

	R score,h_score;

	// alloc space for the score matrix, backtrack structure  and , if wanted, for the calculation-order-matrix
	m_mtrxSize=ppfx->getNumCSFs()*ppfy->getNumCSFs();

	m_mtrx=new R[m_mtrxSize];
	m_rowStart=new Ulong[ppfx->getNumCSFs()];
	m_ppfx = new PPForest<L>(*ppfx);				// copy the ppforests
	m_ppfy = new PPForest<L>(*ppfy);
	m_alg=&alg;
	m_rnaAlg=NULL;
	m_localOptimum=alg.worst_score();


	// initialize variables
	m=ppfx->size();
	n=ppfy->size();
	cols=ppfy->getNumCSFs();

	m_rowStart[0]=0;
	for(h=1;h<ppfx->getNumCSFs();h++)
		m_rowStart[h]=m_rowStart[h-1]+cols;

	// align forests fx and fy

	// the easiest case .. 
	setMtrxVal(0,0,alg.empty());

	// align fx to the empty forest (fill first row of array)
	for(i=m-1;i>=0;i--)  // for all nodes in fx
	{
		for(j=1;j<=ppfx->getMaxLength(i);j++)  // for all non empty csfs induced by i
		{
			score = alg.del(ppfx->label(i),
				            getMtrxVal(ppfx->down(i),0),
				            getMtrxVal(ppfx->over(i,j),0));	  

			setMtrxVal(ppfx->indexpos(i,j),0,score);
		}
	}

	// align fy to the empty forest (fill first column of array)
	for(k=n-1;k>=0;k--)  // for all nodes in fx
	{
		for(l=1;l<=ppfy->getMaxLength(k);l++)  // for all non empty csfs induced by k
		{
			score = alg.insert(getMtrxVal(0,ppfy->down(k)),
					            ppfy->label(k),
					            getMtrxVal(0,ppfy->over(k,l)));

			setMtrxVal(0,ppfy->indexpos(k,l),score);
		}
	}

	// align the rest
	for(i=m-1;i>=0;i--)  // for all nodes in fx  
		for(k=n-1;k>=0;k--)  // for all nodes in fx
		        {
			        j=ppfx->getMaxLength(i);
				for(l=1;l<=ppfy->getMaxLength(k);l++)  // for all non empty csfs induced by k
				{
					// replace
		  
					score = alg.replace(ppfx->label(i),
							            getMtrxVal(ppfx->down(i),ppfy->down(k)),
							            ppfy->label(k),
							            getMtrxVal(ppfx->over(i,j),ppfy->over(k,l)));
					
					// delete				       
					if(ppfx->noc(i)==0 && !noSpeedup)  // no child
					  {
					    h_score = alg.del(ppfx->label(i),0,
							              getMtrxVal(ppfx->over(i,j),ppfy->indexpos(k,l)));

						score=alg.choice(score,h_score);
					  }
					else					  
					  {	
					    if(ppfx->rb(i)==0 && !noSpeedup) // no right brother
					      {
						h_score = alg.del(ppfx->label(i),
								  getMtrxVal(ppfx->down(i),ppfy->indexpos(k,l)),
								  0);
						
						score=alg.choice(score,h_score);
					      }
					    else
					      {
						h=k;               // h is the node where the suffix of the split begins		   					
						for(r=0;r<=l;r++)  // for all splits of fy
						  {
//.........这里部分代码省略.........
开发者ID:jrgreen7,项目名称:SMIRP,代码行数:101,代码来源:alignment.t.cpp

示例2: progressiveAlign

void progressiveAlign(std::vector<RNAProfileAlignment*> &inputList, 
											std::vector<std::pair<double,RNAProfileAlignment*> > &resultList, const Score& score, const Options &options, bool anchored) {

		Algebra<double,RNA_Alphabet_Profile> *alg = NULL;
		AlgebraAffine<double,RNA_Alphabet_Profile> *alg_affine = NULL;

    if (options.has(Options::Affine)) {
			if (options.has(Options::CalculateDistance)) {
        alg_affine = new AffineDoubleDistProfileAlgebra(score);
			}
			else {
        alg_affine = new AffineDoubleSimiProfileAlgebra(score);
			}
		}
		else {
			// distance or similarity
			if (options.has(Options::CalculateDistance))
        alg = new DoubleDistProfileAlgebra(score);
			else
        alg = new DoubleSimiProfileAlgebra(score);
		}

    std::cout << "*** Calculation ***" << std::endl << std::endl;

    // create inputMapProfile to access a profile by an index value
    RNAProfileAliMapType inputMapProfile;
    std::vector<RNAProfileAlignment*>::const_iterator inpIt;
    long i = 1;
    for (inpIt=inputList.begin(); inpIt!=inputList.end(); inpIt++) {
        inputMapProfile[i]=*inpIt;
        i++;
    }
    inputList.clear();

    // create matrix for all against all comparison
		double bestScore;
		if (options.has(Options::Affine))
			bestScore = alg_affine->worst_score();
		else
			bestScore = alg->worst_score();
    Matrix<double> *score_mtrx = new Matrix<double>(inputMapProfile.size(),inputMapProfile.size());

    // set threshold for the clustering algorithm
    double threshold = 0; 
    if (options.has(Options::CalculateDistance))
        options.get(Options::ClusterThreshold, threshold, 20.0);
    else
        options.get(Options::ClusterThreshold, threshold, 0.7);
    std::cout << "clustering threshold is: " << threshold << std::endl;

    // set cutoff value for clustering
		double cutoff = 0;
    if (options.has(Options::CalculateDistance))
        options.get(Options::ClusterJoinCutoff, cutoff, 100.0);
    else
        options.get(Options::ClusterJoinCutoff, cutoff, 0.0);
    std::cout << "join clusters cutoff is: " << cutoff << std::endl << std::endl;

		bool topdown = options.has(Options::Topdown);
		//bool anchored = options.has(Options::Anchoring);
    bool local = options.has(Options::LocalSimilarity);
		bool printBT = options.has(Options::Backtrace);

    // generate dot file
		std::string clusterfilename = options.generateFilename(Options::Help,"_cluster.dot", "cluster.dot");  // use Help as dummy
    std::ofstream s;
    s.open(clusterfilename.c_str());
    s << "digraph forest" << std::endl << "{" << std::endl;

		// generate nodes for the input forests
	  RNAProfileAliMapType::iterator it;
    for (it = inputMapProfile.begin(); it!=inputMapProfile.end(); it++) {
        RNAProfileAlignment * f = it->second;

        s << "\"" << f->getName() << "\"" << "[label=\"" << f->getName() << "\"]" << std::endl;
        s << "\"" << f->getName() << "\"" << "[label=\"" << f->getName() << "\"]" << std::endl;
    }

		// compute all pairwise alignment scores
    // !! NOTE !! iterating through the map is ordered by key number
    // as i only calculate a triangle matrix this is a prerequisite
		long x = 0, y = 0;
		RNAProfileAlignment *f1 = NULL, *f2 = NULL;
    std::cout << "Computing all pairwise similarities" << std::endl;

    RNAProfileAliMapType::iterator it2;
    for (it=inputMapProfile.begin(); it!=inputMapProfile.end(); it++) {
        x = it->first;
        f1 = it->second;
        for (it2=inputMapProfile.begin(); it2->first<it->first; it2++) {
            y = it2->first;
            f2 = it2->second;

						if (options.has(Options::Affine)) {
							AlignmentAffine<double,RNA_Alphabet_Profile,RNA_Alphabet_Profile> * ali = new AlignmentAffine<double,RNA_Alphabet_Profile,RNA_Alphabet_Profile>(f1,f2,*alg_affine,topdown,anchored,local,printBT);
	            if (local)
		              score_mtrx->setAt(x-1,y-1,ali->getLocalOptimum());
			        else
				          score_mtrx->setAt(x-1,y-1,ali->getGlobalOptimumRelative());

//.........这里部分代码省略.........
开发者ID:linse,项目名称:RNAforester,代码行数:101,代码来源:progressive_align.cpp


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