use of org.openscience.cdk.io.ReaderFactory in project ambit-mirror by ideaconsult.
the class CdkJmolAdapter method openBufferedReader.
/* **************************************************************
* the file related methods
* **************************************************************/
public Object openBufferedReader(String name, BufferedReader bufferedReader) {
IChemFile chemFile = null;
try {
ISimpleChemObjectReader chemObjectReader = null;
try {
chemObjectReader = new ReaderFactory().createReader(bufferedReader);
} catch (IOException ex) {
return "Jmol: Error determining input format: " + ex;
}
if (chemObjectReader == null) {
return "Jmol: unrecognized input format";
}
chemFile = (IChemFile) chemObjectReader.read(new org.openscience.cdk.ChemFile());
} catch (CDKException ex) {
return "Error reading input:" + ex;
}
if (chemFile == null)
return "unknown error reading file";
try {
AtomTypeFactory factory = AtomTypeFactory.getInstance("pdb_atomtypes.txt", chemFile.getBuilder());
// IAtomContainer atomContainer = (IAtomContainer)ChemFileManipulator.getAllInOneContainer(chemFile);
Iterator<IChemSequence> seq = chemFile.chemSequences().iterator();
while (seq.hasNext()) {
Iterator<IChemModel> model = seq.next().chemModels().iterator();
while (model.hasNext()) {
Iterator<IAtomContainer> c = model.next().getMoleculeSet().atomContainers().iterator();
while (c.hasNext()) {
Iterator<IAtom> it = c.next().atoms().iterator();
while (it.hasNext()) {
IAtom atom = it.next();
try {
factory.configure(atom);
} catch (CDKException exception) {
bcLogger.severe("Could not configure atom: " + atom);
bcLogger.log(Level.SEVERE, " because: " + exception.getMessage(), exception);
}
}
}
}
}
return chemFile;
} catch (Exception x) {
return "Error configuring atoms input:" + x;
}
}
use of org.openscience.cdk.io.ReaderFactory in project cdk by cdk.
the class ProteinPocketFinder method readBioPolymer.
/**
* Creates from a PDB File a BioPolymer.
*/
private void readBioPolymer(String biopolymerFile) {
// Read PDB file
try (FileReader fileReader = new FileReader(biopolymerFile);
ISimpleChemObjectReader reader = new ReaderFactory().createReader(fileReader)) {
IChemFile chemFile = (IChemFile) reader.read((IChemObject) new ChemFile());
// Get molecule from ChemFile
IChemSequence chemSequence = chemFile.getChemSequence(0);
IChemModel chemModel = chemSequence.getChemModel(0);
IAtomContainerSet setOfMolecules = chemModel.getMoleculeSet();
protein = (IBioPolymer) setOfMolecules.getAtomContainer(0);
} catch (IOException | CDKException exc) {
logger.error("Could not read BioPolymer from file>" + biopolymerFile + " due to: " + exc.getMessage());
logger.debug(exc);
}
}
Aggregations