protected int CompareTo(MsDataFilePath other) { // Culture specific sorting desirable in file paths // ReSharper disable StringCompareToIsCultureSpecific int result = FilePath.CompareTo(other.FilePath); if (result != 0) { return(result); } result = SampleName.CompareTo(other.SampleName); if (result != 0) { return(result); } result = SampleIndex.CompareTo(other.SampleIndex); if (result != 0) { return(result); } result = CentroidMs1.CompareTo(other.CentroidMs1); if (result != 0) { return(result); } result = CentroidMs2.CompareTo(other.CentroidMs2); if (result != 0) { return(result); } return(LockMassParameters.CompareTo(other.LockMassParameters)); // ReSharper restore StringCompareToIsCultureSpecific }
public MsDataFileImplExtInh(string path, int sampleIndex = 0, LockMassParameters lockmassParameters = null, bool simAsSpectra = false, bool srmAsSpectra = false, bool acceptZeroLengthSpectra = true, bool requireVendorCentroidedMS1 = false, bool requireVendorCentroidedMS2 = false, bool ignoreZeroIntensityPoints = false) : base(path, sampleIndex = 0, lockmassParameters = null, simAsSpectra = false, srmAsSpectra = false, acceptZeroLengthSpectra = true, requireVendorCentroidedMS1 = false, requireVendorCentroidedMS2 = false, ignoreZeroIntensityPoints = false) { }
public void MsDataFileUriEncodingTest() { var fname = "test.mzML"; var pathSample = SampleHelp.EncodePath(fname, null, -1, null, true, false); var lockmassParametersA = new LockMassParameters(1.23, 3.45, 4.56); var lockmassParametersB = new LockMassParameters(1.23, null, 4.56); Assert.IsTrue(lockmassParametersA.CompareTo(LockMassParameters.EMPTY) > 0); Assert.IsTrue(lockmassParametersA.CompareTo(null) < 0); Assert.IsTrue(lockmassParametersB.CompareTo(lockmassParametersA) < 0); Assert.IsTrue(lockmassParametersA.CompareTo(new LockMassParameters(1.23, 3.45, 4.56)) == 0); var c = new ChromatogramSet("test", new[] { MsDataFileUri.Parse(pathSample) }); Assert.AreEqual(fname, c.MSDataFilePaths.First().GetFilePath()); Assert.IsTrue(c.MSDataFilePaths.First().GetCentroidMs1()); Assert.IsFalse(c.MSDataFilePaths.First().GetCentroidMs2()); pathSample = SampleHelp.EncodePath(fname, null, -1, lockmassParametersA, false, true); c = new ChromatogramSet("test", new[] { MsDataFileUri.Parse(pathSample) }); Assert.AreEqual(lockmassParametersA, c.MSDataFilePaths.First().GetLockMassParameters()); Assert.IsTrue(c.MSDataFilePaths.First().GetCentroidMs2()); Assert.IsFalse(c.MSDataFilePaths.First().GetCentroidMs1()); pathSample = SampleHelp.EncodePath(fname, "test_0", 1, lockmassParametersB, false, false); c = new ChromatogramSet("test", new[] { MsDataFileUri.Parse(pathSample) }); Assert.AreEqual(lockmassParametersB, c.MSDataFilePaths.First().GetLockMassParameters()); Assert.AreEqual("test_0", c.MSDataFilePaths.First().GetSampleName()); Assert.AreEqual(1, c.MSDataFilePaths.First().GetSampleIndex()); Assert.IsFalse(c.MSDataFilePaths.First().GetCentroidMs1()); Assert.IsFalse(c.MSDataFilePaths.First().GetCentroidMs2()); }
public static void MatchChromatograms(ResultsTestDocumentContainer docContainer, MsDataFileUri path1, MsDataFileUri path2, int delta, int missing, LockMassParameters lockMassParameters = null) { var doc = docContainer.Document; var listChromatograms = new List <ChromatogramSet>(); foreach (var path in new[] { path1, path2 }) { var setAdd = FindChromatogramSet(doc, path); if (setAdd == null) { string addName = (path.GetFileName() ?? "").Replace('.', '_'); addName = Helpers.GetUniqueName(addName, n => listChromatograms.All(set => n != set.Name)); setAdd = new ChromatogramSet(addName, new[] { path }); } listChromatograms.Add(setAdd); } var docResults = doc.ChangeMeasuredResults(new MeasuredResults(listChromatograms)); Assert.IsTrue(docContainer.SetDocument(docResults, doc, true)); docContainer.AssertComplete(); docResults = docContainer.Document; MatchChromatograms(docResults, 0, 1, delta, missing); }
public void ImportResultsAsync(string[] dataFiles, LockMassParameters lockMassParameters, string expectedErrorMessage = null) { var importResultsDlg = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults); RunUI(() => { var filePaths = dataFiles.Select(dataFile => TestFilesDirs[0].GetTestPath(dataFile)).ToArray(); importResultsDlg.NamedPathSets = importResultsDlg.GetDataSourcePathsFileReplicates(filePaths.Select(MsDataFileUri.Parse)); }); if (expectedErrorMessage != null) { var dlg = WaitForOpenForm <MessageDlg>(); Assert.IsTrue(dlg.DetailMessage.Contains(expectedErrorMessage)); dlg.CancelDialog(); } else if (lockMassParameters == null) { OkDialog(importResultsDlg, importResultsDlg.OkDialog); } else { // Expect a Waters lockmass dialog to appear on OK WaitForConditionUI(() => importResultsDlg.NamedPathSets.Count() == dataFiles.Count()); var lockmassDlg = ShowDialog <ImportResultsLockMassDlg>(importResultsDlg.OkDialog); RunUI(() => { lockmassDlg.LockmassPositive = lockMassParameters.LockmassPositive ?? 0; lockmassDlg.LockmassNegative = lockMassParameters.LockmassNegative ?? 0; lockmassDlg.LockmassTolerance = lockMassParameters.LockmassTolerance ?? 0; }); OkDialog(lockmassDlg, lockmassDlg.OkDialog); } }
protected bool Equals(MsDataFilePath other) { return(string.Equals(FilePath, other.FilePath) && string.Equals(SampleName, other.SampleName) && SampleIndex == other.SampleIndex && CentroidMs1 == other.CentroidMs1 && CentroidMs2 == other.CentroidMs2 && LockMassParameters.Equals(other.LockMassParameters)); }
/// <summary> /// Import results from one or more data files. /// </summary> /// <param name="dataFiles">List of data file paths</param> /// <param name="lockMassParameters">For Waters lockmass correction</param> /// <param name="waitForLoadSeconds">Timeout in seconds</param> /// <param name="expectedErrorMessage">anticipated error dialog message, if any</param> public void ImportResults(string[] dataFiles, LockMassParameters lockMassParameters, int waitForLoadSeconds = 420, string expectedErrorMessage = null) { ImportResultsAsync(dataFiles, lockMassParameters); WaitForConditionUI(waitForLoadSeconds * 1000, () => { var document = SkylineWindow.DocumentUI; return(document.Settings.HasResults && document.Settings.MeasuredResults.IsLoaded); }); }
public void NativeVsMz5ChromatogramPerformanceTest(string zipFile, string skyFile, string rawFile, bool centroided = false, LockMassParameters lockMassParameters = null) { if (!RunPerfTests) { return; // PerfTests only run when the global RunPerfTests flag is set } _loopcount = LOOPS_AVG; // Caller may have disabled logging, but we depend on it for data gathering. using (new LogInfoLevel()) { Log.AddMemoryAppender(); for (var loop = 0; loop < _loopcount + 1; loop++) // one extra initial loop for warmup { // compare mz5 and raw import times TestFilesZip = GetPerfTestDataURL(zipFile); var mz5File = Path.ChangeExtension(rawFile, "mz5"); TestFilesPersistent = new[] { rawFile, mz5File }; // list of files that we'd like to unzip alongside parent zipFile, and (re)use in place _testFilesDir = new TestFilesDir(TestContext, TestFilesZip, null, TestFilesPersistent); _baseSkyFile = _testFilesDir.GetTestPath(skyFile); string nativeResults = _testFilesDir.GetTestPath(rawFile); var rawfiles = new List <string>(); var mz5Results = Path.ChangeExtension(nativeResults, "mz5"); if (centroided) { rawfiles.Add(nativeResults); // First time through is centroided } rawfiles.Add(mz5Results); // Then mz5 rawfiles.Add(nativeResults); // Then normal MsDataFileImpl.PerfUtilFactory.IssueDummyPerfUtils = (loop == 0) && (_loopcount > 0); // turn on performance measurement after warmup loop var centroidedThisPass = centroided; var type = 0; foreach (var resultspath in rawfiles) { _replicateName = loop + "_" + type++; _skyFile = _baseSkyFile.Replace(".sky", "_" + _replicateName + ".sky"); _dataFile = resultspath; _centroided = centroidedThisPass; DoTest(); centroidedThisPass = false; } } DebugLog.Info("Done."); var logs = Log.GetMemoryAppendedLogEvents(); var stats = PerfUtilFactory.SummarizeLogs(logs, TestFilesPersistent); // show summary, combining native per test and mz5 per test var report = stats.Replace(_testFilesDir.PersistentFilesDir.Replace(':', '_'), ""); Console.Write(report); // Want this to appear in nightly log var log = new Log("Summary"); log.Info(report); } }
protected bool Equals(MsDataFilePath other) { return(string.Equals(FilePath, other.FilePath) && string.Equals(SampleName, other.SampleName) && SampleIndex == other.SampleIndex && LegacyCentroidMs1 == other.LegacyCentroidMs1 && LegacyCentroidMs2 == other.LegacyCentroidMs2 && LegacyCombineIonMobilitySpectra == other.LegacyCombineIonMobilitySpectra && LockMassParameters.Equals(other.LockMassParameters)); }
public MsDataFilePath(string filePath, string sampleName, int sampleIndex, LockMassParameters lockMassParameters = null, bool centroidMs1 = false, bool centroidMs2 = false) { FilePath = filePath; SampleName = sampleName; SampleIndex = sampleIndex; LockMassParameters = lockMassParameters ?? LockMassParameters.EMPTY; CentroidMs1 = centroidMs1; CentroidMs2 = centroidMs2; }
private MsDataFilePath(string filePath, string sampleName, int sampleIndex, LockMassParameters lockMassParameters, bool centroidMs1, bool centroidMs2, bool combineIonMobilitySpectra) { FilePath = filePath; SampleName = sampleName; SampleIndex = sampleIndex; LockMassParameters = lockMassParameters ?? LockMassParameters.EMPTY; LegacyCentroidMs1 = centroidMs1; LegacyCentroidMs2 = centroidMs2; LegacyCombineIonMobilitySpectra = combineIonMobilitySpectra; }
// ReSharper restore VirtualMemberCallInConstructor protected virtual void Init(NameValueParameters nameValueParameters) { CentroidMs1 = nameValueParameters.GetBoolValue(Attr.centroid_ms1.ToString()); CentroidMs2 = nameValueParameters.GetBoolValue(Attr.centroid_ms2.ToString()); LockMassParameters = new LockMassParameters( nameValueParameters.GetDoubleValue(Attr.lockmass_pos.ToString()), nameValueParameters.GetDoubleValue(Attr.lockmass_neg.ToString()), nameValueParameters.GetDoubleValue(Attr.lockmass_tol.ToString())); ServerUrl = nameValueParameters.GetValue(Attr.server.ToString()); Username = nameValueParameters.GetValue(Attr.username.ToString()); EncodedPath = nameValueParameters.GetValue(Attr.path.ToString()); ModifiedTime = nameValueParameters.GetDateValue(Attr.modified_time.ToString()); }
public override int GetHashCode() { unchecked { int hashCode = FilePath.GetHashCode(); hashCode = (hashCode * 397) ^ (SampleName != null ? SampleName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ SampleIndex; hashCode = (hashCode * 397) ^ (LockMassParameters != null ? LockMassParameters.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CentroidMs1 ? 1 : 0); hashCode = (hashCode * 397) ^ (CentroidMs2 ? 1 : 0); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = CentroidMs1.GetHashCode(); hashCode = (hashCode * 397) ^ CentroidMs2.GetHashCode(); hashCode = (hashCode * 397) ^ (LockMassParameters != null ? LockMassParameters.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ServerUrl != null ? ServerUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Username != null ? Username.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ModifiedTime.GetHashCode(); hashCode = (hashCode * 397) ^ (EncodedPath != null ? EncodedPath.GetHashCode() : 0); return(hashCode); } }
public static void MatchChromatograms(ResultsTestDocumentContainer docContainer, MsDataFileUri path1, MsDataFileUri path2, int delta, int missing, LockMassParameters lockMassParameters = null) { var doc = docContainer.Document; var listChromatograms = new List <ChromatogramSet>(); foreach (var path in new[] { path1, path2 }) { listChromatograms.Add(FindChromatogramSet(doc, path) ?? new ChromatogramSet((path.GetFileName() ?? "").Replace('.', '_'), new[] { path })); } var docResults = doc.ChangeMeasuredResults(new MeasuredResults(listChromatograms)); Assert.IsTrue(docContainer.SetDocument(docResults, doc, true)); docContainer.AssertComplete(); docResults = docContainer.Document; MatchChromatograms(docResults, 0, 1, delta, missing); }
/// <summary> /// Updates the parameters for a list of named results. Including a check to see if any of the files /// are Waters files in potential need of lockmass correction. If lockmass correction is desired, /// the MsDataFileUri values in namedResults are modified. /// /// CONSIDER: Move this to a more general location, since it now does more than just lockmass correction. /// </summary> /// <param name="parent">Parent window to make owner of <see cref="ImportResultsLockMassDlg"/></param> /// <param name="doc">we only do lockmass correction if doc has full scan settings</param> /// <param name="namedResults">list of files to be checked - lockmass settings may be modified by this call</param> /// <returns>false iff cancelled by user</returns> public static bool UpdateNamedResultsParameters(Control parent, SrmDocument doc, ref List <KeyValuePair <string, MsDataFileUri[]> > namedResults) { LockMassParameters lockMassParameters = null; if (doc.Settings.TransitionSettings.FullScan.IsEnabled && namedResults.Any(n => n.Value.Any(m => m.IsWatersLockmassCorrectionCandidate()))) { // We have at least one Waters file possibly needing lockspray correction using (var dlgLockMass = new ImportResultsLockMassDlg()) { var result = dlgLockMass.ShowDialog(parent); if (result != DialogResult.OK) { return(false); // Cancelled } lockMassParameters = dlgLockMass.LockMassParameters; } } namedResults = ChangeLockMassParameters(namedResults, lockMassParameters, doc); return(true); // Success }
public void OkDialog() { var helper = new MessageBoxHelper(this); double lockmassPositive; if (string.IsNullOrEmpty(textLockmassPositive.Text)) { lockmassPositive = 0; } else if (!helper.ValidateDecimalTextBox(textLockmassPositive, 0, null, out lockmassPositive)) { return; } double lockmassNegative; if (string.IsNullOrEmpty(textLockmassNegative.Text)) { lockmassNegative = 0; } else if (!helper.ValidateDecimalTextBox(textLockmassNegative, 0, null, out lockmassNegative)) { return; } double lockmassTolerance; if (string.IsNullOrEmpty(textLockmassTolerance.Text)) { lockmassTolerance = 0; } else if (!helper.ValidateDecimalTextBox(textLockmassTolerance, LockMassParameters.LOCKMASS_TOLERANCE_MIN, LockMassParameters.LOCKMASS_TOLERANCE_MAX, out lockmassTolerance)) { return; } Settings.Default.LockmassParameters = LockMassParameters = new LockMassParameters(lockmassPositive, lockmassNegative, lockmassTolerance); DialogResult = DialogResult.OK; }
public void ImportResults(string dataFile, LockMassParameters lockMassParameters, int waitForLoadSeconds = 420, string expectedErrorMessage = null) { ImportResults(new[] { dataFile }, lockMassParameters, waitForLoadSeconds, expectedErrorMessage); }
public static void MatchChromatograms(ResultsTestDocumentContainer docContainer, string path1, string path2, int delta, int missing, LockMassParameters lockMassParameters = null) { MatchChromatograms(docContainer, MsDataFileUri.Parse(path1), MsDataFileUri.Parse(path2), delta, missing, lockMassParameters); }
public MsDataFilePath(string filePath, LockMassParameters lockMassParameters = null) : this(filePath, null, -1, lockMassParameters, false, false, false) { }
private static KeyValuePair <string, MsDataFileUri[]> ChangeLockMassParameters(KeyValuePair <string, MsDataFileUri[]> namedResult, LockMassParameters lockMassParameters, SrmDocument doc) { var result = new KeyValuePair <string, MsDataFileUri[]>(namedResult.Key, namedResult.Value); for (var i = 0; i < namedResult.Value.Length; i++) { var msDataFileUri = result.Value[i]; if (lockMassParameters == null || lockMassParameters.IsEmpty || !msDataFileUri.IsWatersLockmassCorrectionCandidate()) { result.Value[i] = msDataFileUri.ChangeLockMassParameters(LockMassParameters.EMPTY); } else { result.Value[i] = msDataFileUri.ChangeLockMassParameters(lockMassParameters); } } return(result); }
public MsDataFileUri ChangeParameters(SrmDocument doc, LockMassParameters lockMassParameters) { return(doc.Settings.TransitionSettings.FullScan.ApplySettings(ChangeLockMassParameters(lockMassParameters))); }
public MsDataFilePath(string filePath, LockMassParameters lockMassParameters = null, bool centroidMs1 = false, bool centroidMs2 = false) : this(filePath, null, -1, lockMassParameters, centroidMs1, centroidMs2) { }
/// <summary> /// Returns a copy of itself with updated lockmass parameters /// </summary> public abstract MsDataFileUri ChangeLockMassParameters(LockMassParameters lockMassParameters);
public override MsDataFileUri ChangeLockMassParameters(LockMassParameters lockMassParameters) { return(this); // Chorus will have already performed lockmass correction }
public MsDataFilePath(string filePath, string sampleName, int sampleIndex, LockMassParameters lockMassParameters = null) : this(filePath, sampleName, sampleIndex, lockMassParameters, false, false, false) { }
public override MsDataFileUri ChangeLockMassParameters(LockMassParameters lockMassParameters) { return(new MsDataFilePath(FilePath, SampleName, SampleIndex, lockMassParameters, LegacyCentroidMs1, LegacyCentroidMs2, LegacyCombineIonMobilitySpectra)); }
public override MsDataFileUri ChangeLockMassParameters(LockMassParameters lockMassParameters) { return(ChangeProp(ImClone(this), im => im.LockMassParameters = lockMassParameters)); }
public override MsDataFileUri ChangeLockMassParameters(LockMassParameters lockMassParameters) { return(new MsDataFilePath(FilePath, SampleName, SampleIndex, lockMassParameters, CentroidMs1, CentroidMs2)); }
private static void TestInstrumentInfo(string resultsPath, string docCurrentPath) { var docCurrent = ResultsUtil.DeserializeDocument(docCurrentPath); using (var docContainer = new ResultsTestDocumentContainer(docCurrent, docCurrentPath)) { string replicateName = Path.GetFileNameWithoutExtension(resultsPath); var lockMassParameters = new LockMassParameters(456.78, 567.89, 12.34); var listChromatograms = new List <ChromatogramSet> { new ChromatogramSet(replicateName, new[] { new MsDataFilePath(resultsPath, lockMassParameters) }) }; // Lockmass values are Waters only so don't expect them to be saved to the doc which has no Waters results // So test the serialization here var stringBuilder = new StringBuilder(); using (var xmlWriter = XmlWriter.Create(stringBuilder)) { xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("TestDocument"); xmlWriter.WriteElements(listChromatograms, new XmlElementHelper <ChromatogramSet>()); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); } var xmlReader = XmlReader.Create(new StringReader(stringBuilder.ToString())); xmlReader.ReadStartElement(); var deserializedObjects = new List <ChromatogramSet>(); xmlReader.ReadElements(deserializedObjects); Assert.AreEqual(1, deserializedObjects.Count); var compare = deserializedObjects[0]; Assert.AreEqual(456.78, compare.MSDataFileInfos[0].FilePath.GetLockMassParameters().LockmassPositive.Value); Assert.AreEqual(567.89, compare.MSDataFileInfos[0].FilePath.GetLockMassParameters().LockmassNegative.Value); Assert.AreEqual(12.34, compare.MSDataFileInfos[0].FilePath.GetLockMassParameters().LockmassTolerance.Value); Assert.AreEqual(listChromatograms[0], compare); // We don't expect any new peptides/precursors/transitions added due to the imported results. var docCurrentResults = docContainer.ChangeMeasuredResults(new MeasuredResults(listChromatograms), 0, 0, 0); WriteDocument(docCurrentResults, docCurrentPath); docCurrentResults = ResultsUtil.DeserializeDocument(docCurrentPath); Assert.IsNotNull(docCurrentResults); AssertEx.IsDocumentState(docCurrentResults, 0, 7, 11, 22, 66); Assert.AreEqual(1, docCurrentResults.Settings.MeasuredResults.Chromatograms.Count); XmlDocument xdoc = new XmlDocument(); xdoc.Load(docCurrentPath); var replicateList = xdoc.SelectNodes("/srm_settings/settings_summary/measured_results/replicate"); Assert.IsNotNull(replicateList); Assert.AreEqual(1, replicateList.Count); var replicate = replicateList.Item(0); Assert.IsNotNull(replicate); var attribs = replicate.Attributes; Assert.IsNotNull(attribs); Assert.AreEqual(replicateName, attribs.GetNamedItem(DocumentSerializer.ATTR.name).Value); var instrumentList = replicate.SelectNodes("sample_file/instrument_info_list/instrument_info"); Assert.IsNotNull(instrumentList); Assert.AreEqual(1, instrumentList.Count); var instrumentInfo = instrumentList.Item(0); Assert.IsNotNull(instrumentInfo); Assert.IsNotNull(instrumentInfo.Attributes); // model var model = instrumentInfo.SelectSingleNode(ChromatogramSet.EL.model.ToString()); Assert.IsNotNull(model); Assert.IsNotNull(model.FirstChild); Assert.IsTrue(model.FirstChild.NodeType == XmlNodeType.Text); Assert.AreEqual("TSQ Vantage", model.FirstChild.Value); // ion source var ionsource = instrumentInfo.SelectSingleNode(ChromatogramSet.EL.ionsource.ToString()); Assert.IsNotNull(ionsource); Assert.IsNotNull(ionsource.FirstChild); Assert.AreEqual(ionsource.FirstChild.NodeType, XmlNodeType.Text); Assert.AreEqual("nanoelectrospray", ionsource.FirstChild.Value); // analyzer var analyzer = instrumentInfo.SelectSingleNode(ChromatogramSet.EL.analyzer.ToString()); Assert.IsNotNull(analyzer); Assert.IsNotNull(analyzer.FirstChild); Assert.AreEqual(analyzer.FirstChild.NodeType, XmlNodeType.Text); Assert.AreEqual("quadrupole/quadrupole/quadrupole", analyzer.FirstChild.Value); // dectector var detector = instrumentInfo.SelectSingleNode(ChromatogramSet.EL.detector.ToString()); Assert.IsNotNull(detector); Assert.IsNotNull(detector.FirstChild); Assert.AreEqual(detector.FirstChild.NodeType, XmlNodeType.Text); Assert.AreEqual("electron multiplier", detector.FirstChild.Value); } }