public static StereoConfigurations ToConfiguration(this DoubleBondConformation conformation) { switch (conformation) { case DoubleBondConformation.Unset: return(StereoConfigurations.Unset); case DoubleBondConformation.Together: return(StereoConfigurations.Together); case DoubleBondConformation.Opposite: return(StereoConfigurations.Opposite); default: throw new ArgumentException($"Cannot map enum to config: {conformation}"); } }
/// <summary> /// Get the parity (-1,+1) of the geometric (double bond) configuration. /// </summary> /// <param name="conformation">configuration</param> /// <returns>the parity</returns> private static int Parity(DoubleBondConformation conformation) { return(conformation == DoubleBondConformation.Together ? 1 : -1); }
/// <summary> /// Invert this conformation. /// <see cref="DoubleBondConformation.Together"/>.Invert() = <see cref="DoubleBondConformation.Opposite"/>, <see cref="DoubleBondConformation.Opposite"/>.Invert() = <see cref="DoubleBondConformation.Together"/>. /// </summary> /// <returns>the inverse conformation</returns> public static DoubleBondConformation Invert(this DoubleBondConformation value) => value == DoubleBondConformation.Together ? DoubleBondConformation.Opposite : DoubleBondConformation.Together;
public static bool IsUnset(this DoubleBondConformation value) { return(value == DoubleBondConformation.Unset); }
public object Visit(ASTGroup node, object data) { IAtomContainer fullQuery = (IAtomContainer)data; if (fullQuery == null) { fullQuery = new QueryAtomContainer(builder); } // keeps track of component grouping var components = fullQuery.GetProperty <int[]>("COMPONENT.GROUPING", Array.Empty <int>()); int maxId = 0; if (components.Length > 0) { foreach (int id in components) { if (id > maxId) { maxId = id; } } } for (int i = 0; i < node.JjtGetNumChildren(); i++) { ASTSmarts smarts = (ASTSmarts)node.JjtGetChild(i); ringAtoms = new RingIdentifierAtom[10]; query = new QueryAtomContainer(builder); smarts.JjtAccept(this, null); // update component info if (components.Length > 0 || smarts.ComponentId > 0) { components = Arrays.CopyOf(components, 1 + fullQuery.Atoms.Count + query.Atoms.Count); int id = smarts.ComponentId; Arrays.Fill(components, fullQuery.Atoms.Count, components.Length, id); if (id > maxId) { maxId = id; } } fullQuery.Add(query); } // only store if there was a component grouping if (maxId > 0) { components[components.Length - 1] = maxId; // we left space to store how many groups there were fullQuery.SetProperty("COMPONENT.GROUPING", components); } // create tetrahedral elements foreach (var atom in neighbors.Keys) { IList <IAtom> localNeighbors = neighbors[atom]; if (localNeighbors.Count == 4) { fullQuery.StereoElements.Add(new TetrahedralChirality(atom, localNeighbors.ToArray(), TetrahedralStereo.Clockwise)); // <- to be modified later } else if (localNeighbors.Count == 5) { localNeighbors.Remove(atom); // remove central atom (which represented implicit part) fullQuery.StereoElements.Add(new TetrahedralChirality(atom, localNeighbors.ToArray(), TetrahedralStereo.Clockwise)); // <- to be modified later } } // for each double bond, find the stereo bonds. Currently doesn't // handle logical bonds i.e. C/C-,=C/C foreach (var bond in doubleBonds) { IAtom left = bond.Begin; IAtom right = bond.End; StereoBond leftBond = FindStereoBond(left); StereoBond rightBond = FindStereoBond(right); if (leftBond == null || rightBond == null) { continue; } DoubleBondConformation conformation = leftBond.GetDirection(left) == rightBond.GetDirection(right) ? DoubleBondConformation.Together : DoubleBondConformation.Opposite; fullQuery.StereoElements.Add(new DoubleBondStereochemistry(bond, new IBond[] { leftBond, rightBond }, conformation)); } return(fullQuery); }
/// <summary> /// Creates a new double bond stereo chemistry. The path of length three is defined by /// <paramref name="ligandBonds"/>[0], <paramref name="stereoBond"/>, and <paramref name="ligandBonds"/>[1]. /// </summary> public DoubleBondStereochemistry(IBond stereoBond, IEnumerable <IBond> ligandBonds, DoubleBondConformation stereo) : this(stereoBond, ligandBonds, stereo.ToConfiguration()) { }