本文整理汇总了C++中OBMol::SetIsPatternStructure方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::SetIsPatternStructure方法的具体用法?C++ OBMol::SetIsPatternStructure怎么用?C++ OBMol::SetIsPatternStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::SetIsPatternStructure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeQueriesFromMolInFile
bool MakeQueriesFromMolInFile(vector<OBQuery*>& queries, const std::string& filename, int* pnAtoms, bool noH)
{
OBMol patternMol;
patternMol.SetIsPatternStructure();
OBConversion patternConv;
OBFormat* pFormat;
//Need to distinguish between filename and SMARTS. Not infallable...
if( filename.empty() ||
filename.find('.')==string::npos ||
!(pFormat = patternConv.FormatFromExt(filename.c_str())) ||
!patternConv.SetInFormat(pFormat) ||
!patternConv.ReadFile(&patternMol, filename) ||
patternMol.NumAtoms()==0)
return false;
if(noH)
patternMol.DeleteHydrogens();
do
{
*pnAtoms = patternMol.NumHvyAtoms();
queries.push_back(CompileMoleculeQuery(&patternMol));
}while(patternConv.Read(&patternMol));
return true;
}
示例2: ObtainTarget
bool FastSearchFormat::ObtainTarget(OBConversion* pConv, vector<OBMol>& patternMols, const string& indexname)
{
//Obtains an OBMol from:
// the filename in the -s option or
// the SMARTS string in the -s option or
// by converting the file in the -S or -aS options (deprecated).
// If there is no -s -S or -aS option, information on the index file is displayed.
OBMol patternMol;
patternMol.SetIsPatternStructure();
const char* p = pConv->IsOption("s",OBConversion::GENOPTIONS);
bool OldSOption=false;
//If no -s option, make OBMol from file in -S option or -aS option (both deprecated)
if(!p)
{
p = pConv->IsOption("S",OBConversion::GENOPTIONS);
if(!p)
p = pConv->IsOption("S",OBConversion::INOPTIONS);//for GUI mainly
OldSOption = true;
}
if(p)
{
vector<string> vec;
tokenize(vec, p);
//ignore leading ~ (not relevant to fastsearch)
if(vec[0][0]=='~')
vec[0].erase(0,1);
if(vec.size()>1 && vec[1]=="exact")
pConv->AddOption("e", OBConversion::INOPTIONS);
OBConversion patternConv;
OBFormat* pFormat;
//Interpret as a filename if possible
string& txt =vec [0];
if( txt.empty() ||
txt.find('.')==string::npos ||
!(pFormat = patternConv.FormatFromExt(txt.c_str())) ||
!patternConv.SetInFormat(pFormat) ||
!patternConv.ReadFile(&patternMol, txt) ||
patternMol.NumAtoms()==0)
//if false, have a valid patternMol from a file
{
//is SMARTS/SMILES
//Replace e.g. [#6] in SMARTS by C so that it can be converted as SMILES
//for the fingerprint phase, but allow more generality in the SMARTS phase.
for(;;)
{
string::size_type pos1, pos2;
pos1 = txt.find("[#");
if(pos1==string::npos)
break;
pos2 = txt.find(']');
int atno;
if(pos2!=string::npos && (atno = atoi(txt.substr(pos1+2, pos2-pos1-2).c_str())) && atno>0)
txt.replace(pos1, pos2-pos1+1, etab.GetSymbol(atno));
else
{
obErrorLog.ThrowError(__FUNCTION__,"Ill-formed [#n] atom in SMARTS", obError);
return false;
}
}
bool hasTildeBond;
if( (hasTildeBond = (txt.find('~')!=string::npos)) ) // extra parens to indicate truth value
{
//Find ~ bonds and make versions of query molecule with a single and aromatic bonds
//To avoid having to parse the SMILES here, replace ~ by $ (quadruple bond)
//and then replace this in patternMol. Check first that there are no $ already
//Sadly, isocynanides may have $ bonds.
if(txt.find('$')!=string::npos)
{
obErrorLog.ThrowError(__FUNCTION__,
"Cannot use ~ bonds in patterns with $ (quadruple) bonds.)", obError);
return false;
}
replace(txt.begin(),txt.end(), '~' , '$');
}
//read as standard SMILES
patternConv.SetInFormat("smi");
if(!patternConv.ReadString(&patternMol, vec[0]))
{
obErrorLog.ThrowError(__FUNCTION__,"Cannot read the SMILES string",obError);
return false;
}
if(hasTildeBond)
{
AddPattern(patternMols, patternMol, 0); //recursively add all combinations of tilde bond values
return true;
}
}
else
{
// target(s) are in a file
patternMols.push_back(patternMol);
while(patternConv.Read(&patternMol))
//.........这里部分代码省略.........