public void TestVisiting() { VisitedAtoms visited = new VisitedAtoms(); IAtom atom = new Atom("C"); Assert.IsFalse(visited.IsVisited(atom)); visited.Visited(atom); Assert.IsTrue(visited.IsVisited(atom)); }
/// <summary> /// Creates a ligand attached to a single chiral atom, where the involved /// atoms are identified by there index in the <see cref="IAtomContainer"/>. For ligand /// atom, <see cref="Hydrogen"/> can be passed as index, which will indicate the presence of /// an implicit hydrogen, not explicitly present in the chemical graph of the /// given <paramref name="container"/>. /// </summary> /// <param name="container"><see cref="IAtomContainer"/> for which the returned <see cref="ILigand"/>s are defined</param> /// <param name="visitedAtoms">a list of atoms already visited in the analysis</param> /// <param name="chiralAtom">an integer pointing to the <see cref="IAtom"/> index of the chiral atom</param> /// <param name="ligandAtom">an integer pointing to the <see cref="IAtom"/> index of the <see cref="ILigand"/></param> /// <returns>the created <see cref="ILigand"/></returns> public static ILigand DefineLigand(IAtomContainer container, VisitedAtoms visitedAtoms, int chiralAtom, int ligandAtom) { if (ligandAtom == Hydrogen) { return(new ImplicitHydrogenLigand(container, visitedAtoms, container.Atoms[chiralAtom])); } else { return(new Ligand(container, visitedAtoms, container.Atoms[chiralAtom], container.Atoms[ligandAtom])); } }
private static IReadOnlyList <ILigand> MakeLigands() { molecule = smiles.ParseSmiles("ClC(Br)(I)[H]"); var visitedAtoms = new VisitedAtoms(); var ligand1 = new Ligand(molecule, visitedAtoms, molecule.Atoms[1], molecule.Atoms[4]); var ligand2 = new Ligand(molecule, visitedAtoms, molecule.Atoms[1], molecule.Atoms[3]); var ligand3 = new Ligand(molecule, visitedAtoms, molecule.Atoms[1], molecule.Atoms[2]); var ligand4 = new Ligand(molecule, visitedAtoms, molecule.Atoms[1], molecule.Atoms[0]); return(new ILigand[] { ligand1, ligand2, ligand3, ligand4 }); }
/// <summary> /// Creates a ligancy for chirality around a single chiral atom, where the involved /// atoms are identified by there index in the <see cref="IAtomContainer"/>. For the four ligand /// atoms, <see cref="Hydrogen"/> can be passed as index, which will indicate the presence of /// an implicit hydrogen, not explicitly present in the chemical graph of the /// given <paramref name="container"/>. /// </summary> /// <param name="container"><see cref="IAtomContainer"/> for which the returned <see cref="ILigand"/>s are defined</param> /// <param name="chiralAtom">int pointing to the <see cref="IAtom"/> index of the chiral atom</param> /// <param name="ligand1">int pointing to the <see cref="IAtom"/> index of the first <see cref="ILigand"/></param> /// <param name="ligand2">int pointing to the <see cref="IAtom"/> index of the second <see cref="ILigand"/></param> /// <param name="ligand3">int pointing to the <see cref="IAtom"/> index of the third <see cref="ILigand"/></param> /// <param name="ligand4">int pointing to the <see cref="IAtom"/> index of the fourth <see cref="ILigand"/></param> /// <param name="stereo"><see cref="TetrahedralStereo"/> for the chirality</param> /// <returns>the created <see cref="LigancyFourChirality"/></returns> public static LigancyFourChirality DefineLigancyFourChirality(IAtomContainer container, int chiralAtom, int ligand1, int ligand2, int ligand3, int ligand4, TetrahedralStereo stereo) { var atomIndices = new int[] { ligand1, ligand2, ligand3, ligand4 }; var visitedAtoms = new VisitedAtoms(); var ligands = new ILigand[4]; for (int i = 0; i < 4; i++) { ligands[i] = DefineLigand(container, visitedAtoms, chiralAtom, atomIndices[i]); } return(new LigancyFourChirality(container.Atoms[chiralAtom], ligands, stereo)); }
public void TestAddedVisitedAtoms() { VisitedAtoms visited = new VisitedAtoms(); IAtom atom = new Atom("C"); VisitedAtoms visitedToAdd = new VisitedAtoms(); visited.Visited(atom); Assert.IsFalse(visitedToAdd.IsVisited(atom)); visitedToAdd.Visited(visited); Assert.IsTrue(visitedToAdd.IsVisited(atom)); }
/// <summary> /// Creates a new data model for chirality for the CIP rules based on a chirality definition /// in the CDK data model with <see cref="ITetrahedralChirality"/>. /// </summary> /// <param name="container"><see cref="IAtomContainer"/> to which the chiral atom belongs.</param> /// <param name="cdkChirality"><see cref="ITetrahedralChirality"/> object specifying the chirality.</param> public LigancyFourChirality(IAtomContainer container, ITetrahedralChirality cdkChirality) { this.ChiralAtom = cdkChirality.ChiralAtom; var ligandAtoms = cdkChirality.Ligands; this.ligands = new List <ILigand>(ligandAtoms.Count); var visitedAtoms = new VisitedAtoms(); foreach (var ligandAtom in ligandAtoms) { // ITetrahedralChirality stores a implicit hydrogen as the central atom if (ligandAtom == ChiralAtom) { this.ligands.Add(new ImplicitHydrogenLigand(container, visitedAtoms, ChiralAtom)); } else { this.ligands.Add(new Ligand(container, visitedAtoms, ChiralAtom, ligandAtom)); } } this.Stereo = cdkChirality.Stereo; }
/// <summary> /// Adds all atoms from the <paramref name="visitedAtoms"/> list to the current list. /// </summary> /// <param name="visitedAtoms">the <see cref="VisitedAtoms"/> from which all atoms are added</param> public void Visited(VisitedAtoms visitedAtoms) { visitedItems.AddRange(visitedAtoms.visitedItems); }
public void TestConstructor() { VisitedAtoms visited = new VisitedAtoms(); Assert.IsNotNull(visited); }