Example #1
0
        public pHistBumpViewModel()
        {
            // Initialize this view model with default values
            searchParams = new SearchParams();

            mgf = null;
        }
Example #2
0
        /// <summary>
        /// Initializes the search.
        /// </summary>
        /// <returns>Returns error messages</returns>
        public string parseMGF()
        {
            string errors = searchParams.validateSearchParamsAndConvertToNum();
            if (errors != string.Empty)
                return errors;

            mgf = null;
            mgf = new MGFFile(searchParams.mgfFilePath);
            if (!mgf.parseText_Linear())
                return "Error: Failed to parse MGF input file.";

            return String.Empty;
        }
Example #3
0
        public void parseText_Linear_wellFormedIonListProvided_IonSpectraListPopulated()
        {
            string[] fileLines = sampleData_wellFormed;
            string filePath = createTestMgfFile(fileLines);

            MGFFile target = new MGFFile(filePath);
            bool expected = true;
            bool actual;
            actual = target.parseText_Linear();
            Assert.AreEqual(expected, actual);

            IonSpectrum spectrum1 = getIonSpectrum1();
            IonSpectrum spectrum2 = getIonSpectrum2();

            if (target.ionSpectra.Count != 2)
                Assert.Fail("Parser did not accumulate the same amount of spectra");
            if (!AreSpectraEqual(target.ionSpectra[0], spectrum1))
                Assert.Fail("Spectrum 1 was not parsed correctly");
            if (!AreSpectraEqual(target.ionSpectra[1], spectrum2))
                Assert.Fail("Spectrum 2 was not parsed correctly");
        }
Example #4
0
        public void parseText_Linear_illFormedIonListProvided_parseFails()
        {
            string[] fileLines = sampleData_poorlyFormed;
            string filePath = createTestMgfFile(fileLines);

            MGFFile target = new MGFFile(filePath);
            bool expected = false;
            bool actual;
            actual = target.parseText_Linear();
            Assert.AreEqual(expected, actual);
        }
Example #5
0
        public void parseSpectrum_validSpectrumLineIndex_validParseResult()
        {
            string[] fileLines = sampleData_wellFormed;
            string filePath = createTestMgfFile(fileLines);

            MGFFile target = new MGFFile(filePath);
            int ionStartLineIndex = 16;
            IonSpectrum expected = getIonSpectrum2();
            IonSpectrum actual;

            System.IO.StreamReader sr = getStreamReaderAtLine(filePath, ionStartLineIndex);
            actual = target.parseSpectrum(ionStartLineIndex, sr);

            if (!AreSpectraEqual(expected, actual))
                Assert.Fail("Expected and actual spectra are not equal.");
        }
Example #6
0
        public void parseSpectrum_invalidSpectrumLineIndex_nullResult()
        {
            string[] fileLines = sampleData_wellFormed;
            string filePath = createTestMgfFile(fileLines);

            MGFFile target = new MGFFile(filePath);

            int ionStartLineIndex = -1;
            IonSpectrum expected = null;
            IonSpectrum actual;
            System.IO.StreamReader sr = getStreamReaderAtLine(filePath, ionStartLineIndex);
            actual = target.parseSpectrum(ionStartLineIndex, sr);
            Assert.AreEqual(expected, actual);
        }
Example #7
0
        public void MGFFileConstructor_givenProperMGFFile_ParsesCorrectly()
        {
            string filePath = "C:\\Users\\vbhatia\\Desktop\\pHistBump\\assets\\pH-SHY-PtsI_SythPep-sample.mgf";
            MGFFile target = new MGFFile(filePath);
            target.parseText_Linear();

            if (target.ionSpectra == null || target.ionSpectra.Count < 1)
                Assert.Fail("Failed to parse file correctly.");
        }
Example #8
0
        public void identifyIonsStartIndices_validInputMGFText_correctIndices()
        {
            string[] fileLines = sampleData_wellFormed;
            string filePath = createTestMgfFile(fileLines);

            MGFFile target = new MGFFile(filePath);
            List<int> expected = new List<int>();
            expected.Add(1);
            expected.Add(16);

            List<int> actual;
            actual = target.identifyIonsStartIndices();

            if (expected.Count != actual.Count)
                Assert.Fail("Incorrect number of start indices found.");
            foreach (int index in expected)
                if (!actual.Contains(index))
                    Assert.Fail("Expected and actual start indices are not equivalent.");
        }