Ejemplo n.º 1
0
        public void NistLoadLibrary()
        {
            var streamManager = new MemoryStreamManager();

            streamManager.TextFiles.Add(PATH_NIST_LIB, TEXT_LIB_YEAST_NIST);
            var loader = new TestLibraryLoader {
                StreamManager = streamManager
            };

            var librarySpec = new NistLibSpec("Yeast (NIST)", PATH_NIST_LIB);

            Library lib1 = librarySpec.LoadLibrary(loader);

            CheckLibrary(lib1, 100);

            Assert.AreEqual(streamManager.BinaryFiles.Count, 1);
            Assert.IsTrue(streamManager.IsCached(PATH_NIST_LIB, PATH_NIST_LIB_CACHE));

            // Corrupt the cache, and make sure it still possible to get
            // a valid library.
            byte[] cacheBytes = streamManager.BinaryFiles[PATH_NIST_LIB_CACHE];
            int    len        = cacheBytes.Length;

            byte[] corruptedBytes = new byte[len / 2];
            Array.Copy(cacheBytes, corruptedBytes, corruptedBytes.Length);
            streamManager.BinaryFiles[PATH_NIST_LIB_CACHE] = corruptedBytes;

            Library lib2 = librarySpec.LoadLibrary(loader);

            CheckLibrary(lib2, 100);

            Assert.AreEqual(len, streamManager.BinaryFiles[PATH_NIST_LIB_CACHE].Length);
            Assert.IsTrue(lib1.IsSameLibrary(lib2));
            Assert.AreEqual(0, lib1.CompareRevisions(lib2));
        }
Ejemplo n.º 2
0
        public void NistLoadLibrary()
        {
            var streamManager = new MemoryStreamManager();

            streamManager.TextFiles.Add(PATH_NIST_LIB, TEXT_LIB_YEAST_NIST + TEXT_LIB_BICINE_NIST);
            var loader = new TestLibraryLoader {
                StreamManager = streamManager
            };
            var expectedFragmentAnnotations = new Dictionary <int, List <SpectrumPeakAnnotation> >
            {
                { 3, MakeTestPeakAnnotation(Adduct.M_PLUS, 41.027f, "testfrag3", "85/86") },
                { 44, MakeTestPeakAnnotation(Adduct.M_PLUS, 128.070f, "testfrag_next_to_last", "83/86") },
                { 45, MakeTestPeakAnnotation(Adduct.M_PLUS, 146.081f, "testfrag_last", "85/86 note") },
            };

            var librarySpec = new NistLibSpec("Yeast (NIST)", PATH_NIST_LIB);

            Library lib1 = librarySpec.LoadLibrary(loader);

            CheckLibrary(lib1, 100);
            CheckLibrary(lib1, 46, KEYS_LIB_BICENE_NIST);

            Assert.AreEqual(streamManager.BinaryFiles.Count, 1);
            Assert.IsTrue(streamManager.IsCached(PATH_NIST_LIB, PATH_NIST_LIB_CACHE));

            // Corrupt the cache, and make sure it still possible to get
            // a valid library.
            byte[] cacheBytes = streamManager.BinaryFiles[PATH_NIST_LIB_CACHE];
            int    len        = cacheBytes.Length;

            byte[] corruptedBytes = new byte[len / 2];
            Array.Copy(cacheBytes, corruptedBytes, corruptedBytes.Length);
            streamManager.BinaryFiles[PATH_NIST_LIB_CACHE] = corruptedBytes;

            // Check small molecule library with spectrum attributes
            TestSpectrumPeakAnnotations(); // First, a quick low-level unit test of annotations handler class
            Library lib2 = librarySpec.LoadLibrary(loader);

            CheckLibrary(lib2, 100);
            CheckLibrary(lib2, 46, KEYS_LIB_BICENE_NIST, expectedFragmentAnnotations);


            Assert.AreEqual(len, streamManager.BinaryFiles[PATH_NIST_LIB_CACHE].Length);
            Assert.IsTrue(lib1.IsSameLibrary(lib2));
            Assert.AreEqual(0, lib1.CompareRevisions(lib2));
        }