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

DescriptorValue org::openscience::cdk::qsar::descriptors::bond::ResonancePositiveChargeDescriptor::calculate ( IBond  bond,
IAtomContainer  atomContainer 
) throws CDKException [inline]

The method returns Resonance stabilization value assigned to an heavy atom through Gasteiger Saller It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools.HydrogenAdder.

Parameters:
atomContainer AtomContainer
Returns:
Value of the Resonance stabilization of the two atoms which belong to the bond.
Exceptions:
CDKException Possible Exceptions

Implements org::openscience::cdk::qsar::IBondDescriptor.

Definition at line 137 of file ResonancePositiveChargeDescriptor.java.

References org::openscience::cdk::qsar::result::DoubleArrayResult::add(), org::openscience::cdk::interfaces::IMoleculeSet::addMolecule(), org::openscience::cdk::qsar::descriptors::atomic::BondsToAtomDescriptor::calculate(), org::openscience::cdk::qsar::descriptors::atomic::PiElectronegativityDescriptor::calculate(), cleanFlagReactiveCenter(), org::openscience::cdk::interfaces::IChemObject::clone(), org::openscience::cdk::interfaces::IAtomContainer::contains(), org::openscience::cdk::qsar::result::DoubleArrayResult::get(), org::openscience::cdk::tools::StructureResonanceGenerator::getAllStructures(), org::openscience::cdk::interfaces::IAtomContainer::getAtom(), org::openscience::cdk::interfaces::IBond::getAtom(), org::openscience::cdk::interfaces::IAtomContainerSet::getAtomContainer(), org::openscience::cdk::interfaces::IAtomContainerSet::getAtomContainerCount(), org::openscience::cdk::interfaces::IAtomContainer::getAtomCount(), org::openscience::cdk::interfaces::IAtomContainer::getAtomNumber(), org::openscience::cdk::interfaces::IAtomContainer::getBond(), org::openscience::cdk::interfaces::IAtomContainer::getBondNumber(), org::openscience::cdk::interfaces::IChemObject::getBuilder(), org::openscience::cdk::interfaces::IMapping::getChemObject(), org::openscience::cdk::interfaces::IAtomContainer::getConnectedSingleElectronsCount(), org::openscience::cdk::interfaces::IAtomType::getFormalCharge(), org::openscience::cdk::interfaces::IReaction::getMapping(), getParameterNames(), getParameters(), org::openscience::cdk::interfaces::IReaction::getProducts(), org::openscience::cdk::interfaces::IReactionSet::getReaction(), getSpecification(), org::openscience::cdk::qsar::DescriptorValue::getValue(), org::openscience::cdk::reaction::type::BreakingBondReaction::initiate(), org::openscience::cdk::interfaces::IChemObjectBuilder::newMoleculeSet(), org::openscience::cdk::interfaces::IChemObject::setFlag(), org::openscience::cdk::qsar::descriptors::atomic::BondsToAtomDescriptor::setParameters(), org::openscience::cdk::qsar::descriptors::atomic::PiElectronegativityDescriptor::setParameters(), and org::openscience::cdk::reaction::type::BreakingBondReaction::setParameters().

