The best bet is *always* to e-mail the list. My suggestion if you're writing 
code is to look at what read/write conformers do. :-)

% less src/ops/readconformers.cpp:
…
/*
    To use with OBConversion::Read(), etc.
    OBMol mol;
    vector<OBBase*> vec;
    while(pConv->Read(&mol))
      vec.push_back(&mol);
    OBOp* pOp = OBOp::FindType("readconformers");
    if(!pOp)
      pOp->ProcessVec(vec);
    vec now contains one or more molecules with multiple conformers
*/
…

% less src/obmolecformat.cpp
…
      if(pConv->IsOption("writeconformers", OBConversion::GENOPTIONS)) {
        //The last conformer is written in the calling function
        unsigned int c = 0;
        for (; c < pmol->NumConformers()-1; ++c) {
          pmol->SetConformer(c);
          if(!pConv->GetOutFormat()->WriteMolecule(pmol, pConv))
            break;
        }
        pmol->SetConformer(c);
      }
...

Not very hard, and of course you could do something like this:

// Write all conformers in pmol to std::cout
pConv->AddOption("writeconformers",OBConversion::GENOPTIONS);
pConv->Write(pmol, &cout);

Hope that helps,
-Geoff

On May 15, 2013, at 12:50 AM, bm <b...@berkeley.edu> wrote:

> Hello:
> 
> I am using OpenBabel to help me generate multiple conformers of one molecule, 
> and then using them to calculate spatial fit with another molecule.  However, 
> I would like to save the conformers to a single file as I run my 
> calculations, so that I have a record of the random conformers I have used.  
> Is there a way to get OBConversion to read and write multiple conformers of a 
> single molecule?  I understand that one can do this using the obabel 
> program's --readconformer and --writeconformers flags, but I would like to do 
> all this in-code; i.e.
> 
> // to save conformers
> OBMol *mol = generateConformers();
> mol->NumConformers() // returns value greater than 1
> obconversion->saveMoleculeAndAllConformersToFile();
> 
> // later, when I want to revisit my generated conformers
> obconversion->openFile("file")
> obconversion->loadAllConformersInFileToMolecule(mol)
> mol->NumConformers() // returns value greater than 1
> 
> I also tried using OpReadConformers to help me, but its churning out an 
> incomplete type error on compile...
> 
> Any help would be greatly appreciated!
> bm
> 

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
OpenBabel-Devel mailing list
OpenBabel-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-devel

Reply via email to