Logo Search packages:      
Sourcecode: cdk version File versions  Download package

IReaction org::openscience::cdk::reaction::mechanism::HomolyticCleavageMechanism::initiate ( IMoleculeSet  moleculeSet,
ArrayList< IAtom atomList,
ArrayList< IBond bondList 
) throws CDKException [inline]

Initiates the process for the given mechanism. The atoms to apply are mapped between reactants and products.

Parameters:
moleculeSetThe IMolecule to apply the mechanism
atomListThe list of atoms taking part in the mechanism. Only allowed two atoms. Both atoms acquire a ISingleElectron
bondListThe list of bonds taking part in the mechanism. Only allowed one bond
Returns:
The Reaction mechanism

Implements org::openscience::cdk::reaction::IReactionMechanism.

Definition at line 68 of file HomolyticCleavageMechanism.java.

References org::openscience::cdk::interfaces::IReaction::addMapping(), org::openscience::cdk::interfaces::IReaction::addProduct(), org::openscience::cdk::interfaces::IReaction::addReactant(), org::openscience::cdk::interfaces::IAtomContainer::addSingleElectron(), org::openscience::cdk::interfaces::IChemObject::clone(), org::openscience::cdk::tools::manipulator::BondManipulator::decreaseBondOrder(), org::openscience::cdk::atomtype::CDKAtomTypeMatcher::findMatchingAtomType(), org::openscience::cdk::interfaces::IAtomContainer::getAtom(), org::openscience::cdk::interfaces::IAtomContainerSet::getAtomContainerCount(), org::openscience::cdk::interfaces::IAtomContainer::getAtomNumber(), org::openscience::cdk::interfaces::IAtomContainer::getBond(), org::openscience::cdk::interfaces::IAtomContainer::getBondNumber(), org::openscience::cdk::interfaces::IMoleculeSet::getMolecule(), org::openscience::cdk::interfaces::IBond::getOrder(), org::openscience::cdk::DefaultChemObjectBuilder::newMapping(), org::openscience::cdk::DefaultChemObjectBuilder::newReaction(), org::openscience::cdk::graph::ConnectivityChecker::partitionIntoMolecules(), org::openscience::cdk::tools::manipulator::AtomContainerManipulator::percieveAtomTypesAndConfigureAtoms(), org::openscience::cdk::interfaces::IAtomContainer::removeBond(), and org::openscience::cdk::interfaces::IAtomType::setHybridization().

                                                                                                                                   {
            CDKAtomTypeMatcher atMatcher = CDKAtomTypeMatcher.getInstance(moleculeSet.getBuilder());
            if (moleculeSet.getMoleculeCount() != 1) {
                  throw new CDKException("TautomerizationMechanism only expects one IMolecule");
            }
            if (atomList.size() != 2) {
                  throw new CDKException("HomolyticCleavageMechanism expects two atoms in the ArrayList");
            }
            if (bondList.size() != 1) {
                  throw new CDKException("HomolyticCleavageMechanism only expect one bond in the ArrayList");
            }
            IMolecule molecule = moleculeSet.getMolecule(0);
            IMolecule reactantCloned;
            try {
                  reactantCloned = (IMolecule) molecule.clone();
            } catch (CloneNotSupportedException e) {
                  throw new CDKException("Could not clone IMolecule!", e);
            }
            IAtom atom1 = atomList.get(0);
            IAtom atom1C = reactantCloned.getAtom(molecule.getAtomNumber(atom1));
            IAtom atom2 = atomList.get(1);
            IAtom atom2C = reactantCloned.getAtom(molecule.getAtomNumber(atom2));
            IBond bond1 = bondList.get(0);
            int posBond1 = molecule.getBondNumber(bond1);

            if(bond1.getOrder() == IBond.Order.SINGLE)
                  reactantCloned.removeBond(reactantCloned.getBond(posBond1));    
            else
            BondManipulator.decreaseBondOrder(reactantCloned.getBond(posBond1));

            reactantCloned.addSingleElectron(new SingleElectron(atom1C));
            reactantCloned.addSingleElectron(new SingleElectron(atom2C));
            AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactantCloned);
            
        // check if resulting atom type is reasonable
            atom1C.setHybridization(null);
            IAtomType type = atMatcher.findMatchingAtomType(reactantCloned, atom1C);
            if (type == null) return null;
            
        // check if resulting atom type is reasonable: an acceptor atom cannot be charged positive*/
            atom2C.setHybridization(null);
            type = atMatcher.findMatchingAtomType(reactantCloned, atom2C);
            if (type == null) return null;
            
            IReaction reaction = DefaultChemObjectBuilder.getInstance().newReaction();
            reaction.addReactant(molecule);
            
            /* mapping */
            IMapping mapping = DefaultChemObjectBuilder.getInstance().newMapping(atom1, atom1C);
        reaction.addMapping(mapping);
        mapping = DefaultChemObjectBuilder.getInstance().newMapping(atom2, atom2C);
        reaction.addMapping(mapping);
        if(bond1.getOrder() != IBond.Order.SINGLE) {
            mapping = DefaultChemObjectBuilder.getInstance().newMapping(bond1, reactantCloned.getBond(posBond1));
            reaction.addMapping(mapping);
            reaction.addProduct(reactantCloned);
        } else{
              IMoleculeSet moleculeSetP = ConnectivityChecker.partitionIntoMolecules(reactantCloned);
                  for(int z = 0; z < moleculeSetP.getAtomContainerCount() ; z++){
                        reaction.addProduct(moleculeSetP.getMolecule(z));
                  }
        }
            
            return reaction;
      }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index