public void TestMixedNamespaces() { var ins = ResourceLoader.GetAsStream(this.GetType(), "US06358966-20020319-C00001-enr.cml"); var reader = new CMLReader(ins); try { IChemFile cfile = reader.Read(ChemObjectBuilder.Instance.NewChemFile()); Assert.AreEqual(34, ChemFileManipulator.GetAtomCount(cfile)); Assert.AreEqual(39, ChemFileManipulator.GetBondCount(cfile)); } finally { reader.Close(); } }
public void TestObjectCountsChemFile(IChemFile chemFile, int chemSequenceCount, int chemModelCount, int moleculeCount, int atomCount, int strandCount, int monomerCount, int structureCount) { var container = GetFirstAtomContainer(chemFile, chemSequenceCount, chemModelCount, moleculeCount); Assert.IsTrue(container is IBioPolymer); var polymer = (IBioPolymer)container; // chemical validation Assert.AreEqual(atomCount, ChemFileManipulator.GetAtomCount(chemFile)); Assert.AreEqual(strandCount, polymer.GetStrandMap().Count); Assert.AreEqual(monomerCount, polymer.GetMonomerMap().Count()); Assert.IsTrue(polymer is IPDBPolymer); var pdb = (IPDBPolymer)polymer; // PDB validation Assert.AreEqual(structureCount, pdb.GetStructures().Count()); }
void AssertAtomCount(int expectedAtomCount, IChemObject chemObject) { if (expectedAtomCount != -1) { if (chemObject is IChemFile) { Assert.AreEqual(expectedAtomCount, ChemFileManipulator.GetAtomCount((IChemFile)chemObject)); } else if (chemObject is IChemModel) { Assert.AreEqual(expectedAtomCount, ChemModelManipulator.GetAtomCount((IChemModel)chemObject)); } else if (chemObject is IAtomContainer) { Assert.AreEqual(expectedAtomCount, ((IAtomContainer)chemObject).Atoms.Count); } else if (chemObject is IReaction) { Assert.AreEqual(expectedAtomCount, ReactionManipulator.GetAtomCount((IReaction)chemObject)); } } }
public void Test114D() { var filename = "NCDK.Data.PDB.114D.pdb"; var ins = ResourceLoader.GetAsStream(filename); var reader = new PDBReader(ins); Assert.IsNotNull(reader); var chemFile = (IChemFile)reader.Read(builder.NewChemFile()); Assert.IsNotNull(chemFile); Assert.AreEqual(1, chemFile.Count); var seq = chemFile[0]; Assert.IsNotNull(seq); Assert.AreEqual(1, seq.Count); var model = seq[0]; Assert.IsNotNull(model); Assert.AreEqual(1, model.MoleculeSet.Count()); var container = model.MoleculeSet[0]; Assert.IsTrue(container is IBioPolymer); var polymer = (IBioPolymer)container; Assert.IsTrue(polymer.GetStrand("A") is IPDBStrand, "Strand A is not a PDBStrand"); var strandA = (IPDBStrand)polymer.GetStrand("A"); var lst = strandA.GetMonomerNamesInSequentialOrder().GetEnumerator(); lst.MoveNext(); var monomer1 = lst.Current; var mono1 = strandA.GetMonomer(monomer1); Assert.IsNotNull(mono1); Assert.IsNotNull(mono1.MonomerName); Assert.IsTrue(mono1 is IPDBMonomer, "Monomer is not a PDBMonomer"); var pdbMonomer = (IPDBMonomer)mono1; Assert.AreEqual(pdbMonomer.ResSeq, "1"); lst.MoveNext(); var monomer2 = lst.Current; var mono2 = strandA.GetMonomer(monomer2); Assert.IsTrue(mono2 is IPDBMonomer, "Monomer is not a PDBMonomer"); var pdbMonomer2 = (IPDBMonomer)mono2; Assert.AreEqual(pdbMonomer2.ResSeq, "2"); // chemical validation Assert.AreEqual(552, ChemFileManipulator.GetAtomCount(chemFile)); Assert.AreEqual(2, polymer.GetStrandMap().Count()); Assert.AreEqual(24, polymer.GetMonomerMap().Count()); Assert.IsTrue(polymer.GetStrandNames().Contains("A")); Assert.IsTrue(polymer.GetStrandNames().Contains("B")); Assert.IsFalse(polymer.GetStrandNames().Contains("C")); Assert.AreEqual(24, polymer.GetMonomerMap().Count()); Assert.IsTrue(polymer is IPDBPolymer); var pdb = (IPDBPolymer)polymer; // PDB validation Assert.AreEqual(0, pdb.GetStructures().Count()); }