public AtomWrapper(IAtom atom) { this.atom = atom; // rip some stats from the atom pe = (PeriodicTableElement)atom.Properties["PeriodicTableElement"]; }
public BondAngle(Device device, IAtom atom1, IAtom atom2, IAtom atom3) { this.device = device; this.atom1 = atom1; this.atom2 = atom2; this.atom3 = atom3; }
/// <summary> Method that assign properties to an atom given a particular atomType. /// /// </summary> /// <param name="atom"> Atom to configure /// </param> /// <param name="atomType"> AtomType /// </param> public static void configure(IAtom atom, IAtomType atomType) { atom.AtomTypeName = atomType.AtomTypeName; atom.MaxBondOrder = atomType.MaxBondOrder; atom.BondOrderSum = atomType.BondOrderSum; atom.VanderwaalsRadius = atomType.VanderwaalsRadius; atom.CovalentRadius = atomType.CovalentRadius; atom.Valency = atomType.Valency; atom.setFormalCharge(atomType.getFormalCharge()); atom.Hybridization = atomType.Hybridization; atom.FormalNeighbourCount = atomType.FormalNeighbourCount; atom.setFlag(CDKConstants.IS_HYDROGENBOND_ACCEPTOR, atomType.getFlag(CDKConstants.IS_HYDROGENBOND_ACCEPTOR)); atom.setFlag(CDKConstants.IS_HYDROGENBOND_DONOR, atomType.getFlag(CDKConstants.IS_HYDROGENBOND_DONOR)); System.Object constant = atomType.getProperty(CDKConstants.CHEMICAL_GROUP_CONSTANT); if (constant != null) { atom.setProperty(CDKConstants.CHEMICAL_GROUP_CONSTANT, constant); } atom.setFlag(CDKConstants.ISAROMATIC, atomType.getFlag(CDKConstants.ISAROMATIC)); System.Object color = atomType.getProperty("org.openscience.cdk.renderer.color"); if (color != null) { atom.setProperty("org.openscience.cdk.renderer.color", color); } if (atomType.AtomicNumber != 0) { atom.AtomicNumber = atomType.AtomicNumber; } if (atomType.getExactMass() > 0.0) { atom.setExactMass(atomType.getExactMass()); } }
public static void removeAtomAndConnectedElectronContainers(ISetOfReactions set_Renamed, IAtom atom) { IReaction[] reactions = set_Renamed.Reactions; for (int i = 0; i < reactions.Length; i++) { IReaction reaction = reactions[i]; ReactionManipulator.removeAtomAndConnectedElectronContainers(reaction, atom); } }
/// <summary> /// Joins two paths. The joint point is given by an atom /// which is shared by the two pathes. /// </summary> /// <param name="path1">First path to join</param> /// <param name="path2">Second path to join</param> /// <param name="atom">The atom which is the joint point</param> /// <returns>The newly formed longer path</returns> public static Path join(Path path1, Path path2, IAtom atom) { Path newPath = new Path(); Path tempPath = new Path(); if (path1[0] == atom) { path1.revert(); } newPath.AddRange(path1); if (path2[path2.Count-1] == atom) { path2.revert(); } tempPath.AddRange(path2); tempPath.Remove(atom); newPath.AddRange(tempPath); return newPath; }
public static void removeAtomAndConnectedElectronContainers(IReaction reaction, IAtom atom) { IMolecule[] reactants = reaction.Reactants.Molecules; for (int i = 0; i < reactants.Length; i++) { IMolecule mol = reactants[i]; if (mol.contains(atom)) { mol.removeAtomAndConnectedElectronContainers(atom); } } IMolecule[] products = reaction.Products.Molecules; for (int i = 0; i < products.Length; i++) { IMolecule mol = products[i]; if (mol.contains(atom)) { mol.removeAtomAndConnectedElectronContainers(atom); } } }
public static bool replaceAtomByAtom(IAtomContainer container, IAtom atom, IAtom newAtom) { if (!container.contains(atom)) { // it should complain return false; } else { container.setAtomAt(container.getAtomNumber(atom), newAtom); IElectronContainer[] electronContainers = container.ElectronContainers; for (int i = 0; i < electronContainers.Length; i++) { if (electronContainers[i] is IBond) { IBond bond = (IBond)electronContainers[i]; if (bond.contains(atom)) { for (int j = 0; j < bond.AtomCount; j++) { if (atom.Equals(bond.getAtomAt(j))) { bond.setAtomAt(newAtom, j); } } } } else if (electronContainers[i] is ILonePair) { ILonePair lonePair = (ILonePair)electronContainers[i]; if (atom.Equals(lonePair.Atom)) { lonePair.Atom = newAtom; } } } return true; } }
public static void removeAtomAndConnectedElectronContainers(ISetOfAtomContainers set_Renamed, IAtom atom) { IAtomContainer[] acs = set_Renamed.AtomContainers; for (int i = 0; i < acs.Length; i++) { IAtomContainer container = acs[i]; if (container.contains(atom)) { container.removeAtomAndConnectedElectronContainers(atom); IMolecule[] molecules = ConnectivityChecker.partitionIntoMolecules(container).Molecules; if (molecules.Length > 1) { set_Renamed.removeAtomContainer(container); for (int k = 0; k < molecules.Length; k++) { set_Renamed.addAtomContainer(molecules[k]); } } return; } } }
/// <summary> /// writes all the molecules supplied in a MoleculeSet class to /// a single HIN file. You can also supply a single Molecule object /// as well /// </summary> /// <param name="som">the set of molecules to write</param> /// <exception cref="IOException">if there is a problem writing the molecule</exception> private void WriteAtomContainer(IEnumerableChemObject <IAtomContainer> som) { string sym; double chrg; int molnumber = 0; foreach (var mol in som) { molnumber++; try { string molname = "mol " + molnumber + " " + mol.Title; writer.Write(molname, 0, molname.Length); writer.Write('\n'); // Loop through the atoms and write them out: int i = 0; foreach (var atom in mol.Atoms) { string line = "atom "; sym = atom.Symbol; chrg = atom.Charge.Value; Vector3 point = atom.Point3D.Value; line = line + (i + 1).ToString(NumberFormatInfo.InvariantInfo) + " - " + sym + " ** - " + chrg.ToString(NumberFormatInfo.InvariantInfo) + " " + point.X.ToString(NumberFormatInfo.InvariantInfo) + " " + point.Y.ToString(NumberFormatInfo.InvariantInfo) + " " + point.Z.ToString(NumberFormatInfo.InvariantInfo) + " "; string abuf = ""; int ncon = 0; foreach (var bond in mol.Bonds) { if (bond.Contains(atom)) { // current atom is in the bond so lets get the connected atom IAtom connectedAtom = bond.GetOther(atom); BondOrder bondOrder = bond.Order; int serial; string bondType = ""; // get the serial no for this atom serial = mol.Atoms.IndexOf(connectedAtom); if (bondOrder == BondOrder.Single) { bondType = "s"; } else if (bondOrder == BondOrder.Double) { bondType = "d"; } else if (bondOrder == BondOrder.Triple) { bondType = "t"; } else if (bond.IsAromatic) { bondType = "a"; } abuf = abuf + (serial + 1).ToString(NumberFormatInfo.InvariantInfo) + " " + bondType + " "; ncon++; } } line = line + " " + ncon.ToString(NumberFormatInfo.InvariantInfo) + " " + abuf; writer.Write(line, 0, line.Length); writer.Write('\n'); i++; } string buf = "endmol " + molnumber; writer.Write(buf, 0, buf.Length); writer.Write('\n'); } catch (IOException) { throw; } } }
public int CalculateNumberOfImplicitHydrogens(IAtom atom) { var bonds = new List <IBond>(); return(this.CalculateNumberOfImplicitHydrogens(atom, 0, 0, bonds, false)); }
/// <inheritdoc/> public bool Contains(IAtom atom) { return(bond.Contains(atom)); }
private static double getAngle(IAtom atom1, IAtom atom2, IAtom atom3) { Vector3d centerAtom = new Vector3d(); centerAtom.x = atom1.X3d; centerAtom.y = atom1.Y3d; centerAtom.z = atom1.Z3d; Vector3d firstAtom = new Vector3d(); Vector3d secondAtom = new Vector3d(); firstAtom.x = atom2.X3d; firstAtom.y = atom2.Y3d; firstAtom.z = atom2.Z3d; secondAtom.x = atom3.X3d; secondAtom.y = atom3.Y3d; secondAtom.z = atom3.Z3d; firstAtom.sub(centerAtom); secondAtom.sub(centerAtom); return firstAtom.angle(secondAtom); }
/// <summary> /// Rebonds one atom by looking up nearby atom using the binary space partition tree. /// </summary> private void bondAtom(IAtomContainer container, IAtom atom) { double myCovalentRadius = atom.CovalentRadius; double searchRadius = myCovalentRadius + maxCovalentRadius + bondTolerance; Point tupleAtom = new Point(atom.X3d, atom.Y3d, atom.Z3d); Bspt.EnumerateSphere e = bspt.enumHemiSphere(tupleAtom, searchRadius); while (e.MoveNext()) { IAtom atomNear = ((TupleAtom)e.Current).Atom; if (atomNear != atom && container.getBond(atom, atomNear) == null) { bool isBonded_ = isBonded(myCovalentRadius, atomNear.CovalentRadius, e.foundDistance2()); if (isBonded_) { IBond bond = atom.Builder.newBond(atom, atomNear, 1.0); container.addBond(bond); } } } }
// private procedures /// <summary> Private method that actually parses the input to read a ChemFile /// object. /// /// </summary> /// <returns> A ChemFile containing the data parsed from input. /// </returns> private IChemFile readChemFile(IChemFile file) { IChemSequence chemSequence = file.Builder.newChemSequence(); int number_of_atoms = 0; SupportClass.Tokenizer tokenizer; try { System.String line = input.ReadLine(); while (input.Peek() != -1 && line != null) { // parse frame by frame tokenizer = new SupportClass.Tokenizer(line, "\t ,;"); System.String token = tokenizer.NextToken(); number_of_atoms = System.Int32.Parse(token); System.String info = input.ReadLine(); IChemModel chemModel = file.Builder.newChemModel(); ISetOfMolecules setOfMolecules = file.Builder.newSetOfMolecules(); IMolecule m = file.Builder.newMolecule(); m.setProperty(CDKConstants.TITLE, info); for (int i = 0; i < number_of_atoms; i++) { line = input.ReadLine(); if (line == null) { break; } if (line.StartsWith("#") && line.Length > 1) { System.Object comment = m.getProperty(CDKConstants.COMMENT); if (comment == null) { comment = ""; } //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" comment = comment.ToString() + line.Substring(1).Trim(); m.setProperty(CDKConstants.COMMENT, comment); //logger.debug("Found and set comment: ", comment); } else { double x = 0.0f, y = 0.0f, z = 0.0f; double charge = 0.0f; tokenizer = new SupportClass.Tokenizer(line, "\t ,;"); int fields = tokenizer.Count; if (fields < 4) { // this is an error but cannot throw exception } else { System.String atomtype = tokenizer.NextToken(); //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" x = (System.Double.Parse(tokenizer.NextToken())); //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" y = (System.Double.Parse(tokenizer.NextToken())); //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" z = (System.Double.Parse(tokenizer.NextToken())); if (fields == 8) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" charge = (System.Double.Parse(tokenizer.NextToken())); } IAtom atom = file.Builder.newAtom(atomtype, new Point3d(x, y, z)); atom.setCharge(charge); m.addAtom(atom); } } } setOfMolecules.addMolecule(m); chemModel.SetOfMolecules = setOfMolecules; chemSequence.addChemModel(chemModel); line = input.ReadLine(); } file.addChemSequence(chemSequence); } catch (System.IO.IOException e) { // should make some noise now file = null; //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //logger.error("Error while reading file: ", e.Message); //logger.debug(e); } return(file); }
public override bool Matches(IAtom atom) { return(this.Atom.Matches(atom)); }
/// <summary> /// Gets structure from InChI, and converts InChI library data structure into an IAtomContainer. /// </summary> /// <param name="builder"></param> private void GenerateAtomContainerFromInChI(IChemObjectBuilder builder) { try { output = NInchiWrapper.GetStructureFromInchi(input); } catch (NInchiException jie) { throw new CDKException("Failed to convert InChI to molecule: " + jie.Message, jie); } //molecule = new AtomContainer(); AtomContainer = builder.NewAtomContainer(); var inchiCdkAtomMap = new Dictionary <NInchiAtom, IAtom>(); for (int i = 0; i < output.Atoms.Count; i++) { var iAt = output.Atoms[i]; var cAt = builder.NewAtom(); inchiCdkAtomMap[iAt] = cAt; cAt.Id = "a" + i; cAt.Symbol = iAt.ElementType; cAt.AtomicNumber = PeriodicTable.GetAtomicNumber(cAt.Symbol); // Ignore coordinates - all zero - unless aux info was given... but // the CDK doesn't have an API to provide that // InChI does not have unset properties so we set charge, // hydrogen count (implicit) and isotopic mass cAt.FormalCharge = iAt.Charge; cAt.ImplicitHydrogenCount = iAt.ImplicitH; var isotopicMass = iAt.IsotopicMass; if (isotopicMass != 0) { if (ISOTOPIC_SHIFT_FLAG == (isotopicMass & ISOTOPIC_SHIFT_FLAG)) { try { var massNumber = CDK.IsotopeFactory.GetMajorIsotope(cAt.AtomicNumber).MassNumber.Value; cAt.MassNumber = massNumber + (isotopicMass - ISOTOPIC_SHIFT_FLAG); } catch (IOException e) { throw new CDKException("Could not load Isotopes data", e); } } else { cAt.MassNumber = isotopicMass; } } AtomContainer.Atoms.Add(cAt); cAt = AtomContainer.Atoms[AtomContainer.Atoms.Count - 1]; for (int j = 0; j < iAt.ImplicitDeuterium; j++) { var deut = builder.NewAtom(); deut.AtomicNumber = 1; deut.Symbol = "H"; deut.MassNumber = 2; deut.ImplicitHydrogenCount = 0; AtomContainer.Atoms.Add(deut); deut = AtomContainer.Atoms[AtomContainer.Atoms.Count - 1]; var bond = builder.NewBond(cAt, deut, BondOrder.Single); AtomContainer.Bonds.Add(bond); } for (int j = 0; j < iAt.ImplicitTritium; j++) { var trit = builder.NewAtom(); trit.AtomicNumber = 1; trit.Symbol = "H"; trit.MassNumber = 3; trit.ImplicitHydrogenCount = 0; AtomContainer.Atoms.Add(trit); trit = AtomContainer.Atoms[AtomContainer.Atoms.Count - 1]; var bond = builder.NewBond(cAt, trit, BondOrder.Single); AtomContainer.Bonds.Add(bond); } } for (int i = 0; i < output.Bonds.Count; i++) { var iBo = output.Bonds[i]; var atO = inchiCdkAtomMap[iBo.OriginAtom]; var atT = inchiCdkAtomMap[iBo.TargetAtom]; var cBo = builder.NewBond(atO, atT); var type = iBo.BondType; switch (type) { case INCHI_BOND_TYPE.Single: cBo.Order = BondOrder.Single; break; case INCHI_BOND_TYPE.Double: cBo.Order = BondOrder.Double; break; case INCHI_BOND_TYPE.Triple: cBo.Order = BondOrder.Triple; break; case INCHI_BOND_TYPE.Altern: cBo.IsAromatic = true; break; default: throw new CDKException("Unknown bond type: " + type); } var stereo = iBo.BondStereo; switch (stereo) { // No stereo definition case INCHI_BOND_STEREO.None: cBo.Stereo = BondStereo.None; break; // Bond ending (fat end of wedge) below the plane case INCHI_BOND_STEREO.Single1Down: cBo.Stereo = BondStereo.Down; break; // Bond ending (fat end of wedge) above the plane case INCHI_BOND_STEREO.Single1Up: cBo.Stereo = BondStereo.Up; break; // Bond starting (pointy end of wedge) below the plane case INCHI_BOND_STEREO.Single2Down: cBo.Stereo = BondStereo.DownInverted; break; // Bond starting (pointy end of wedge) above the plane case INCHI_BOND_STEREO.Single2Up: cBo.Stereo = BondStereo.UpInverted; break; // Bond with undefined stereochemistry case INCHI_BOND_STEREO.Single1Either: case INCHI_BOND_STEREO.DoubleEither: cBo.Stereo = BondStereo.None; break; } AtomContainer.Bonds.Add(cBo); } for (int i = 0; i < output.Stereos.Count; i++) { var stereo0d = output.Stereos[i]; if (stereo0d.StereoType == INCHI_STEREOTYPE.Tetrahedral || stereo0d.StereoType == INCHI_STEREOTYPE.Allene) { var central = stereo0d.CentralAtom; var neighbours = stereo0d.Neighbors; var focus = inchiCdkAtomMap[central]; var neighbors = new IAtom[] { inchiCdkAtomMap[neighbours[0]], inchiCdkAtomMap[neighbours[1]], inchiCdkAtomMap[neighbours[2]], inchiCdkAtomMap[neighbours[3]] }; TetrahedralStereo stereo; // as per JNI InChI doc even is clockwise and odd is // anti-clockwise switch (stereo0d.Parity) { case INCHI_PARITY.Odd: stereo = TetrahedralStereo.AntiClockwise; break; case INCHI_PARITY.Even: stereo = TetrahedralStereo.Clockwise; break; default: // CDK Only supports parities of + or - continue; } IStereoElement <IChemObject, IChemObject> stereoElement = null; switch (stereo0d.StereoType) { case INCHI_STEREOTYPE.Tetrahedral: stereoElement = builder.NewTetrahedralChirality(focus, neighbors, stereo); break; case INCHI_STEREOTYPE.Allene: { // The periphals (p<i>) and terminals (t<i>) are refering to // the following atoms. The focus (f) is also shown. // // p0 p2 // \ / // t0 = f = t1 // / \ // p1 p3 var peripherals = neighbors; var terminals = ExtendedTetrahedral.FindTerminalAtoms(AtomContainer, focus); // InChI always provides the terminal atoms t0 and t1 as // periphals, here we find where they are and then add in // the other explicit atom. As the InChI create hydrogens // for stereo elements, there will always we an explicit // atom that can be found - it may be optionally suppressed // later. // not much documentation on this (at all) but they appear // to always be the middle two atoms (index 1, 2) we therefore // test these first - but handle the other indices just in // case foreach (var terminal in terminals) { if (peripherals[1].Equals(terminal)) { peripherals[1] = FindOtherSinglyBonded(AtomContainer, terminal, peripherals[0]); } else if (peripherals[2].Equals(terminal)) { peripherals[2] = FindOtherSinglyBonded(AtomContainer, terminal, peripherals[3]); } else if (peripherals[0].Equals(terminal)) { peripherals[0] = FindOtherSinglyBonded(AtomContainer, terminal, peripherals[1]); } else if (peripherals[3].Equals(terminal)) { peripherals[3] = FindOtherSinglyBonded(AtomContainer, terminal, peripherals[2]); } } stereoElement = new ExtendedTetrahedral(focus, peripherals, stereo); } break; } Trace.Assert(stereoElement != null); AtomContainer.StereoElements.Add(stereoElement); } else if (stereo0d.StereoType == INCHI_STEREOTYPE.DoubleBond) { NInchiAtom[] neighbors = stereo0d.Neighbors; // from JNI InChI doc // neighbor[4] : {#X,#A,#B,#Y} in this order // X central_atom : NO_ATOM // \ X Y type : INCHI_StereoType_DoubleBond // A == B \ / // \ A == B // Y var x = inchiCdkAtomMap[neighbors[0]]; var a = inchiCdkAtomMap[neighbors[1]]; var b = inchiCdkAtomMap[neighbors[2]]; var y = inchiCdkAtomMap[neighbors[3]]; // XXX: AtomContainer is doing slow lookup var stereoBond = AtomContainer.GetBond(a, b); stereoBond.SetAtoms(new[] { a, b }); // ensure a is first atom var conformation = DoubleBondConformation.Unset; switch (stereo0d.Parity) { case INCHI_PARITY.Odd: conformation = DoubleBondConformation.Together; break; case INCHI_PARITY.Even: conformation = DoubleBondConformation.Opposite; break; } // unspecified not stored if (conformation.IsUnset()) { continue; } AtomContainer.StereoElements.Add(new DoubleBondStereochemistry(stereoBond, new IBond[] { AtomContainer.GetBond(x, a), AtomContainer.GetBond(b, y) }, conformation)); } else { // TODO - other types of atom parity - double bond, etc } } }
/// <summary> /// Finds a neighbor attached to 'atom' that is singley bonded and isn't 'exclude'. If no such atom exists, the 'atom' is returned. /// </summary> /// <param name="container">a molecule container</param> /// <param name="atom">the atom to find the neighbor or</param> /// <param name="exclude">don't find this atom</param> /// <returns>the other atom (or 'atom')</returns> private static IAtom FindOtherSinglyBonded(IAtomContainer container, IAtom atom, IAtom exclude) { foreach (var bond in container.GetConnectedBonds(atom)) { if (!BondOrder.Single.Equals(bond.Order) || bond.Contains(exclude)) { continue; } return(bond.GetOther(atom)); } return(atom); }
/// <summary> /// Initiates the process for the given mechanism. The atoms to apply are mapped between /// reactants and products. /// </summary> /// <param name="atomContainerSet"></param> /// <param name="atomList">The list of atoms taking part in the mechanism. Only allowed two three. /// The first atom is the atom which must contain the charge to be moved, the second /// is the atom which is in the middle and the third is the atom which acquires the new charge /// <param name="bondList">The list of bonds taking part in the mechanism. Only allowed two bond.</param> /// The first bond is the bond to increase the order and the second is the bond /// to decrease the order /// It is the bond which is moved</param> /// <returns>The Reaction mechanism</returns> public IReaction Initiate(IChemObjectSet <IAtomContainer> atomContainerSet, IList <IAtom> atomList, IList <IBond> bondList) { var atMatcher = CDK.AtomTypeMatcher; if (atomContainerSet.Count != 1) { throw new CDKException("RearrangementChargeMechanism only expects one IAtomContainer"); } if (atomList.Count != 3) { throw new CDKException("RearrangementChargeMechanism expects three atoms in the List"); } if (bondList.Count != 2) { throw new CDKException("RearrangementChargeMechanism only expect one bond in the List"); } IAtomContainer molecule = atomContainerSet[0]; IAtomContainer reactantCloned; reactantCloned = (IAtomContainer)molecule.Clone(); IAtom atom1 = atomList[0]; // Atom with the charge IAtom atom1C = reactantCloned.Atoms[molecule.Atoms.IndexOf(atom1)]; IAtom atom3 = atomList[2]; // Atom which acquires the charge IAtom atom3C = reactantCloned.Atoms[molecule.Atoms.IndexOf(atom3)]; IBond bond1 = bondList[0]; // Bond with single bond int posBond1 = molecule.Bonds.IndexOf(bond1); IBond bond2 = bondList[1]; // Bond with double bond int posBond2 = molecule.Bonds.IndexOf(bond2); BondManipulator.IncreaseBondOrder(reactantCloned.Bonds[posBond1]); if (bond2.Order == BondOrder.Single) { reactantCloned.Bonds.Remove(reactantCloned.Bonds[posBond2]); } else { BondManipulator.DecreaseBondOrder(reactantCloned.Bonds[posBond2]); } //Depending of the charge moving (radical, + or -) there is a different situation if (reactantCloned.GetConnectedSingleElectrons(atom1C).Any()) { var selectron = reactantCloned.GetConnectedSingleElectrons(atom1C); reactantCloned.SingleElectrons.Remove(selectron.Last()); reactantCloned.SingleElectrons.Add(bond2.Builder.NewSingleElectron(atom3C)); } else if (atom1C.FormalCharge > 0) { int charge = atom1C.FormalCharge.Value; atom1C.FormalCharge = charge - 1; charge = atom3C.FormalCharge.Value; atom3C.FormalCharge = charge + 1; } else if (atom1C.FormalCharge < 1) { int charge = atom1C.FormalCharge.Value; atom1C.FormalCharge = charge + 1; var ln = reactantCloned.GetConnectedLonePairs(atom1C); reactantCloned.LonePairs.Remove(ln.Last()); atom1C.IsAromatic = false; charge = atom3C.FormalCharge.Value; atom3C.FormalCharge = charge - 1; reactantCloned.LonePairs.Add(bond2.Builder.NewLonePair(atom3C)); atom3C.IsAromatic = false; } else { return(null); } atom1C.Hybridization = Hybridization.Unset; atom3C.Hybridization = Hybridization.Unset; AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(reactantCloned); IAtomType type = atMatcher.FindMatchingAtomType(reactantCloned, atom1C); if (type == null || type.AtomTypeName.Equals("X", StringComparison.Ordinal)) { return(null); } type = atMatcher.FindMatchingAtomType(reactantCloned, atom3C); if (type == null || type.AtomTypeName.Equals("X", StringComparison.Ordinal)) { return(null); } IReaction reaction = bond2.Builder.NewReaction(); reaction.Reactants.Add(molecule); /* mapping */ foreach (var atom in molecule.Atoms) { IMapping mapping = bond2.Builder.NewMapping(atom, reactantCloned.Atoms[molecule.Atoms.IndexOf(atom)]); reaction.Mappings.Add(mapping); } if (bond2.Order != BondOrder.Single) { reaction.Products.Add(reactantCloned); } else { IChemObjectSet <IAtomContainer> moleculeSetP = ConnectivityChecker.PartitionIntoMolecules(reactantCloned); for (int z = 0; z < moleculeSetP.Count(); z++) { reaction.Products.Add((IAtomContainer)moleculeSetP[z]); } } return(reaction); }
/// <summary> /// Grounds the specified atom by the given substitution and returns it. /// </summary> /// <param name="atom">Function or predicate atom.</param> /// <param name="substitution">Variables substitution.</param> /// <returns>Grounded atom.</returns> public IAtom GroundAtom(IAtom atom, ISubstitution substitution) { return(TermsAndAtomsGrounder.Value.GroundAtom(atom, substitution)); }
/// <summary> /// The method returns apha partial charges assigned to an heavy atom through Gasteiger Marsili /// It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools.HydrogenAdder. /// For this method will be only possible if the heavy atom has single bond. /// </summary> /// <param name="atom">The <see cref="IAtom"/> for which the <see cref="Result"/> is requested</param> /// <returns>Value of the alpha partial charge</returns> public Result Calculate(IAtom atom) { var index = container.Atoms.IndexOf(atom); return(new Result(clonedContainer.Atoms[index].Charge.Value)); }
/// <summary> Add an Atom and makes it the N-terminus atom. /// /// </summary> /// <param name="atom"> The Atom that is the N-terminus /// /// </param> /// <seealso cref="getNTerminus"> /// </seealso> public virtual void addNTerminus(IAtom atom) { base.addAtom(atom); nTerminus = atom; }
/// <summary> /// Calculate effective atom polarizability. /// </summary> /// <param name="atomContainer">IAtomContainer</param> /// <param name="atom">atom for which effective atom polarizability should be calculated</param> /// <param name="influenceSphereCutOff">cut off for spheres which should taken into account for calculation</param> /// <param name="addExplicitH">if set to true, then explicit H's will be added, otherwise it assumes that they have /// been added to the molecule before being called</param> /// <returns>polarizabilitiy</returns> public static double CalculateGHEffectiveAtomPolarizability(IAtomContainer atomContainer, IAtom atom, int influenceSphereCutOff, bool addExplicitH) { double polarizabilitiy = 0; IAtomContainer acH; if (addExplicitH) { acH = atomContainer.Builder.NewAtomContainer(atomContainer); AddExplicitHydrogens(acH); } else { acH = atomContainer; } var startAtom = new List <IAtom>(1); startAtom.Insert(0, atom); double bond; polarizabilitiy += GetKJPolarizabilityFactor(acH, atom); for (int i = 0; i < acH.Atoms.Count; i++) { if (!acH.Atoms[i].Equals(atom)) { bond = PathTools.BreadthFirstTargetSearch(acH, startAtom, acH.Atoms[i], 0, influenceSphereCutOff); if (bond == 1) { polarizabilitiy += GetKJPolarizabilityFactor(acH, acH.Atoms[i]); } else { polarizabilitiy += (Math.Pow(0.5, bond - 1) * GetKJPolarizabilityFactor(acH, acH.Atoms[i])); } //if bond==0 } //if !=atom } //for return(polarizabilitiy); }
public static IAtomContainer getRelevantAtomContainer(IReaction reaction, IAtom atom) { IAtomContainer result = SetOfMoleculesManipulator.getRelevantAtomContainer(reaction.Reactants, atom); if (result != null) { return result; } return SetOfMoleculesManipulator.getRelevantAtomContainer(reaction.Products, atom); }
/// <summary> /// Calculate effective atom polarizability. /// </summary> /// <param name="atomContainer">IAtomContainer</param> /// <param name="atom">atom for which effective atom polarizability should be calculated</param> /// <param name="addExplicitH">if set to true, then explicit H's will be added, otherwise it assumes that they have /// been added to the molecule before being called</param> /// <param name="distanceMatrix">an n x n matrix of topological distances between all the atoms in the molecule. /// if this argument is non-null, then BFS will not be used and instead path lengths will be looked up. This /// form of the method is useful, if it is being called for multiple atoms in the same molecule</param> /// <returns>polarizabilitiy</returns> public static double CalculateGHEffectiveAtomPolarizability(IAtomContainer atomContainer, IAtom atom, bool addExplicitH, int[][] distanceMatrix) { double polarizabilitiy = 0; IAtomContainer acH; if (addExplicitH) { acH = atomContainer.Builder.NewAtomContainer(atomContainer); AddExplicitHydrogens(acH); } else { acH = atomContainer; } double bond; polarizabilitiy += GetKJPolarizabilityFactor(acH, atom); for (int i = 0; i < acH.Atoms.Count; i++) { if (acH.Atoms[i] != atom) { int atomIndex = atomContainer.Atoms.IndexOf(atom); bond = distanceMatrix[atomIndex][i]; if (bond == 1) { polarizabilitiy += GetKJPolarizabilityFactor(acH, acH.Atoms[i]); } else { polarizabilitiy += (Math.Pow(0.5, bond - 1) * GetKJPolarizabilityFactor(acH, acH.Atoms[i])); } //if bond==0 } //if !=atom } //for return(polarizabilitiy); }
/// <summary> Determines the best alignment for the label of an atom in 2D space. It /// returns 1 if left aligned, and -1 if right aligned. /// See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets /// /// </summary> /// <param name="container"> Description of the Parameter /// </param> /// <param name="atom"> Description of the Parameter /// </param> /// <returns> The bestAlignmentForLabel value /// </returns> public static int getBestAlignmentForLabel(IAtomContainer container, IAtom atom) { IAtom[] connectedAtoms = container.getConnectedAtoms(atom); int overallDiffX = 0; for (int i = 0; i < connectedAtoms.Length; i++) { IAtom connectedAtom = connectedAtoms[i]; //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" overallDiffX = overallDiffX + (int)(connectedAtom.X2d - atom.X2d); } if (overallDiffX <= 0) { return 1; } else { return -1; } }
/// <summary> /// Method which assigns the polarizabilitiyFactors. /// </summary> /// <param name="atomContainer">AtomContainer</param> /// <param name="atom">Atom</param> /// <returns>double polarizabilitiyFactor</returns> private static double GetKJPolarizabilityFactor(IAtomContainer atomContainer, IAtom atom) { double polarizabilitiyFactor = 0; switch (atom.AtomicNumber) { case AtomicNumbers.H: polarizabilitiyFactor = 0.387; break; case AtomicNumbers.C: if (atom.IsAromatic) { polarizabilitiyFactor = 1.230; } else if (atomContainer.GetMaximumBondOrder(atom) == BondOrder.Single) { polarizabilitiyFactor = 1.064; /* 1.064 */ } else if (atomContainer.GetMaximumBondOrder(atom) == BondOrder.Double) { if (GetNumberOfHydrogen(atomContainer, atom) == 0) { polarizabilitiyFactor = 1.382; } else { polarizabilitiyFactor = 1.37; } } else if (atomContainer.GetMaximumBondOrder(atom) == BondOrder.Triple || atomContainer.GetMaximumBondOrder(atom) == BondOrder.Quadruple) { polarizabilitiyFactor = 1.279; } break; case AtomicNumbers.N: if (atom.Charge != null && atom.Charge < 0) { polarizabilitiyFactor = 1.090; } else if (atomContainer.GetMaximumBondOrder(atom) == BondOrder.Single) { polarizabilitiyFactor = 1.094; } else if (atomContainer.GetMaximumBondOrder(atom) == BondOrder.Double) { polarizabilitiyFactor = 1.030; } else { polarizabilitiyFactor = 0.852; } break; case AtomicNumbers.O: if (atom.Charge != null && atom.Charge == -1) { polarizabilitiyFactor = 1.791; } else if (atom.Charge != null && atom.Charge == 1) { polarizabilitiyFactor = 0.422; } else if (atomContainer.GetMaximumBondOrder(atom) == BondOrder.Single) { polarizabilitiyFactor = 0.664; } else if (atomContainer.GetMaximumBondOrder(atom) == BondOrder.Double) { polarizabilitiyFactor = 0.460; } break; case AtomicNumbers.P: if (atomContainer.GetConnectedBonds(atom).Count() == 4 && atomContainer.GetMaximumBondOrder(atom) == BondOrder.Double) { polarizabilitiyFactor = 0; } break; case AtomicNumbers.S: if (atom.IsAromatic) { polarizabilitiyFactor = 3.38; } else if (atomContainer.GetMaximumBondOrder(atom) == BondOrder.Single) { polarizabilitiyFactor = 3.20; /* 3.19 */ } else if (atomContainer.GetMaximumBondOrder(atom) == BondOrder.Double) { if (GetNumberOfHydrogen(atomContainer, atom) == 0) { polarizabilitiyFactor = 3.51; } else { polarizabilitiyFactor = 3.50; } } else { polarizabilitiyFactor = 3.42; } break; case AtomicNumbers.F: polarizabilitiyFactor = 0.296; break; case AtomicNumbers.Cl: polarizabilitiyFactor = 2.343; break; case AtomicNumbers.Br: polarizabilitiyFactor = 3.5; break; case AtomicNumbers.I: polarizabilitiyFactor = 5.79; break; } return(polarizabilitiyFactor); }
/// <summary> Calculates the center of the given atoms and returns it as a Point2d, using /// an external set of coordinates /// See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets /// /// </summary> /// <param name="atoms"> The vector of the given atoms /// </param> /// <param name="renderingCoordinates"> The set of coordinates to use coming from RendererModel2D /// </param> /// <returns> The center of the given atoms as Point2d /// /// </returns> //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'" public static Point2d get2DCenter(IAtom[] atoms, System.Collections.Hashtable renderingCoordinates) { IAtom atom; double x = 0; double y = 0; for (int f = 0; f < atoms.Length; f++) { atom = (IAtom)atoms[f]; //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'" if (renderingCoordinates[atom] != null) { //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'" x += ((Point2d)renderingCoordinates[atom]).x; //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'" y += ((Point2d)renderingCoordinates[atom]).y; } } return new Point2d(x / (double)atoms.Length, y / (double)atoms.Length); }
/// <summary> /// Gets the polarizabilitiy factor for atom. /// </summary> /// <param name="atomContainer">atom container</param> /// <param name="atom">atom for which the factor should become known</param> /// <returns>The polarizabilitiy factor for atom</returns> public static double GetPolarizabilitiyFactorForAtom(IAtomContainer atomContainer, IAtom atom) { var acH = atomContainer.Builder.NewAtomContainer(atomContainer); AddExplicitHydrogens(acH); return(GetKJPolarizabilityFactor(acH, atom)); }
/// <summary> Adds the atom oAtom to a specified Monomer. Additionally, it keeps /// record of the iCode. /// /// </summary> /// <param name="oAtom"> The atom to add /// </param> /// <param name="oMonomer"> The monomer the atom belongs to /// </param> public override void addAtom(IAtom oAtom, IMonomer oMonomer) { base.addAtom(oAtom, oMonomer); if (!sequentialListOfMonomers.Contains(oMonomer.MonomerName)) sequentialListOfMonomers.Add(oMonomer.MonomerName); }
// // public static Molecule CreateNeopentane() { // Molecule result = new DefaultMolecule(); // Atom c0 = result.Atoms.Add("C"); // Atom c1 = result.Atoms.Add("C"); // Atom c2 = result.Atoms.Add("C"); // Atom c3 = result.Atoms.Add("C"); // Atom c4 = result.Atoms.Add("C"); // // result.Connect(c0, c1, 1); // result.Connect(c0, c2, 1); // result.Connect(c0, c3, 1); // result.Connect(c0, c4, 1); // // return result; // } // public static IAtomContainer CreateCubane() { IAtomContainer result = builder.NewAtomContainer(); IAtom c1 = builder.NewAtom("C"); c1.Id = "1"; IAtom c2 = builder.NewAtom("C"); c2.Id = "2"; IAtom c3 = builder.NewAtom("C"); c3.Id = "3"; IAtom c4 = builder.NewAtom("C"); c4.Id = "4"; IAtom c5 = builder.NewAtom("C"); c5.Id = "5"; IAtom c6 = builder.NewAtom("C"); c6.Id = "6"; IAtom c7 = builder.NewAtom("C"); c7.Id = "7"; IAtom c8 = builder.NewAtom("C"); c8.Id = "8"; result.Atoms.Add(c1); result.Atoms.Add(c2); result.Atoms.Add(c3); result.Atoms.Add(c4); result.Atoms.Add(c5); result.Atoms.Add(c6); result.Atoms.Add(c7); result.Atoms.Add(c8); IBond bond1 = builder.NewBond(c1, c2, BondOrder.Single); IBond bond2 = builder.NewBond(c2, c3, BondOrder.Single); IBond bond3 = builder.NewBond(c3, c4, BondOrder.Single); IBond bond4 = builder.NewBond(c4, c1, BondOrder.Single); IBond bond5 = builder.NewBond(c5, c6, BondOrder.Single); IBond bond6 = builder.NewBond(c6, c7, BondOrder.Single); IBond bond7 = builder.NewBond(c7, c8, BondOrder.Single); IBond bond8 = builder.NewBond(c8, c5, BondOrder.Single); IBond bond9 = builder.NewBond(c1, c5, BondOrder.Single); IBond bond10 = builder.NewBond(c2, c6, BondOrder.Single); IBond bond11 = builder.NewBond(c3, c7, BondOrder.Single); IBond bond12 = builder.NewBond(c4, c8, BondOrder.Single); result.Bonds.Add(bond1); result.Bonds.Add(bond2); result.Bonds.Add(bond3); result.Bonds.Add(bond4); result.Bonds.Add(bond5); result.Bonds.Add(bond6); result.Bonds.Add(bond7); result.Bonds.Add(bond8); result.Bonds.Add(bond9); result.Bonds.Add(bond10); result.Bonds.Add(bond11); result.Bonds.Add(bond12); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(result); var adder = CDK.HydrogenAdder; adder.AddImplicitHydrogens(result); Aromaticity.CDKLegacy.Apply(result); return(result); }
/// <inheritdoc/> public IEnumerable <IAtom> GetConnectedAtoms(IAtom atom) { return(bond.GetConnectedAtoms(atom)); }
IDescriptorResult IAtomicDescriptor.Calculate(IAtom atom) => Calculate(atom);
/// <summary> /// Calculate the number of missing hydrogens by subtracting the number of /// bonds for the atom from the expected number of bonds. Charges are included /// in the calculation. The number of expected bonds is defined by the atom type /// generated with the atom type factory. /// </summary> public int CalculateNumberOfImplicitHydrogens(IAtom atom, IAtomContainer container) { return(this.CalculateNumberOfImplicitHydrogens(atom, container, false)); }
/// <summary> Method that saturates an atom in a molecule by adding explicit hydrogens. /// In order to get coordinates for these Hydrogens, you need to /// remember the average bondlength of you molecule (coordinates for /// all atoms should be available) by using /// double bondLength = GeometryTools.getBondLengthAverage(atomContainer); /// and then use this method here and then use /// org.openscience.cdk.HydrogenPlacer(atomContainer, bondLength); /// /// </summary> /// <param name="atom"> Atom to saturate /// </param> /// <param name="container">AtomContainer containing the atom /// </param> /// <param name="totalContainer">In case you have a container containing multiple structures, this is the total container, whereas container is a partial structure /// /// </param> /// <cdk.keyword> hydrogen, adding </cdk.keyword> /// <cdk.keyword> explicit hydrogen </cdk.keyword> /// <summary> /// </summary> /// <deprecated> /// </deprecated> public virtual IAtomContainer addHydrogensToSatisfyValency(IAtomContainer container, IAtom atom, IAtomContainer totalContainer) { //logger.debug("Start of addHydrogensToSatisfyValency(AtomContainer container, Atom atom)"); IAtomContainer changedAtomsAndBonds = addExplicitHydrogensToSatisfyValency(container, atom, totalContainer); //logger.debug("End of addHydrogensToSatisfyValency(AtomContainer container, Atom atom)"); return changedAtomsAndBonds; }
public int CalculateNumberOfImplicitHydrogens(IAtom atom, IAtomContainer container, bool throwExceptionForUnknowAtom) { return(this.CalculateNumberOfImplicitHydrogens(atom, container.GetBondOrderSum(atom), container.GetConnectedSingleElectrons(atom).Count(), container.GetConnectedBonds(atom), throwExceptionForUnknowAtom)); }
/// <summary> Method that saturates an atom in a molecule by adding explicit hydrogens. /// /// </summary> /// <param name="atom"> Atom to saturate /// </param> /// <param name="container">AtomContainer containing the atom /// </param> /// <param name="count"> Number of hydrogens to add /// </param> /// <param name="totalContainer">In case you have a container containing multiple structures, this is the total container, whereas container is a partial structure /// /// </param> /// <cdk.keyword> hydrogen, adding </cdk.keyword> /// <cdk.keyword> explicit hydrogen </cdk.keyword> public virtual IAtomContainer addExplicitHydrogensToSatisfyValency(IAtomContainer container, IAtom atom, int count, IAtomContainer totalContainer) { //boolean create2DCoordinates = GeometryTools.has2DCoordinates(container); IIsotope isotope = IsotopeFactory.getInstance(container.Builder).getMajorIsotope("H"); atom.setHydrogenCount(0); IAtomContainer changedAtomsAndBonds = container.Builder.newAtomContainer(); for (int i = 1; i <= count; i++) { IAtom hydrogen = container.Builder.newAtom("H"); IsotopeFactory.getInstance(container.Builder).configure(hydrogen, isotope); totalContainer.addAtom(hydrogen); IBond newBond = container.Builder.newBond((IAtom) atom, hydrogen, 1.0); totalContainer.addBond(newBond); changedAtomsAndBonds.addAtom(hydrogen); changedAtomsAndBonds.addBond(newBond); } return changedAtomsAndBonds; }
/// <summary> Marks an Atom as being the C-terminus atom. It assumes that the Atom /// is already added to the AminoAcid. /// /// </summary> /// <param name="atom"> The Atom that is the C-terminus /// /// </param> /// <seealso cref="addCTerminus"> /// </seealso> private void setCTerminus(IAtom atom) { cTerminus = atom; }
/// <summary> Removes an atom from the AtomContainer under certain conditions. /// See {@cdk.cite HAN96} for details /// /// /// </summary> /// <param name="atom"> The atom to be removed /// </param> /// <param name="ac"> The AtomContainer to work on /// </param> /// <param name="pathes"> The pathes to manipulate /// </param> /// <param name="rings"> The ringset to be extended /// </param> /// <exception cref="CDKException"> Thrown if something goes wrong or if the timeout is exceeded /// </exception> private void remove(IAtom atom, IAtomContainer ac, System.Collections.ArrayList pathes, IRingSet rings) { Path path1 = null; Path path2 = null; Path union = null; int intersectionSize = 0; newPathes.Clear(); removePathes.Clear(); potentialRings.Clear(); if (debug) { System.Console.Out.WriteLine("*** Removing atom " + originalAc.getAtomNumber(atom) + " ***"); } for (int i = 0; i < pathes.Count; i++) { path1 = (Path)pathes[i]; if (path1[0] == atom || path1[path1.Count - 1] == atom) { for (int j = i + 1; j < pathes.Count; j++) { //System.out.print("."); path2 = (Path)pathes[j]; if (path2[0] == atom || path2[path2.Count - 1] == atom) { intersectionSize = path1.getIntersectionSize(path2); if (intersectionSize < 3) { //if (debug) System.out.println("Joining " + path1.toString(originalAc) + " and " + path2.toString(originalAc)); union = Path.join(path1, path2, atom); if (intersectionSize == 1) { newPathes.Add(union); } else { potentialRings.Add(union); } //if (debug) System.out.println("Intersection Size: " + intersectionSize); //if (debug) System.out.println("Union: " + union.toString(originalAc)); /* * Now we know that path1 and * path2 share the Atom atom. */ removePathes.Add(path1); removePathes.Add(path2); } } checkTimeout(); } } } for (int f = 0; f < removePathes.Count; f++) { pathes.Remove(removePathes[f]); } for (int f = 0; f < newPathes.Count; f++) { pathes.Add(newPathes[f]); } detectRings(potentialRings, rings, originalAc); ac.removeAtomAndConnectedElectronContainers(atom); if (debug) { System.Console.Out.WriteLine("\n" + pathes.Count + " pathes and " + ac.AtomCount + " atoms left."); } }
public AtomEntity NewAtom(IAtom newAtom) { throw new Exception("The method or operation is not implemented."); }
/// <summary> Sorts a Vector of atoms such that the 2D distances of the atom locations /// from a given point are smallest for the first atoms in the vector /// See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets /// /// </summary> /// <param name="point"> The point from which the distances to the atoms are measured /// </param> /// <param name="atoms"> The atoms for which the distances to point are measured /// </param> public static void sortBy2DDistance(IAtom[] atoms, Point2d point) { double distance1; double distance2; IAtom atom1 = null; IAtom atom2 = null; bool doneSomething = false; do { doneSomething = false; for (int f = 0; f < atoms.Length - 1; f++) { atom1 = atoms[f]; atom2 = atoms[f + 1]; distance1 = point.distance(atom1.getPoint2d()); distance2 = point.distance(atom2.getPoint2d()); if (distance2 < distance1) { atoms[f] = atom2; atoms[f + 1] = atom1; doneSomething = true; } } } while (doneSomething); }
/// <summary> /// Returns true if the given atom already has been visited. /// </summary> /// <param name="atom"><see cref="IAtom"/> which may have been visited</param> /// <returns>true if the <see cref="IAtom"/> was visited</returns> public bool IsVisited(IAtom atom) { return(visitedItems.Contains(atom)); }
/// <summary> /// Grounds the specified atom by the given substitution and returns it. The "deep" version of terms grounding is used. /// </summary> /// <param name="atom">Function or predicate atom.</param> /// <param name="substitution">Variables substitution.</param> /// <param name="state">Reference state.</param> /// <returns>Grounded atom.</returns> public IAtom GroundAtomDeep(IAtom atom, ISubstitution substitution, IState state) { return(TermsAndAtomsGrounder.Value.GroundAtomDeep(atom, substitution, state)); }
/// <summary> Method that saturates an atom in a molecule by adding explicit hydrogens. /// In order to get coordinates for these Hydrogens, you need to /// remember the average bondlength of you molecule (coordinates for /// all atoms should be available) by using /// double bondLength = GeometryTools.getBondLengthAverage(atomContainer); /// and then use this method here and then use /// org.openscience.cdk.HydrogenPlacer(atomContainer, bondLength); /// /// </summary> /// <param name="atom"> Atom to saturate /// </param> /// <param name="container">AtomContainer containing the atom /// </param> /// <param name="totalContainer">In case you have a container containing multiple structures, this is the total container, whereas container is a partial structure /// /// </param> /// <cdk.keyword> hydrogen, adding </cdk.keyword> /// <cdk.keyword> explicit hydrogen </cdk.keyword> public virtual IAtomContainer addExplicitHydrogensToSatisfyValency(IAtomContainer container, IAtom atom, IAtomContainer totalContainer) { // set number of implicit hydrogens to zero // add explicit hydrogens //logger.debug("Start of addExplicitHydrogensToSatisfyValency(AtomContainer container, Atom atom)"); int missingHydrogens = valencyChecker.calculateNumberOfImplicitHydrogens(atom, container); //logger.debug("According to valencyChecker, " + missingHydrogens + " are missing"); IAtomContainer changedAtomsAndBonds = addExplicitHydrogensToSatisfyValency(container, atom, missingHydrogens, totalContainer); //logger.debug("End of addExplicitHydrogensToSatisfyValency(AtomContainer container, Atom atom)"); return changedAtomsAndBonds; }
/// <summary> /// Marks the given atom as visited. /// </summary> /// <param name="atom"><see cref="IAtom"/> that is now marked as visited</param> public void Visited(IAtom atom) { visitedItems.Add(atom); }
/// <summary> Method that saturates an atom in a molecule by adding implicit hydrogens. /// /// </summary> /// <param name="container"> Molecule to saturate /// </param> /// <param name="atom"> Atom to satureate. /// </param> /// <cdk.keyword> hydrogen, adding </cdk.keyword> /// <cdk.keyword> implicit hydrogen </cdk.keyword> public virtual int[] addImplicitHydrogensToSatisfyValency(IAtomContainer container, IAtom atom) { int formerHydrogens = atom.getHydrogenCount(); int missingHydrogens = valencyChecker.calculateNumberOfImplicitHydrogens(atom, container); atom.setHydrogenCount(missingHydrogens); int[] hydrogens = new int[2]; hydrogens[0] = formerHydrogens; hydrogens[1] = missingHydrogens; return hydrogens; }
public override void TestInitiate_IAtomContainerSet_IAtomContainerSet() { /* ionize >C=C< , set the reactive center */ IAtomContainer reactant = builder.NewAtomContainer();//CreateFromSmiles("C=CCC(=O)CC") reactant.Atoms.Add(builder.NewAtom("C")); reactant.Atoms.Add(builder.NewAtom("C")); reactant.Atoms.Add(builder.NewAtom("C")); reactant.Atoms.Add(builder.NewAtom("C")); reactant.Atoms.Add(builder.NewAtom("O")); reactant.Atoms.Add(builder.NewAtom("C")); reactant.Atoms.Add(builder.NewAtom("C")); reactant.AddBond(reactant.Atoms[0], reactant.Atoms[1], BondOrder.Double); reactant.AddBond(reactant.Atoms[1], reactant.Atoms[2], BondOrder.Single); reactant.AddBond(reactant.Atoms[2], reactant.Atoms[3], BondOrder.Single); reactant.AddBond(reactant.Atoms[3], reactant.Atoms[4], BondOrder.Double); reactant.AddBond(reactant.Atoms[3], reactant.Atoms[5], BondOrder.Single); reactant.AddBond(reactant.Atoms[5], reactant.Atoms[6], BondOrder.Single); AddExplicitHydrogens(reactant); foreach (var bond in reactant.Bonds) { IAtom atom1 = bond.Atoms[0]; IAtom atom2 = bond.Atoms[1]; if (bond.Order == BondOrder.Double && atom1.Symbol.Equals("C") && atom2.Symbol.Equals("C")) { bond.IsReactiveCenter = true; atom1.IsReactiveCenter = true; atom2.IsReactiveCenter = true; } } var setOfReactants = ChemObjectBuilder.Instance.NewAtomContainerSet(); setOfReactants.Add(reactant); /* initiate */ AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(reactant); MakeSureAtomTypesAreRecognized(reactant); var type = new ElectronImpactPDBReaction(); var paramList = new List <IParameterReaction>(); var param = new SetReactionCenter { IsSetParameter = true }; paramList.Add(param); type.ParameterList = paramList; var setOfReactions = type.Initiate(setOfReactants, null); Assert.AreEqual(2, setOfReactions.Count); IAtomContainer molecule = setOfReactions[0].Products[0]; Assert.AreEqual(1, molecule.Atoms[0].FormalCharge.Value); Assert.AreEqual(1, molecule.GetConnectedSingleElectrons(molecule.Atoms[1]).Count()); Assert.AreEqual(1, molecule.SingleElectrons.Count); molecule = setOfReactions[1].Products[0]; Assert.AreEqual(1, molecule.Atoms[1].FormalCharge.Value); Assert.AreEqual(1, molecule.GetConnectedSingleElectrons(molecule.Atoms[0]).Count()); Assert.AreEqual(1, molecule.SingleElectrons.Count); Assert.AreEqual(17, setOfReactions[0].Mappings.Count); }
/// <summary> Returns the atom of the given molecule that is closest to the given /// coordinates, using an external set of coordinates. /// See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets /// /// </summary> /// <param name="xPosition"> The x coordinate /// </param> /// <param name="yPosition"> The y coordinate /// </param> /// <param name="renderingCoordinates"> The set of coordinates to use coming from RendererModel2D /// </param> /// <returns> The atom that is closest to the given coordinates /// </returns> //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'" public static IAtom getClosestAtom(int xPosition, int yPosition, IChemModel model, IAtom ignore, System.Collections.Hashtable renderingCoordinates) { IAtom closestAtom = null; IAtom currentAtom; double smallestMouseDistance = -1; double mouseDistance; double atomX; double atomY; IAtomContainer all = ChemModelManipulator.getAllInOneContainer(model); for (int i = 0; i < all.AtomCount; i++) { currentAtom = all.getAtomAt(i); //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'" if (renderingCoordinates[currentAtom] == null && currentAtom.getPoint2d() != null) { renderingCoordinates[currentAtom] = new Point2d(currentAtom.getPoint2d().x, currentAtom.getPoint2d().y); } //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'" if (currentAtom != ignore && renderingCoordinates[currentAtom] != null) { //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'" atomX = ((Point2d)renderingCoordinates[currentAtom]).x; //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'" atomY = ((Point2d)renderingCoordinates[currentAtom]).y; mouseDistance = System.Math.Sqrt(System.Math.Pow(atomX - xPosition, 2) + System.Math.Pow(atomY - yPosition, 2)); if (mouseDistance < smallestMouseDistance || smallestMouseDistance == -1) { smallestMouseDistance = mouseDistance; closestAtom = currentAtom; } } } return closestAtom; }
/// <summary> /// Constructs a query bond with a single query bond order.. /// </summary> /// <param name="atom1">the first Atom in the query bond</param> /// <param name="atom2">the second Atom in the query bond</param> /// <param name="order"></param> public QueryBond(IAtom atom1, IAtom atom2, BondOrder order) : base(atom1, atom2, order) { }
/// <summary> Determines if this Atom contains 2D coordinates. /// See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets /// /// </summary> /// <param name="a"> Description of the Parameter /// </param> /// <returns> boolean indication that 2D coordinates are available /// </returns> public static bool has2DCoordinates(IAtom a) { return (a.getPoint2d() != null); }
/// <summary> /// Constructs a query bond with a given order and stereo orientation from an array of atoms. /// </summary> /// <param name="atom1">the first Atom in the query bond</param> /// <param name="atom2">the second Atom in the query bond</param> /// <param name="order">the query bond order</param> /// <param name="stereo">a descriptor the stereochemical orientation of this query bond</param> public QueryBond(IAtom atom1, IAtom atom2, BondOrder order, BondStereo stereo) { SetAtoms(new[] { atom1, atom2 }); this.order = order; this.stereo = stereo; }
/// <summary> Returns the atoms which are closes to an atom in an AtomContainer by /// distance in 3d. /// /// </summary> /// <param name="ac"> The AtomContainer to examine /// </param> /// <param name="a"> the atom to start from /// </param> /// <param name="max"> the number of neighbours to return /// </param> /// <returns> the average bond length /// </returns> /// <exception cref="CDKException"> Description of the Exception /// </exception> public static System.Collections.ArrayList findClosestInSpace(IAtomContainer ac, IAtom a, int max) { IAtom[] atoms = ac.Atoms; Point3d originalPoint = a.getPoint3d(); if (originalPoint == null) { throw new CDKException("No point3d, but findClosestInSpace is working on point3ds"); } //UPGRADE_TODO: Constructor 'java.util.TreeMap.TreeMap' was converted to 'System.Collections.SortedList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapTreeMap'" //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.TreeMap' and 'System.Collections.SortedList' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'" System.Collections.IDictionary hm = new System.Collections.SortedList(); for (int i = 0; i < atoms.Length; i++) { if (atoms[i] != a) { if (atoms[i].getPoint3d() == null) { throw new CDKException("No point3d, but findClosestInSpace is working on point3ds"); } double distance = atoms[i].getPoint3d().distance(originalPoint); hm[(double)distance] = atoms[i]; } } //UPGRADE_TODO: Method 'java.util.Map.keySet' was converted to 'CSGraphT.SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilMapkeySet'" CSGraphT.SupportClass.SetSupport ks = new CSGraphT.SupportClass.HashSetSupport(hm.Keys); System.Collections.IEnumerator it = ks.GetEnumerator(); System.Collections.ArrayList returnValue = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); int i2 = 0; //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" while (it.MoveNext() && i2 < max) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" returnValue.Add(hm[it.Current]); i2++; } return (returnValue); }
/// <summary> Procedure required by the CDOInterface. This function is only /// supposed to be called by the JCFL library /// </summary> public virtual void startObject(System.String objectType) { //logger.debug("START:" + objectType); if (objectType.Equals("Molecule")) { if (currentChemModel == null) { currentChemModel = currentChemFile.Builder.newChemModel(); } if (currentSetOfMolecules == null) { currentSetOfMolecules = currentChemFile.Builder.newSetOfMolecules(); } currentMolecule = currentChemFile.Builder.newMolecule(); } else if (objectType.Equals("Atom")) { currentAtom = currentChemFile.Builder.newAtom("H"); //logger.debug("Atom # " + numberOfAtoms); numberOfAtoms++; } else if (objectType.Equals("Bond")) { bond_id = null; bond_stereo = -99; } else if (objectType.Equals("Animation")) { currentChemSequence = currentChemFile.Builder.newChemSequence(); } else if (objectType.Equals("Frame")) { currentChemModel = currentChemFile.Builder.newChemModel(); } else if (objectType.Equals("SetOfMolecules")) { currentSetOfMolecules = currentChemFile.Builder.newSetOfMolecules(); currentMolecule = currentChemFile.Builder.newMolecule(); } else if (objectType.Equals("Crystal")) { currentMolecule = currentChemFile.Builder.newCrystal(currentMolecule); } else if (objectType.Equals("a-axis") || objectType.Equals("b-axis") || objectType.Equals("c-axis")) { crystal_axis_x = 0.0; crystal_axis_y = 0.0; crystal_axis_z = 0.0; } else if (objectType.Equals("SetOfReactions")) { currentSetOfReactions = currentChemFile.Builder.newSetOfReactions(); } else if (objectType.Equals("Reaction")) { if (currentSetOfReactions == null) { startObject("SetOfReactions"); } currentReaction = currentChemFile.Builder.newReaction(); } else if (objectType.Equals("Reactant")) { if (currentReaction == null) { startObject("Reaction"); } currentMolecule = currentChemFile.Builder.newMolecule(); } else if (objectType.Equals("Product")) { if (currentReaction == null) { startObject("Reaction"); } currentMolecule = currentChemFile.Builder.newMolecule(); } }
/// <summary> Rotates a 3D point about a specified line segment by a specified angle. /// /// The code is based on code available <a href="http://astronomy.swin.edu.au/~pbourke/geometry/rotate/source.c">here</a>. /// Positive angles are anticlockwise looking down the axis towards the origin. /// Assume right hand coordinate system. /// /// </summary> /// <param name="atom">The atom to rotate /// </param> /// <param name="p1"> The first point of the line segment /// </param> /// <param name="p2"> The second point of the line segment /// </param> /// <param name="angle"> The angle to rotate by (in degrees) /// </param> public static void rotate(IAtom atom, Point3d p1, Point3d p2, double angle) { double costheta, sintheta; Point3d r = new Point3d(); r.x = p2.x - p1.x; r.y = p2.y - p1.y; r.z = p2.z - p1.z; normalize(r); angle = angle * System.Math.PI / 180.0; costheta = System.Math.Cos(angle); sintheta = System.Math.Sin(angle); Point3d p = atom.getPoint3d(); p.x -= p1.x; p.y -= p1.y; p.z -= p1.z; Point3d q = new Point3d(0, 0, 0); q.x += (costheta + (1 - costheta) * r.x * r.x) * p.x; q.x += ((1 - costheta) * r.x * r.y - r.z * sintheta) * p.y; q.x += ((1 - costheta) * r.x * r.z + r.y * sintheta) * p.z; q.y += ((1 - costheta) * r.x * r.y + r.z * sintheta) * p.x; q.y += (costheta + (1 - costheta) * r.y * r.y) * p.y; q.y += ((1 - costheta) * r.y * r.z - r.x * sintheta) * p.z; q.z += ((1 - costheta) * r.x * r.z - r.y * sintheta) * p.x; q.z += ((1 - costheta) * r.y * r.z + r.x * sintheta) * p.y; q.z += (costheta + (1 - costheta) * r.z * r.z) * p.z; q.x += p1.x; q.y += p1.y; q.z += p1.z; atom.setPoint3d(q); }
/// <summary> Procedure required by the CDOInterface. This function is only /// supposed to be called by the JCFL library /// </summary> public virtual void endObject(System.String objectType) { //logger.debug("END: " + objectType); if (objectType.Equals("Molecule")) { if (currentMolecule is IMolecule) { //logger.debug("Adding molecule to set"); currentSetOfMolecules.addMolecule((IMolecule)currentMolecule); //logger.debug("#mols in set: " + currentSetOfMolecules.MoleculeCount); } else if (currentMolecule is ICrystal) { //logger.debug("Adding crystal to chemModel"); currentChemModel.Crystal = (ICrystal)currentMolecule; currentChemSequence.addChemModel(currentChemModel); } } else if (objectType.Equals("SetOfMolecules")) { currentChemModel.SetOfMolecules = currentSetOfMolecules; currentChemSequence.addChemModel(currentChemModel); } else if (objectType.Equals("Frame")) { // endObject("Molecule"); } else if (objectType.Equals("Animation")) { addChemSequence(currentChemSequence); //logger.info("This file has " + ChemSequenceCount + " sequence(s)."); } else if (objectType.Equals("Atom")) { currentMolecule.addAtom(currentAtom); } else if (objectType.Equals("Bond")) { //logger.debug("Bond(" + bond_id + "): " + bond_a1 + ", " + bond_a2 + ", " + bond_order); if (bond_a1 > currentMolecule.AtomCount || bond_a2 > currentMolecule.AtomCount) { //logger.error("Cannot add bond between at least one non-existant atom: " + bond_a1 + " and " + bond_a2); } else { IAtom a1 = currentMolecule.getAtomAt(bond_a1); IAtom a2 = currentMolecule.getAtomAt(bond_a2); IBond b = currentChemFile.Builder.newBond(a1, a2, bond_order); if (bond_id != null) { b.ID = bond_id; } if (bond_stereo != -99) { b.Stereo = bond_stereo; } if (bond_order == CDKConstants.BONDORDER_AROMATIC) { b.setFlag(CDKConstants.ISAROMATIC, true); } currentMolecule.addBond(b); } } else if (objectType.Equals("a-axis")) { // set these variables if (currentMolecule is ICrystal) { ICrystal current = (ICrystal)currentMolecule; current.A = new Vector3d(crystal_axis_x, crystal_axis_y, crystal_axis_z); } else { //logger.warn("Current object is not a crystal"); } } else if (objectType.Equals("b-axis")) { if (currentMolecule is ICrystal) { ICrystal current = (ICrystal)currentMolecule; current.B = new Vector3d(crystal_axis_x, crystal_axis_y, crystal_axis_z); } else { //logger.warn("Current object is not a crystal"); } } else if (objectType.Equals("c-axis")) { if (currentMolecule is ICrystal) { ICrystal current = (ICrystal)currentMolecule; current.C = new Vector3d(crystal_axis_x, crystal_axis_y, crystal_axis_z); } else { //logger.warn("Current object is not a crystal"); } } else if (objectType.Equals("SetOfReactions")) { currentChemModel.SetOfReactions = currentSetOfReactions; currentChemSequence.addChemModel(currentChemModel); /* FIXME: this should be when document is closed! */ } else if (objectType.Equals("Reaction")) { //logger.debug("Adding reaction to SOR"); currentSetOfReactions.addReaction(currentReaction); } else if (objectType.Equals("Reactant")) { currentReaction.addReactant((IMolecule)currentMolecule); } else if (objectType.Equals("Product")) { currentReaction.addProduct((IMolecule)currentMolecule); } else if (objectType.Equals("Crystal")) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //logger.debug("Crystal: " + currentMolecule); } }
/// <summary> Calculates the center of the given atoms and returns it as a Point2d /// See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets /// /// </summary> /// <param name="atoms"> The vector of the given atoms /// </param> /// <returns> The center of the given atoms as Point2d /// </returns> public static Point2d get2DCenter(IAtom[] atoms) { IAtom atom; double x = 0; double y = 0; for (int f = 0; f < atoms.Length; f++) { atom = (IAtom)atoms[f]; if (atom.getPoint2d() != null) { x += atom.X2d; y += atom.Y2d; } } return new Point2d(x / (double)atoms.Length, y / (double)atoms.Length); }
/// <summary> Procedure required by the CDOInterface. This function is only /// supposed to be called by the JCFL library /// </summary> public virtual void setObjectProperty(System.String objectType, System.String propertyType, System.String propertyValue) { //logger.debug("objectType: " + objectType); //logger.debug("propType: " + propertyType); //logger.debug("property: " + propertyValue); if (objectType == null) { //logger.error("Cannot add property for null object"); return; } if (propertyType == null) { //logger.error("Cannot add property for null property type"); return; } if (propertyValue == null) { //logger.warn("Will not add null property"); return; } if (objectType.Equals("Molecule")) { if (propertyType.Equals("id")) { currentMolecule.ID = propertyValue; } else if (propertyType.Equals("inchi")) { currentMolecule.setProperty("iupac.nist.chemical.identifier", propertyValue); } else if (propertyType.Equals("pdb:residueName")) { currentMolecule.setProperty(new DictRef(propertyType, propertyValue), propertyValue); } else if (propertyType.Equals("pdb:oneLetterCode")) { currentMolecule.setProperty(new DictRef(propertyType, propertyValue), propertyValue); } else if (propertyType.Equals("pdb:id")) { currentMolecule.setProperty(new DictRef(propertyType, propertyValue), propertyValue); } else { //logger.warn("Not adding molecule property!"); } } else if (objectType.Equals("PseudoAtom")) { if (propertyType.Equals("label")) { if (!(currentAtom is IPseudoAtom)) { currentAtom = currentChemFile.Builder.newPseudoAtom(currentAtom); } ((IPseudoAtom)currentAtom).Label = propertyValue; } } else if (objectType.Equals("Atom")) { if (propertyType.Equals("type")) { if (propertyValue.Equals("R") && !(currentAtom is IPseudoAtom)) { currentAtom = currentChemFile.Builder.newPseudoAtom(currentAtom); } currentAtom.Symbol = propertyValue; } else if (propertyType.Equals("x2")) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" currentAtom.X2d = System.Double.Parse(propertyValue); } else if (propertyType.Equals("y2")) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" currentAtom.Y2d = System.Double.Parse(propertyValue); } else if (propertyType.Equals("x3")) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" currentAtom.X3d = System.Double.Parse(propertyValue); } else if (propertyType.Equals("y3")) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" currentAtom.Y3d = System.Double.Parse(propertyValue); } else if (propertyType.Equals("z3")) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" currentAtom.Z3d = System.Double.Parse(propertyValue); } else if (propertyType.Equals("xFract")) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" currentAtom.FractX3d = System.Double.Parse(propertyValue); } else if (propertyType.Equals("yFract")) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" currentAtom.FractY3d = System.Double.Parse(propertyValue); } else if (propertyType.Equals("zFract")) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" currentAtom.FractZ3d = System.Double.Parse(propertyValue); } else if (propertyType.Equals("formalCharge")) { currentAtom.setFormalCharge(System.Int32.Parse(propertyValue)); } else if (propertyType.Equals("charge") || propertyType.Equals("partialCharge")) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" currentAtom.setCharge(System.Double.Parse(propertyValue)); } else if (propertyType.Equals("hydrogenCount")) { currentAtom.setHydrogenCount(System.Int32.Parse(propertyValue)); } else if (propertyType.Equals("dictRef")) { currentAtom.setProperty("org.openscience.cdk.dict", propertyValue); } else if (propertyType.Equals("atomicNumber")) { currentAtom.AtomicNumber = System.Int32.Parse(propertyValue); } else if (propertyType.Equals("massNumber")) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" currentAtom.MassNumber = (int)(System.Double.Parse(propertyValue)); } else if (propertyType.Equals("spinMultiplicity")) { int unpairedElectrons = System.Int32.Parse(propertyValue) - 1; for (int i = 0; i < unpairedElectrons; i++) { currentMolecule.addElectronContainer(currentChemFile.Builder.newSingleElectron(currentAtom)); } } else if (propertyType.Equals("id")) { //logger.debug("id: ", propertyValue); currentAtom.ID = propertyValue; atomEnumeration[propertyValue] = (System.Int32)numberOfAtoms; } } else if (objectType.Equals("Bond")) { if (propertyType.Equals("atom1")) { bond_a1 = System.Int32.Parse(propertyValue); } else if (propertyType.Equals("atom2")) { bond_a2 = System.Int32.Parse(propertyValue); } else if (propertyType.Equals("id")) { //logger.debug("id: " + propertyValue); bond_id = propertyValue; } else if (propertyType.Equals("order")) { try { bond_order = System.Double.Parse(propertyValue); } catch (System.Exception e) { //logger.error("Cannot convert to double: " + propertyValue); bond_order = 1.0; } } else if (propertyType.Equals("stereo")) { if (propertyValue.Equals("H")) { bond_stereo = CDKConstants.STEREO_BOND_DOWN; } else if (propertyValue.Equals("W")) { bond_stereo = CDKConstants.STEREO_BOND_UP; } } } else if (objectType.Equals("Reaction")) { if (propertyType.Equals("id")) { currentReaction.ID = propertyValue; } } else if (objectType.Equals("SetOfReactions")) { if (propertyType.Equals("id")) { currentSetOfReactions.ID = propertyValue; } } else if (objectType.Equals("Reactant")) { if (propertyType.Equals("id")) { currentMolecule.ID = propertyValue; } } else if (objectType.Equals("Product")) { if (propertyType.Equals("id")) { currentMolecule.ID = propertyValue; } } else if (objectType.Equals("Crystal")) { // set these variables if (currentMolecule is ICrystal) { ICrystal current = (ICrystal)currentMolecule; if (propertyType.Equals("spacegroup")) { //logger.debug("Setting crystal spacegroup to: " + propertyValue); current.SpaceGroup = propertyValue; } else if (propertyType.Equals("z")) { try { //logger.debug("Setting z to: " + propertyValue); current.Z = System.Int32.Parse(propertyValue); } catch (System.FormatException exception) { //logger.error("Error in format of Z value"); } } } else { //logger.warn("Cannot add crystal cell parameters to a non " + "Crystal class!"); } } else if (objectType.Equals("a-axis") || objectType.Equals("b-axis") || objectType.Equals("c-axis")) { // set these variables if (currentMolecule is ICrystal) { //logger.debug("Setting axis (" + objectType + "): " + propertyValue); if (propertyType.Equals("x")) { crystal_axis_x = System.Double.Parse(propertyValue); } else if (propertyType.Equals("y")) { crystal_axis_y = System.Double.Parse(propertyValue); } else if (propertyType.Equals("z")) { crystal_axis_z = System.Double.Parse(propertyValue); } } else { //logger.warn("Cannot add crystal cell parameters to a non " + "Crystal class!"); } } //logger.debug("Object property set..."); }
public TupleAtom(IAtom atom) { this.atom = atom; }
/// <inheritdoc/> public IAtom GetConnectedAtom(IAtom atom) { return(bond.GetConnectedAtom(atom)); }
/// <summary> Constructs an completely unset AtomParity. /// /// </summary> /// <param name="centralAtom">Atom for which the parity is defined /// </param> /// <param name="first"> First Atom of four that define the stereochemistry /// </param> /// <param name="second"> Second Atom of four that define the stereochemistry /// </param> /// <param name="third"> Third Atom of four that define the stereochemistry /// </param> /// <param name="fourth"> Fourth Atom of four that define the stereochemistry /// </param> /// <param name="parity"> +1 or -1, defining the parity /// </param> public AtomParity(IAtom centralAtom, IAtom first, IAtom second, IAtom third, IAtom fourth, int parity) { this.centralAtom = centralAtom; this.neighbors = new Atom[4]; this.neighbors[0] = first; this.neighbors[1] = second; this.neighbors[2] = third; this.neighbors[3] = fourth; this.parity = parity; }
/// <inheritdoc/> public virtual IAtom GetOther(IAtom atom) { return(bond.GetOther(atom)); }