コード例 #1
0
ファイル: Seg.cpp プロジェクト: SamStudio8/RAPSearch2
//---------------------------------
char* Seg::maskseq(const char *fastaseq)
{
    Segment *segs;
    Sequen *seq = openseq(fastaseq);

    segs = (Segment *) NULL;
    segseq(seq, &segs, 0);
    mergesegs(seq, segs);
    char *masked = singreport(seq, segs);

    freesegs(segs);
    closeseq(seq);

    return masked;
}
コード例 #2
0
//call this function when a new sequence is chosen to set the default window size;
void CFoldView::NewSequence() 
{

	
	
	//load the ct file:
	if((openseq (&(GetFoldDocument()->ct),m_sequencename.GetBuffer(10)))==0) {
   	//errmsg(5,5);
   }
   if ((GetFoldDocument()->ct.numofbases)>1200) {
   			m_window=20;
   }
   else if ((GetFoldDocument()->ct.numofbases)>800) {
   			m_window=15;
            
   }
   else if ((GetFoldDocument()->ct.numofbases)>500) {
   			m_window=11;
            
   }
   else if ((GetFoldDocument()->ct.numofbases)>300) {
   			m_window=7;
            
   }
   else if ((GetFoldDocument()->ct.numofbases)>120) {
   			m_window=5;
            
   }
   else if ((GetFoldDocument()->ct.numofbases)>50) {
   			m_window=3;
            
   }
	else m_window=2;



	UpdateData(FALSE);
}
コード例 #3
0
void CBiFoldView::OnStart() 
{
	int i,j;

	//a trap to make sure the calculation is started more than once
	if (started) return;
	started=true;

	UpdateData(TRUE);

	
	if(m_sequence1=="") {
		MessageBox("Please specify a sequence name for the first sequence.");
		return;
	}
	else if(m_sequence2=="") {
		MessageBox("Please specify a sequence name for the second sequence./nUse unimolecular folding for a single sequence.");
		return;
	}

	

	if((openseq (&(GetBiFoldDocument()->ct),m_sequence1.GetBuffer(10)))==0||
		(openseq (&ct2,m_sequence2.GetBuffer(10)))==0) {

		AfxMessageBox( "One of the sequences is unrecognizable.", 
			MB_OK|MB_ICONSTOP);

		return;

	}

    //if (dynnumber<m_number) dynnumber = m_number;
    //if (dynpercent<m_percent) dynpercent = m_percent;
    //if (dynwindow>m_window) dynwindow = m_window;

	strcpy(ct3.ctlabel[1],GetBiFoldDocument()->ct.ctlabel[1]);
	//remove the new line at the end of ct.ctlabel[1]
	i = strlen(ct3.ctlabel[1]);
	ct3.ctlabel[1][i-1]='\0';

	strcat(ct3.ctlabel[1],"_");
	strcat(ct3.ctlabel[1],ct2.ctlabel[1]);

	//prepare ct3 with both sequences:
	ct3.numofbases=GetBiFoldDocument()->ct.numofbases+ct2.numofbases+3;
	ct3.allocate(GetBiFoldDocument()->ct.numofbases+ct2.numofbases+3);
	for (i=1;i<=GetBiFoldDocument()->ct.numofbases;i++) {
		ct3.numseq[i] = GetBiFoldDocument()->ct.numseq[i];
		ct3.nucs[i] = GetBiFoldDocument()->ct.nucs[i];
		ct3.hnumber[i] = GetBiFoldDocument()->ct.hnumber[i];

	}
	
	for (i=1;i<=ct2.numofbases;i++) {
		ct3.numseq[i+GetBiFoldDocument()->ct.numofbases+3] = ct2.numseq[i];
		ct3.nucs[i+GetBiFoldDocument()->ct.numofbases+3] = ct2.nucs[i];
		ct3.hnumber[i+GetBiFoldDocument()->ct.numofbases+3] = ct2.hnumber[i];

	} 	
      
   
   ct3.numseq[GetBiFoldDocument()->ct.numofbases+1] = 5;
   ct3.numseq[GetBiFoldDocument()->ct.numofbases+2] = 5;
   ct3.numseq[GetBiFoldDocument()->ct.numofbases+3] = 5;

   ct3.nucs[GetBiFoldDocument()->ct.numofbases+1] = 'I';
   ct3.nucs[GetBiFoldDocument()->ct.numofbases+2] = 'I';
   ct3.nucs[GetBiFoldDocument()->ct.numofbases+3] = 'I';

   ct3.hnumber[GetBiFoldDocument()->ct.numofbases+1] = 0;
   ct3.hnumber[GetBiFoldDocument()->ct.numofbases+2] = 0;
   ct3.hnumber[GetBiFoldDocument()->ct.numofbases+3] = 0;


   ct3.inter[0] = GetBiFoldDocument()->ct.numofbases+1;
   ct3.inter[1] = GetBiFoldDocument()->ct.numofbases+2;
   ct3.inter[2] = GetBiFoldDocument()->ct.numofbases+3;

   ct3.intermolecular = true;


   //Also copy information about nucleotides that must be single stranded
		//(These were entered as lowercase by the user.)

   for (i=1;i<=GetBiFoldDocument()->ct.nnopair;i++) {
		ct3.nnopair++;
		ct3.nopair[ct3.nnopair] = GetBiFoldDocument()->ct.nopair[i];

   }
   for (i=1;i<=ct2.nnopair;i++) {
		ct3.nnopair++;
		ct3.nopair[ct3.nnopair] = ct2.nopair[i]+GetBiFoldDocument()->ct.numofbases+3;

   }


   if (forbidunimolecular) {
		//forbid unimolecular pairs
	   ct3.allocatetem();
	   for (i=1;i<GetBiFoldDocument()->ct.numofbases;i++) {
		   for (j=i+1;j<=GetBiFoldDocument()->ct.numofbases;j++) {
				ct3.tem[j][i]=false;
		   }

	   }
	   for (i=GetBiFoldDocument()->ct.numofbases+3;i<ct3.numofbases;i++) {
		   for (j=i+1;j<=ct3.numofbases;j++) {
				ct3.tem[j][i]=false;
		   }

	   }
   }

   //check to see if the temperature has been changed.
	if (GetBiFoldDocument()->T<310||GetBiFoldDocument()->T>311) {

		//change the temperature from 310.15
		if (GetBiFoldDocument()->newtemp()==0) {
			//if newtemp returned zero, pass a warning to the user
			AfxMessageBox( "An enthalpy data file could not be found!\nTemperature of prediction will revert back to 37 degrees C.\nData files can be downloaded on the Mathews Lab website,\nhttp://rna.urmc.rochester.edu.", 
				MB_OK|MB_ICONHAND);

		}

	}


	//TProgressDialog *progress;
	progress = new TProgressDialog();//parent,"Folding the RNA..."
	CRect *rect;
	rect = new CRect(10,40,210,120);
	
	if (GetBiFoldDocument()->ISRNA)
	progress->Create(NULL,"Folding the RNA...",WS_CHILD|WS_VISIBLE|WS_CAPTION,*rect);
	else progress->Create(NULL,"Folding the DNA...",WS_CHILD|WS_VISIBLE|WS_CAPTION,*rect);
	delete rect;


	
	
	foldobject.parent=this;
	foldobject.ct=&ct3;
	foldobject.data=&GetBiFoldDocument()->data;
	foldobject.dynpercent = m_percent;
	foldobject.dynwindow = m_window;
	//foldobject.m_number = m_number;
	//foldobject.m_percent = m_percent;
	//foldobject.m_window = m_window;
	foldobject.progress = progress;
	foldobject.ctoutfile = m_ctname.GetBuffer(10);
	foldobject.dynnumber = m_number;
	foldobject.subfold=false;//No "subfolding" allowed for bimolecular. 
							//This is a feature for single strands only. 


	//The maximum internal loop size is fixed at 30 for now.
	foldobject.maximuminternalloopsize=30;

	if (m_save) {
		i = m_ctname.GetLength();
		
		foldobject.savefile = new char[i+4];
		strcpy(foldobject.savefile,m_ctname.GetBuffer(10));
		//count the characters to the .
		
		while(i>=0){
			
			if (foldobject.savefile[i]=='.') break;
			i--;
		}
		if (i==0) i = strlen(foldobject.savefile);
		strcpy(foldobject.savefile+i+1,"sav\0");
		if (GetBiFoldDocument()->savefile !=NULL)
			*GetBiFoldDocument()->savefile = true; 

	}
	else {
		foldobject.savefile = 0;
		if (GetBiFoldDocument()->savefile !=NULL)
			*GetBiFoldDocument()->savefile = false; 
	}
	


	



	
	AfxBeginThread(FoldProc,&foldobject);


	

}