예제 #1
0
        private static double GetBondEnergy(IBond bond, BondEnergies bondEnergy)
        {
            double energy = 0.0;

            if ((bond.Atoms[0].IsPlaced == true && bond.Atoms[1].IsPlaced == false) ||
                (bond.Atoms[0].IsPlaced == false && bond.Atoms[1].IsPlaced == true))
            {
                int val = bondEnergy.GetEnergies(bond.Atoms[0], bond.Atoms[1], bond.Order);
                energy = val;
            }
            return(energy);
        }
예제 #2
0
        private static double GetEnergy(IAtomContainer educt, IAtomContainer product)
        {
            double       eEnergy    = 0.0;
            BondEnergies bondEnergy = BondEnergies.Instance;

            for (int i = 0; i < educt.Bonds.Count; i++)
            {
                IBond bond = educt.Bonds[i];
                eEnergy += GetBondEnergy(bond, bondEnergy);
            }
            double pEnergy = 0.0;

            for (int j = 0; j < product.Bonds.Count; j++)
            {
                IBond bond = product.Bonds[j];
                pEnergy += GetBondEnergy(bond, bondEnergy);
            }
            return(eEnergy + pEnergy);
        }
예제 #3
0
        private void SetTargetSingleAtomMap(bool removeHydrogen)
        {
            int          counter = 0;
            BondEnergies be      = BondEnergies.Instance;

            foreach (var targetAtom in target.Atoms)
            {
                if ((removeHydrogen && !targetAtom.AtomicNumber.Equals(AtomicNumbers.H)) || (!removeHydrogen))
                {
                    foreach (var sourceAtoms in source.Atoms)
                    {
                        var mapAtoms = new Dictionary <IAtom, IAtom>();

                        if (string.Equals(targetAtom.Symbol, sourceAtoms.Symbol, StringComparison.OrdinalIgnoreCase))
                        {
                            mapAtoms[sourceAtoms] = targetAtom;
                            var bonds = source.GetConnectedBonds(sourceAtoms);

                            double totalOrder = 0;
                            foreach (var bond in bonds)
                            {
                                BondOrder order = bond.Order;
                                totalOrder += order.Numeric() + BondEnergies.GetEnergies(bond);
                            }
                            if (sourceAtoms.FormalCharge != targetAtom.FormalCharge)
                            {
                                totalOrder += 0.5;
                            }
                            connectedBondOrder[counter] = totalOrder;
                            mappings.Insert(counter++, mapAtoms);
                        }
                    }
                }
                else
                {
                    Console.Error.WriteLine("Skipping Hydrogen mapping or This is not a single mapping case!");
                }
            }
        }
예제 #4
0
        private void SetSourceSingleAtomMap(IQueryAtomContainer source, bool removeHydrogen)
        {
            int          counter = 0;
            BondEnergies be      = BondEnergies.Instance;

            foreach (var sourceAtom in source.Atoms)
            {
                var smartAtom = (IQueryAtom)sourceAtom;
                if ((removeHydrogen && !smartAtom.AtomicNumber.Equals(AtomicNumbers.H)) || (!removeHydrogen))
                {
                    foreach (var targetAtom in target.Atoms)
                    {
                        var mapAtoms = new Dictionary <IAtom, IAtom>();
                        if (smartAtom.Matches(targetAtom))
                        {
                            mapAtoms[sourceAtom] = targetAtom;
                            var bonds = target.GetConnectedBonds(targetAtom);

                            double totalOrder = 0;
                            foreach (var bond in bonds)
                            {
                                BondOrder order = bond.Order;
                                totalOrder += order.Numeric() + BondEnergies.GetEnergies(bond);
                            }
                            if (targetAtom.FormalCharge != sourceAtom.FormalCharge)
                            {
                                totalOrder += 0.5;
                            }
                            connectedBondOrder[counter] = totalOrder;
                            mappings.Insert(counter++, mapAtoms);
                        }
                    }
                }
                else
                {
                    Console.Error.WriteLine("Skipping Hydrogen mapping or This is not a single mapping case!");
                }
            }
        }