public void TestProjectTwoChanges() { var chirality = new LigancyFourChirality(molecule.Atoms[1], ligands, TetrahedralStereo.Clockwise); var newLigands = new ILigand[] { ligands[1], ligands[0], ligands[3], ligands[2] }; chirality = chirality.Project(newLigands); Assert.AreEqual(TetrahedralStereo.Clockwise, chirality.Stereo); }
public void TestGetCIPChiralityAnti() { var antiLigands = new ILigand[] { ligands[0], ligands[1], ligands[3], ligands[2] }; var chirality = new LigancyFourChirality(molecule.Atoms[1], antiLigands, TetrahedralStereo.AntiClockwise); var rsChirality = CIPTool.GetCIPChirality(chirality); Assert.AreEqual(CIPTool.CIPChirality.S, rsChirality); }
/// <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)); }
/// <summary> /// Returns a CIP-expanded array of side chains of a ligand. If the ligand atom is only connected to /// the chiral atom, the method will return an empty list. The expansion involves the CIP rules, /// so that a double bonded oxygen will be represented twice in the list. /// </summary> /// <param name="ligand">the <see cref="ILigand"/> for which to return the ILigands</param> /// <returns>a <see cref="ILigand"/> array with the side chains of the ligand atom</returns> public static IReadOnlyList <ILigand> GetLigandLigands(ILigand ligand) { if (ligand is TerminalLigand) { return(Array.Empty <ILigand>()); } var container = ligand.AtomContainer; var ligandAtom = ligand.LigandAtom; var centralAtom = ligand.CentralAtom; var visitedAtoms = ligand.VisitedAtoms; var bonds = container.GetConnectedBonds(ligandAtom); // duplicate ligands according to bond order, following the CIP rules var ligands = new List <ILigand>(); foreach (var bond in bonds) { if (bond.Contains(centralAtom)) { if (BondOrder.Single == bond.Order) { continue; } int duplication = GetDuplication(bond.Order) - 1; if (duplication > 0) { for (int i = 1; i <= duplication; i++) { ligands.Add(new TerminalLigand(container, visitedAtoms, ligandAtom, centralAtom)); } } } else { var duplication = GetDuplication(bond.Order); var connectedAtom = bond.GetOther(ligandAtom); if (visitedAtoms.IsVisited(connectedAtom)) { ligands.Add(new TerminalLigand(container, visitedAtoms, ligandAtom, connectedAtom)); } else { ligands.Add(new Ligand(container, visitedAtoms, ligandAtom, connectedAtom)); } for (int i = 2; i <= duplication; i++) { ligands.Add(new TerminalLigand(container, visitedAtoms, ligandAtom, connectedAtom)); } } } return(ligands); }
public void TestGetCIPChiralityAntiILigancyFourChirality() { var antiLigands = new ILigand[] { ligands[0], ligands[1], ligands[3], ligands[2] }; var ligandAtoms = new List <IAtom>(); foreach (var ligand in antiLigands) { ligandAtoms.Add(ligand.LigandAtom); } var chirality = new TetrahedralChirality(molecule.Atoms[1], ligandAtoms, TetrahedralStereo.AntiClockwise); CIPTool.CIPChirality rsChirality = CIPTool.GetCIPChirality(molecule, chirality); Assert.AreEqual(CIPTool.CIPChirality.S, rsChirality); }
public void TestCheckIfAllLigandsAreDifferentFalse() { var sameLigands = new ILigand[] { ligands[0], ligands[0], ligands[1], ligands[2] }; Assert.IsFalse(CIPTool.CheckIfAllLigandsAreDifferent(sameLigands)); }