Esempio n. 1
0
        /// <summary>
        /// RemovePseudoAtoms
        /// </summary>
        /// <param name="mol"></param>
        /// <returns>Pseudo atom count</returns>

        public static int RemovePseudoAtoms(IAtomContainer mol)
        {
            List <IAtom> pseudoAtoms = new List <IAtom>();

            for (int ai = 0; ai < mol.Atoms.Count; ai++)
            {
                IAtom atom = mol.Atoms[ai];
                if (atom is IPseudoAtom)
                {
                    pseudoAtoms.Add(atom);
                }
            }

            if (pseudoAtoms.Count == 0)
            {
                return(0);
            }

            foreach (IAtom atom in pseudoAtoms)
            {
                mol.RemoveAtom(atom);
            }

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            mol = AtomContainerManipulator.SuppressHydrogens(mol);
            GetHydrogenAdder().AddImplicitHydrogens(mol);

            return(pseudoAtoms.Count);
        }
Esempio n. 2
0
        public static void RemoveAtomAndConnectedElectronContainers(IReaction reaction, IAtom atom)
        {
            var reactants = reaction.Reactants;

            for (int i = 0; i < reactants.Count; i++)
            {
                IAtomContainer mol = reactants[i];
                if (mol.Contains(atom))
                {
                    mol.RemoveAtom(atom);
                }
            }
            var agents = reaction.Reactants;

            for (int i = 0; i < agents.Count; i++)
            {
                var mol = agents[i];
                if (mol.Contains(atom))
                {
                    mol.RemoveAtom(atom);
                }
            }
            var products = reaction.Products;

            for (int i = 0; i < products.Count; i++)
            {
                var mol = products[i];
                if (mol.Contains(atom))
                {
                    mol.RemoveAtom(atom);
                }
            }
        }
Esempio n. 3
0
        public static void FixSulphurH(IAtomContainer m)
        {
            // removes extra H's attached to sulphurs
            for (int i = 0; i <= m.Atoms.Count - 1; i++)
            {
                var a = m.Atoms[i];

                if (a.AtomicNumber.Equals(AtomicNumbers.S))
                {
                    var connectedAtoms = m.GetConnectedAtoms(a);

                    int bondOrderSum = 0;

                    foreach (var conAtom in connectedAtoms)
                    {
                        if (!conAtom.AtomicNumber.Equals(AtomicNumbers.H))
                        {
                            IBond bond = m.GetBond(a, conAtom);
                            if (bond.Order == BondOrder.Single)
                            {
                                bondOrderSum += 1;
                            }
                            else if (bond.Order == BondOrder.Double)
                            {
                                bondOrderSum += 2;
                            }
                            else if (bond.Order == BondOrder.Triple)
                            {
                                bondOrderSum += 3;
                            }
                            else if (bond.Order == BondOrder.Quadruple)
                            {
                                bondOrderSum += 4;
                            }
                        }
                    }

                    if (bondOrderSum > 1)
                    {
                        foreach (var conAtom in connectedAtoms)
                        {
                            if (conAtom.AtomicNumber.Equals(AtomicNumbers.H))
                            {
                                m.RemoveAtom(conAtom);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        private static void RemoveHydrogens(IAtomContainer ac)
        {
            IAtom atom = null;
            int   f    = ac.Atoms.Count - 1;

            do
            {
                atom = ac.Atoms[f];
                switch (atom.AtomicNumber)
                {
                case AtomicNumbers.H:
                    ac.RemoveAtom(atom);
                    break;
                }
                f--;
            } while (f >= 0);
        }