Beispiel #1
0
        /// <summary> Method that assign properties to an atom given a particular atomType.
        ///
        /// </summary>
        /// <param name="atom"> Atom to configure
        /// </param>
        /// <param name="atomType">   AtomType
        /// </param>
        public static void configure(IAtom atom, IAtomType atomType)
        {
            atom.AtomTypeName      = atomType.AtomTypeName;
            atom.MaxBondOrder      = atomType.MaxBondOrder;
            atom.BondOrderSum      = atomType.BondOrderSum;
            atom.VanderwaalsRadius = atomType.VanderwaalsRadius;
            atom.CovalentRadius    = atomType.CovalentRadius;
            atom.Valency           = atomType.Valency;
            atom.setFormalCharge(atomType.getFormalCharge());
            atom.Hybridization        = atomType.Hybridization;
            atom.FormalNeighbourCount = atomType.FormalNeighbourCount;
            atom.setFlag(CDKConstants.IS_HYDROGENBOND_ACCEPTOR, atomType.getFlag(CDKConstants.IS_HYDROGENBOND_ACCEPTOR));
            atom.setFlag(CDKConstants.IS_HYDROGENBOND_DONOR, atomType.getFlag(CDKConstants.IS_HYDROGENBOND_DONOR));
            System.Object constant = atomType.getProperty(CDKConstants.CHEMICAL_GROUP_CONSTANT);
            if (constant != null)
            {
                atom.setProperty(CDKConstants.CHEMICAL_GROUP_CONSTANT, constant);
            }
            atom.setFlag(CDKConstants.ISAROMATIC, atomType.getFlag(CDKConstants.ISAROMATIC));

            System.Object color = atomType.getProperty("org.openscience.cdk.renderer.color");
            if (color != null)
            {
                atom.setProperty("org.openscience.cdk.renderer.color", color);
            }
            if (atomType.AtomicNumber != 0)
            {
                atom.AtomicNumber = atomType.AtomicNumber;
            }
            if (atomType.getExactMass() > 0.0)
            {
                atom.setExactMass(atomType.getExactMass());
            }
        }
        /// <summary> Method that assign properties to an atom given a particular atomType.
        /// 
        /// </summary>
        /// <param name="atom"> Atom to configure
        /// </param>
        /// <param name="atomType">   AtomType
        /// </param>
        public static void configure(IAtom atom, IAtomType atomType)
        {
            atom.AtomTypeName = atomType.AtomTypeName;
            atom.MaxBondOrder = atomType.MaxBondOrder;
            atom.BondOrderSum = atomType.BondOrderSum;
            atom.VanderwaalsRadius = atomType.VanderwaalsRadius;
            atom.CovalentRadius = atomType.CovalentRadius;
            atom.Valency = atomType.Valency;
            atom.setFormalCharge(atomType.getFormalCharge());
            atom.Hybridization = atomType.Hybridization;
            atom.FormalNeighbourCount = atomType.FormalNeighbourCount;
            atom.setFlag(CDKConstants.IS_HYDROGENBOND_ACCEPTOR, atomType.getFlag(CDKConstants.IS_HYDROGENBOND_ACCEPTOR));
            atom.setFlag(CDKConstants.IS_HYDROGENBOND_DONOR, atomType.getFlag(CDKConstants.IS_HYDROGENBOND_DONOR));
            System.Object constant = atomType.getProperty(CDKConstants.CHEMICAL_GROUP_CONSTANT);
            if (constant != null)
            {
                atom.setProperty(CDKConstants.CHEMICAL_GROUP_CONSTANT, constant);
            }
            atom.setFlag(CDKConstants.ISAROMATIC, atomType.getFlag(CDKConstants.ISAROMATIC));

            System.Object color = atomType.getProperty("org.openscience.cdk.renderer.color");
            if (color != null)
            {
                atom.setProperty("org.openscience.cdk.renderer.color", color);
            }
            if (atomType.AtomicNumber != 0)
            {
                atom.AtomicNumber = atomType.AtomicNumber;
            }
            if (atomType.getExactMass() > 0.0)
            {
                atom.setExactMass(atomType.getExactMass());
            }
        }
Beispiel #3
0
 /// <summary> Configures an atom. Finds the correct element type by looking at the Atom's
 /// atom type name, and if that fails, picks the first atom type matching
 /// the Atom's element symbol..
 ///
 /// </summary>
 /// <param name="atom"> The atom to be configured
 /// </param>
 /// <returns>       The configured atom
 /// </returns>
 /// <throws>        CDKException when it could not recognize and configure the  </throws>
 /// <summary>               IAtom
 /// </summary>
 public virtual IAtom configure(IAtom atom)
 {
     if (atom is IPseudoAtom)
     {
         // do not try to configure PseudoAtom's
         return(atom);
     }
     try
     {
         IAtomType     atomType     = null;
         System.String atomTypeName = atom.AtomTypeName;
         if (atomTypeName == null || atomTypeName.Length == 0)
         {
             //logger.debug("Using atom symbol because atom type name is empty...");
             IAtomType[] types = getAtomTypes(atom.Symbol);
             if (types.Length > 0)
             {
                 //logger.warn("Taking first atom type, but other may exist");
                 atomType = types[0];
             }
             else
             {
                 //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                 System.String message = "Could not configure atom with unknown ID: " + atom.ToString() + " + (id=" + atom.AtomTypeName + ")";
                 //logger.warn(message);
                 throw new CDKException(message);
             }
         }
         else
         {
             atomType = getAtomType(atom.AtomTypeName);
         }
         //logger.debug("Configuring with atomtype: ", atomType);
         atom.Symbol            = atomType.Symbol;
         atom.MaxBondOrder      = atomType.MaxBondOrder;
         atom.BondOrderSum      = atomType.BondOrderSum;
         atom.VanderwaalsRadius = atomType.VanderwaalsRadius;
         atom.CovalentRadius    = atomType.CovalentRadius;
         atom.Hybridization     = atomType.Hybridization;
         System.Object color = atomType.getProperty("org.openscience.cdk.renderer.color");
         if (color != null)
         {
             atom.setProperty("org.openscience.cdk.renderer.color", color);
         }
         if (atomType.AtomicNumber != 0)
         {
             atom.AtomicNumber = atomType.AtomicNumber;
         }
         else
         {
             //logger.debug("Did not configure atomic number: AT.an=", atomType.AtomicNumber);
         }
         if (atomType.getExactMass() > 0.0)
         {
             atom.setExactMass(atomType.getExactMass());
         }
         else
         {
             //logger.debug("Did not configure mass: AT.mass=", atomType.AtomicNumber);
         }
     }
     catch (System.Exception exception)
     {
         //logger.warn("Could not configure atom with unknown ID: ", atom, " + (id=", atom.AtomTypeName, ")");
         //logger.debug(exception);
         //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
         throw new CDKException(exception.ToString());
     }
     //logger.debug("Configured: ", atom);
     return(atom);
 }