Search in sources :

Example 1 with ICiteable

use of ambit2.base.interfaces.ICiteable in project ambit-mirror by ideaconsult.

the class RawIteratingFolderReader method getItemReader.

protected IRawReader<IStructureRecord> getItemReader(int index) throws Exception {
    String name = files[index].getName().toLowerCase();
    if (name.endsWith(FileInputState._FILE_TYPE.SDF_INDEX.getExtension())) {
        RawIteratingSDFReader r = new RawIteratingSDFReader(new FileReader(files[index]));
        r.setReference(LiteratureEntry.getInstance(files[index].getName(), "file:///" + files[index].getAbsolutePath()));
        return (IRawReader<IStructureRecord>) r;
    } else if (name.endsWith(FileInputState._FILE_TYPE.MOL_INDEX.getExtension())) {
        RawIteratingMOLReader r = new RawIteratingMOLReader(new FileReader(files[index]));
        r.setReference(LiteratureEntry.getInstance(files[index].getName(), "file:///" + files[index].getAbsolutePath()));
        return (IRawReader<IStructureRecord>) r;
    } else if (name.endsWith(FileInputState._FILE_TYPE.I5D_INDEX.getExtension())) {
        IIteratingChemObjectReader r = FileInputState.getI5DReader(files[index]);
        if (r instanceof ICiteable) {
            ((ICiteable) r).setReference(LiteratureEntry.getI5UUIDReference());
        }
        return (IRawReader<IStructureRecord>) r;
    } else if (name.endsWith(FileInputState._FILE_TYPE.ZIP_INDEX.getExtension())) {
        return new ZipReader(files[index]);
    } else if (name.endsWith(FileInputState._FILE_TYPE.GZ_INDEX.getExtension())) {
        // assuming gzipped sdf only...
        InputStreamReader reader = new InputStreamReader(new GZIPInputStream(new FileInputStream(files[index])));
        return new RawIteratingSDFReader(reader);
    } else
        throw new Exception("Unsupported format " + name);
}
Also used : InputStreamReader(java.io.InputStreamReader) IIteratingChemObjectReader(org.openscience.cdk.io.iterator.IIteratingChemObjectReader) FileInputStream(java.io.FileInputStream) GZIPInputStream(java.util.zip.GZIPInputStream) IStructureRecord(ambit2.base.interfaces.IStructureRecord) ICiteable(ambit2.base.interfaces.ICiteable) FileReader(java.io.FileReader)

Aggregations

ICiteable (ambit2.base.interfaces.ICiteable)1 IStructureRecord (ambit2.base.interfaces.IStructureRecord)1 FileInputStream (java.io.FileInputStream)1 FileReader (java.io.FileReader)1 InputStreamReader (java.io.InputStreamReader)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 IIteratingChemObjectReader (org.openscience.cdk.io.iterator.IIteratingChemObjectReader)1