Hi Gilleain,

Although I don't see why they should be
used for IO-options, there is another possibility.

Not specifically it was more in this case the 'name' was adding extra to the smiles. Something to think about though is that it is possible to replace every conditional statement with polymorphism. Of course this is ridiculous and you'd never do all of them but on inner loops (specifically those which can't be branch predicted) it can be beneficial.

It seems like this should be quite a good fit with decorators, so that
you would do:

SMILESWriter writer = new SMILESWriter(new SignatureWriter(molecule));

I was thinking kind of the same but that the canonical labelling is a separate function in it's own right. 
I think what you're saying is to have a layering of the labelling schemes? 

Also the nesting isn't bad, much easier to test and add functionality too. It should be easy to use in the API though, as an example the back end of the hash looks something like this:

new PerturbedAtomHashGenerator(new SeedGenerator(
ATOMIC_NUMBER, // also classes, but as an enum
MASS_NUMBER,
FORMAL_CHARGE,
ORBITAL_HYBRIDIZATION,
FREE_RADICALS
),
new Xorshift(),
new ConjugatedStereoEncoder(
new GeometricTetrahedralEncoderFactory(),
new GeometricDoubleBondEncoderFactory(),
new GeometricCumuleneEncoderFactory()),
new MinimumEquivalentCyclicSet(),
depth);


whilst the front end looks like this:

new HashGeneratorMaker().depth(8)
.elemental()
.isotopic()
.charged()
.orbitals()
.radicals()
.chiral()
.perturbed()
.molecular();


J

On 29 Apr 2013, at 17:54, gilleain torrance <gilleain.torrance@gmail.com> wrote:

Hi,

The suggestion on CDK-user by John May that SMILESWriter should use
decorators got me thinking. Although I don't see why they should be
used for IO-options, there is another possibility.

Noel's post on Universal smiles
(http://baoilleach.blogspot.co.uk/2013/04/talk-on-universal-smiles-at-new-orleans.html)
reminded me of some code to do with using smiles with signature
numbering (or v.v.) or in general combining canonical numbering
schemes with output formats.

It seems like this should be quite a good fit with decorators, so that
you would do:

SMILESWriter writer = new SMILESWriter(new SignatureWriter(molecule));

where the inner writer provides a numbering, and the outer one a
format. Of course, that would allow ridiculous levels of nesting, but
you can do the same with BufferedReader(BufferedReader(...)) if you're
not careful.

Just a thought, anyway.

gilleain

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Cdk-devel mailing list
Cdk-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-devel