コード例 #1
0
ファイル: DrawDoc.cpp プロジェクト: franfyh/structureanalysis
CDrawDoc::CDrawDoc(const char *ctfilename, bool *Clockwise, CMainFrame *pMainFrame, CRNAstructureApp *App)
{
	CString name;

	clockwise = Clockwise;
	pmainframe = pMainFrame;

	name = ctfilename;
	openct(&ct,ctfilename);	
	SetTitle(name);

	//allocate space for the coordinates
	out = new coordinates(ct.numofbases);
	iscolorannotated = false;
	isSHAPEannotated = false;
	app = App;
	

}
コード例 #2
0
ファイル: Dynalign_object.cpp プロジェクト: DasLab/BPPalign
//Run a dynalign calculation.
//Return 0 if there is no error, return 107 if the dat files aren't found, 
int Dynalign_object::Dynalign(const short int maxtrace, 
	const short int bpwin, const short int awin, const short int percent, const short int imaxseparation, const float gap, const bool singleinsert, const char savefile[], const bool optimalonly, const short int singlefold_subopt_percent, const bool local, 
	const short int numProcessors,
      const int maxpairs,
      const short int cycles) {


	bool constraints= false;
	bool **allowed_alignments;//An array for storing those nucleotide pairs that can align or not.
	int errormessage;
	int i;

	structure *ct;//have a structure pointer in case the user does template from ct

	//Read the thermodynamic parameters, if necessary, and store in RNA1:
	errormessage = GetRNA1()->ReadThermodynamic();
	if (errormessage!=0) return 110;



	//decide if there are folding or alignment constraints:
	if (forcealign!=NULL) constraints=true;
	else if (GetRNA1()->GetStructure()->npair>0) constraints=true;
	else if (GetRNA2()->GetStructure()->npair>0) constraints=true;
	else if (GetRNA1()->GetStructure()->nforbid>0) constraints=true;
	else if (GetRNA2()->GetStructure()->nforbid>0) constraints=true;
	else if (GetRNA1()->GetStructure()->nnopair>0) constraints=true;
	else if (GetRNA2()->GetStructure()->nnopair>0) constraints=true;
	else if (GetRNA1()->GetStructure()->nmod>0) constraints=true;
	else if (GetRNA2()->GetStructure()->nmod>0) constraints=true;
	else if (GetRNA1()->GetStructure()->ngu>0) constraints=true;
	else if (GetRNA2()->GetStructure()->ngu>0) constraints=true;


	//convert the gap parameter to 10*kcal/mol
	short igapincrease = (int)(gap * 10.0);
	

	//do the dynalign calculation
  	
	//This section folds thie individual sequences to find insignificant pairs to be ingnored by Dynalign.
	GetRNA1()->GetStructure()->allocatetem();
	GetRNA2()->GetStructure()->allocatetem();

	//The default behavior is to fold the sequences to determine pair hat should be not allowed in dynalign
	
	if(dsv_templated) {
		if(templatefromdsv(GetRNA1()->GetStructure(), templatefilename, MAXDSV, maxpairs))
          return 109;
	}
	else if (ct_templated) {
		ct = new structure();

		openct(ct,templatefilename);

		templatefromct(ct);

		delete ct;
	}
	else templatefromfold(GetRNA1()->GetStructure(), GetRNA1()->GetDatatable(), singlefold_subopt_percent);
	templatefromfold( GetRNA2()->GetStructure(), GetRNA1()->GetDatatable(), singlefold_subopt_percent );

	//This next section determined the allowed nucleotide alignments if the HMM forward-backward is used:
	if (imaxseparation < 0) {
		//allocate space in allowed_alignments
		allowed_alignments = new bool *[GetRNA1()->GetStructure()->numofbases+1];
		for (i=0;i<=GetRNA1()->GetStructure()->numofbases;i++) {
			allowed_alignments[i] = new bool [GetRNA2()->GetStructure()->numofbases+1];	
	
		}

		// Needed for having nucleotide sequences as c strings.
		GetRNA1()->GetStructure()->nucs[GetRNA1()->GetStructure()->numofbases + 1] = 0;
		GetRNA2()->GetStructure()->nucs[GetRNA2()->GetStructure()->numofbases + 1] = 0;

		
		calculate_coinc_probs_env(GetRNA1()->GetStructure(), GetRNA2()->GetStructure(), NULL, allowed_alignments, NULL, forcealign);
	
	}
	else allowed_alignments = NULL;

	//allocate space for the alignment
	align = new short *[maxtrace];//maximum number of tracebacks and next line and below at delete
	for (i=0;i<maxtrace;i++)  align[i] = new short [GetRNA1()->GetStructure()->numofbases+1];
	//also store the maxtrace for deleting later
	Maxtrace = maxtrace;



	//The heart of the calculation is here:

	
	errormessage = dynalign(GetRNA1()->GetStructure(), GetRNA2()->GetStructure(), align, imaxseparation, igapincrease, GetRNA1()->GetDatatable(),
           singleinsert, maxtrace, bpwin, awin, percent, forcealign, allowed_alignments, GetRNA1()->GetProgress(),
           savefile, optimalonly, local,
           /*force =*/ constraints, numProcessors); 

	

	if (imaxseparation < 0) {
		//delete space in allowed_alignments
		
		for (i=0;i<=GetRNA1()->GetStructure()->numofbases;i++) {
			delete[] allowed_alignments[i];	
	
		}

		delete[] allowed_alignments;

	}

	return errormessage;

}