/// <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());
            }
        }
示例#2
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());
            }
        }
示例#3
0
 /// <summary> Sets a property on all <code>Atom</code>s in the given container.</summary>
 public static void setAtomProperties(IAtomContainer container, System.Object propKey, System.Object propVal)
 {
     if (container != null)
     {
         IAtom[] atoms = container.Atoms;
         for (int i = 0; i < atoms.Length; i++)
         {
             IAtom atom = atoms[i];
             atom.setProperty(propKey, propVal);
         }
     }
 }
示例#4
0
 public InvPair(long c, IAtom a)
 {
     curr = c;
     atom = a;
     a.setProperty(INVARIANCE_PAIR, this);
 }
示例#5
0
 public virtual void comit()
 {
     atom.setProperty("CanonicalLable", (System.Object)curr);
 }
示例#6
0
        /// <summary> Procedure required by the CDOInterface. This function is only
        /// supposed to be called by the JCFL library
        /// </summary>
        public virtual void setObjectProperty(System.String objectType, System.String propertyType, System.String propertyValue)
        {
            //logger.debug("objectType: " + objectType);
            //logger.debug("propType: " + propertyType);
            //logger.debug("property: " + propertyValue);

            if (objectType == null)
            {
                //logger.error("Cannot add property for null object");
                return;
            }
            if (propertyType == null)
            {
                //logger.error("Cannot add property for null property type");
                return;
            }
            if (propertyValue == null)
            {
                //logger.warn("Will not add null property");
                return;
            }

            if (objectType.Equals("Molecule"))
            {
                if (propertyType.Equals("id"))
                {
                    currentMolecule.ID = propertyValue;
                }
                else if (propertyType.Equals("inchi"))
                {
                    currentMolecule.setProperty("iupac.nist.chemical.identifier", propertyValue);
                }
                else if (propertyType.Equals("pdb:residueName"))
                {
                    currentMolecule.setProperty(new DictRef(propertyType, propertyValue), propertyValue);
                }
                else if (propertyType.Equals("pdb:oneLetterCode"))
                {
                    currentMolecule.setProperty(new DictRef(propertyType, propertyValue), propertyValue);
                }
                else if (propertyType.Equals("pdb:id"))
                {
                    currentMolecule.setProperty(new DictRef(propertyType, propertyValue), propertyValue);
                }
                else
                {
                    //logger.warn("Not adding molecule property!");
                }
            }
            else if (objectType.Equals("PseudoAtom"))
            {
                if (propertyType.Equals("label"))
                {
                    if (!(currentAtom is IPseudoAtom))
                    {
                        currentAtom = currentChemFile.Builder.newPseudoAtom(currentAtom);
                    }
                    ((IPseudoAtom)currentAtom).Label = propertyValue;
                }
            }
            else if (objectType.Equals("Atom"))
            {
                if (propertyType.Equals("type"))
                {
                    if (propertyValue.Equals("R") && !(currentAtom is IPseudoAtom))
                    {
                        currentAtom = currentChemFile.Builder.newPseudoAtom(currentAtom);
                    }
                    currentAtom.Symbol = propertyValue;
                }
                else if (propertyType.Equals("x2"))
                {
                    //UPGRADE_TODO: The differences in the format  of parameters for constructor 'java.lang.Double.Double'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
                    currentAtom.X2d = System.Double.Parse(propertyValue);
                }
                else if (propertyType.Equals("y2"))
                {
                    //UPGRADE_TODO: The differences in the format  of parameters for constructor 'java.lang.Double.Double'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
                    currentAtom.Y2d = System.Double.Parse(propertyValue);
                }
                else if (propertyType.Equals("x3"))
                {
                    //UPGRADE_TODO: The differences in the format  of parameters for constructor 'java.lang.Double.Double'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
                    currentAtom.X3d = System.Double.Parse(propertyValue);
                }
                else if (propertyType.Equals("y3"))
                {
                    //UPGRADE_TODO: The differences in the format  of parameters for constructor 'java.lang.Double.Double'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
                    currentAtom.Y3d = System.Double.Parse(propertyValue);
                }
                else if (propertyType.Equals("z3"))
                {
                    //UPGRADE_TODO: The differences in the format  of parameters for constructor 'java.lang.Double.Double'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
                    currentAtom.Z3d = System.Double.Parse(propertyValue);
                }
                else if (propertyType.Equals("xFract"))
                {
                    //UPGRADE_TODO: The differences in the format  of parameters for constructor 'java.lang.Double.Double'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
                    currentAtom.FractX3d = System.Double.Parse(propertyValue);
                }
                else if (propertyType.Equals("yFract"))
                {
                    //UPGRADE_TODO: The differences in the format  of parameters for constructor 'java.lang.Double.Double'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
                    currentAtom.FractY3d = System.Double.Parse(propertyValue);
                }
                else if (propertyType.Equals("zFract"))
                {
                    //UPGRADE_TODO: The differences in the format  of parameters for constructor 'java.lang.Double.Double'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
                    currentAtom.FractZ3d = System.Double.Parse(propertyValue);
                }
                else if (propertyType.Equals("formalCharge"))
                {
                    currentAtom.setFormalCharge(System.Int32.Parse(propertyValue));
                }
                else if (propertyType.Equals("charge") || propertyType.Equals("partialCharge"))
                {
                    //UPGRADE_TODO: The differences in the format  of parameters for constructor 'java.lang.Double.Double'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
                    currentAtom.setCharge(System.Double.Parse(propertyValue));
                }
                else if (propertyType.Equals("hydrogenCount"))
                {
                    currentAtom.setHydrogenCount(System.Int32.Parse(propertyValue));
                }
                else if (propertyType.Equals("dictRef"))
                {
                    currentAtom.setProperty("org.openscience.cdk.dict", propertyValue);
                }
                else if (propertyType.Equals("atomicNumber"))
                {
                    currentAtom.AtomicNumber = System.Int32.Parse(propertyValue);
                }
                else if (propertyType.Equals("massNumber"))
                {
                    //UPGRADE_TODO: The differences in the format  of parameters for constructor 'java.lang.Double.Double'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
                    currentAtom.MassNumber = (int)(System.Double.Parse(propertyValue));
                }
                else if (propertyType.Equals("spinMultiplicity"))
                {
                    int unpairedElectrons = System.Int32.Parse(propertyValue) - 1;
                    for (int i = 0; i < unpairedElectrons; i++)
                    {
                        currentMolecule.addElectronContainer(currentChemFile.Builder.newSingleElectron(currentAtom));
                    }
                }
                else if (propertyType.Equals("id"))
                {
                    //logger.debug("id: ", propertyValue);
                    currentAtom.ID = propertyValue;
                    atomEnumeration[propertyValue] = (System.Int32)numberOfAtoms;
                }
            }
            else if (objectType.Equals("Bond"))
            {
                if (propertyType.Equals("atom1"))
                {
                    bond_a1 = System.Int32.Parse(propertyValue);
                }
                else if (propertyType.Equals("atom2"))
                {
                    bond_a2 = System.Int32.Parse(propertyValue);
                }
                else if (propertyType.Equals("id"))
                {
                    //logger.debug("id: " + propertyValue);
                    bond_id = propertyValue;
                }
                else if (propertyType.Equals("order"))
                {
                    try
                    {
                        bond_order = System.Double.Parse(propertyValue);
                    }
                    catch (System.Exception e)
                    {
                        //logger.error("Cannot convert to double: " + propertyValue);
                        bond_order = 1.0;
                    }
                }
                else if (propertyType.Equals("stereo"))
                {
                    if (propertyValue.Equals("H"))
                    {
                        bond_stereo = CDKConstants.STEREO_BOND_DOWN;
                    }
                    else if (propertyValue.Equals("W"))
                    {
                        bond_stereo = CDKConstants.STEREO_BOND_UP;
                    }
                }
            }
            else if (objectType.Equals("Reaction"))
            {
                if (propertyType.Equals("id"))
                {
                    currentReaction.ID = propertyValue;
                }
            }
            else if (objectType.Equals("SetOfReactions"))
            {
                if (propertyType.Equals("id"))
                {
                    currentSetOfReactions.ID = propertyValue;
                }
            }
            else if (objectType.Equals("Reactant"))
            {
                if (propertyType.Equals("id"))
                {
                    currentMolecule.ID = propertyValue;
                }
            }
            else if (objectType.Equals("Product"))
            {
                if (propertyType.Equals("id"))
                {
                    currentMolecule.ID = propertyValue;
                }
            }
            else if (objectType.Equals("Crystal"))
            {
                // set these variables
                if (currentMolecule is ICrystal)
                {
                    ICrystal current = (ICrystal)currentMolecule;
                    if (propertyType.Equals("spacegroup"))
                    {
                        //logger.debug("Setting crystal spacegroup to: " + propertyValue);
                        current.SpaceGroup = propertyValue;
                    }
                    else if (propertyType.Equals("z"))
                    {
                        try
                        {
                            //logger.debug("Setting z to: " + propertyValue);
                            current.Z = System.Int32.Parse(propertyValue);
                        }
                        catch (System.FormatException exception)
                        {
                            //logger.error("Error in format of Z value");
                        }
                    }
                }
                else
                {
                    //logger.warn("Cannot add crystal cell parameters to a non " + "Crystal class!");
                }
            }
            else if (objectType.Equals("a-axis") || objectType.Equals("b-axis") || objectType.Equals("c-axis"))
            {
                // set these variables
                if (currentMolecule is ICrystal)
                {
                    //logger.debug("Setting axis (" + objectType + "): " + propertyValue);
                    if (propertyType.Equals("x"))
                    {
                        crystal_axis_x = System.Double.Parse(propertyValue);
                    }
                    else if (propertyType.Equals("y"))
                    {
                        crystal_axis_y = System.Double.Parse(propertyValue);
                    }
                    else if (propertyType.Equals("z"))
                    {
                        crystal_axis_z = System.Double.Parse(propertyValue);
                    }
                }
                else
                {
                    //logger.warn("Cannot add crystal cell parameters to a non " + "Crystal class!");
                }
            }
            //logger.debug("Object property set...");
        }
示例#7
0
 public InvPair(long c, IAtom a)
 {
     curr = c;
     atom = a;
     a.setProperty(INVARIANCE_PAIR, this);
 }
示例#8
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);
 }
 /// <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;
 }