I think the motivation for this is that some readers will return a
single molecule or sequence of molecules (those that implement
ISimpleChemObjectReader, which is a subclass of IChemObjectReader) but
other readers such as the iterating readers return iterators, from
which a molecule is obtained.

But to be honest, I am still fuzzy on the IO architecture. For reading
in files from arbitrary formats I use the following code:

              File input = new File(filenames[i]);
                ReaderFactory readerFactory = new ReaderFactory();
                ISimpleChemObjectReader reader =
readerFactory.createReader(new FileReader(input));

                if (reader == null) { // see if it's a SMI file
                    if (filenames[i].endsWith(".smi")) {
                        reader = new SMILESReader(new FileReader(input));
                    }
                }
                IChemFile content = (IChemFile)
reader.read(builder.newChemFile());
                if (content == null) continue;

                List<IAtomContainer> c =
ChemFileManipulator.getAllAtomContainers(content);



On Thu, Jul 22, 2010 at 8:22 AM, Jules Kerssemakers
<[email protected]> wrote:
> Dear CDK-People,
>
> I'm trying to duplicate a bit of Rajarshi Guha's code to read
> compounds from any on-disk format, located here:
> http://rguha.net/code/java/#fread
> It all looks very nice and generic, but I run into trouble with this line:
>
>  IChemFile content = (IChemFile) reader.read(builder.newChemFile());
>
> This results in the error-message "The method read(IChemFile) is
> undefined for the type IChemObjectReader".
> To be more exact, the entire IChemObjectReader interface does not
> specify _any_ "read" method whatsoever (at least in cdk v1.3.5, v1.2.5
> seems to lack one either).
>
> Now I can understand that method/interface signatures change over
> time, Rajarshi even specifically warns some of his code snippets may
> be outdated, but why on earth would an interface labeled
> "...ObjectReader" NOT specify a "read" method. This is so
> counter-intuitive it makes my brain hurt..
> Of course the individual subclasses have proper read methods, but with
> the interface lacking the common method, the entire pattern of the
> ReaderFactory becomes pointless.
>
> Fortunately I know the input will be SDF format in this application,
> so I'll just use the specific reader. I'd still appreciate it if
> someone could cast some light on the disappearance of "read" from the
> interface, though.
>
> Kind regards,
> Jules Kerssemakers
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Cdk-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/cdk-user
>



-- 
Rajarshi Guha
NIH Chemical Genomics Center

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to