Hi
SmilesParser.parseSmiles(String smiles) method gets stuck on a smile
string for a unusually long period of time and finally throws a
SmilesParseException. The smiles string I used was
c1ccc2c3nc(nc4[nH]c(nc5nc(nc6[nH]c(n3)c7ccccc67)c8ccccc58)c9ccccc49)c2c1o
, do you already have a bug number for this or can I report this as a bug.
The work around I used was to call the above method in a different
Thread and join that
Thread with a time out. Here is my code
public final int SMILES_PARSE_TIMEOUT = 100000;
IMolecule parseSmiles(final String smiles) throws ChemistryException
{
final List output = new ArrayList(1);
Thread t = new Thread()
{
public void run()
{
try
{
output.add(parser.parseSmiles(smiles));
}
catch (Exception e)
{
output.add( e );
}
}
};
t.start();
try
{
t.join(SMILES_PARSE_TIMEOUT);
}
catch (InterruptedException e)
{
//ignore
}
if ( output.size() == 0 )
{
throw new ChemistryException("timed out parsing smiles
string "+smiles);
}
else if ( output.get( 0 ) instanceof Exception)
{
throw new ChemistryException( (Exception)output.get(0) );
}
else
{
assert ( output.get( 0 ) instanceof IMolecule);
return (IMolecule)output.get( 0 );
}
}
Thanks
Wiraj Bibile
Software Engineer
-------------------------------------------------------------------------
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=/
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user