/////////////////////////////////////////////////////////////////////////////// // Run bimolecular folding calculations. /////////////////////////////////////////////////////////////////////////////// void bifold::run() { // Create a variable that handles errors. int error = 0; /* * Use the constructor for HybridRNA that specifies two filenames and types. * For both sequences, specify type = 2 (sequence file). * isRNA identifies whether the strand is RNA (true) or DNA (false). * * After construction of the strand data structure, create the error checker * which monitors for errors. * Throughout, the error status of the calculation is checked with a variant * of the isErrorStatus method, which returns 0 if no error occurred. The * calculation proceeds as long as error = 0. */ cout << "Initializing nucleic acids..." << flush; HybridRNA* strand = new HybridRNA( seqFile1.c_str(), 2, seqFile2.c_str(), 2, isRNA ); ErrorChecker<HybridRNA>* checker = new ErrorChecker<HybridRNA>( strand ); error = checker->isErrorStatus(); if( error == 0 ) { cout << "done." << endl; } /* * Set the temperature using the SetTemperature method. * Only set the temperature if a given temperature doesn't equal the default. * If the temperature does need to be set, use the error checker's * isErrorStatus method to check for errors. */ if( ( error == 0 ) && ( temperature != 310.15 ) ) { // Show a message saying that the temperature is being set. cout << "Setting temperature..." << flush; // Set the temperature and check for errors. int tempError = strand->SetTemperature( temperature ); error = checker->isErrorStatus( tempError ); // If no error occurred, print a message saying that temperature is set. if( error == 0 ) { cout << "done." << endl; } } /* * Set allowance or denial of intramolecular pairs using the * SetForbidIntramolecular method. * Since this method only sets a flag, error checking is not necessary. */ if( error == 0 ) { strand->SetForbidIntramolecular( intramolecular ); } /* * Fold the hybrid strand using the FoldBimolecular method. * If a save file name has been specified, the FoldBimolecular method also * has the ability to write a folding save file. * During calculation, monitor progress using the TProgressDialog class and * the Start/StopProgress methods of the RNA class. Neither of these methods * require any error checking. * After the main calculation is complete, use the error checker's * isErrorStatus method to check for errors in the main calculation. */ if( error == 0 ) { // Show a message saying that the main calculation has started. cout << "Folding two strands..." << endl; // Create the progress monitor. TProgressDialog* progress = new TProgressDialog(); strand->SetProgress( *progress ); // Fold the hybrid strand and check for errors. int mainCalcError = strand->FoldBimolecular( percent, maxStructures, windowSize, saveFile.c_str(), maxLoop ); error = checker->isErrorStatus( mainCalcError ); // Delete the progress monitor. strand->StopProgress(); delete progress; // If no error occurred, print message that main calculation is done. if( error == 0 ) { cout << "done." << endl; } } /* * Write a CT output file using the WriteCt method. * After writing is complete, use the error checker's isErrorStatus method to * check for errors. */ if( error == 0 ) { // Show a message saying that the CT file is being written. cout << "Writing output ct file..." << flush; // Write the CT file and check for errors. int writeError = strand->WriteCt( ctFile.c_str() ); error = checker->isErrorStatus( writeError ); // If no errors occurred, show a CT file writing completion message. if( error == 0 ) { cout << "done." << endl; } } // Delete the error checker and data structure. delete checker; delete strand; // Print confirmation of run finishing. if( error == 0 ) { cout << calcType << " complete." << endl; } else { cerr << calcType << " complete with errors." << endl; } }
/////////////////////////////////////////////////////////////////////////////// // Run calculations. /////////////////////////////////////////////////////////////////////////////// void DuplexFold::run() { // Create a variable that handles errors. int error = 0; /* * Use the constructor for HybridRNA that specifies two filenames and types. * For both sequences, specify type = 2 (sequence file). * isRNA identifies whether the strand is RNA (true) or DNA (false). * * After construction of the strand data structure, create the error checker which monitors for errors. * Throughout, the error status of the calculation is checked with a variant of the isErrorStatus method, which returns 0 if no error occurred. * The calculation proceeds as long as error = 0. */ cout << "Initializing nucleic acids..." << flush; HybridRNA* strand = new HybridRNA( seqFile1.c_str(), 2, seqFile2.c_str(), 2, isRNA ); ErrorChecker<HybridRNA>* checker = new ErrorChecker<HybridRNA>( strand ); error = checker->isErrorStatus(); if( error == 0 ) { cout << "done." << endl; } /* * Set the temperature using the SetTemperature method. * Only set the temperature if a given temperature doesn't equal the default. * If the temperature does need to be set, use the error checker's isErrorStatus method to check for errors. */ if( ( error == 0 ) && ( temperature != 310.15 ) ) { // Show a message saying that the temperature is being set. cout << "Setting temperature..." << flush; // Set the temperature and check for errors. int tempError = strand->SetTemperature( temperature ); error = checker->isErrorStatus( tempError ); // If no error occurred, print a message saying that temperature is set. if( error == 0 ) { cout << "done." << endl; } } /* * Fold the hybrid strand using the FoldDuplex method. * After the main calculation is complete, use the error checker's isErrorStatus method to check for errors. */ if( error == 0 ) { // Show a message saying that the main calculation has started. cout << "Folding duplex..." << endl; // Create the progress monitor. TProgressDialog* progress = new TProgressDialog(); strand->SetProgress( *progress ); // Do the main calculation and check for errors. int mainCalcError = strand->FoldDuplex( percent, maxStructures, windowSize, maxLoop ); error = checker->isErrorStatus( mainCalcError ); // Delete the progress monitor. strand->StopProgress(); delete progress; // If no error occurred, print message that main calculation is done. if( error == 0 ) { cout << "done." << endl; } } /* * Write a CT output file using the WriteCt method. * After writing is complete, use the error checker's isErrorStatus method to check for errors. */ if( error == 0 ) { // Show a message saying that the CT file is being written. cout << "Writing output ct file..." << flush; // Write the CT file and check for errors. int writeError = strand->WriteCt( ctFile.c_str() ); error = checker->isErrorStatus( writeError ); // If no errors occurred, show a CT file writing completion message. if( error == 0 ) { cout << "done." << endl; } } // Delete the error checker and data structure. delete checker; delete strand; // Print confirmation of run finishing. if( error == 0 ) { cout << calcType << " complete." << endl; } else { cerr << calcType << " complete with errors." << endl; } }