QString IndexOrganizedTableProperties::generateDdl() const { QString ddl; if(pctThreshold!=-1){ ddl.append(" PCTTHRESHOLD ").append(QString::number(pctThreshold)); } ddl.append(optionText(mappingTable, " MAPPING TABLE", " NOMAPPING")); if(keyCompression==1){ ddl.append(" COMPRESS "); if(keyCompressionPrefixLength!=-1){ ddl.append(QString::number(keyCompressionPrefixLength)); } }else if(keyCompression==2){ ddl.append(" NOCOMPRESS"); } if(overflow){ ddl.append(" OVERFLOW"); if(!including.isEmpty()){ ddl.append(" INCLUDING \"").append(including).append("\" "); } QString storageParamsDdl=storageParams.generateDdl(); if(!storageParamsDdl.isEmpty()){ ddl.append(" ").append(storageParamsDdl); } ddl.append(optionText(logging, " LOGGING ", " NOLOGGING ")); } return ddl; }
QString IndexOrganizedTableProperties::generateDiffDdl(const IndexOrganizedTableProperties &other) const { QString ddl; if(pctThreshold!=other.pctThreshold){ ddl.append(" PCTTHRESHOLD ").append(QString::number(pctThreshold)); } QString overflowDdl; if(overflow){ if(!including.isEmpty() && including!=other.including){ overflowDdl.append(" INCLUDING \"").append(including).append("\" "); } QString storageParamsDdl=storageParams.generateDiffDdl(other.storageParams); if(!storageParamsDdl.isEmpty()){ overflowDdl.append(storageParamsDdl); } if(logging!=other.logging){ overflowDdl.append(optionText(logging, " LOGGING", " NOLOGGING")); } if(!other.overflow){ overflowDdl.prepend(" ADD OVERFLOW"); }else if(!overflowDdl.isEmpty()){ overflowDdl.prepend(" OVERFLOW"); } } if(!overflowDdl.isEmpty()){ ddl.append(overflowDdl); } return ddl; }
OBBase* OBMol::DoTransformations(const std::map<std::string, std::string>* pOptions, OBConversion* pConv) { // Perform any requested transformations // on a OBMol //The input map has option letters or name as the key and //any associated text as the value. //For normal(non-filter) transforms: // returns a pointer to the OBMol (this) if ok or NULL if not. //For filters returns a pointer to the OBMol (this) if there is a match, //and NULL when not and in addition the OBMol object is deleted NULL. //This is now a virtual function. The OBBase version just returns the OBMol pointer. //This is declared in mol.h //The filter options, s and v allow a obgrep facility. //Used together they must both be true to allow a molecule through. //Parse GeneralOptions if(pOptions->empty()) return this; // DoOps calls Do() for each of the plugin options in the map // It normally returns true, even if there are no options but // can return false if one of the options decides that the // molecule should not be output. If it is a filtering op, it // should delete the molecule itself (unlike the -s, --filter options, // which delete it in this function). if(!OBOp::DoOps(this, pOptions, pConv)) return (OBBase *)NULL; bool ret=true; map<string,string>::const_iterator itr, itr2; if(pOptions->find("b")!=pOptions->end()) if(!ConvertDativeBonds()) ret=false; if(pOptions->find("d")!=pOptions->end()) if(!DeleteHydrogens()) ret=false; if(pOptions->find("h")!=pOptions->end()) if(!AddHydrogens(false, false)) ret=false; if(pOptions->find("r")!=pOptions->end()) { StripSalts(); ret = true; } itr = pOptions->find("p"); if(itr!=pOptions->end()) { double pH = strtod(itr->second.c_str(), 0); if(!AddHydrogens(false, true, pH)) ret=false; } if(pOptions->find("c")!=pOptions->end()) Center(); itr = pOptions->find("title"); //Replaces title if(itr!=pOptions->end()) SetTitle(itr->second.c_str()); itr = pOptions->find("addtotitle"); //Appends text to title if(itr!=pOptions->end()) { string title(GetTitle()); title += itr->second; SetTitle(title.c_str()); } /* itr = pOptions->find("addformula"); //Appends tab + formula to title if(itr!=pOptions->end()) { string title(GetTitle()); title += '\t' + GetSpacedFormula(1,"");//actually unspaced SetTitle(title.c_str()); } */ //Add an extra property to the molecule. //Parameter has atrribute and value separated by a space itr = pOptions->find("property"); if(itr!=pOptions->end()) { string txt(itr->second); string::size_type pos = txt.find(' '); if(pos==string::npos) { obErrorLog.ThrowError(__FUNCTION__, "Missing property value", obError); ret=false; } else { string attr(txt.substr(0,pos)), val(txt.substr(pos+1)); //Update value if it already exists OBPairData* dp = dynamic_cast<OBPairData*>(GetData(attr)); if(dp) { dp->SetValue(val); dp->SetOrigin(userInput); } else { // Pair did not exist; make new one dp = new OBPairData; dp->SetAttribute(attr); dp->SetValue(val); dp->SetOrigin(userInput); SetData(dp); } } } itr = pOptions->find("add"); //adds new properties from descriptors in list if(itr!=pOptions->end()) OBDescriptor::AddProperties(this, itr->second); itr = pOptions->find("delete"); //deletes the specified properties if(itr!=pOptions->end()) OBDescriptor::DeleteProperties(this, itr->second); itr = pOptions->find("append"); //Appends values of descriptors or properties to title if(itr!=pOptions->end()) { string title(GetTitle()); title += OBDescriptor::GetValues(this, itr->second); if(ispunct(title[0])) title[0]=' ';//a leading punct char is used only as a separator, not at start SetTitle(Trim(title).c_str()); } //Filter using OBDescriptor comparison and (older) SMARTS tests //Continue only if previous test was true. bool fmatch = true; itr = pOptions->find("filter"); if(itr!=pOptions->end()) { std::istringstream optionText(itr->second); fmatch = OBDescriptor::FilterCompare(this, optionText, false); } if(fmatch) { itr = pOptions->find("v"); if(itr!=pOptions->end() && !itr->second.empty()) { //inverse match quoted SMARTS string which follows OBSmartsPattern sp; sp.Init(itr->second); fmatch = !sp.Match(*this); //(*pmol) ; } } if(fmatch) { itr = pOptions->find("s"); if(itr!=pOptions->end() && !itr->second.empty()) { //SMARTS filter //If exactmatch option set (probably in fastsearchformat) the //number of atoms in the pattern (passed as a string in the option text) //has to be the same as in the molecule. itr2 = pOptions->find("exactmatch"); if(itr2!=pOptions->end() && NumHvyAtoms()!=atoi(itr2->second.c_str())) fmatch=false; else { //match quoted SMARTS string which follows OBSmartsPattern sp; sp.Init(itr->second.c_str()); fmatch = sp.Match(*this); } } } if(!fmatch) { //filter failed: delete OBMol and return NULL delete this; return NULL; } else { if(ret==false) { obErrorLog.ThrowError(__FUNCTION__, "Error executing an option", obError); delete this; //added 9March2006 return NULL; } else return this; } }