Search in sources :

Example 6 with IAtomContainerSet

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;
    }
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IChemObject(org.openscience.cdk.interfaces.IChemObject) AtomContainerSet(org.openscience.cdk.silent.AtomContainerSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) CDKException(org.openscience.cdk.exception.CDKException) IOException(java.io.IOException)

Example 7 with IAtomContainerSet

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;
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet)

Example 8 with IAtomContainerSet

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;
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.silent.AtomContainer) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) SmilesGenerator(org.openscience.cdk.smiles.SmilesGenerator) HeadlessException(java.awt.HeadlessException)

Example 9 with IAtomContainerSet

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;
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) Vector2d(javax.vecmath.Vector2d) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) QueryAtomContainer(org.openscience.cdk.isomorphism.matchers.QueryAtomContainer) AtomContainerSet(org.openscience.cdk.silent.AtomContainerSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) StructureDiagramGenerator(org.openscience.cdk.layout.StructureDiagramGenerator)

Example 10 with IAtomContainerSet

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();
}
Also used : IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet)

Aggregations

IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)596 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)535 Test (org.junit.Test)327 IAtom (org.openscience.cdk.interfaces.IAtom)284 ArrayList (java.util.ArrayList)223 IReactionSet (org.openscience.cdk.interfaces.IReactionSet)217 IParameterReact (org.openscience.cdk.reaction.type.parameters.IParameterReact)192 IReactionProcess (org.openscience.cdk.reaction.IReactionProcess)166 SetReactionCenter (org.openscience.cdk.reaction.type.parameters.SetReactionCenter)160 ReactionProcessTest (org.openscience.cdk.reaction.ReactionProcessTest)158 CDKException (org.openscience.cdk.exception.CDKException)129 IBond (org.openscience.cdk.interfaces.IBond)57 IReaction (org.openscience.cdk.interfaces.IReaction)56 IChemModel (org.openscience.cdk.interfaces.IChemModel)52 IQueryAtomContainer (org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer)45 InputStream (java.io.InputStream)41 UniversalIsomorphismTester (org.openscience.cdk.isomorphism.UniversalIsomorphismTester)35 QueryAtomContainer (org.openscience.cdk.isomorphism.matchers.QueryAtomContainer)35 IChemSequence (org.openscience.cdk.interfaces.IChemSequence)34 ChemFile (org.openscience.cdk.ChemFile)31