I'll admit that using StringIO here feels more pythonic, although SetData can 
be reused without a reconstructing the class.

I suppose I would prefer having something like

MolToSDDataBlock

Which can be used in conjunction with MolToMolBlock.  I have often found that 
many times data changes without molecule change so perhaps both could be useful.

----
Brian Kelley

> On Oct 3, 2016, at 7:08 AM, Andrew Dalke <[email protected]> wrote:
> 
>> On Oct 2, 2016, at 10:48 PM, Maciek Wójcikowski wrote:
>> Yes I get it, but obviously there is no MolFromSDBlock, so one would suspect 
>> MolFromMolBlock to support both formats. As I understand correctly the only 
>> way of reading SD from variable is as presented in my example? Or is there 
>> some marvelous undocumented API? ;)
> 
> Six years ago, Greg Landrum at 
> http://www.mail-archive.com/[email protected]/msg01436.html 
> suggested:
> 
>   nsuppl = Chem.SDMolSupplier()
>   nsuppl.SetData(mb)
>   mol = nsuppl.next()
> 
> This is simpler than passing in a StringIO().
> 
> I knew about this posting because my own code has MolFromSDBlock() wrapper 
> layer, and a comment pointing to that URL as explanation.
> 
> 
>> On Oct 2, 2016, at 11:06 PM, Brian Kelley wrote:
>> The general idea, I believe, is that if the format can result in multiple 
>> molecules a supplier should be used.
> 
> I wrote the function to make it easier to deal with web service input or 
> database records where the text contains one and only one record in SD 
> format. This is a proper subset of the SD format, which contains 0 or more 
> records.
> 
> If there are no records then my function returns a None, so I don't need to 
> deal with a StopIteration. I don't care if there is more than one record, so 
> I ignore anything past the first record.
> 
> The use case occurs pretty frequently in my work, so I figured a 
> MolFromSDBlock() for my own use was worthwhile.
> 
> Cheers,
> 
>                Andrew
>                [email protected]
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most 
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Rdkit-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to