void THISTimeline::exportEntireSequence()
{
	exporter->startFrame = 0;
	exporter->endFrame = getSequenceLength()-1;

	startExport();
}
unsigned char* THISTimeline::getSourcePixelsForFrame(int offset, bool thumb)
{
	float channel = sourcekeys->sampleTimelineAt(offset/(getSequenceLength()-1.0f));
	if(channel > .5){
		return sourceA->getPixelsForFrame(offset, thumb);
	}
	else{
		return sourceB->getPixelsForFrame(offset, thumb);
	}
}
Exemple #3
0
void Genome::copySequence(Genome *dest) const
{
  DNAIteratorConstPtr inDna = getDNAIterator();
  DNAIteratorPtr outDna = dest->getDNAIterator();
  hal_size_t n = getSequenceLength();
  assert(n == dest->getSequenceLength());
  for (; (hal_size_t)inDna->getArrayIndex() < n; inDna->toRight(), 
         outDna->toRight())
  {
    outDna->setChar(inDna->getChar());
  }
}
float* THISTimeline::getBlendedDistortionFrame(float percent, bool thumb)
{
	int index = distortion->getIndexAtPercent(percent);
	if(index < 0 || index >= blendedDistortionThumbnails.size() || index >= blendedDistortion.size()){
		ofLog(OF_LOG_ERROR, "THISTimeline -- Asking for index %d when we only have %d frames", index, blendedDistortion.size());
		return NULL;
	}

	//cout << "asking for distortion at index " << index << " percent " << percent << endl;

	BlendedDistortionFrame* bdf = thumb ? &blendedDistortionThumbnails[index] : &blendedDistortion[index];
	int fullDistortionWidth = getDistortionWidth(percent);
	int taperedDistortionWidth = MAX(fullDistortionWidth * blendkeys->sampleTimelineAt(percent), 1);

	if(!bdf->loaded || bdf->distortionWidth != taperedDistortionWidth){

		int imgwidth  = thumb ? distortion->getThumbWidth()  : distortion->getImageWidth();
		int imgheight = thumb ? distortion->getThumbHeight() : distortion->getImageHeight();
		if(bdf->pixels == NULL){
			bdf->pixels = new float[imgwidth*imgheight];
		}
		memset(bdf->pixels, 0, sizeof(float)*imgwidth*imgheight);
		int midIndex = getWindowStartFrame(percent) + fullDistortionWidth/2;
		int startIndex = midIndex - (taperedDistortionWidth / 2);
		int endIndex = midIndex + ((1+taperedDistortionWidth) / 2);
		if(startIndex >= endIndex){
			endIndex = startIndex+1;
		}
		//add all the images together...
		for(int i = startIndex; i < MIN(endIndex, getSequenceLength()-1); i++){
			unsigned char* distortionPixels = distortion->getPixelsForFrame(i, thumb);
			for(int y = 0; y < imgheight; y++){
				for(int x = 0; x < imgwidth; x++){
					bdf->pixels[y*imgwidth+x] += distortionPixels[y*imgwidth+x];
				}
			}
		}

		//average
		for(int i = 0; i < imgwidth*imgheight; i++){
			bdf->pixels[i] /= (taperedDistortionWidth*255.0);
		}

		bdf->loaded = true;
		bdf->distortionWidth = taperedDistortionWidth;
	}

	bdf->lastUsedTime = ofGetElapsedTimef();
	return bdf->pixels;
}
void THISTimeline::togglePlayback()
{
	if(exporting) return;

	if(isPlayingBack){
		isPlayingBack = false;
	}
	else{
		isPlayingBack = true;
		rollingOverPlayhead = true;
		playbackStartTime = ofGetElapsedTimef();
		percentPerFrame = 1. / getSequenceLength();
	}
}
Exemple #6
0
void ReadsLayout::getVcoverage(size_t listIndex, bool direction, vector<unsigned int> &cov)
{
    unsigned int pos;
    unsigned int sequenceLength=getSequenceLength(listIndex);
    int rl=R->getReadsLength();
    size_t index;
    
    cov.clear();
    cov.assign(sequenceLength,0);
    vector<unsigned int> tmp;
    tmp.assign(sequenceLength,0);

    if (direction)
    {
        index = getBegin(listIndex);

        while (index != 0)
        {
            pos = getPosition(index);
            cov[pos - 1]++;
            index = getNext(index);
        }
    }
    else
    {
        index = listIndex;
        sequenceLength-= (rl-1);

        while (index != 0)
        {
            pos = getPosition(index);
            pos=sequenceLength-pos;
            cov[pos]++;
            index = getPrevious(index);
        }
    }
    
    tmp[0]=cov[0];
   
    for (size_t i=1; i<cov.size(); i++)
    {
        cov[i]=cov[i]+cov[i-1];
        tmp[i]=cov[i];
    }
    
    for (size_t i=rl; i<cov.size(); i++)
        cov[i]-=tmp[i-rl];
}
float* THISTimeline::getBlendedDistortionFrame(int index, bool thumb)
{
	return getBlendedDistortionFrame(index/(getSequenceLength()-1.0f), thumb);
}
int THISTimeline::getDistortionWidth(int baseFrame)
{
	return getDistortionWidth(baseFrame/(getSequenceLength()-1.0f));
}
int THISTimeline::getWindowEndFrame(float percent)
{
	return MIN(getWindowStartFrame(percent) + getDistortionWidth( percent ), getSequenceLength()-1);
}
int THISTimeline::getWindowEndFrame(int baseFrame)
{
	return getWindowEndFrame( (baseFrame+.5f)/(getSequenceLength()-1.0f) );
}
void THISTimeline::draw()
{

	//update keyframers
	minwidthkeys->setZoomBounds(zoomer->getViewRange());
	maxwidthkeys->setZoomBounds(zoomer->getViewRange());
	sourcekeys->setZoomBounds(zoomer->getViewRange());
	blendkeys->setZoomBounds(zoomer->getViewRange());

	if(!zoomer->isActive()){
		sourceA->setDrawRange(zoomer->getViewRange());
		sourceB->setDrawRange(zoomer->getViewRange());
		distortion->setDrawRange(zoomer->getViewRange());
	}

	if(exporting && !exporter->isExporting()){
		exporting = false;
		minwidthkeys->enable();
		maxwidthkeys->enable();
		sourcekeys->enable();
		blendkeys->enable();
		zoomer->enable();
	}

	if(isPlayingBack){
		zoomedPlayheadFloatPosition = ofMap(ofGetElapsedTimef(), playbackStartTime, playbackStartTime+(getLastFrameInView()-getFirstFrameInView())/25., 0, zoomer->getViewRange().max-zoomer->getViewRange().min, false);
		zoomedPlayheadFloatPosition = zoomer->getViewRange().min + fmod(zoomedPlayheadFloatPosition, zoomer->getViewRange().max-zoomer->getViewRange().min);
	}

	//-------- POSITION ALL ELEMENTS

	//-------- COMP ELEMENTS
	newCompButton->setPos(uiposition.x, uiposition.y);
	newCompButton->setSize(BIG_BUTTON_WIDTH, BIG_BUTTON_HEIGHT);

	loadCompButton->setPos(uiposition.x, uiposition.y+BIG_BUTTON_HEIGHT+ELEMENT_SPACER);
    loadCompButton->setSize(BIG_BUTTON_WIDTH, BIG_BUTTON_HEIGHT);

//	loadSourceBButton->setPos(uiposition.x, uiposition.y+(BIG_BUTTON_HEIGHT+ELEMENT_SPACER)*2);
//    loadSourceBButton->setSize(BIG_BUTTON_WIDTH, BIG_BUTTON_HEIGHT);
//
//	loadDistortionButton->setPos(uiposition.x, uiposition.y+(BIG_BUTTON_HEIGHT+ELEMENT_SPACER)*3);
//    loadDistortionButton->setSize(BIG_BUTTON_WIDTH, BIG_BUTTON_HEIGHT);
//
//	setOutputDirectoryButton->setPos(uiposition.x, uiposition.y+(BIG_BUTTON_HEIGHT+ELEMENT_SPACER)*4);
//    setOutputDirectoryButton->setSize(BIG_BUTTON_WIDTH, BIG_BUTTON_HEIGHT);


	//------------- EXPORT BUTTONS
	exportCurrentViewButton->setPos(uiposition.x, uiposition.y+(BIG_BUTTON_HEIGHT+ELEMENT_SPACER)*5);
	exportCurrentViewButton->setSize(BIG_BUTTON_WIDTH/3.0, BIG_BUTTON_HEIGHT);

	exportEntireSequenceButton->setPos(uiposition.x+BIG_BUTTON_WIDTH/3.0, uiposition.y+(BIG_BUTTON_HEIGHT+ELEMENT_SPACER)*5);
	exportEntireSequenceButton->setSize(BIG_BUTTON_WIDTH/3.0, BIG_BUTTON_HEIGHT);

	cancelExportButton->setPos(uiposition.x+2*BIG_BUTTON_WIDTH/3.0, uiposition.y+(BIG_BUTTON_HEIGHT+ELEMENT_SPACER)*5);
	cancelExportButton->setSize(BIG_BUTTON_WIDTH/3.0, BIG_BUTTON_HEIGHT);


	//---------- TIMELINE ELEMENTS
	THISSequence* loadedReferenceSource = NULL;
	if(sourceA->isLoaded()) loadedReferenceSource = sourceA;
	else if(sourceB->isLoaded()) loadedReferenceSource = sourceB;
	else if(distortion->isLoaded()) loadedReferenceSource = distortion;

	float sourcePreviewHeight = SOURCE_PREVIEW_HEIGHT;
	if(loadedReferenceSource != NULL){
		sourcePreviewHeight = loadedReferenceSource->heightPerFrame;
	}
						//frame ticker		  //3 previews			  //5 keyframes		  //A-B Switch		//zoomer
	float totalHeight = FRAME_TICKER_HEIGHT + sourcePreviewHeight*3 + KEYFRAME_HEIGHT*4 + GRAPH_HEIGHT + SWITCHER_HEIGHT + FRAME_TICKER_HEIGHT + ELEMENT_SPACER*4;
    float totalWidth = width-BUTTON_WIDTH*2;
    playheadBar->setPos(position.x+BUTTON_WIDTH, position.y);
    playheadBar->setSize(totalWidth, totalHeight);



	//---------- KEYFRAME POSITIONS
	float keyframeStartY = position.y+FRAME_TICKER_HEIGHT+sourcePreviewHeight*3+ELEMENT_SPACER;
	maxwidthkeys->setDrawRect(ofRectangle(BUTTON_WIDTH, keyframeStartY, totalWidth, KEYFRAME_HEIGHT));
	//inbetween is the min/max visualizer
	minwidthkeys->setDrawRect(ofRectangle(BUTTON_WIDTH, keyframeStartY+KEYFRAME_HEIGHT+GRAPH_HEIGHT, totalWidth, KEYFRAME_HEIGHT));
	sourcekeys->setDrawRect(ofRectangle(BUTTON_WIDTH, keyframeStartY+KEYFRAME_HEIGHT*2+GRAPH_HEIGHT+ELEMENT_SPACER, totalWidth, SWITCHER_HEIGHT));
	blendkeys->setDrawRect(ofRectangle(BUTTON_WIDTH, keyframeStartY+KEYFRAME_HEIGHT*2+GRAPH_HEIGHT+SWITCHER_HEIGHT+ELEMENT_SPACER*2, totalWidth, KEYFRAME_HEIGHT));
	zoomer->setDrawRect(ofRectangle(BUTTON_WIDTH, keyframeStartY+KEYFRAME_HEIGHT*3+GRAPH_HEIGHT+SWITCHER_HEIGHT+ELEMENT_SPACER*3, totalWidth, FRAME_TICKER_HEIGHT));

//    cout << "CHECK 3: cur comp " << currentCompFolder << endl;


	//----------- BEGIN DRAWING
	ofPushStyle();

	//draw UI elements
	ofNoFill();
	ofSetColor(80, 80, 80);
	
	ofRect(newCompButton->x,newCompButton->y, newCompButton->width, newCompButton->height	);
	ofDrawBitmapString("new comp", newCompButton->x + 10, newCompButton->y + 15);

	ofRect(loadCompButton->x,loadCompButton->y, loadCompButton->width,loadCompButton->height);
	ofDrawBitmapString("load comp", loadCompButton->x + 10, loadCompButton->y + 15);

	float yStart = loadCompButton->y+loadCompButton->height+20;
	ofRect(loadCompButton->x,yStart, loadCompButton->width, 80);
	ofDrawBitmapString("Comp " + currentCompFolder + 
					   "\nSource A " + sourceA->directory +
					   "\nSource B " + sourceB->directory +
					   "\nDistortion " + distortion->directory +
					   "\nOutput " + exporter->pathPrefix, 
					   loadCompButton->x + 10, yStart + 15);

	
	ofRect(exportCurrentViewButton->x,exportCurrentViewButton->y, exportCurrentViewButton->width,exportCurrentViewButton->height);
	ofDrawBitmapString("export\ncurrent view", exportCurrentViewButton->x + 10, exportCurrentViewButton->y + 15);

	ofRect(exportEntireSequenceButton->x,exportEntireSequenceButton->y, exportEntireSequenceButton->width,exportEntireSequenceButton->height);
	ofDrawBitmapString("export\nentire sequence", exportEntireSequenceButton->x + 10, exportEntireSequenceButton->y + 15);

	ofRect(cancelExportButton->x,cancelExportButton->y, cancelExportButton->width,cancelExportButton->height);
	ofDrawBitmapString("cancel export", cancelExportButton->x + 10, cancelExportButton->y + 15);

    ofPopStyle();

	//draw frame ticker
    //TODO: put into timeline object
    int firstFrame = getFirstFrameInView();
    int lastFrame = getLastFrameInView();
    int totalFrames = (lastFrame - firstFrame);
	
	ofDrawBitmapString("First Frame:  " + ofToString(firstFrame) + "\n"+
					   "Last Frame:   " + ofToString(lastFrame) + "\n" +
					   "Total Frames: " + ofToString(totalFrames), frameInfoPosition);
	
	
    if(!allSequencesLoaded()){
        return;
    }

    ofPushStyle();
	//---------- PROGRESS


	ofNoFill();
	ofRect(uiposition.x, uiposition.y+(BIG_BUTTON_HEIGHT+ELEMENT_SPACER)*6, BIG_BUTTON_WIDTH, BIG_BUTTON_HEIGHT/2);
	if(exporting){
		float percentDone = exporter->getPercentDone();
		ofFill();
		ofSetColor(200, 200, 100, 40);
		ofRect(uiposition.x, uiposition.y+(BIG_BUTTON_HEIGHT+ELEMENT_SPACER)*6, BIG_BUTTON_WIDTH*percentDone, BIG_BUTTON_HEIGHT/2);
	}
	
	//draw frame numbers
	
	//---------- frame Info


    float pixelsPerFrame = (width-BUTTON_WIDTH*2.0) / totalFrames;
    int frameStep = 1;
    bool drawFullRect = false;
    if(pixelsPerFrame < .5){
        frameStep = 20;
        drawFullRect = true;
    }
    else if(pixelsPerFrame < 1.0){
        frameStep = 10;
        drawFullRect = true;
    }
    else if(pixelsPerFrame < 2.0){
        frameStep = 5;
    }
    else if(pixelsPerFrame < 4.0){
        frameStep = 2;
    }

    if(drawFullRect){
        ofSetColor(200, 200, 100, 40);
        ofRect(BUTTON_WIDTH, position.y+FRAME_TICKER_HEIGHT/2., totalWidth, FRAME_TICKER_HEIGHT/2);
    }

    ofSetColor(200, 200, 100, 100);
    for(int i = 0; i <= totalFrames; i+=frameStep){
        float xPixelPos = ofMap(i, 0, totalFrames, BUTTON_WIDTH, width-BUTTON_WIDTH, true);
        ofLine(xPixelPos, position.y+FRAME_TICKER_HEIGHT/2., xPixelPos, position.y+FRAME_TICKER_HEIGHT);
    }

	ofSetColor(255, 255, 255);
    sourceA->setDrawWidth(totalWidth);
	sourceB->setDrawWidth(totalWidth);
    distortion->setDrawWidth(totalWidth);

	//backgroup
	ofSetColor(0, 0, 0);
	ofRect(position.x + BUTTON_WIDTH, position.y+FRAME_TICKER_HEIGHT, totalWidth, sourcePreviewHeight*3);


	ofSetColor(255, 255, 255);
	sourceA->draw(position.x + BUTTON_WIDTH, position.y+FRAME_TICKER_HEIGHT);
	sourceB->draw(position.x + BUTTON_WIDTH, position.y+FRAME_TICKER_HEIGHT+sourcePreviewHeight);
	distortion->draw(position.x + BUTTON_WIDTH, position.y+FRAME_TICKER_HEIGHT+sourcePreviewHeight*2);


	ofEnableSmoothing();
    ofEnableAlphaBlending();
	ofSetColor(40, 40, 40);

	//---------- DRAW .5 LINE
	ofLine(BUTTON_WIDTH, sourcekeys->getDrawRect().y + .5*sourcekeys->getDrawRect().height,
		   BUTTON_WIDTH+totalWidth, sourcekeys->getDrawRect().y + .5*sourcekeys->getDrawRect().height);

	//--------DRAW MIN-MAX GRAPH VISUALIZATION
	float minMaxVisualizerOffset = keyframeStartY + KEYFRAME_HEIGHT;
	ofSetColor(200, 120, 0);
	for(int i = 0; i <= totalWidth; i+=4){
		//draw lines, then blank out with bars
		ofLine(BUTTON_WIDTH+i, minMaxVisualizerOffset, BUTTON_WIDTH+i, minMaxVisualizerOffset+GRAPH_HEIGHT);
	}


	ofSetColor(20, 20, 20);
	ofFill();
	for(int i = 0; i <= totalWidth; i+=2){
		float samplepos = ofMap(1.0f*i/totalWidth,0,1.0, zoomer->getViewRange().min, zoomer->getViewRange().max, true);
		//toprect
		ofRect(BUTTON_WIDTH+i, minMaxVisualizerOffset, 2, (1-maxwidthkeys->sampleTimelineAt(samplepos))*GRAPH_HEIGHT);
		//bottomrect
		float bottomheight = minwidthkeys->sampleTimelineAt(samplepos)*GRAPH_HEIGHT;
		ofRect(BUTTON_WIDTH+i, minMaxVisualizerOffset + (GRAPH_HEIGHT-bottomheight), 2, bottomheight);
	}


	//---------- DRAW KEYFRAMES
	maxwidthkeys->draw();
	minwidthkeys->draw();
	sourcekeys->draw();
	blendkeys->draw();
	zoomer->draw();

	if(loadedReferenceSource != NULL){
		ofSetColor(200, 200, 100, 100);
		//draw lines for preview points
		for(int i = 0; i < loadedReferenceSource->previewTextures.size(); i++){
			float xPixelPos = loadedReferenceSource->previewTextures[i].bounds.x + BUTTON_WIDTH;
			ofLine(xPixelPos, position.y, xPixelPos, position.y+FRAME_TICKER_HEIGHT+sourcePreviewHeight*3);
			ofDrawBitmapString(ofToString(loadedReferenceSource->previewTextures[i].frameIndex), xPixelPos+3, position.y+5);
		}
	}

    //--------------- DRAW PLAYHEAD
    if(rollingOverPlayhead){
	    ofSetColor(255, 0, 0, 100);
		float playheadX = position.x + BUTTON_WIDTH + totalWidth*playheadFloatPosition;
        ofLine(playheadX, position.y,
               playheadX, position.y+totalHeight-FRAME_TICKER_HEIGHT-ELEMENT_SPACER);

						   
		//draw distortion width
		if(loadedReferenceSource != NULL){
			ofSetColor(255, 0, 0, 50);
			float minXPercent = ofMap(getCurrentWindowStartFrame(), 0, getSequenceLength()-1, 0.0, 1.0, true);
			float maxXPercent = ofMap(getCurrentWindowEndFrame(), 0, getSequenceLength()-1, 0.0, 1.0, true);
			float minX = BUTTON_WIDTH + ofMap(minXPercent, zoomer->getViewRange().min, zoomer->getViewRange().max, 0, totalWidth, true);
			float maxX = BUTTON_WIDTH + ofMap(maxXPercent, zoomer->getViewRange().min, zoomer->getViewRange().max, 0, totalWidth, true);
			ofRect(minX, position.y+FRAME_TICKER_HEIGHT,  (maxX-minX), totalHeight-FRAME_TICKER_HEIGHT*2-ELEMENT_SPACER);
			
			ofSetColor(255, 200, 20);
			//draw frame ticker
			ofDrawBitmapString(ofToString(getCurrentWindowStartFrame()), ofPoint(minX, position.y-10)) ;

			//draw frame ticker
			ofDrawBitmapString(ofToString(getCurrentWindowEndFrame()), ofPoint(maxX, position.y+10)) ;
			
		}
		ofSetColor(255, 200, 20);
		//draw frame ticker
		ofDrawBitmapString(ofToString(loadedReferenceSource->getIndexAtPercent(zoomedPlayheadFloatPosition)), ofPoint(playheadX, position.y)) ;
		
    }

    ofPopStyle();
    return;

    ofSetColor(255, 255, 0, 255);
    ofLine(position.x + BUTTON_WIDTH + totalWidth*playheadPosition, position.y,
           position.x + BUTTON_WIDTH + totalWidth*playheadPosition, position.y+totalHeight-FRAME_TICKER_HEIGHT-ELEMENT_SPACER);

    ofNoFill();
    ofSetColor(255,0,255);
    ofRect(position.x + BUTTON_WIDTH, position.y+FRAME_TICKER_HEIGHT, totalWidth, sourcePreviewHeight*3);

    //------ DRAW DISABLED FIELD
	if(exporting){
		ofFill();
		ofSetColor(200, 200, 200, 20);
		ofRect(position.x+BUTTON_WIDTH, position.y, totalWidth, totalHeight);
	}

    ofPopStyle();

    sourceA->purgeThumbs();
    sourceB->purgeThumbs();
    distortion->purgeThumbs();
}
Exemple #12
0
int main( int argc, char *argv[] ) {

  char seqChar[MAXSEQLENGTH];
  int seqNum[MAXSEQLENGTH+1];  

  DBL_TYPE pf;
  int complexity = 3;
  int length, tmpLength;
  char inputFile[ MAXLINE];
  int vs;
  char sampleFile[MAXLINE];
  //permAvgPairs stores the expected value of each 
  //class of base pairs, grouped by permutation or complex, respectively

  int inputFileSpecified;
  FILE *F_sample = NULL; // ppairs file
  int index;

  strcpy( inputFile, "");
  nupack_sample = 1;
  nupack_num_samples = 10;
  struct timeval rand_time;

  gettimeofday(&rand_time,0);
  nupack_random_seed = (rand_time.tv_sec)*1000000 + rand_time.tv_usec;

  inputFileSpecified = ReadCommandLineNPK( argc, argv, inputFile);

  if(NupackShowHelp) {
    printf("Usage: sample [OPTIONS] PREFIX\n");
    printf("Randomly sample unpseudoknotted structures from the equilibrium distribution\n");
    printf("Example: sample -multi -T 25 -material dna -samples 100 example\n");
    PrintNupackThermoHelp();
    PrintNupackUtilitiesHelp();
    exit(1);
  }

  if( !inputFileSpecified ) {
    printf("Enter output file prefix: ");
    scanf("%s", inputFile);
    strcat(inputFile,".in"); // Here, .in is just a placeholder
  }

  if(!inputFileSpecified ||
     !ReadInputFile( inputFile, seqChar, &vs, NULL, NULL, NULL) ) {
       if (inputFileSpecified==0) getUserInput( seqChar, &vs, NULL, NULL);
       else abort();
  }

  strncpy(sampleFile,inputFile,strlen(inputFile)-3);
  sampleFile[strlen(inputFile)-3] = '\0';
  strcat(sampleFile,".sample");

  header( argc, argv, "sample", sampleFile);
  printInputs( argc, argv, seqChar, vs, NULL, NULL,sampleFile);


  tmpLength = length = strlen( seqChar);
  convertSeq(seqChar, seqNum, tmpLength);
  int ns1,ns2;
  getSequenceLength(seqChar, &ns1);
  getSequenceLengthInt(seqNum, &ns2);

  init_genrand(nupack_random_seed);

  pairPr = NULL;
  if (complexity != 3) {
    printf("Sampling supported only for complexity = 3. Exiting\n");
    exit(1);
  }

  nupack_sample_list = (char **)calloc(nupack_num_samples, sizeof(char *));
  printf("Number of Samples = %i\n",nupack_num_samples);
  for(index = 0 ; index < nupack_num_samples ; index++) {
    nupack_sample_list[index] = (char *) calloc(tmpLength+1,sizeof(char));
  }

  printf("Started Calculation\n");
  pf = pfuncFull(seqNum, complexity, DNARNACOUNT, DANGLETYPE, TEMP_K - ZERO_C_IN_KELVIN, 0,
      SODIUM_CONC, MAGNESIUM_CONC, USE_LONG_HELIX_FOR_SALT_CORRECTION);
  printf("Finished Calculation\n");


  

  
  if ((F_sample = fopen(sampleFile,"a")) == NULL) {
    printf("Error opening file %s!\n",sampleFile);
    exit(1);
  }

  // Print the free energy to the output file
  fprintf(F_sample,"%s Free energy: %.8Le kcal/mol\n",
          COMMENT_STRING,-kB*TEMP_K*logl(pf));
  fprintf(F_sample,"%s Number of Samples: %i\n",COMMENT_STRING,nupack_num_samples);

  // Put newline for stylistic reasons
  fprintf(F_sample,"\n");


  for(index = 0 ; index < nupack_num_samples ; index++) {
    fprintf(F_sample, "%s\n",nupack_sample_list[index]);
    free(nupack_sample_list[index]);
    nupack_sample_list[index] = NULL;
  }
  free(nupack_sample_list);

#ifdef GC_DEBUG
  CHECK_LEAKS();
#endif
  return 0;
}
Exemple #13
0
    updateSize();
    updateVisibleRange();
}

void DetView::setDisabledDetViewActions(bool t){
    showTranslationAction->setDisabled(t);
    showComplementAction->setDisabled(t);
    wrapSequenceAction->setDisabled(t);
}

int DetView::getShift() const {
    return isWrapMode() ? currentShiftsCounter * getDetViewRenderArea()->getShiftHeight() : 0;
}

void DetView::ensurePositionVisible(int pos) {
    CHECK(pos >= 0 && pos <= getSequenceLength(), );

    DetViewRenderArea* detViewRenderArea = getDetViewRenderArea();
    if (isWrapMode()) {
        if (!visibleRange.contains(pos)) {
            if (pos < visibleRange.startPos) {
                // scroll up till the line is visible
                int line = pos / getSymbolsPerLine();
                int listStartPos = line * getSymbolsPerLine();
                visibleRange.startPos = listStartPos;
                currentShiftsCounter = detViewRenderArea->getDirectLine() + 1;
            } else {
                // scroll down till the line becomes visible
                const int line = pos / getSymbolsPerLine();
                const int visibleShiftsCount = detViewRenderArea->height() / detViewRenderArea->getShiftHeight();
                const int shiftToEnsureIsVisible = line * numShiftsInOneLine + detViewRenderArea->getDirectLine() + 1;
Exemple #14
0
unsigned int ReadsLayout::sampleOH(size_t listIndex,
                               bool dir,
                               unsigned int maxD,
                               unsigned int maxN,
                               unsigned int *distr)
{
    unsigned int index;
    unsigned int pos;
    int nodeLength=getSequenceLength(listIndex);
    unsigned int rl=R->getReadsLength();
    unsigned int nOverlap=0;
    unsigned int mult;
    int oh; //overhang

    if (dir)
    {
        index = getBegin(listIndex);
        pos = 1;
        index = getNext(index);

        while (index != 0)
        {
            if (pos > maxD && maxD!=0)
                break;
            if (nOverlap > maxN && nOverlap!=0)
                break;
            
            mult = 1;
            oh = getPosition(index) - pos;

            while (oh == 0)
            {
                mult++;
                index = getNext(index);
                if (index == 0)
                    break;

                oh = getPosition(index) - pos;
            }

            if (mult > 1)
            {
                nOverlap += mult - 1;
                mult = (mult * mult) - mult;
                distr[0] += mult;

                if (index == 0)
                    break;
            }

            distr[oh]++;
            nOverlap++;
            pos += oh;
            index = getNext(index);
        }
    }
    else
    {
        pos=nodeLength-rl+1;
        index = getPrevious(listIndex);

        while (index != 0)
        {
            if (nodeLength - (pos+rl-1) > maxD && maxD!=0)
                break;
            if (nOverlap > maxN && nOverlap!=0)
                break;
            
            mult = 1;
            oh = pos - getPosition(index);

            while (oh == 0)
            {
                mult++;
                index = getPrevious(index);
                if (index == 0)
                    break;

                oh = pos - getPosition(index);
            }

            if (mult > 1)
            {
                nOverlap += mult - 1;
                mult = (mult * mult) - mult;
                distr[0] += mult;

                if (index == 0)
                    break;
            }

            distr[oh]++;
            nOverlap++;
            pos -= oh;
            index = getPrevious(index);
        }
    }
    
    return nOverlap;
}