Hi Matthew,

In latest version of OB (master branch on github) automatically detects .gz
extensions and compresses the output - adds "-z" option to converter.
https://github.com/openbabel/openbabel/blob/master/scripts/python/pybel.py#L253
If you're using newest OB it should work out of the box. Otherwise
Stefano's solution is the one you go for.

----
Pozdrawiam,  |  Best regards,
Maciek Wójcikowski
mac...@wojcikowski.pl

2015-04-25 0:45 GMT+02:00 Matthew Lardy <mla...@gmail.com>:

> Hi Stefano,
>
> That worked!  Thanks!
> Matthew
>
> On Fri, Apr 24, 2015 at 3:34 PM, Stefano Forli <fo...@scripps.edu> wrote:
>
>> Hi Matthew,
>> I guess something like this could do the trick:
>> -------------------------
>> import gzip
>> import pybel
>>
>> mol = pybel.readfile('sdf', 'filename.sdf').next()
>> outfilename = 'example.sdf.gz'
>> output = gzip.open(outfilename, 'wb')
>> molString = mol.write(format='sdf')
>> output.write(molString)
>> output.close()
>> -------------------------
>> I didn't tested but I don't see why it shouldn't work(TM)
>>
>> S
>>
>>
>>
>> On 04/24/2015 03:12 PM, Matthew Lardy wrote:
>>
>>> Hi all,
>>>
>>> Does anyone have a route to write compressed sdf.gz files that are
>>> compatible with
>>> pybel.Outputfile?
>>>
>>> Thanks in advance!
>>> Matthew
>>>
>>
>> --
>>  Stefano Forli, PhD
>>
>>  Staff Scientist
>>  Molecular Graphics Laboratory
>>  Dept. of Integrative Structural
>>   and Computational Biology, MB-112F
>>  The Scripps Research Institute
>>  10550  North Torrey Pines Road
>>  La Jolla,  CA 92037-1000,  USA.
>>
>>     tel: +1 (858)784-2055
>>     fax: +1 (858)784-2860
>>     email: fo...@scripps.edu
>>     http://www.scripps.edu/~forli/
>>
>
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>
>
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to