public void TestBondProperty() { string[] key = { "customBondProperty1", "customBondProperty2" }; string[] value = { "true", "false" }; IAtomContainer mol = TestMoleculeFactory.MakeBenzene(); foreach (var b in mol.Bonds) { for (int i = 0; i < key.Length; i++) { b.SetProperty(key[i], value[i]); } } IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); //Assert.AreEqual(convertor.CDKMoleculeToCMLMolecule(mol).ToXML(), // convertor.CDKMoleculeToCMLMolecule(roundTrippedMol).ToXML()); foreach (var b in roundTrippedMol.Bonds) { for (int i = 0; i < key.Length; i++) { var actual = b.GetProperty <object>(key[i]); Assert.IsNotNull(actual); Assert.AreEqual(value[i], actual); } } }
public void TestBondAromatic_Double() { var mol = new AtomContainer(); // surely, this bond is not aromatic... but fortunately, file formats do not care about chemistry Atom atom = new Atom("C"); Atom atom2 = new Atom("C"); mol.Atoms.Add(atom); mol.Atoms.Add(atom2); Bond bond = new Bond(atom, atom2, BondOrder.Double) { IsAromatic = true }; mol.Bonds.Add(bond); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(2, roundTrippedMol.Atoms.Count); Assert.AreEqual(1, roundTrippedMol.Bonds.Count); IBond roundTrippedBond = roundTrippedMol.Bonds[0]; Assert.AreEqual(bond.IsAromatic, roundTrippedBond.IsAromatic); Assert.AreEqual(bond.Order, roundTrippedBond.Order); }
public void TestIElement_Symbol() { IAtomContainer mol = builder.NewAtomContainer(); IAtom atom = builder.NewAtom("C"); atom.Id = "a1"; mol.Atoms.Add(atom); IAtomContainer copy = CMLRoundTripTool.RoundTripMolecule(convertor, mol); string difference = AtomDiff.Diff(atom, copy.Atoms[0]); Assert.AreEqual(0, difference.Length, "Found non-zero diff: " + difference); }
public void TestInChI() { var mol = new AtomContainer(); string inchi = "InChI=1/CH2O2/c2-1-3/h1H,(H,2,3)"; mol.SetProperty(CDKPropertyName.InChI, inchi); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.IsNotNull(roundTrippedMol); Assert.AreEqual(inchi, roundTrippedMol.GetProperty <string>(CDKPropertyName.InChI)); }
public void TestIAtom_FractionalPoint3d() { IAtomContainer mol = builder.NewAtomContainer(); IAtom atom = builder.NewAtom("C"); atom.Id = "a1"; atom.FractionalPoint3D = new Vector3(1, 2, 3); mol.Atoms.Add(atom); IAtomContainer copy = CMLRoundTripTool.RoundTripMolecule(convertor, mol); string difference = AtomDiff.Diff(atom, copy.Atoms[0]); Assert.AreEqual(0, difference.Length, "Found non-zero diff: " + difference); }
public void TestAtom() { var mol = new AtomContainer(); Atom atom = new Atom("N"); mol.Atoms.Add(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(1, roundTrippedMol.Atoms.Count); IAtom roundTrippedAtom = roundTrippedMol.Atoms[0]; Assert.AreEqual(atom.Symbol, roundTrippedAtom.Symbol); }
public void TestIsotope() { var mol = new AtomContainer(); Atom atom = new Atom("C") { MassNumber = 13 }; mol.Atoms.Add(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(1, roundTrippedMol.Atoms.Count); IAtom roundTrippedAtom = roundTrippedMol.Atoms[0]; Assert.AreEqual(atom.MassNumber, roundTrippedAtom.MassNumber); }
[TestMethod(), Ignore()] // Have to figure out how to store atom parity in CML2 public void TestAtomStereoParity() { var mol = new AtomContainer(); Atom atom = new Atom("C"); var stereo = StereoAtomParities.Plus; atom.StereoParity = stereo; mol.Atoms.Add(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(1, roundTrippedMol.Atoms.Count); IAtom roundTrippedAtom = roundTrippedMol.Atoms[0]; Assert.AreEqual(atom.StereoParity, roundTrippedAtom.StereoParity); }
[TestMethod(), Ignore()] // Have to figure out how to store partial charges in CML2 public void TestAtomPartialCharge() { var mol = new AtomContainer(); Atom atom = new Atom("N"); double partialCharge = 0.5; atom.Charge = partialCharge; mol.Atoms.Add(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(1, roundTrippedMol.Atoms.Count); IAtom roundTrippedAtom = roundTrippedMol.Atoms[0]; Assert.AreEqual(atom.Charge.Value, roundTrippedAtom.Charge.Value, 0.0001); }
public void TestAtomFormalCharge() { var mol = new AtomContainer(); Atom atom = new Atom("N"); int formalCharge = +1; atom.FormalCharge = formalCharge; mol.Atoms.Add(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(1, roundTrippedMol.Atoms.Count); IAtom roundTrippedAtom = roundTrippedMol.Atoms[0]; Assert.AreEqual(atom.FormalCharge, roundTrippedAtom.FormalCharge); }
public void TestAtomFract3D() { var mol = new AtomContainer(); Atom atom = new Atom("N"); Vector3 p3d = new Vector3(0.3, 0.4, 0.9); atom.FractionalPoint3D = p3d; mol.Atoms.Add(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(1, roundTrippedMol.Atoms.Count); IAtom roundTrippedAtom = roundTrippedMol.Atoms[0]; base.AssertAreEqual(atom.Point3D, roundTrippedAtom.Point3D, 0.00001); }
public void TestAtom2D() { var mol = new AtomContainer(); Atom atom = new Atom("N"); Vector2 p2d = new Vector2(1.3, 1.4); atom.Point2D = p2d; mol.Atoms.Add(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(1, roundTrippedMol.Atoms.Count); IAtom roundTrippedAtom = roundTrippedMol.Atoms[0]; base.AssertAreEqual(atom.Point2D, roundTrippedAtom.Point2D, 0.00001); }
public void TestAtomAromaticity() { IAtomContainer molecule = TestMoleculeFactory.MakeBenzene(); foreach (var atom in molecule.Atoms) { atom.IsAromatic = true; } IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, molecule); foreach (var atom in roundTrippedMol.Atoms) { Assert.IsTrue(atom.IsAromatic); } }
public void TestSpinMultiplicity() { var mol = new AtomContainer(); Atom atom = new Atom("C"); mol.Atoms.Add(atom); mol.SingleElectrons.Add(new SingleElectron(atom)); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(1, roundTrippedMol.Atoms.Count); Assert.AreEqual(1, roundTrippedMol.GetElectronContainers().Count()); IAtom roundTrippedAtom = roundTrippedMol.Atoms[0]; Assert.AreEqual(1, roundTrippedMol.GetConnectedSingleElectrons(roundTrippedAtom).Count()); }
public void TestHydrogenCount_UNSET() { var mol = new AtomContainer(); Atom atom = new Atom("N") { ImplicitHydrogenCount = null }; mol.Atoms.Add(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(1, roundTrippedMol.Atoms.Count); IAtom roundTrippedAtom = roundTrippedMol.Atoms[0]; Assert.AreEqual(null, roundTrippedAtom.ImplicitHydrogenCount); }
[TestMethod(), Ignore()] // Functionality not yet implemented - natural abundance can not be written/read public void TestIsotope_Abundance() { var mol = new AtomContainer(); Atom atom = new Atom("C") { Abundance = 1.0 }; mol.Atoms.Add(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(1, roundTrippedMol.Atoms.Count); IAtom roundTrippedAtom = roundTrippedMol.Atoms[0]; Assert.IsNotNull(atom.Abundance); Assert.IsNotNull(roundTrippedAtom.Abundance); Assert.AreEqual(atom.Abundance.Value, roundTrippedAtom.Abundance.Value, 0.01); }
public void TestMoleculeSet() { var list = new ChemObjectSet <IAtomContainer> { new AtomContainer(), new AtomContainer() }; var model = new ChemModel { MoleculeSet = list }; IChemModel roundTripped = CMLRoundTripTool.RoundTripChemModel(convertor, model); var newList = roundTripped.MoleculeSet; Assert.IsNotNull(newList); Assert.AreEqual(2, newList.Count()); Assert.IsNotNull(newList[0]); Assert.IsNotNull(newList[1]); }
public void TestPseudoAtom() { var mol = new AtomContainer(); PseudoAtom atom = new PseudoAtom("N") { Label = "Glu55" }; mol.Atoms.Add(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(1, roundTrippedMol.Atoms.Count); IAtom roundTrippedAtom = roundTrippedMol.Atoms[0]; Assert.IsNotNull(roundTrippedAtom); Assert.IsTrue(roundTrippedAtom is IPseudoAtom); Assert.AreEqual("Glu55", ((IPseudoAtom)roundTrippedAtom).Label); }
public void TestAromaticity() { IAtomContainer molecule = TestMoleculeFactory.MakeBenzene(); foreach (var bond in molecule.Bonds) { bond.IsAromatic = true; } IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, molecule); var bonds = roundTrippedMol.Bonds; double orderSum = BondManipulator.GetSingleBondEquivalentSum(bonds); foreach (var bond in bonds) { Assert.IsTrue(bond.IsAromatic); } Assert.AreEqual(9.0, orderSum, 0.001); }
public void TestDescriptorValue() { IAtomContainer molecule = TestMoleculeFactory.MakeBenzene(); string[] propertyName = { "testKey1", "testKey2" }; string[] propertyValue = { "testValue1", "testValue2" }; for (int i = 0; i < propertyName.Length; i++) { molecule.SetProperty(propertyName[i], propertyValue[i]); } IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, molecule); for (int i = 0; i < propertyName.Length; i++) { Assert.IsNotNull(roundTrippedMol.GetProperty <string>(propertyName[i])); Assert.AreEqual(propertyValue[i], roundTrippedMol.GetProperty <string>(propertyName[i])); } }
public void TestBondID() { var mol = new AtomContainer(); Atom atom = new Atom("C"); Atom atom2 = new Atom("O"); mol.Atoms.Add(atom); mol.Atoms.Add(atom2); Bond bond = new Bond(atom, atom2, BondOrder.Single) { Id = "b1" }; mol.Bonds.Add(bond); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); IBond roundTrippedBond = roundTrippedMol.Bonds[0]; Assert.AreEqual(bond.Id, roundTrippedBond.Id); }
public void TestChemModel() { ChemModel model = new ChemModel(); var moleculeSet = new ChemObjectSet <IAtomContainer>(); var mol = new AtomContainer(); PseudoAtom atom = new PseudoAtom("N"); mol.Atoms.Add(atom); moleculeSet.Add(mol); model.MoleculeSet = moleculeSet; IChemModel roundTrippedModel = CMLRoundTripTool.RoundTripChemModel(convertor, model); var roundTrippedMolSet = roundTrippedModel.MoleculeSet; Assert.IsNotNull(roundTrippedMolSet); Assert.AreEqual(1, roundTrippedMolSet.Count); IAtomContainer roundTrippedMolecule = roundTrippedMolSet[0]; Assert.IsNotNull(roundTrippedMolecule); Assert.AreEqual(1, roundTrippedMolecule.Atoms.Count); }
public void TestBondStereo() { var mol = new AtomContainer(); Atom atom = new Atom("C"); Atom atom2 = new Atom("O"); mol.Atoms.Add(atom); mol.Atoms.Add(atom2); Bond bond = new Bond(atom, atom2, BondOrder.Single); BondStereo stereo = BondStereo.Down; bond.Stereo = stereo; mol.Bonds.Add(bond); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(2, roundTrippedMol.Atoms.Count); Assert.AreEqual(1, roundTrippedMol.Bonds.Count); IBond roundTrippedBond = roundTrippedMol.Bonds[0]; Assert.AreEqual(bond.Stereo, roundTrippedBond.Stereo); }
public void TestBond() { var mol = new AtomContainer(); Atom atom = new Atom("C"); Atom atom2 = new Atom("O"); mol.Atoms.Add(atom); mol.Atoms.Add(atom2); Bond bond = new Bond(atom, atom2, BondOrder.Single); mol.Bonds.Add(bond); IAtomContainer roundTrippedMol = CMLRoundTripTool.RoundTripMolecule(convertor, mol); Assert.AreEqual(2, roundTrippedMol.Atoms.Count); Assert.AreEqual(1, roundTrippedMol.Bonds.Count); IBond roundTrippedBond = roundTrippedMol.Bonds[0]; Assert.AreEqual(2, roundTrippedBond.Atoms.Count); Assert.AreEqual("C", roundTrippedBond.Begin.Symbol); // preserved direction? Assert.AreEqual("O", roundTrippedBond.End.Symbol); Assert.AreEqual(bond.Order, roundTrippedBond.Order); }
public void TestReaction() { Debug.WriteLine("********** TEST REACTION **********"); IReaction reaction = new Reaction { Id = "reaction.1" }; IAtomContainer reactant = reaction.Builder.NewAtomContainer(); reactant.Id = "react"; IAtom atom = reaction.Builder.NewAtom("C"); reactant.Atoms.Add(atom); reaction.Reactants.Add(reactant); IAtomContainer product = reaction.Builder.NewAtomContainer(); product.Id = "product"; atom = reaction.Builder.NewAtom("R"); product.Atoms.Add(atom); reaction.Products.Add(product); IAtomContainer agent = reaction.Builder.NewAtomContainer(); agent.Id = "water"; atom = reaction.Builder.NewAtom("H"); agent.Atoms.Add(atom); reaction.Agents.Add(agent); IReaction roundTrippedReaction = CMLRoundTripTool.RoundTripReaction(convertor, reaction); Assert.IsNotNull(roundTrippedReaction); Assert.AreEqual("reaction.1", roundTrippedReaction.Id); Assert.IsNotNull(roundTrippedReaction); var reactants = roundTrippedReaction.Reactants; Assert.IsNotNull(reactants); Assert.AreEqual(1, reactants.Count); IAtomContainer roundTrippedReactant = reactants[0]; Assert.AreEqual("react", roundTrippedReactant.Id); Assert.AreEqual(1, roundTrippedReactant.Atoms.Count); var products = roundTrippedReaction.Products; Assert.IsNotNull(products); Assert.AreEqual(1, products.Count); IAtomContainer roundTrippedProduct = products[0]; Assert.AreEqual("product", roundTrippedProduct.Id); Assert.AreEqual(1, roundTrippedProduct.Atoms.Count); var agents = roundTrippedReaction.Agents; Assert.IsNotNull(agents); Assert.AreEqual(1, agents.Count); IAtomContainer roundTrippedAgent = agents[0]; Assert.AreEqual("water", roundTrippedAgent.Id); Assert.AreEqual(1, roundTrippedAgent.Atoms.Count); }