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

IReactionSet org::openscience::cdk::reaction::type::CleavageBondMultiReaction::initiate ( IMoleculeSet  reactants,
IMoleculeSet  agents 
) throws CDKException [inline]

Initiate process. It is needed to call the addExplicitHydrogensToSatisfyValency from the class tools.HydrogenAdder.

Parameters:
reactants reactants of the reaction.
agents agents of the reaction (Must be in this case null).
Exceptions:
CDKException Description of the Exception

Implements org::openscience::cdk::reaction::IReactionProcess.

Definition at line 140 of file CleavageBondMultiReaction.java.

References org::openscience::cdk::interfaces::IMoleculeSet::addMolecule(), org::openscience::cdk::interfaces::IReaction::addProduct(), org::openscience::cdk::interfaces::IReaction::addReactant(), org::openscience::cdk::interfaces::IReactionSet::addReaction(), org::openscience::cdk::interfaces::IAtomContainer::addSingleElectron(), cleanFlagBOND(), org::openscience::cdk::interfaces::IChemObject::clone(), org::openscience::cdk::tools::LoggingTool::debug(), existAC(), org::openscience::cdk::interfaces::IAtomContainer::getAtom(), org::openscience::cdk::interfaces::IBond::getAtom(), org::openscience::cdk::interfaces::IAtomContainerSet::getAtomContainerCount(), org::openscience::cdk::interfaces::IAtomContainer::getBond(), org::openscience::cdk::interfaces::IAtomContainer::getBondCount(), org::openscience::cdk::interfaces::IChemObject::getBuilder(), org::openscience::cdk::interfaces::IChemObject::getFlag(), org::openscience::cdk::interfaces::IAtomType::getFormalCharge(), org::openscience::cdk::interfaces::IMoleculeSet::getMolecule(), org::openscience::cdk::interfaces::IBond::getOrder(), org::openscience::cdk::interfaces::IReaction::getProductCount(), org::openscience::cdk::interfaces::IReaction::getProducts(), org::openscience::cdk::interfaces::IReactionSet::getReactionCount(), org::openscience::cdk::interfaces::IMoleculeSet::molecules(), org::openscience::cdk::interfaces::IChemObjectBuilder::newMoleculeSet(), org::openscience::cdk::interfaces::IChemObjectBuilder::newSingleElectron(), org::openscience::cdk::interfaces::IReactionSet::reactions(), org::openscience::cdk::interfaces::IAtomContainer::removeBond(), setActiveCenters(), org::openscience::cdk::interfaces::IChemObject::setFlag(), and org::openscience::cdk::interfaces::IBond::setOrder().

                                                                                                   {
            logger.debug("initiate reaction: CleavageBondMultiReaction");
            
            
            if (reactants.getMoleculeCount() != 1) {
                  throw new CDKException("CleavageBondMultiReaction only expects one reactant");
            }
            if (agents != null) {
                  throw new CDKException("CleavageBondMultiReaction don't expects agents");
            }
            
            IReactionSet setOfReactions = reactants.getBuilder().newReactionSet();
            
            IMolecule reactant = reactants.getMolecule(0);
            if(existAC(moleculeSetTOTAL,reactant))
                  return setOfReactions;
            else
                  moleculeSetTOTAL.addMolecule(reactant);
            
            /* if the parameter hasActiveCenter is not fixed yet, set the active centers*/
            if(!hasActiveCenter){
                  setActiveCenters(reactant);
            }

        Iterator bonds = reactants.getMolecule(0).bonds();
        while (bonds.hasNext()) {
            IBond aBond = (IBond) bonds.next();

                  if(aBond.getFlag(CDKConstants.REACTIVE_CENTER))
                        if(aBond.getAtom(0).getFormalCharge() == 0 && aBond.getAtom(1).getFormalCharge() == 0){
                        
                        int atom1 = reactants.getMolecule(0).getAtomNumber(aBond.getAtom(0));
                        int atom2 = reactants.getMolecule(0).getAtomNumber(aBond.getAtom(1));
                        cleanFlagBOND(reactants.getMolecule(0));
                        aBond.setFlag(BONDTOFLAG, true);
                        
                        IReaction reaction = reactants.getBuilder().newReaction();
                        reaction.addReactant(reactants.getMolecule(0));
                        
                        IMolecule reactantCloned;
                        try {
                              reactantCloned = (IMolecule) reactant.clone();
                        } catch (CloneNotSupportedException e) {
                              throw new CDKException("Could not clone IMolecule!", e);
                        }
                        
                        reactantCloned.addSingleElectron(reactant.getBuilder().newSingleElectron(reactantCloned.getAtom(atom1)));
                        reactantCloned.addSingleElectron(reactant.getBuilder().newSingleElectron(reactantCloned.getAtom(atom2)));
                        
                        double order = 0;
                        IBond bondClon = null;
                        for(int l = 0 ; l<reactantCloned.getBondCount();l++){
                              if(reactantCloned.getBond(l).getFlag(BONDTOFLAG)){
                                    IBond bondFlag = reactantCloned.getBond(l);
                                    order = bondFlag.getOrder();
                                    if(order == 1){
                                          reactantCloned.removeBond(bondFlag.getAtom(0), bondFlag.getAtom(1));
                                    }
                                    else{
                                          reactantCloned.getBond(l).setOrder(order-1);
                                          bondClon = reactantCloned.getBond(l);
                                    }
                                    break;
                              }
                        }

                        IMoleculeSet moleculeSet;
                        if(order == 1)/*break molecule*/{
                              moleculeSet = ConnectivityChecker.partitionIntoMolecules(reactantCloned);
                              int exx = 0;
                              for(int z = 0 ; z < moleculeSet.getAtomContainerCount(); z++){
                                    IMolecule ac = moleculeSet.getMolecule(z);
                                    
                                    if(!existAC(moleculeSetTOTAL,ac)){
                                          exx++;
                                          reaction.addProduct(ac);
                                    }
                              }
                              if(exx == 0)
                                    return setOfReactions;
                        }
                        else{
                              if(existAC(moleculeSetTOTAL,reactantCloned))
                                    return setOfReactions;
                              else{
                                    reaction.addProduct(reactantCloned);
                              }
                        }
                              
                        
                        /*adding only that contains product*/
                        if(reaction.getProductCount() != 0)
                              setOfReactions.addReaction(reaction);
                        

                        aBond.setFlag(BONDTOFLAG, false);
                        
                        /* fragmentation again with the obtained fragments*/
                        if(reaction.getProductCount() != 0)
                        for(Iterator iter = reaction.getProducts().molecules(); iter.hasNext();){
                              IMolecule molF = (IMolecule) iter.next();
                              if(existAC(moleculeSetTOTAL,molF))
                                    continue;
                              IMoleculeSet moleculeSetF = molF.getBuilder().newMoleculeSet();
                              moleculeSetF.addMolecule(molF);
                              IReactionSet setOfReactionsF = initiate(moleculeSetF, null);
                              if(setOfReactionsF != null)
                              if(setOfReactionsF.getReactionCount() != 0)
                                    for(Iterator iterR = setOfReactionsF.reactions(); iterR.hasNext();){
                                          setOfReactions.addReaction((IReaction) iterR.next());
                                    }
                        }
                        
                  }
                        
            }
            
            return setOfReactions;  
      }


Generated by  Doxygen 1.6.0   Back to index