/// <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 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."); }