public pHistBumpViewModel() { // Initialize this view model with default values searchParams = new SearchParams(); mgf = null; }
/// <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; }
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"); }
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); }
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."); }
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); }
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."); }
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."); }