This begs a couple of more questions...
- Are the flushes required when writing to a non compressed/zipped file?
- Should the call to the flush method be mentioned in, say,
http://www.rdkit.org/docs/api/rdkit.Chem.rdmolfiles.SDWriter-class.html
- Is it sensible to have a .close() method in SDWriter which does both for
you?
- Does the
http://www.rdkit.org/Python_Docs/rdkit.Chem.rdmolfiles.SDMolSupplier-class.html
page
need a gzip example like the writer one?
-
Jean-Paul Ebejer
Early Stage Researcher
On 26 January 2012 10:00, Greg Landrum <[email protected]> wrote:
> Dear Jean-Paul,
>
> On Thu, Jan 26, 2012 at 4:30 AM, JP <[email protected]> wrote:
> >
> > Good morning, I know that now we can use GZ file directly in MolSuppliers
> > (with the code in trunk), but can we use zipped/compressed files when
> > writing too?
>
> One minor clarification before I answer your question: the capability
> to deal with GZ files in SDMolSuppliers and SDWriters is also in the
> 2011_12_1 release.
>
> To answer your question, the following bit of code works:
>
> f = gzip.open('output.sdf.gz','w+')
> w = Chem.SDWriter(f)
> for m in ms: w.write(m)
> w.flush()
> f.flush()
> w=None
> f=None
>
> The bit with being required to call "flush" is ugly and possibly
> unnecessary, but it's safe (otherwise there's some risk that the file
> won't be complete). This is something that should be improved on the
> backend, but in the meantime the above steps should work.
>
> -greg
>
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss