Exemple #1
0
 /// <summary>
 /// Checks if <paramref name="atom1"/> and <paramref name="atom2"/> share membership in the same ring or ring system.
 /// Membership in the same ring is checked if the RingSet contains the SSSR of a molecule; membership in
 /// the same ring or same ring system is checked if the RingSet contains all rings of a molecule.
 /// </summary>
 /// <remarks>
 /// <note type="important">
 /// This method only returns meaningful results if <paramref name="atom1"/> and
 /// <paramref name="atom2"/> are members of the same molecule for which the ring set was calculated!
 /// </note>
 /// </remarks>
 /// <param name="ringSet">The collection of rings</param>
 /// <param name="atom1">The first atom</param>
 /// <param name="atom2">The second atom</param>
 /// <returns><see langword="true"/> if <paramref name="atom1"/> and <paramref name="atom2"/> share membership of at least one ring or ring system, false otherwise</returns>
 public static bool IsSameRing(IRingSet ringSet, IAtom atom1, IAtom atom2)
 {
     foreach (var atomContainer in ringSet)
     {
         IRing ring = (IRing)atomContainer;
         if (ring.Contains(atom1) && ring.Contains(atom2))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #2
0
        /// <summary>
        /// Partition the bonding partners of a given atom into ring atoms and non-ring atoms
        /// </summary>
        /// <param name="atom">The atom whose bonding partners are to be partitioned</param>
        /// <param name="ring">The ring against which the bonding partners are checked</param>
        /// <param name="ringAtoms">An AtomContainer to store the ring bonding partners</param>
        /// <param name="nonRingAtoms">An AtomContainer to store the non-ring bonding partners</param>
        public void PartitionNonRingPartners(IAtom atom, IRing ring, IAtomContainer ringAtoms, IAtomContainer nonRingAtoms)
        {
            var atoms = Molecule.GetConnectedAtoms(atom);

            foreach (var curAtom in atoms)
            {
                if (!ring.Contains(curAtom))
                {
                    nonRingAtoms.Atoms.Add(curAtom);
                }
                else
                {
                    ringAtoms.Atoms.Add(curAtom);
                }
            }
        }
Exemple #3
0
        public static void FixAromaticityForXLogP(IAtomContainer m)
        {
            // need to find rings and aromaticity again since added H's

            IRingSet rs = null;

            try
            {
                AllRingsFinder arf = new AllRingsFinder();
                rs = arf.FindAllRings(m);

                // SSSRFinder s = new SSSRFinder(m);
                // srs = s.FindEssentialRings();
            }
            catch (Exception e)
            {
                Console.Out.WriteLine(e.StackTrace);
            }

            try
            {
                // figure out which atoms are in aromatic rings:
                AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(m);
                Aromaticity.CDKLegacy.Apply(m);
                // figure out which rings are aromatic:
                RingSetManipulator.MarkAromaticRings(rs);
                // figure out which simple (non cycles) rings are aromatic:
                // HueckelAromaticityDetector.DetectAromaticity(m, srs);
            }
            catch (Exception e)
            {
                Console.Out.WriteLine(e.StackTrace);
            }

            // only atoms in 6 membered rings are aromatic
            // determine largest ring that each atom is a part of

            for (int i = 0; i <= m.Atoms.Count - 1; i++)
            {
                m.Atoms[i].IsAromatic = false;

                for (int j = 0; j <= rs.Count - 1; j++)
                {
                    //Debug.WriteLine(i+"\t"+j);
                    IRing r = (IRing)rs[j];
                    if (!r.IsAromatic)
                    {
                        goto continue_jloop;
                    }

                    bool haveatom = r.Contains(m.Atoms[i]);

                    //Debug.WriteLine("haveatom="+haveatom);

                    if (haveatom && r.Atoms.Count == 6)
                    {
                        m.Atoms[i].IsAromatic = true;
                    }
continue_jloop:
                    ;
                }
            }
        }