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

IReaction org::openscience::cdk::reaction::mechanism::SharingElectronMechanism::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
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 SharingElectronMechanism.java.

References org::openscience::cdk::interfaces::IReaction::addMapping(), org::openscience::cdk::interfaces::IReaction::addProduct(), org::openscience::cdk::interfaces::IReaction::addReactant(), org::openscience::cdk::interfaces::IChemObject::clone(), org::openscience::cdk::atomtype::CDKAtomTypeMatcher::findMatchingAtomType(), org::openscience::cdk::interfaces::IAtomContainer::getAtom(), org::openscience::cdk::interfaces::IAtomContainer::getAtomNumber(), org::openscience::cdk::interfaces::IAtomContainer::getBond(), org::openscience::cdk::interfaces::IAtomContainer::getBondNumber(), org::openscience::cdk::interfaces::IAtomContainer::getConnectedLonePairsList(), org::openscience::cdk::interfaces::IAtomType::getFormalCharge(), org::openscience::cdk::tools::manipulator::BondManipulator::increaseBondOrder(), org::openscience::cdk::DefaultChemObjectBuilder::newMapping(), org::openscience::cdk::DefaultChemObjectBuilder::newReaction(), org::openscience::cdk::tools::manipulator::AtomContainerManipulator::percieveAtomTypesAndConfigureAtoms(), org::openscience::cdk::interfaces::IAtomContainer::removeLonePair(), org::openscience::cdk::interfaces::IAtomType::setFormalCharge(), and org::openscience::cdk::interfaces::IAtomType::setHybridization().

                                                                                                                                   {
            CDKAtomTypeMatcher atMatcher = CDKAtomTypeMatcher.getInstance(moleculeSet.getBuilder());
            if (moleculeSet.getMoleculeCount() != 1) {
                  throw new CDKException("SharingElectronMechanism only expects one IMolecule");
            }
            if (atomList.size() != 2) {
                  throw new CDKException("SharingElectronMechanism expects two atoms in the ArrayList");
            }
            if (bondList.size() != 1) {
                  throw new CDKException("SharingElectronMechanism 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); // Atom containing the lone pair to share
            IAtom atom1C = reactantCloned.getAtom(molecule.getAtomNumber(atom1));
            IAtom atom2 = atomList.get(1); // Atom to neutralize the deficiency of charge
            IAtom atom2C = reactantCloned.getAtom(molecule.getAtomNumber(atom2));
            IBond bond1 = bondList.get(0);
            int posBond1 = molecule.getBondNumber(bond1);

            BondManipulator.increaseBondOrder(reactantCloned.getBond(posBond1));
            
            List<ILonePair> lonePair = reactantCloned.getConnectedLonePairsList(atom1C);
            reactantCloned.removeLonePair(lonePair.get(lonePair.size() -1));
            int charge = atom1C.getFormalCharge();
            atom1C.setFormalCharge(charge+1);
            
            charge = atom2C.getFormalCharge();
            atom2C.setFormalCharge(charge-1);
      
      atom1C.setHybridization(null);
            AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactantCloned);

            IAtomType type = atMatcher.findMatchingAtomType(reactantCloned, atom1C);
            if (type == null) return null;
            
            atom2C.setHybridization(null);
            AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactantCloned);
            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);
        mapping = DefaultChemObjectBuilder.getInstance().newMapping(bond1, reactantCloned.getBond(posBond1));
      reaction.addMapping(mapping);
      reaction.addProduct(reactantCloned);
            
            return reaction;
      }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index