From: Manuel M. F. <man...@gm...> - 2007-11-13 15:39:23
|
Dear Noel, First thanks so much for your help, It works, it does what I want. There is a small strange problem, whenever I run my software with the following file (which contains only one molecule) it breaks (segmentation fault) in the separate part. It is not a problem for me, but ... best regards Manu On Nov 6, 2007 10:20 AM, Noel O'Boyle <bao...@gm...> wrote: > Dear Manuel, > > If you look at the documentation for OBMol at: > http://openbabel.sourceforge.net/api/2.1.0/classOpenBabel_1_1OBMol.shtml#1e5c6955a32c0ec2317a8de12ab7ba5a > you will see that there is a method called OBMol::Separate() which > will do exactly what you wish. > > For example, given the PDB file below: > >>> import pybel > >>> input_molecule = pybel.readfile("pdb", "example.pdb").next() > >>> separate_mols = input_molecule.OBMol.Separate() > >>> pybel_mols = [pybel.Molecule(x) for x in separate_mols] > >>> print pybel_mols[0].atoms[0].coords > (8.0389999999999997, 5.8680000000000003, 0.49299999999999999) > > You can access the second molecule with pybel_mols[1], and you can > find the number of molecules with len(pybel_mols), etc. > > Regards, > Noel > > > On 06/11/2007, Manuel Melle Franco <man...@gm...> wrote: > > Thanks for the prompt answer, > > > > Sorry, I guess I am using the wrong terminology here. > > For instace this a file containing two molecules of water: > > > > An easy input in pdb: > > HEADER two water molecules > > COMPND > > SOURCE > > HETATM 1 O 1 1 8.039 5.868 0.493 > > HETATM 2 H 2 1 7.581 5.023 0.404 > > HETATM 3 H 2 1 8.287 6.062 -0.397 > > HETATM 4 O 1 2 0.115 -8.877 6.446 > > HETATM 5 H 2 2 0.959 -8.446 6.405 > > HETATM 6 H 2 2 0.247 -9.794 6.138 > > CONECT 1 2 3 > > CONECT 2 1 > > CONECT 3 1 > > CONECT 4 5 6 > > CONECT 5 4 > > CONECT 6 4 > > END > > > > > > atoms 1 2 3 are part of molecule 1 > > atoms 4 5 6 are part of molecule 2 > > > > actually now that I think about I could make one file for each > > molecule and that would > > solve the problem, since I have only few molecules in this case. This > > would not be > > > > > > best regards, and thanks > > > > Manu > > > > On 11/5/07, Noel O'Boyle <bao...@gm...> wrote: > > > Can you give an example of your input file? I've never used a file > > > format containing multiple molecules... > > > > > > Noel > > > > > > On 05/11/2007, manulinho72 <man...@gm...> wrote: > > > > > > > > Dear All, > > > > > > > > I am pretty new to openbabel, so hope this is not a too silly question. > > > > > > > > I have a file with a number of molecules ( as shown but their connectivity). > > > > > > > > I've got an algorithm that tells me how many molecules there are an index > > > > each atom > > > > as corresponding to one molecule. However, my system is quite large and in > > > > python this it is very slow. I could try another algorithm but maybe there > > > > is something already implemented in the libraries I can try. > > > > > > > > The idea is, for instance I have to water molecules, I would get an array > > > > with values > > > > > > > > H1 1 > > > > O1 1 > > > > H1 1 > > > > H2 2 > > > > O2 2 > > > > H2 2 > > > > > > > > Thanks in advance. > > > > > > > > regards > > > > > > > > Manu > > > > -- > > > > View this message in context: http://www.nabble.com/finding-different-molecules-inside-a-file-from-python-tf4752415.html#a13589313 > > > > Sent from the openbabel-scripting mailing list archive at Nabble.com. > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > This SF.net email is sponsored by: Splunk Inc. > > > > Still grepping through log files to find problems? Stop. > > > > Now Search log events and configuration files using AJAX and a browser. > > > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > > > _______________________________________________ > > > > OpenBabel-scripting mailing list > > > > Ope...@li... > > > > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > > > > > > > > > > > > > -- > > ____________________________________________________________ > > > > Mohandas K. Gandhi often changed his mind publicly. An aide once asked > > him how he could so freely contradict this week what he had said just > > last week. The great man replied that it was because this week he knew > > better. > > ____________________________________________________________ > > > > Manuel Melle-Franco, Ph.D. > > Dip. di Chimica "G. Ciamician" > > Universita Di Bologna > > via Selmi 2, I-40126 > > Bologna, Italy > > --------------------------------------------------------- > > Fax : +39-051-2099456 > > Phone : +39-051-2099578 *NEW NUMBER 09/07* > > --------------------------------------------------------- > > > -- ____________________________________________________________ Mohandas K. Gandhi often changed his mind publicly. An aide once asked him how he could so freely contradict this week what he had said just last week. The great man replied that it was because this week he knew better. ____________________________________________________________ Manuel Melle-Franco, Ph.D. Dip. di Chimica "G. Ciamician" Universita Di Bologna via Selmi 2, I-40126 Bologna, Italy --------------------------------------------------------- Fax : +39-051-2099456 Phone : +39-051-2099578 *NEW NUMBER 09/07* --------------------------------------------------------- |