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);
}
Aggregations