Dear Greg,

Can you please show how to extract text from stringstream (which in your
case actually ostream) into string?
ROMol *mol;
mol = SmilesToMol(strSmile);
ostream *ss = new stringstream();
SDWriter *writer = new SDWriter(ss, false);
writer->write(*mol);

string strMolStructure;
//Now we want to put MDLMol into the string. For stringstream ss->str() will
do the job but ss is ostream....)

Regards,
Evgueni


-----Original Message-----
From: [email protected] [mailto:
[email protected]] On Behalf Of Greg Landrum
Sent: 05 August 2008 19:07
To: Igor Filippov [Contr]
Cc: [email protected]
Subject: Re: [Rdkit-discuss] SD File output


Dear Igor,

This is a good one for the mailing list, so I'm cross-posting my reply.

On Tue, Aug 5, 2008 at 6:47 PM, Igor Filippov [Contr] <[email protected]>
wrote:
>
> Is there any way to convert a mol object into an SD file (i.e. CTAB
> plus user-defined properties) and have the result in a string?
> MolToMolBlock() only outputs CTAB portion without the properties.

Indeed there is. You can construct an SDWriter (defined in
$RDBASE/GraphMol/FileParsers/MolWriters.h) using a pointer to a
stringstream, then use the SDWriter's write() method. It's probably safest
to call the flush() method before reading your text out of the stringstream.

An example for using this with a SmilesWriter is in the function
testSmilesWriter2() in testMolWriter.cpp. Using an SDWriter is exactly
equivalent.

-greg

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes Grand prize is a trip for two to an Open Source event anywhere in the
world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to