~ubuntu-branches/debian/stretch/openbabel/stretch

« back to all changes in this revision

Viewing changes to src/ops/opisomorph.cpp

  • Committer: Package Import Robot
  • Author(s): Daniel Leidert
  • Date: 2013-05-22 19:08:27 UTC
  • mfrom: (1.1.11) (7.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20130522190827-72q0fnx5y2nm3bc0
Tags: 2.3.2+dfsg-1
* New upstream release.
* debian/control: Dropped DM-Upload-Allowed field.
  (Standards-Version): Bumped to 3.9.4.
* debian/copyright: Massive update.
* debian/upstream: Author name update.
* debian/get-orig-source.sh: Remove the windows-*/ directory too.
* debian/openbabel.install: Removed roundtrip manpage.
* debian/openbabel-gui.install: Fixed manpage name.
* debian/openbabel-gui.links: Removed unused file.
* debian/rules: Enable OpenMP. Disable tests on `nocheck'.
* debian/patches/gaussformat_nosym.patch: Dropped. Applied upstream.
* debian/patches/moldenformat_coordonly.patch: Ditto.
* debian/patches/obspectrophore_man.patch: Ditto.
* debian/patches/fix_ftbfs.patch: Added.
  - Fix several FTBFS issues in upstream build system.
* debian/patches/series: Adjusted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        const std::string& value)
36
36
{
37
37
  //Add data to atoms
38
 
  for(int j=0; j<atomIdxs.size(); ++j)
 
38
  for(unsigned int j=0; j<atomIdxs.size(); ++j)
39
39
  {
40
40
    OBAtom* pAtom = pmol->GetAtom(atomIdxs[j]);
41
41
    if(!pAtom)
113
113
    "With -v, only molecules NOT matching the SMARTS are converted.\n"
114
114
    "The optional second parameter causes the matched substructure to be\n"
115
115
    "colored if it is a color name like ``green`` or a hex value like\n"
116
 
    "``#8dcb70``. The coloring is recognized by SVGFormat and CMLFormat.\n\n"
 
116
    "``#8dcb70``. The coloring is recognized by SVGFormat and CMLFormat.\n \n"
117
117
 
118
118
    "The first parameter can also be a filename with an extension that\n"
119
119
    "can be interpreted as a file format:\n"
129
129
    "converted molecule corresponds to the first pattern molecule matched,\n"
130
130
    "or the last color if there are fewer colors than pattern molecules.\n\n"
131
131
 
 
132
    "If the last parameter is ``showall``, all molecules are shown, even if\n"
 
133
    "they do not match. This allows the -s option to be used for highlighting.\n \n"
 
134
 
132
135
    "If the second parameter is ``exact`` only exact matches are converted.\n"
133
136
    "If the second parameter is ``extract`` all the atoms in the converted\n"
134
137
    "molecule are deleted except for those matched. Since these retain their\n"
179
182
      vec[0].erase(0,1);
180
183
    }
181
184
 
 
185
    //Do not filter out any molecules if there is a parameter "showall";
 
186
    //allows -s option to be used for highlighting substructures (--highlight also does this)
 
187
    vector<string>::iterator it = std::remove(vec.begin(), vec.end(),"showall");
 
188
    showAll = it != vec.end();
 
189
    if(showAll)
 
190
      vec.erase(it);
 
191
 
182
192
    //Interpret as a filename if possible
183
193
    MakeQueriesFromMolInFile(queries, vec[0], &nPatternAtoms, strstr(OptionText,"noH"));
184
194
    vec.erase(remove(vec.begin(),vec.end(),"noH"),vec.end());//to prevent "noH2" being seen as a color
204
214
    }
205
215
    else
206
216
      nPatternAtoms = 0;
207
 
    
 
217
 
208
218
    //disable old versions
209
219
    if(pConv)
210
220
      pConv->AddOption(GetID(), OBConversion::GENOPTIONS, "");
211
221
  }
212
222
 
213
 
  bool match;
 
223
  bool match = false;
214
224
  //These are a vector of each mapping, each containing atom indxs.
215
225
  vector<vector<int> > vecatomvec;
216
226
  vector<vector<int> >* pMappedAtoms = NULL;
220
230
    if(pmol->NumHvyAtoms() != nPatternAtoms)
221
231
      return false;
222
232
 
223
 
  int imol=0; //index of mol in pattern file
 
233
  unsigned int imol=0; //index of mol in pattern file
224
234
  if(!queries.empty()) //filename supplied
225
235
  {
226
236
    //match is set true if any of the structures match - OR behaviour
227
 
    for(qiter=queries.begin();qiter!=queries.end();++qiter, ++imol) 
 
237
    for(qiter=queries.begin();qiter!=queries.end();++qiter, ++imol)
228
238
    {
229
239
      OBIsomorphismMapper* mapper = OBIsomorphismMapper::GetInstance(*qiter);
230
240
      OBIsomorphismMapper::Mappings mappings;
253
263
    // only when SMARTS contains [H]. Doing more has complications with atom typing,
254
264
    // so AddHydrogens here on the molecule (not a copy) when #1 detected.
255
265
    bool addHydrogens = (vec[0].find("#1]")!=string::npos);
256
 
      
 
266
 
257
267
    if(!sp.Init(vec[0]))
258
268
    {
259
269
      string msg = vec[0] + " cannot be interpreted as either valid SMARTS "
273
283
      pMappedAtoms = &sp.GetMapList();
274
284
  }
275
285
 
276
 
  if((!match && !inv) || (match && inv))
 
286
  if(!showAll && (!match && !inv) || (match && inv))
277
287
  {
278
288
    //delete a non-matching mol
279
289
    delete pmol;
280
290
    pmol = NULL;
281
291
    return false;
282
292
  }
283
 
  
 
293
 
284
294
  if(match)
285
295
    //Copy the idxes of the first match to a member variable so that it can be retrieved from outside
286
296
    firstmatch.assign(pMappedAtoms->begin()->begin(), pMappedAtoms->begin()->end());
287
297
  else
288
298
    firstmatch.clear();
289
299
 
290
 
  if(!inv && vec.size()>=2 && !vec[1].empty() && !nPatternAtoms)
 
300
  if(match && !inv && vec.size()>=2 && !vec[1].empty() && !nPatternAtoms)
291
301
  {
292
302
    vector<vector<int> >::iterator iter;
293
303
 
294
 
    if(vec[1]=="extract" || vec.size()>3 && vec[2]=="extract")
 
304
    if (vec[1]=="extract" || (vec.size()>3 && vec[2]=="extract"))
295
305
    {
296
306
      //Delete all unmatched atoms. Use only the first match
297
307
      ExtractSubstruct(pmol, *pMappedAtoms->begin());