On 2014-03-08 22:21, Paul van Maaren wrote:
> I had a look at it too, the following hack seems to work for all types
> of imidazolium ions.
>
> In gaussformat.cpp I moved mol.SetTotalCharge(charge) close to the
> location where the charge is extracted from the Gaussian file and in
> kekulize.cpp I added the following:
>
> diff --git a/src/kekulize.cpp b/src/kekulize.cpp
> index dedf371..e5f7841 100644
> --- a/src/kekulize.cpp
> +++ b/src/kekulize.cpp
> @@ -515,6 +515,9 @@ namespace OpenBabel
>       int idx;
>       OBAtom *atom;
>       OBBond *bond;
> +    int charge;
> +
> +    charge = _totalCharge;
>
>       // Figure out which atoms are in this ring system and whether or not 
> each
>       // atom can donate an electron.
> @@ -532,6 +535,13 @@ namespace OpenBabel
>           atomState[idx] = DOUBLE_PROHIBITED;
>           if (DEBUG) { cout << "atom " << idx << " rejected NR3 double bonds 
> " << endl; }
>         }
> +
> +      if (atom->IsNitrogen() && atom->GetFormalCharge() == 0 && 
> atom->GetValence() == 3 && charge > 0) {
> +        atomState[idx] = DOUBLE_ALLOWED;       // It has an electron it can 
> donate, because of the total charge
> +       charge--;
> +        if (DEBUG) { cout << "atom " << idx << " rejected NR3 double bonds 
> overruled by totalcharge " << endl; }
> +      }
> +
>
> And I get:
>
> babel -ig03 1-ethyl-3-methylimidazolium3-esp.log.gz -osmi
> c1n(ccn1C)CC
>

Any further insights?

Are we on the right track here or should this be handled differently?


-- 
David van der Spoel, Ph.D., Professor of Biology
Dept. of Cell & Molec. Biol., Uppsala University.
Box 596, 75124 Uppsala, Sweden. Phone:  +46184714205.
sp...@xray.bmc.uu.se    http://folding.bmc.uu.se

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
OpenBabel-Devel mailing list
OpenBabel-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-devel

Reply via email to