conversion AddOption doesn't work

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

conversion AddOption doesn't work

xh s
Hi, 

I'd like to output my molecules to svg with some options (e.g. implicit hydrogen). Here's a minimal example code: 

#include <openbabel/obconversion.h>
#include <openbabel/mol.h>
#include <iostream>
using namespace std;
using namespace OpenBabel;

int main() {
  stringstream inputSmiles("CCC(CC)C");
  ofstream pic("minimal_conversion_pic.svg");
  OBConversion conv(&inputSmiles, &pic);
  conv.SetInAndOutFormats("can", "svg");
  OBMol mol;
  conv.Read(&mol);
  mol.AddHydrogens();
  conv.AddOption("C",OBConversion::OUTOPTIONS);
  conv.Write(&mol);
}


I believe "C" is an option to turn off explicit hydrogen in svg drawing. However this program still prints hydrogens. I tried other options too but none of them worked. Am I using AddOption wrong? 

Thank you,
Xianghai

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: conversion AddOption doesn't work

Fredrik Wallner
Hi,

I believe you are using AddOption correct, but not the correct option. Option “C” does not turn off explicit hydrogens it turns off terminal C with hydrogens (i.e. CH3 groups). If your molecule has explicit hydrogens, you should remove them before creating the SVG (or in your example code, don’t add them…)

Kind regards,
Fredrik

On 5 maj 2017 19:46 +0200, xh s <[hidden email]>, wrote:
Hi, 

I'd like to output my molecules to svg with some options (e.g. implicit hydrogen). Here's a minimal example code: 

#include <openbabel/obconversion.h>
#include <openbabel/mol.h>
#include <iostream>
using namespace std;
using namespace OpenBabel;

int main() {
  stringstream inputSmiles("CCC(CC)C");
  ofstream pic("minimal_conversion_pic.svg");
  OBConversion conv(&inputSmiles, &pic);
  conv.SetInAndOutFormats("can", "svg");
  OBMol mol;
  conv.Read(&mol);
  mol.AddHydrogens();
  conv.AddOption("C",OBConversion::OUTOPTIONS);
  conv.Write(&mol);
}


I believe "C" is an option to turn off explicit hydrogen in svg drawing. However this program still prints hydrogens. I tried other options too but none of them worked. Am I using AddOption wrong? 

Thank you,
Xianghai
------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: conversion AddOption doesn't work

Fredrik Wallner
I would make a copy of it myself, but deleting/adding should also work.

(It’s always good to keep the list cc:ed on replies to maximize the likelihood of a reply)

Kind regards,
Fredrik

On 6 maj 2017 00:53 +0200, xh s <[hidden email]>, wrote:
Thanks for the reply! 

So if I still want the hydrogens in my molecule in the long run, I should delete them before creating the SVG and then add them back? 

Xianghai

On Fri, May 5, 2017 at 3:05 PM, Fredrik Wallner <[hidden email]> wrote:
Hi,

I believe you are using AddOption correct, but not the correct option. Option “C” does not turn off explicit hydrogens it turns off terminal C with hydrogens (i.e. CH3 groups). If your molecule has explicit hydrogens, you should remove them before creating the SVG (or in your example code, don’t add them…)

Kind regards,
Fredrik

On 5 maj 2017 19:46 +0200, xh s <[hidden email]>, wrote:
Hi, 

I'd like to output my molecules to svg with some options (e.g. implicit hydrogen). Here's a minimal example code: 

#include <openbabel/obconversion.h>
#include <openbabel/mol.h>
#include <iostream>
using namespace std;
using namespace OpenBabel;

int main() {
  stringstream inputSmiles("CCC(CC)C");
  ofstream pic("minimal_conversion_pic.svg");
  OBConversion conv(&inputSmiles, &pic);
  conv.SetInAndOutFormats("can", "svg");
  OBMol mol;
  conv.Read(&mol);
  mol.AddHydrogens();
  conv.AddOption("C",OBConversion::OUTOPTIONS);
  conv.Write(&mol);
}


I believe "C" is an option to turn off explicit hydrogen in svg drawing. However this program still prints hydrogens. I tried other options too but none of them worked. Am I using AddOption wrong? 

Thank you,
Xianghai
------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: conversion AddOption doesn't work

DavidCyryl
This post has NOT been accepted by the mailing list yet.
In reply to this post by xh s
Thanks for your code ... These codes are very helpful for me in future because i am IT expert ... Dissertation Proposal Writing Services