use of org.openscience.cdk.interfaces.IAtomContainerSet in project ambit-mirror by ideaconsult.
the class DelimitedFileReader method readSetOfMolecules.
private IAtomContainerSet readSetOfMolecules() {
try {
IAtomContainerSet som = new AtomContainerSet();
IteratingDelimitedFileReader reader = new IteratingDelimitedFileReader(input, format);
while (reader.hasNext()) {
Object object = reader.next();
if (object instanceof IAtomContainer)
som.addAtomContainer((IAtomContainer) object);
}
reader.close();
return som;
} catch (Exception x) {
logger.error(x);
return null;
}
}
use of org.openscience.cdk.interfaces.IAtomContainerSet in project ambit-mirror by ideaconsult.
the class MDLReader method readChemModel.
private IChemModel readChemModel(IChemModel chemModel) throws CDKException {
IAtomContainerSet setOfMolecules = chemModel.getMoleculeSet();
if (setOfMolecules == null) {
setOfMolecules = MoleculeTools.newMoleculeSet(chemModel.getBuilder());
}
IAtomContainer m = readMolecule(MoleculeTools.newMolecule(chemModel.getBuilder()));
if (m != null) {
setOfMolecules.addAtomContainer(m);
}
chemModel.setMoleculeSet(setOfMolecules);
return chemModel;
}
use of org.openscience.cdk.interfaces.IAtomContainerSet in project ambit-mirror by ideaconsult.
the class JChemPaintDialog method okAction.
public IAtomContainer okAction() {
result = JOptionPane.OK_OPTION;
setVisible(false);
IAtomContainer updatedMolecule = new AtomContainer();
IAtomContainerSet m = jcpep.getChemModel().getMoleculeSet();
for (int i = 0; i < m.getAtomContainerCount(); i++) updatedMolecule.add(m.getAtomContainer(i));
/*
* TODO MoleculeSetManipulator.getAllInOneContainer(
* jcpep.getJChemPaintModel().getChemModel().getMoleculeSet());
*/
SmilesGenerator g = SmilesGenerator.generic();
try {
updatedMolecule.setProperty("SMILES", g.create(updatedMolecule));
} catch (Exception x) {
x.printStackTrace();
}
return updatedMolecule;
}
use of org.openscience.cdk.interfaces.IAtomContainerSet in project ambit-mirror by ideaconsult.
the class MoleculeEditAction method getMoleculeForEdit.
protected IAtomContainerSet getMoleculeForEdit(IAtomContainer atomContainer) throws Exception {
if (atomContainer == null)
return null;
if (atomContainer instanceof QueryAtomContainer) {
return null;
}
IAtomContainerSet molecules = ConnectivityChecker.partitionIntoMolecules(atomContainer);
IAtomContainerSet m = new AtomContainerSet();
for (int i = 0; i < molecules.getAtomContainerCount(); i++) {
IAtomContainer a = molecules.getAtomContainer(i);
if (!GeometryTools.has2DCoordinates(a)) {
if (sdg == null)
sdg = new StructureDiagramGenerator();
sdg.setMolecule((IAtomContainer) a);
sdg.generateCoordinates(new Vector2d(0, 1));
molecules.replaceAtomContainer(i, sdg.getMolecule());
}
m.addAtomContainer(molecules.getAtomContainer(i));
}
if (// otherwise JChemPaint crashes
m.getAtomContainerCount() == 0)
m.addAtomContainer(MoleculeTools.newMolecule(DefaultChemObjectBuilder.getInstance()));
return m;
}
use of org.openscience.cdk.interfaces.IAtomContainerSet in project ambit-mirror by ideaconsult.
the class AmbitSmirksCli method applyReaction.
void applyReaction(SMIRKSReaction reaction, IAtomContainer target) throws Exception {
smrkMan.setFlagSSMode(FlagSSMode);
smrkMan.setFlagProcessResultStructures(FlagProductPreprocessing);
smrkMan.setFlagClearHybridizationBeforeResultProcess(FlagClearHybridizationOnProductPreProcess);
smrkMan.setFlagClearImplicitHAtomsBeforeResultProcess(FlagClearImplicitHAtomsBeforeProductPreProcess);
smrkMan.setFlagClearAromaticityBeforeResultProcess(FlagClearAromaticityBeforePreProcess);
smrkMan.setFlagAddImplicitHAtomsOnResultProcess(FlagAddImplicitHAtomsOnProductPreProcess);
smrkMan.setFlagConvertAddedImplicitHToExplicitOnResultProcess(FlagImplicitHToExplicitOnProductPreProcess);
smrkMan.setFlagConvertExplicitHToImplicitOnResultProcess(FlagExplicitHToImplicitOnProductPreProcess);
smrkMan.setFlagApplyStereoTransformation(FlagApplyStereoTransformation);
smrkMan.setFlagHAtomsTransformation(FlagHAtomsTransformation);
smrkMan.setFlagHAtomsTransformationMode(FlagHAtomsTransformationMode);
smrkMan.setFlagAromaticityTransformation(FlagAromaticityTransformation);
if (FlagPrintAtomAttributes) {
System.out.println("Target (reactant):");
System.out.println("Reactant atom attributes:\n" + SmartsHelper.getAtomsAttributes(target));
System.out.println("Reactant bond attributes:\n" + SmartsHelper.getBondAttributes(target));
}
System.out.println(" " + SmartsHelper.moleculeToSMILES(target, true));
switch(FlagReactionApplication) {
case Target:
boolean res = smrkMan.applyTransformation(target, reaction);
String transformedSmiles = SmartsHelper.moleculeToSMILES(target, true);
if (res) {
System.out.println("Reaction application: " + inputArg + " --> " + transformedSmiles + " abs. smiles res " + SmilesGenerator.absolute().create(target));
} else
System.out.println("Reaction not appicable!");
break;
case CombinedOverlappedPos:
IAtomContainerSet resSet = smrkMan.applyTransformationWithCombinedOverlappedPos(target, null, reaction);
if (resSet == null)
System.out.println("Reaction not appicable!");
else {
System.out.println("Reaction application With Combined Overlapped Positions: ");
for (int i = 0; i < resSet.getAtomContainerCount(); i++) System.out.println(SmartsHelper.moleculeToSMILES(resSet.getAtomContainer(i), true));
}
break;
case SingleCopyForEachPos:
IAtomContainerSet resSet2 = smrkMan.applyTransformationWithSingleCopyForEachPos(target, null, reaction, FlagSSMode);
if (resSet2 == null)
System.out.println("Reaction not appicable!");
else {
System.out.println("Reaction application With Single Copy For Each Position: ");
for (int i = 0; i < resSet2.getAtomContainerCount(); i++) System.out.println(SmartsHelper.moleculeToSMILES(resSet2.getAtomContainer(i), true));
}
break;
}
System.out.println();
}
Aggregations