void Table::AlignFields() { RemoveSpaces(); int l_Columns = GetColumns(); Content l_Content = GetContent(); Content l_ResultContent = l_Content; for (int l_Itr = 0; l_Itr < l_Columns; ++l_Itr) { int l_FieldSize = 0; for (Row l_Row : l_ResultContent) l_FieldSize = l_Row[l_Itr].size() > l_FieldSize ? l_Row[l_Itr].size() : l_FieldSize; l_FieldSize += 3; for (Row& l_Row : l_ResultContent) { int l_WhitespaceNumber = l_FieldSize - l_Row[l_Itr].size(); for (int l_ThirdItr = 0; l_ThirdItr < l_WhitespaceNumber; ++l_ThirdItr) { if (!l_Itr && GetStructure(true) && !(l_ThirdItr < 2)) l_Row[l_Itr] = " " + l_Row[l_Itr]; else l_Row[l_Itr] += " "; } } } SetContent(l_ResultContent); }
//Destructor Oligowalk_object::~Oligowalk_object() { int i; if (table!=NULL) { //Table and numofsubstructures were allocated, so delete them for (i = 0; i < GetStructure()->GetSequenceLength() - length + 2; ++i) { delete[] table[i]; delete[] numofsubstructures[i]; } delete[] table; delete[] numofsubstructures; delete prefilter; } }
//Get the oligo-self DG for a given nucleotide. double Oligowalk_object::GetOligoSelfDG(const int index) { //Perform error checking: if (table==NULL) { //This means that OligoWalk() was not called successfully. ErrorCode = 100; return 0.0; } else if (index<1||index>GetStructure()->GetSequenceLength() - length + 1) { //This means an invalid index is being used ErrorCode = 3; return 0.0; } //note that the free eneergy changes are stored internally as integers, where they are multiplied by conversionfactor return (((double) table[index][3])/conversionfactor); }
//Write a report to disk using the OligoWalk data. int Oligowalk_object::WriteReport(const char outputfilename[], const int oligo_length, const bool isDNA, const int option, const double oligo_concentration, const int usesub, const int start, const int stop) { //Perform error checking: if (table==NULL) { //This means that OligoWalk() was not called successfully. return 100; } //The last three 0's indicate this is not siRNA design report(outputfilename, GetStructure(), table, numofsubstructures, oligo_length, isDNA, oligo_concentration, usesub,start,stop,prefilter,0, NULL,0,0,0,false); //No errors: return 0; }
// Get the Tm for a given nucleotide. double Oligowalk_object::GetTm(const int index) { //Perform error checking: if (table==NULL) { //This means that OligoWalk() was not called successfully. ErrorCode = 100; return 0.0; } else if (index<1||index>GetStructure()->GetSequenceLength() - length + 1) { //This means an invalid index is being used ErrorCode = 3; return 0.0; } //note that the Tm is stored as an integer, multiplied by 10. return (((double) table[index][5])/10); }
void Table::Shift() { Content l_NewContent; for (int l_Itr = 0; l_Itr < m_Columns; ++l_Itr) { l_NewContent.push_back(null); for (Row l_Row : m_Content) { l_NewContent[l_Itr].push_back(l_Row[l_Itr]); } } m_Content = l_NewContent; if (GetStructure(true)) { TableStruct l_NewStruct; l_NewStruct.first = m_Struct.second; l_NewStruct.second = m_Struct.first; m_Struct = l_NewStruct; } RemoveSpaces(); UpdateRowsAndColumns(); }
void Table::SetStructure(TableStruct p_Struct) { if (p_Struct.first.size() == m_Columns) { if (m_Struct.first.size()) m_Content.pop_front(); m_Struct.first = p_Struct.first; m_Content.push_front(m_Struct.first); } if (m_Struct.first.size() ? p_Struct.second.size() + 1 == m_Content.size() : p_Struct.second.size() == m_Content.size()) { bool l_NeedRemove = false; if (m_Struct.second.size()) l_NeedRemove = true; m_Struct.second = p_Struct.second; int l_Itr = 0; for (Row& l_row : m_Content) { if (l_NeedRemove) l_row.pop_front(); if (!l_Itr) l_row.push_front(""); else l_row.push_front(p_Struct.second[l_Itr - 1]); l_Itr++; } } if (GetStructure(true)) { RemoveSpaces(); AlignFields(); } UpdateRowsAndColumns(); }
//Perform an OligoWalk calculation //usesub = 0 -> no suboptimal; 3 -> heuristic int Oligowalk_object::Oligowalk(const int oligo_length, const bool isDNA, const int option, const double oligo_concentration, const int usesub, const int start, const int stop ) { datatable *enthalpy; thermo *helixstack; int test=-1; char stackf[maxfil],datapath[maxfil]; int error; datatable *dnadata; //use a character array to turn off SHAPE: char shapefile='\0'; int i,j,k,l; Thermodynamics *ddata; rddata *hybriddata,*enthalpyhybrid; char *pointer; //Make sure this is the first (and only allowed call of OligoWalk) if (table!=NULL) return 101; length = oligo_length;//save oligo_length for use in the destructor and for error checking later if (!energyread) { //The thermodynamic data tables have not been read and need to be read now. if (ReadThermodynamic()!=0) return 5;//return non-zero if a problem occurs } //Read the enthalpy data from disk using the underlying thermodynamics class GetEnthalpyData function: enthalpy = GetEnthalpyTable(); //make sure that the thermodynamics parameters could be read from disk if (enthalpy==NULL) { return 5;//5 is the error code that indicates the thermodynamic parameters were not found } //Although prefiltering isn't used in this version of OligoWalk, it needs to be initialized and passed to function. //Note that the true indicates that empirical scores would be used a prefilter = new siPREFILTER(*GetDatatable(),*enthalpy,0,true,GetStructure()->GetSequenceLength() - oligo_length + 2,isDNA); //Allocate the tables needed for storing the results table = new int*[GetStructure()->GetSequenceLength() - oligo_length + 2]; for (i = 0; i < GetStructure()->GetSequenceLength() - oligo_length + 2; i++) { //DHM commented out these lines for now. They need to be restored later. //if (siRNA) table[i] = new int[7]; //else table[i] = new int[6]; table[i] = new int[6]; } //allocate memory of number of suboptimal structures numofsubstructures= new int*[GetStructure()->GetSequenceLength() - oligo_length +2]; for (i = 0; i < GetStructure()->GetSequenceLength() - oligo_length + 2; i++) { numofsubstructures[i]= new int [2]; numofsubstructures[i][0]=0; numofsubstructures[i][1]=0; } //Get the path information for location of data files from $DATAPATH, if available pointer = getenv("DATAPATH"); if (pointer!=NULL) { strcpy(datapath,pointer); strcat(datapath,"/"); } else strcpy(datapath,""); //Allocate helixstack: helixstack = new thermo(pointer); //Now read the DNA parameters if the oligos are DNA: if (isDNA) { ddata = new Thermodynamics(false);//allocate space for DNA parameters //set the temperature for the DNA parameters error = ddata->SetTemperature(GetTemperature()); //Check fo an error if (error!=0) { delete ddata; delete prefilter; delete helixstack; return error; } //Read the dna thermodynamic parameters error = ddata->ReadThermodynamic(); //Check fo an error if (error!=0) { delete ddata; delete prefilter; delete helixstack; return error; } //Read the hybrid data as well hybriddata = new rddata; strcpy(stackf,datapath); strcat (stackf,"stackdr.dat"); //Check for errors if (readrd (hybriddata,stackf)==0) { delete ddata; delete prefilter; delete helixstack; return 5; } if (GetTemperature()<310||GetTemperature()>311) { //The temperature is simgificantly different from 37 dgrees C, so read and use the enthalpy data. strcpy(stackf,datapath); //strcat(stackf,"/"); strcat (stackf,"stackdr.dh"); enthalpyhybrid = new rddata; //Check for errors if (readrd (enthalpyhybrid,stackf)==0) { delete ddata; delete prefilter; delete enthalpyhybrid; delete helixstack; return 5; } for (i=0;i<5;i++) { for (j=0;j<5;j++) { for (k=0;k<5;k++) { for (l=0;l<5;l++) { hybriddata->stack[i][j][k][l]=Tscale(GetTemperature(),hybriddata->stack[i][j][k][l],enthalpyhybrid->stack[i][j][k][l]); } } } } hybriddata->init=Tscale(GetTemperature(),hybriddata->init,enthalpyhybrid->init); delete enthalpyhybrid; } strcpy(helixstack->DH,datapath); //strcat(helixstack->DH,"\\"); strcat(helixstack->DH,"stackdr.dh"); strcpy(helixstack->DS,datapath); //strcat(helixstack->DS,"\\"); strcat(helixstack->DS,"stackdr.ds"); strcpy(helixstack->HELIX,datapath); //strcat(helixstack->HELIX,"\\"); strcat(helixstack->HELIX,"helixdr.dat"); dnadata = ddata->GetDatatable(); } else { dnadata = NULL; } if (helixstack->read()==0) { //This means an error occurred reading the helixstack parameters if (isDNA) delete ddata; delete prefilter; delete helixstack; return 5; } //For now, siRNA is off. //if (siRNA) { // //mask will store whether an oligo meets siRNA design criteria // mask = new bool [ct.numofbases - length + 2]; //} //else mask = NULL; //note that foldsize is temporarilly set to zero so that there is no folding size limit //note that distance is set to zero so that there is no maximum pairping distance //note that test is set to -1 so there is no testing //note that write is set to FALSE to turn off writing olig(isDNA, option, GetStructure(), oligo_length, oligo_concentration, table, numofsubstructures, *GetDatatable(), *dnadata, hybriddata,usesub,GetProgress(),helixstack, start,stop,prefilter, 0, 0, &shapefile,&test,false); //siRNA is off right now //if (oligoobject->siRNA) { // filterbysirna(&oligoobject->ct,oligoobject->table,oligoobject->length,&oligoobject->data,oligoobject->mask,oligoobject->asuf,oligoobject->tofe,oligoobject->fnnfe); //} //note that foldsize is temporarilly set to zero here. //report(oligoobject->outputfile, &oligoobject->ct, oligoobject->table, oligoobject->numofsubstructures, // oligoobject->length, oligoobject->isdna, oligoobject->c, oligoobject->usesub,oligoobject->start,oligoobject->stop,prefilter,0, // oligoobject->mask,oligoobject->asuf,oligoobject->tofe,oligoobject->fnnfe); //Clean up if this is DNA if (isDNA) { delete ddata; } delete helixstack; return 0; }