public void DoTestOlderProteomeDb(TestContext testContext, bool doActualWebAccess) { using (var testFilesDir = new TestFilesDir(testContext, ZIP_FILE)) { string fastaPath = testFilesDir.GetTestPath("tiny.fasta"); string protDbPath = testFilesDir.GetTestPath("celegans_mini.protdb"); // a version 0 protdb file string blibPath = testFilesDir.GetTestPath("random.blib"); // a bibliospec file // What happens when you try to open a random file as a protdb file? AssertEx.ThrowsException <DbException>(() => ProteomeDb.OpenProteomeDb(fastaPath)); // What happens when you try to open a non-protdb database file as a protdb file? AssertEx.ThrowsException <FileLoadException>(() => ProteomeDb.OpenProteomeDb(blibPath)); using (ProteomeDb proteomeDb = ProteomeDb.OpenProteomeDb(protDbPath)) { Assert.IsTrue(proteomeDb.GetSchemaVersionMajor() == 0); // the initial db from our zipfile should be ancient Assert.IsTrue(proteomeDb.GetSchemaVersionMinor() == 0); // the initial db from our zipfile should be ancient Assert.AreEqual(9, proteomeDb.GetProteinCount()); var protein = proteomeDb.GetProteinByName("Y18D10A.20"); Assert.IsNotNull(protein); Assert.IsTrue(String.IsNullOrEmpty(protein.Accession)); // old db won't have this populated WebEnabledFastaImporter searcher = new WebEnabledFastaImporter(doActualWebAccess ? null :new WebEnabledFastaImporter.FakeWebSearchProvider()); bool searchComplete; IProgressStatus status = new ProgressStatus(string.Empty); Assert.IsTrue(proteomeDb.LookupProteinMetadata(new SilentProgressMonitor(), ref status, searcher, false, out searchComplete)); // add any missing protein metadata Assert.IsTrue(searchComplete); protein = proteomeDb.GetProteinByName("Y18D10A.20"); Assert.IsNotNull(protein); if (doActualWebAccess) // We can actually go to the web for metadata { Assert.AreEqual("Q9XW16", protein.Accession); } using (var reader = new StreamReader(fastaPath)) { proteomeDb.AddFastaFile(reader, new SilentProgressMonitor(), ref status, false); } // the act of writing should update to the current version Assert.AreEqual(ProteomeDb.SCHEMA_VERSION_MAJOR_CURRENT, proteomeDb.GetSchemaVersionMajor()); Assert.AreEqual(ProteomeDb.SCHEMA_VERSION_MINOR_CURRENT, proteomeDb.GetSchemaVersionMinor()); Assert.AreEqual(19, proteomeDb.GetProteinCount()); // check for propery processed protein metadata Assert.IsTrue(proteomeDb.LookupProteinMetadata(new SilentProgressMonitor(), ref status, searcher, false, out searchComplete)); Assert.IsTrue(searchComplete); protein = proteomeDb.GetProteinByName("IPI00000044"); Assert.IsNotNull(protein); Assert.AreEqual("P01127", protein.Accession); // We get this offline with our ipi->uniprot mapper if (doActualWebAccess) { Assert.AreEqual("PDGFB_HUMAN", protein.PreferredName); // But this we get only with web access } /* * // TODO(bspratt): fix "GetDigestion has no notion of a Db that has been added to, doesn't digest the new proteins and returns immediately (issue #304)" * Enzyme trypsin = EnzymeList.GetDefault(); * proteomeDb.Digest(trypsin, new SilentProgressMonitor()); * Digestion digestion = proteomeDb.GetDigestion(trypsin.Name); * var digestedProteins0 = digestion.GetProteinsWithSequencePrefix("EDGWVK", 100); * Assert.IsTrue(digestedProteins0.Count >= 1); * */ } } }