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

IReaction org::openscience::cdk::reaction::mechanism::RemovingSEofBMechanism::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. The first atom receives the charge and the second the single electron
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 69 of file RemovingSEofBMechanism.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::IAtomType::getFormalCharge(), 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(), org::openscience::cdk::interfaces::IAtomType::setFormalCharge(), and org::openscience::cdk::interfaces::IAtomType::setHybridization().

                                                                                                                                   {
            CDKAtomTypeMatcher atMatcher = CDKAtomTypeMatcher.getInstance(moleculeSet.getBuilder(), CDKAtomTypeMatcher.REQUIRE_EXPLICIT_HYDROGENS);
            if (moleculeSet.getMoleculeCount() != 1) {
                  throw new CDKException("RemovingSEofBMechanism only expects one IMolecule");
            }
            if (atomList.size() != 2) {
                  throw new CDKException("RemovingSEofBMechanism expects two atoms in the ArrayList");
            }
            if (bondList.size() != 1) {
                  throw new CDKException("RemovingSEofBMechanism only expects 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));
            
            int charge = atom1C.getFormalCharge();
            atom1C.setFormalCharge(charge+1);
            reactantCloned.addSingleElectron(new SingleElectron(atom2C));

            // check if resulting atom type is reasonable
            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);
        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