Referenced by org::openscience::cdk::qsar::descriptors::atomic::IPAtomicDescriptor::calculateCarbonylDescriptor(), org::openscience::cdk::qsar::descriptors::bond::IPBondDescriptor::calculateCojugatedPiSystDescriptor(), org::openscience::cdk::qsar::descriptors::atomic::IPAtomicDescriptor::calculateHeteroAtomConjugatedDescriptor(), and org::openscience::cdk::qsar::descriptors::bond::IPBondDescriptor::calculatePiSystDescriptor().

                                                                                                   {
        IAtomContainer localClone;
        try {
            localClone = (IAtomContainer) atomContainer.clone();
        } catch (CloneNotSupportedException e) {
            throw new CDKException("Error during clone");
        }
        IBond clonedBond = localClone.getBond(atomContainer.getBondNumber(bond));

        cleanFlagReactiveCenter((IMolecule) localClone);

      DoubleArrayResult dar = new DoubleArrayResult(2);
      IAtomContainer secondClone;
            try {
                  secondClone = (IMolecule) localClone.clone();
            } catch (CloneNotSupportedException e) {
                  throw new CDKException("Could not clone IAtomContainer!", e);
            }
            IBond secondClonedBond = secondClone.getBond(atomContainer.getBondNumber(bond));

            ArrayList result1 = new ArrayList();
      ArrayList distance1 = new ArrayList();
      ArrayList result2 = new ArrayList();
      ArrayList distance2 = new ArrayList();
      
      
      IAtom atom0 = secondClonedBond.getAtom(0);
      int atomPos0 = secondClone.getAtomNumber(atom0);
      IAtom atom1 = secondClonedBond.getAtom(1);
      int atomPos1 = secondClone.getAtomNumber(atom1);
      
      secondClone.getAtom(atomPos0).setFlag(CDKConstants.REACTIVE_CENTER,true);
      secondClone.getAtom(atomPos1).setFlag(CDKConstants.REACTIVE_CENTER,true);
      secondClone.getBond(localClone.getBondNumber(clonedBond)).setFlag(CDKConstants.REACTIVE_CENTER,true);
            

      /*break bond*/
      if(secondClone.getConnectedSingleElectronsCount(atom0) > 0 || secondClone.getConnectedSingleElectronsCount(atom1) > 0){
            dar.add(0.0);
            dar.add(0.0);
            return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(),dar);
      }
      
      BreakingBondReaction type = new BreakingBondReaction();
      
        Object[] paramsR = {Boolean.TRUE};
        type.setParameters(paramsR);
        
        IMoleculeSet setOfReactants = secondClone.getBuilder().newMoleculeSet();
            setOfReactants.addMolecule((IMolecule) secondClone);
        IReactionSet setOfReactions = type.initiate(setOfReactants, null);
      
        /*search resonance for each product obtained. Only 2*/
        for(int i = 0 ; i < 2; i++){
            if(setOfReactions.getReaction(i) == null)
                  continue;
                  for(int z = 0; z < setOfReactions.getReaction(i).getProducts().getAtomContainerCount(); z++){
                  IAtomContainer product = setOfReactions.getReaction(i).getProducts().getAtomContainer(z);

                  int positionAC = 0;
                  IMapping mapping = (IMapping)setOfReactions.getReaction(i).getMapping(0);
                  IAtom mappedProductA1 = (IAtom)mapping.getChemObject(1);
                  if(!product.contains(mappedProductA1)){
                        mapping = (IMapping)setOfReactions.getReaction(i).getMapping(1);
                        mappedProductA1 = (IAtom)mapping.getChemObject(1);
                  }
                  if(mappedProductA1.getFormalCharge() > 0){
                        positionAC = product.getAtomNumber(mappedProductA1);
                  }else{
                        if(setOfReactions.getReaction(i).getProducts().getAtomContainerCount() == 1)
                              positionAC =  product.getAtomNumber((IAtom)((IMapping)setOfReactions.getReaction(i).getMapping(1)).getChemObject(1));
                        else
                              continue;
                  }
                  
                  
                  if(product.getAtomCount() < 2)
                        continue;
                  
                  int maxNumbStruc = 50;
                  boolean isAromatic = false;
                  if(HueckelAromaticityDetector.detectAromaticity(localClone)){
                         isAromatic = true;
                         IRingSet ringSet = new SSSRFinder(product).findSSSR();
                         if( ringSet.getAtomContainerCount() > 4)
                                    maxNumbStruc = 1;
                         else
                               maxNumbStruc = 5;
                  }
                  StructureResonanceGenerator gRI = new StructureResonanceGenerator(true,true,false,false,true,false,maxNumbStruc);
                  
                  IAtomContainerSet setOfResonance = gRI.getAllStructures(product);
                  if(setOfResonance.getAtomContainerCount() == 1)
                        continue;

                  if(setOfResonance.getAtomContainerCount() > 1){
                        for(int j = 1 ; j < setOfResonance.getAtomContainerCount() ; j++){
                              IAtomContainer prod = setOfResonance.getAtomContainer(j);
                        QueryAtomContainer qAC = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(prod);
                               if(!UniversalIsomorphismTester.isIsomorph(secondClone,qAC)){
                                    /*search positive charge*/
                                     pielectronegativity = new PiElectronegativityDescriptor();
                                    for(int k = 0; k < prod.getAtomCount(); k++){
                                           if(prod.getAtomCount() < 2)
                                                 continue;
                                           IAtom atomsP = prod.getAtom(k);
                                           if(product.getAtom(k).getFormalCharge() !=
                                                 atomsP.getFormalCharge() /*> 0*/)
                                           if(atomsP.getFormalCharge()== 1 || product.getAtom(k).getFormalCharge() == 1){
                                                 DoubleResult electroneg = new DoubleResult(0.0); 
                                              Object[] params = new Integer[2];
                                          params[0] = new Integer(6);
                                          if(isAromatic)
                                                params[1] = new Integer(maxNumbStruc);
                                                
                                          pielectronegativity.setParameters(params);
                                          try{
                                                electroneg = (DoubleResult)pielectronegativity.calculate(atomsP,prod).getValue();
                                          } catch (Exception ex1) {
                                                continue;
                                          }
                                      if(i == 0)result1.add(electroneg);
                                      else result2.add(electroneg);
                                      BondsToAtomDescriptor descriptor   = new BondsToAtomDescriptor();
                                      Object[] paramsD = {new Integer(prod.getAtomNumber(atomsP))};
                                      descriptor.setParameters(paramsD);
                                      IntegerResult dis = ((IntegerResult)descriptor.calculate(prod.getAtom(positionAC),prod).getValue());
                                      
                                      if(i == 0)distance1.add(dis);
                                      else distance2.add(dis);
                                          
                                      break;
                                           }
                                     }
                               }
                        }
                  }
            }
        }
        /*logarithm*/
        
        double value = 0.0;
        double sum = 0.0;
        for(int i = 0 ; i < result1.size() ; i++){
            double suM = ((DoubleResult)result1.get(i)).doubleValue();
            if(suM < 0)
                  suM = -1*suM;
            sum += suM*Math.pow(0.67,((IntegerResult)distance1.get(i)).intValue());
        }
        value = 26.63/sum;
        if(result1.size() > 0){
            dar.add(value);
        }else{
            dar.add(0.0);
        }
        value = 0.0;
        sum = 0.0;
        for(int i = 0 ; i < result2.size() ; i++){
            double suM = ((DoubleResult)result2.get(i)).doubleValue();
            if(suM < 0)
                  suM = -1*suM;
            sum += suM*Math.pow(0.67,((IntegerResult)distance2.get(i)).intValue());
        }
        value = 26.63/sum;
        if(result2.size() > 0){
            dar.add(value);
        }else{
            dar.add(0.0);
        }
        
        /*put first the atom which is smaller*/
        int p0 = atomPos0;
        int p1 = atomPos1;
        if(p0 > p1){
            double o1 = dar.get(0);
            double o0 = dar.get(1);
            dar = new DoubleArrayResult(2);
            dar.add(o0);
            dar.add(o1);
        }
        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(),dar);
    }


Generated by  Doxygen 1.6.0   Back to index