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

IReaction org::openscience::cdk::reaction::mechanism::RemovingSEofNBMechanism::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 one atom
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 67 of file RemovingSEofNBMechanism.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::atomtype::CDKAtomTypeMatcher::findMatchingAtomType(), org::openscience::cdk::interfaces::IAtomContainer::getAtom(), org::openscience::cdk::interfaces::IAtomContainer::getAtomNumber(), org::openscience::cdk::interfaces::IAtomContainer::getConnectedLonePairsList(), org::openscience::cdk::interfaces::IAtomType::getFormalCharge(), 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("RemovingSEofNBMechanism only expects one IMolecule");
            }
            if (atomList.size() != 1) {
                  throw new CDKException("RemovingSEofNBMechanism only expects one atom in the ArrayList");
            }
            if (bondList != null) {
                  throw new CDKException("RemovingSEofNBMechanism don't expect any 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);
            }
            
            // remove one lone pair electron and substitute with one single electron and charge 1.
            int posAtom = molecule.getAtomNumber(atomList.get(0));
            List<ILonePair> lps = reactantCloned.getConnectedLonePairsList(reactantCloned.getAtom(posAtom));
            reactantCloned.removeLonePair(lps.get(lps.size() - 1));

            reactantCloned.addSingleElectron(new SingleElectron(reactantCloned.getAtom(posAtom)));
            int charge = reactantCloned.getAtom(posAtom).getFormalCharge();
            reactantCloned.getAtom(posAtom).setFormalCharge(charge+1);

            // check if resulting atom type is reasonable
            reactantCloned.getAtom(posAtom).setHybridization(null);
            AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactantCloned);
            IAtomType type = atMatcher.findMatchingAtomType(reactantCloned, reactantCloned.getAtom(posAtom));
            if (type == null)
                  return null;
            
            IReaction reaction = DefaultChemObjectBuilder.getInstance().newReaction();
            reaction.addReactant(molecule);
            
            /* mapping */
            IMapping mapping = DefaultChemObjectBuilder.getInstance().newMapping(atomList.get(0), reactantCloned.getAtom(posAtom));
        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