Hi Tim
Right you are =D
That fixed my problem!
Thanks a lot
Kasper
On Thu, Jul 26, 2012 at 1:27 AM, Tim Vandermeersch <
tim.vandermeer...@gmail.com> wrote:
> Hi,
>
> I could not run your example since I don't know what the repr_mols
> contains and don't have split(), is_any_of() and token_compress_on.
> However, I suspect that your rotorKey does not have the correct number
> of elements. The first element is ignored and adding an assert after
> this line:
>
> vector<int> rotorKey(split_vec.size());
>
> add
>
> assert(rotorKey.size() == rl.Size() + 1);
>
> If this assertion fails, change the line to:
>
> vector<int> rotorKey(split_vec.size() + 1);
>
> and
>
> rotorKey[i] = int_;
>
> to
>
> rotorKey[i+1] = int_;
>
> This should fix your problem.
>
> Tim
>
> On Thu, Jul 26, 2012 at 1:03 AM, Kasper Thofte <kasper.tho...@gmail.com>
> wrote:
> > Hi Tim
> >
> > Thanks for your answer. I am guessing that it is mostly the code
> starting at
> > OBRotamerList declaration I need to look at. I did more or less what it
> says
> > in the code snippet, and I still end up with 0 conformers. My code is
> here:
> >
> > OBConversion conv;
> > conv.SetInAndOutFormats("xyz", "mol");
> >
> > OBMol mol;
> > string xyz_file = "coords.xyz";
> > conv.ReadFile(&mol, xyz_file);
> >
> > OBRotamerList rotamers;
> > rotamers.SetBaseCoordinateSets(mol);
> >
> > OBRotorList rl;
> > rl.Setup(mol);
> >
> > rotamers.Setup(mol, rl);
> >
> > ifstream rm_file("repr_mols");
> > string line;
> > while (!rm_file.eof()) {
> > getline(rm_file, line);
> > vector<string> split_vec;
> > split(split_vec, line, is_any_of(" "),
> token_compress_on);
> > vector<int> rotorKey(split_vec.size());
> > for (int i = 0; i < split_vec.size(); i++) {
> > istringstream buffer(split_vec[i]);
> > int int_;
> > buffer >> int_;
> > rotorKey[i] = int_;
> > }
> > rotamers.AddRotamer(rotorKey);
> > }
> > rm_file.close();
> > vector<double*> conformers;
> > rotamers.ExpandConformerList(mol,
> > conformers);//mol.GetConformers());
> > mol.SetConformers(conformers);
> >
> > cout << mol.NumConformers() << endl;
> >
> > What am I doing wrong?
> >
> > Thanks
> >
> >
> > On Wed, Jul 25, 2012 at 10:16 PM, Tim Vandermeersch
> > <tim.vandermeer...@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> Based on src/conformer.cpp:
> >>
> >> OBMol mol; // read a molecule...
> >>
> >> OBRototList rotorList
> >> rotorList.Setup(mol);
> >> if (!rotorList.Size()) { // only one conformer
> >> return;
> >> }
> >>
> >> // create some random rotor keys
> >> RotorKey rotorKey(rotorList.Size() + 1, 0); // indexed from 1
> >> rotorKeys.push_back(rotorKey);
> >>
> >> OBRandom generator;
> >> generator.TimeSeed();
> >>
> >> int tries = 0;
> >> while (rotorKeys.size() < numConformers && tries < numConformers *
> >> 1000) {
> >> tries++;
> >> // perform random mutation(s)
> >> OBRotorIterator ri;
> >> OBRotor *rotor = rotorList.BeginRotor(ri);
> >> for (int i = 1; i < rotorList.Size() + 1; ++i, rotor =
> >> rotorList.NextRotor(ri)) {
> >> rotorKey[i] = generator.NextInt() %
> rotor->GetResolution().size();
> >> }
> >> // add the key
> >> rotorKeys.push_back(rotorKey);
> >> }
> >>
> >>
> >> OBRotamerList rotamers;
> >> rotamers.SetBaseCoordinateSets(mol);
> >> rotamers.Setup(mol, m_rotorList);
> >>
> >> // Add all rotor keys
> >> for (unsigned int i = 0; i < m_rotorKeys.size(); ++i)
> >> rotamers.AddRotamer(m_rotorKeys[i]);
> >>
> >> // Get conformers for the rotor keys
> >> std::vector<double*> conformers;
> >> rotamers.ExpandConformerList(mol, conformers);
> >> if (conformers.size())
> >> mol.SetConformers(conformers);
> >>
> >> Most of the code is populating the rotorKeys variable but it outlines
> >> how to go from the start to real conformers. Documentation on this is
> >> not that clear as you mentioned.
> >>
> >> Tim
> >>
> >> On Wed, Jul 25, 2012 at 10:01 PM, Kasper Thofte <
> kasper.tho...@gmail.com>
> >> wrote:
> >> > Hello
> >> >
> >> > I am trying to go from a set of rotorKeys (lists of integers,
> conforming
> >> > to
> >> > the rotor rules) to a set of conformers attached to the OBMol object,
> >> > given
> >> > a base coordinate set (which I take to mean bond angles and lengths
> and
> >> > dihedrals including non-heavy atoms).
> >> >
> >> > The example given in the OBRotamerList docs page,
> >> >
> >> >
> http://openbabel.org/api/current/classOpenBabel_1_1OBRotamerList.shtml#_details
> ,
> >> > seems to me to be doing this. However, when I try it and call
> >> > mol.NumConformers, I get zero conformers.
> >> >
> >> > I apologize if this question is answered by looking at the docs, but
> I'm
> >> > kinda stuck here. I just want to go from rotorkeys to multiple
> >> > conformers in
> >> > an OBMol object, given the base coordinates.
> >> >
> >> > Thanks
> >> >
> >> > Kasper
> >> >
> >> >
> >> >
> ------------------------------------------------------------------------------
> >> > Live Security Virtual Conference
> >> > Exclusive live event will cover all the ways today's security and
> >> > threat landscape has changed and how IT managers can respond.
> >> > Discussions
> >> > will include endpoint security, mobile security and the latest in
> >> > malware
> >> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> >> > _______________________________________________
> >> > OpenBabel-discuss mailing list
> >> > OpenBabel-discuss@lists.sourceforge.net
> >> > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
> >> >
> >
> >
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss