On 08/08/2012 20:15, Rob Smith wrote:
> Is there a way (like obabel -L svg) to get the GENOPTIONS? I am
> struggling to get the -s "<substring> <color>" section to transfer
> programmatically.

The -s option is not part of SVGFormat and works on the internal OBMol 
object, so you can also see the color when it is output to PNG or even 
CML format. It would have an option type OBConversion::GENOPTIONS. 
Obtaining its documentation is complicated by there also being a SMARTS 
descriptor called s, but
   obabel -L ops s
will work.

I'm not familiar with ruby syntax, but the following C++ code (without 
error checking) illustrates doing a conversion with options at two 
different levels.

The first is close to the command line method.

int main(int argc,char **argv)
{
   std::ofstream ofs("out.svg");
   std::stringstream ss("CCCO");
   OBConversion conv(&ss, &ofs);
   conv.SetInAndOutFormats("smi", "svg");
   conv.AddOption("s", OBConversion::GENOPTIONS, "CO purple");
   conv.Convert();
   return 0;
}

The second is at a lower level, and it is necessary to explicitly call 
DoTransformations() to apply the GENOPTIONS.

int main(int argc,char **argv)
{
   OBConversion conv(&std::cin, &std::cout);
   conv.SetInAndOutFormats("smi", "svg");
   conv.AddOption("s", OBConversion::GENOPTIONS, "CO purple");
   OBMol mol;
   conv.ReadString(&mol,"CCCO");
   mol.DoTransformations(conv.GetOptions(OBConversion::GENOPTIONS), &conv);
   std::cout << conv.WriteString(&mol) << std::endl;
   return 0;
}

I hope this helps.

Chris

>
> I've tried a lot of variants, the current one being:
>                       self.obconv.add_option("s #{substructure}
> red",OpenBabel::OBConversion::INOPTIONS)
>
> The goal for this option is to color the substructure red.
>
> On Tue, Aug 7, 2012 at 8:12 PM, Geoff Hutchison
> <ge...@geoffhutchison.net> wrote:
>>> characters to complete the translation of the command line argument
>>> for what I am trying to do:
>>>
>>> obabel benzodiazepine.sdf.gz -O out.svg --filter "title=3016" -s
>>> "c1ccc2c(c1)C(=NCCN2)c3ccccc3 red" -xu -d
>>
>> Keep in mind that if you're doing it programmatically, you don't use the 'x' 
>> part of the flag. So that '-xu' is just "u" for your OUTOPTIONS ruby script.
>>
>> Hope that helps,
>> -Geoff
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to