If you read the output of help(pybel.Molecule.draw) you will see that
it does what you want:

>>> mol = pybel.readstring("smi", "CC(=O)Cl")
>>> mol.draw(show=False, update=True)
>>> print mol.write("mol")

 OpenBabel10221609022D

  4  3  0  0  0  0  0  0  0  0999 V2000
    1.7321   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.8660    0.5000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.8660    1.5000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -0.0000   -0.0000    0.0000 Cl  0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  2  3  2  0  0  0  0
  2  4  1  0  0  0  0
M  END

On 21 October 2016 at 22:17, T V <th...@ucdavis.edu> wrote:
> Draw doesn't have a means of flattening the molecule. And basically does the
> same thing as write. I don't need a picture, I need the mol file, with JUST
> 2d coordinates.
>
> On Thu, Oct 20, 2016 at 6:35 AM, Noel O'Boyle <baoille...@gmail.com> wrote:
>>
>> Take a look at the draw method.
>>
>>
>> On 20 Oct 2016 2:08 p.m., "T V" <th...@ucdavis.edu> wrote:
>>>
>>> Hi,
>>>
>>> In Pybel, it seems like every InChi or SMILES string I convert into a
>>> molecule object (after "pybel.readstring") file using the method
>>> ".write(format="mol")" generates mol files where the atoms are all at the
>>> center. The coordinates are all 0's and it's really frustrating because I
>>> know there is in fact a mol.make3d() that will add those 3d coordinates in
>>> space for even the most complex molecules, so it's possible that they could
>>> be given the correct coordinates. All I really need is a way to render my
>>> mol files with the first two columns so that I have 2d representation as you
>>> would typically expect when you save a mol file. I'm using kekule to render
>>> those mol files into pngs, and just look horribly warped in 3D.
>>>
>>>
>>> Additionally, I know openbabel is capable of generating 2d images because
>>> mol.write(format="png") is possible and will generate a perfect 2d image
>>> despite having all its coordinates be 0. Additionlly the obabel command
>>> option of "-Opng" seems to be able to make images from inchi, smiles, or mol
>>> into 2d plots regardless of the fact that I never provided the 2d
>>> coordinates.
>>> So why can't I just simply get the mol file with those same coordinates?
>>>
>>> --
>>> Thanh
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>>> _______________________________________________
>>> OpenBabel-discuss mailing list
>>> OpenBabel-discuss@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>>>
>
>
>
> --
> Thanh

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to