Dear Lee-Ping,
I do my 2D structure diagram generation [1] from 3D coordinates like this:
import openbabel as ob
molecule = ob.OBMol()
# load your file into `molecule` with ob.OBConversion()
molecule2D = ob.OBMol(molecule)
gen2D = ob.OBOp.FindType("gen2D")
if not gen2D: raise NameError("name 'gen2D' is not defined")
gen2D.Do(molecule2D)
assert(not molecule2D.Has3D())
assert(molecule.NumAtoms() == molecule2D.NumAtoms())
This is copy-edited-pasted from my code [2], I hope I did not forget anything
crucial and that it helps...
[1] Helson Rev. Comput. Chem. 1999 pp. 313-398
[2] http://vibeplot.sf.net
Best regards
Mathias Laurin
On 26 Sep 2014, at 14:53, Lee-Ping Wang <leep...@stanford.edu> wrote:
> Hi everyone,
>
> Thanks for the suggestions – I realize that by starting with the SMILES
> string and not the 3D structure I might have caused some confusion.
>
> My main goal is actually to draw the 2D representation from the 3D structure,
> attached again here (I’m a quantum chemist); the SMILES string is derived
> from the 3D structure and I think it’s correct, though I could be wrong about
> that.
>
> This is a more general problem – often I want to draw carbenes, radicals, and
> isolated atoms from the 3D structure where the hydrogens are there (though
> the octet rule may not be satisfied) – thus I don’t want the program to
> interpret the molecules chemically and fill in hydrogens that it thinks is
> missing. I don’t think the OBMol object is adding any extra atoms because it
> corresponds to the 3D structure, but when I draw the SVG the extra hydrogens
> show up.
>
> Note that the added unnumbered hydrogens appear as “CH” rather than “C-H”, so
> they are different from the hydrogens that I explicitly added when creating
> the OBMol object from the 3D structure.
>
> Noel: I do want explicit hydrogens to be displayed, but only the hydrogens
> that I explicitly have. I don’t want carbon monoxide to be shown as O#CH
> since my starting point is the CO in the 3D structure.
>
> If you could point me to the correct file, I could write the code myself.
> I’m a bit new to the code base so I might have some questions along the way.
>
> Thanks,
>
> - Lee-Ping
>
> From: Pascal Muller [mailto:pascal.jm.mul...@gmail.com]
> Sent: Friday, September 26, 2014 3:03 AM
> Cc: openbabel-discuss@lists.sourceforge.net
> Subject: Re: [Open Babel] SVG draws unwanted extra hydrogens
>
> Hi,
>
>
> For carbon monoxyde, try this smile: [C-]#[O+]
>
> Regards,
> Pascal
>
>
> <coords.xyz><can.svg>------------------------------------------------------------------------------
> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk_______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss