protected override void DoTest() { TestFilesZip = GetPerfTestDataURL(@"PerfNegativeIonDIA.zip"); TestFilesPersistent = new[] { "neg.mzML", "pos.mzML" }; // list of files that we'd like to unzip alongside parent zipFile, and (re)use in place var testFilesDir = new TestFilesDir(TestContext, TestFilesZip, null, TestFilesPersistent); RunUI(() => SkylineWindow.OpenFile(testFilesDir.GetTestPath("Test positive-negative.sky"))); WaitForDocumentLoaded(); ImportResultsFiles(TestFilesPersistent.Select(file => MsDataFileUri.Parse(testFilesDir.GetTestPath(file)))); // Verify that pos ion has a chromatogram for pos replicate, and neg ion has one for neg replicate var doc = WaitForDocumentLoaded(400000); var results = doc.Settings.MeasuredResults; var negIndex = results.Chromatograms[0].Name.Equals("neg") ? 0 : 1; var posIndex = (negIndex == 1) ? 0 : 1; var tolerance = .005f; foreach (var pair in doc.MoleculePrecursorPairs) { var index = pair.NodeGroup.PrecursorCharge < 0 ? negIndex : posIndex; var message = "expected a chromatogram for precursor and for product in replicate \"" + results.Chromatograms[index].Name + "\""; ChromatogramGroupInfo[] chromGroupInfo; Assert.IsTrue(results.TryLoadChromatogram(index, pair.NodePep, pair.NodeGroup, tolerance, true, out chromGroupInfo), message); foreach (var chromGroup in chromGroupInfo) { Assert.AreEqual(2, chromGroup.TransitionPointSets.Count(), message); } } }
public IEnumerable <DbSpectrum> GetSpectraByPrecursor(MsDataFileUri file, double precursor) { const double precursorTolerance = 0.001; return(GetSpectraByFile(file).Where(spectrum => spectrum.HasPrecursorMatch && Math.Abs(spectrum.MatchedPrecursorMz.GetValueOrDefault() - precursor) <= precursorTolerance)); }
public SelectionInfo(int targetIndex, Target sequence, Adduct charge, MsDataFileUri filePath) { TargetIndex = targetIndex; Sequence = sequence; Charge = charge; FilePath = filePath; }
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()); }
private void upOneLevelButton_Click(object sender, EventArgs e) { MsDataFileUri parent = null; var dataFilePath = _currentDirectory as MsDataFilePath; if (dataFilePath != null && !string.IsNullOrEmpty(dataFilePath.FilePath)) { DirectoryInfo parentDirectory = Directory.GetParent(dataFilePath.FilePath); if (parentDirectory != null) { parent = new MsDataFilePath(parentDirectory.FullName); } } else { if (_previousDirectories.Any()) { CurrentDirectory = _previousDirectories.Pop(); return; } } if (null != parent && !Equals(parent, _currentDirectory)) { _previousDirectories.Push(_currentDirectory); CurrentDirectory = parent; } }
private static bool HasUnmatchedLibraryRuns(SrmDocument doc) { var libraries = doc.Settings.PeptideSettings.Libraries; if (!libraries.HasLibraries || !libraries.HasDocumentLibrary) { return(false); } for (int i = 0; i < libraries.LibrarySpecs.Count; i++) { if (libraries.LibrarySpecs[i].IsDocumentLibrary) { var documentLibrary = libraries.Libraries[i]; // CONSIDER: Load the library? if (documentLibrary == null) { return(false); } foreach (var dataFile in documentLibrary.LibraryFiles.FilePaths) { if (!doc.Settings.HasResults || doc.Settings.MeasuredResults.FindMatchingMSDataFile(MsDataFileUri.Parse(dataFile)) == null) { return(true); } } } } return(false); }
public override bool TryGetRetentionTimes(MsDataFileUri filePath, out LibraryRetentionTimes retentionTimes) { int j = _librarySourceFiles.IndexOf(info => Equals(filePath.ToString(), info.FilePath)); if (j != -1) { var source = _librarySourceFiles[j]; ILookup <Target, double[]> timesLookup = _libraryEntries.ToLookup( entry => entry.Key.Target, entry => entry.RetentionTimesByFileId.GetTimes(source.Id)); var timesDict = timesLookup.ToDictionary( grouping => grouping.Key, grouping => { var array = grouping.SelectMany(values => values).ToArray(); Array.Sort(array); return(array); }); var nonEmptyTimesDict = timesDict .Where(kvp => kvp.Value.Length > 0) .ToDictionary(kvp => kvp.Key, kvp => new Tuple <TimeSource, double[]>(TimeSource.peak, kvp.Value)); retentionTimes = new LibraryRetentionTimes(filePath.ToString(), nonEmptyTimesDict); return(true); } return(base.TryGetRetentionTimes(filePath, out retentionTimes)); }
public Key(SrmDocument document, ChromatogramSet chromatogramSet, MsDataFileUri filePath, IdentityPath precursorIdentityPath) { _documentReference = document.ReferenceId; _chromatogramSet = chromatogramSet; _filePath = filePath; _precursorIdentityPath = precursorIdentityPath; }
private FileProgressControl FindProgressControl(MsDataFileUri filePath) { FileProgressControl fileProgressControl; _fileProgressControls.TryGetValue(filePath.GetLocation(), out fileProgressControl); return(fileProgressControl); }
public SingleFileLoadMonitor(MultiFileLoadMonitor loadMonitor, MsDataFileUri dataFile) { _loadMonitor = loadMonitor; _dataFile = dataFile; _lastCancelCheck = DateTime.UtcNow; // Said to be 117x faster than Now and this is for a delta HasUI = loadMonitor.HasUI; }
public override IEnumerable <double> GetRetentionTimesWithSequences(string filePath, IEnumerable <Target> peptideSequences, ref int?iFile) { if (!iFile.HasValue) { iFile = FindFileInList(MsDataFileUri.Parse(filePath), _sourceFiles); } if (iFile.Value < 0) { return(new double[0]); } var times = new List <double>(); foreach (var entry in LibraryEntriesWithSequences(peptideSequences)) { FileData fileData; if (entry.FileDatas.TryGetValue(iFile.Value, out fileData)) { if (fileData.ApexTime.HasValue) { times.Add(fileData.ApexTime.Value); } } } return(times); }
public override bool TryGetRetentionTimes(LibKey key, MsDataFileUri filePath, out double[] retentionTimes) { retentionTimes = null; DbSpectrum[] spectra; if (!key.IsPrecursorKey) { spectra = GetSpectraByPeptide(filePath, key).ToArray(); } else { spectra = GetSpectraByPrecursor(filePath, key.PrecursorMz.GetValueOrDefault()).ToArray(); var keyRt = key.RetentionTime; if (keyRt.HasValue) { spectra = spectra.Where(s => Equals(keyRt.Value, s.RetentionTime)).ToArray(); } } if (!spectra.Any()) { return(false); } retentionTimes = spectra.Select(s => s.RetentionTime).ToArray(); return(true); }
public override bool TryGetRetentionTimes(LibKey key, MsDataFileUri filePath, out double[] retentionTimes) { retentionTimes = null; int i = FindEntry(key); if (i < 0) { return(false); } int fileId = FindFileInList(filePath, _sourceFiles); if (fileId < 0) { return(false); } var entry = _libraryEntries[i]; FileData fileData; if (!entry.FileDatas.TryGetValue(fileId, out fileData)) { return(false); } if (!fileData.ApexTime.HasValue) { return(false); } retentionTimes = new[] { fileData.ApexTime.Value }; return(true); }
public override ExplicitPeakBounds GetExplicitPeakBounds(MsDataFileUri filePath, IEnumerable <Target> peptideSequences) { int fileId = FindFileInList(filePath, _sourceFiles); if (fileId < 0) { return(null); } bool anyMatch = false; foreach (var entry in LibraryEntriesWithSequences(peptideSequences)) { FileData fileData; if (entry.FileDatas.TryGetValue(fileId, out fileData)) { return(fileData.PeakBounds); } if (entry.FileDatas.Any()) { anyMatch = true; } } if (anyMatch) { return(ExplicitPeakBounds.EMPTY); } return(null); }
public override IEnumerable <RemoteItem> ListContents(MsDataFileUri parentUrl) { var unifiUrl = (UnifiUrl)parentUrl; ImmutableList <UnifiFolderObject> folders; if (TryGetData(GetRootContentsUrl(), out folders)) { foreach (var folderObject in folders) { if (folderObject.ParentId == unifiUrl.Id) { var childUrl = unifiUrl.ChangeId(folderObject.Id) .ChangePathParts(unifiUrl.GetPathParts().Concat(new[] { folderObject.Name })); yield return(new RemoteItem(childUrl, folderObject.Name, DataSourceUtil.FOLDER_TYPE, null, 0)); } } } ImmutableList <UnifiFileObject> files; if (TryGetData(GetFileContentsUrl(unifiUrl), out files)) { foreach (var fileObject in files) { var childUrl = unifiUrl.ChangeId(fileObject.Id) .ChangePathParts(unifiUrl.GetPathParts().Concat(new[] { fileObject.Name })) .ChangeModifiedTime(fileObject.ModifiedAt); yield return(new RemoteItem(childUrl, fileObject.Name, DataSourceUtil.TYPE_WATERS_RAW, fileObject.ModifiedAt, 0)); } } }
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 RemoteItem(MsDataFileUri msDataFileUri, string label, string type, DateTime?lastModified, long fileSizeBytes) { MsDataFileUri = msDataFileUri; Label = label; Type = type; LastModified = lastModified; FileSize = (ulong)fileSizeBytes; }
public IEnumerable <DbSpectrum> GetSpectraByRetentionTime(MsDataFileUri file, double precursor, double rtMin, double rtMax) { var min = rtMin - RT_TOLERANCE; var max = rtMax + RT_TOLERANCE; return(GetSpectraByPrecursor(file, precursor).Where(spectrum => min <= spectrum.RetentionTime && spectrum.RetentionTime <= max)); }
public bool Matches(MsDataFileUri msDataFilePath) { if (null != FilePath && !FilePath.Equals(msDataFilePath)) { return(false); } return(Name.Equals(GetName(msDataFilePath))); }
public void DoAgilentMseChromatogramTest(RefinementSettings.ConvertToSmallMoleculesMode asSmallMolecules) { if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none && !RunSmallMoleculeTestVersions) { System.Console.Write(MSG_SKIPPING_SMALLMOLECULE_TEST_VERSION); return; } var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE); TestSmallMolecules = false; // We have an explicit test for that here string docPath; SrmDocument document = InitAgilentMseDocument(testFilesDir, out docPath); if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none) { var refine = new RefinementSettings(); document = refine.ConvertToSmallMolecules(document, asSmallMolecules); } using (var docContainer = new ResultsTestDocumentContainer(document, docPath)) { var doc = docContainer.Document; var listChromatograms = new List <ChromatogramSet>(); var path = MsDataFileUri.Parse(@"AgilentMse\BSA-AI-0-10-25-41_first_100_scans.mzML"); listChromatograms.Add(AssertResult.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(); document = docContainer.Document; float tolerance = (float)document.Settings.TransitionSettings.Instrument.MzMatchTolerance; var results = document.Settings.MeasuredResults; foreach (var pair in document.MoleculePrecursorPairs) { ChromatogramGroupInfo[] chromGroupInfo; Assert.IsTrue(results.TryLoadChromatogram(0, pair.NodePep, pair.NodeGroup, tolerance, true, out chromGroupInfo)); Assert.AreEqual(1, chromGroupInfo.Length); } // now drill down for specific values int nPeptides = 0; foreach (var nodePep in document.Molecules.Where(nodePep => nodePep.Results[0] != null)) { // expecting just one peptide result in this small data set if (nodePep.Results[0].Sum(chromInfo => chromInfo.PeakCountRatio > 0 ? 1 : 0) > 0) { Assert.AreEqual(0.2462, (double)nodePep.GetMeasuredRetentionTime(0), .0001, "averaged retention time differs in node " + nodePep.RawTextId); Assert.AreEqual(0.3333, (double)nodePep.GetPeakCountRatio(0), 0.0001); nPeptides++; } } Assert.AreEqual(1, nPeptides); } testFilesDir.Dispose(); }
/// <summary> /// Display chromatogram data. /// </summary> /// <param name="status"></param> public void UpdateStatus(ChromatogramLoadingStatus status) { // Update progress bars and progress labels. var fileCount = Math.Max(1, status.SegmentCount - 1); // Update file label. if (status.Segment == status.SegmentCount - 1) { lblFileName.Visible = false; progressBarFile.Visible = false; lblFileCount.Text = Resources.AllChromatogramsGraph_UpdateStatus_Joining_chromatograms___; } else { progressBarFile.Value = status.ZoomedPercentComplete; // Clear graph when a new file starts loading. if (null != status.FilePath && _currentFilePath != status.FilePath) { _currentFilePath = status.FilePath; // LOG.Info("Showing " + _currentFilePath); // Not L10N lblFileName.Text = status.FilePath.GetFileName() + status.FilePath.GetSampleName(); asyncGraph.ClearGraph(status); } lblFileCount.Text = string.Format(Resources.AllChromatogramsGraph_UpdateStatus__0__of__1__files, status.Segment + 1, fileCount); } // Show multi-file progress bar if we have more than one file to import. if (fileCount != 1) { if (Visible && !panelMultifileProgress.Visible) { panelMultifileProgress.Visible = true; panelFileProgress.Top -= _adjustLayoutForMultifile; panelGraph.Height -= _adjustLayoutForMultifile; // TODO: uncomment this when single file cancellation works //btnCancelFile.Visible = true; } progressBarAllFiles.Value = status.PercentComplete; } // Show warning message if necessary. if (status.WarningMessage != null) { lblWarning.Text = status.WarningMessage; lblWarning.Visible = true; asyncGraph.Height = lblWarning.Top - 7; } else { lblWarning.Visible = false; asyncGraph.Height = panelFileProgress.Top - 7; } lblDuration.Text = _stopwatch.Elapsed.ToString(@"hh\:mm\:ss"); // Not L10N }
private void OpenFolder(MsDataFileUri uri) { if (_currentDirectory != null) { _previousDirectories.Push(_currentDirectory); } CurrentDirectory = uri; _abortPopulateList = true; }
private void RunMultiplePeptidesSameMz(RefinementSettings.ConvertToSmallMoleculesMode asSmallMolecules) { if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none) { TestDirectoryName = asSmallMolecules.ToString(); } TestSmallMolecules = false; // Don't need the magic test node, we have an explicit test var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE); string docPath; SrmDocument document = InitMultiplePeptidesSameMzDocument(testFilesDir, out docPath); document = (new RefinementSettings()).ConvertToSmallMolecules(document, asSmallMolecules); var docContainer = new ResultsTestDocumentContainer(document, docPath); var doc = docContainer.Document; var listChromatograms = new List <ChromatogramSet>(); var path = MsDataFileUri.Parse(@"AMultiplePeptidesSameMz\ljz_20131201k_Newvariant_standards_braf.mzML"); listChromatograms.Add(AssertResult.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(); document = docContainer.Document; float tolerance = (float)document.Settings.TransitionSettings.Instrument.MzMatchTolerance; var results = document.Settings.MeasuredResults; foreach (var pair in document.MoleculePrecursorPairs) { ChromatogramGroupInfo[] chromGroupInfo; Assert.IsTrue(results.TryLoadChromatogram(0, pair.NodePep, pair.NodeGroup, tolerance, true, out chromGroupInfo)); Assert.AreEqual(1, chromGroupInfo.Length); // without the fix, only the first pair will have a chromatogram } // now drill down for specific values int nPeptides = 0; foreach (var nodePep in document.Molecules.Where(nodePep => nodePep.Results[0] != null)) { // expecting three peptide result in this small data set if (nodePep.Results[0].Sum(chromInfo => chromInfo.PeakCountRatio > 0 ? 1 : 0) > 0) { Assert.AreEqual(34.2441024780273, (double)nodePep.GetMeasuredRetentionTime(0), .0001); nPeptides++; } } Assert.AreEqual(3, nPeptides); // without the fix this will give just one result // Release file handles docContainer.Release(); testFilesDir.Dispose(); }
/// <summary> /// If the passed in MsDataFileUri is a multi-sample wiff file, then return a list of /// MsDataFileUri's representing the samples, otherwise, return the MsDataFileUri itself. /// </summary> public static IEnumerable <MsDataFileUri> ListSubPaths(MsDataFileUri msDataFileUri) { var msDataFilePath = msDataFileUri as MsDataFilePath; if (msDataFilePath == null || !IsWiffFile(msDataFilePath.FilePath)) { return(new[] { msDataFileUri }); } return(GetWiffSubPaths(msDataFilePath.FilePath)); }
public IProgressStatus GetStatus(MsDataFileUri filePath) { foreach (var loadingStatus in ProgressList) { if (loadingStatus.FilePath.Equals(filePath)) { return(loadingStatus); } } return(null); }
private static IDictionary <Target, double> GetFirstRetentionTimes( SrmSettings settings, RetentionTimeSource retentionTimeSource) { var libraryRetentionTimes = settings.GetRetentionTimes(MsDataFileUri.Parse(retentionTimeSource.Name)); if (null == libraryRetentionTimes) { return(new Dictionary <Target, double>()); } return(libraryRetentionTimes.GetFirstRetentionTimes()); }
public SpectrumDisplayInfo(SpectrumInfo spectrumInfo, string replicateName, MsDataFileUri filePath, int fileOrder, double?retentionTime, bool isBest) { _spectrumInfo = spectrumInfo; ReplicateName = replicateName; FilePath = filePath; FileOrder = fileOrder; RetentionTime = retentionTime; IsBest = isBest; }
private ChromatogramLoadingStatus FindStatus(MultiProgressStatus status, MsDataFileUri filePath) { foreach (ChromatogramLoadingStatus loadingStatus in status.ProgressList) { if (loadingStatus.FilePath.Equals(filePath)) { return(loadingStatus); } } return(null); }
public void ClearFile(MsDataFileUri filePath) { lock (this) { _loadingPaths.Remove(filePath); if (_loadingPaths.Count == 0) { ResetStatus(); } } }
private FileProgressControl FindProgressControl(MsDataFileUri filePath) { foreach (FileProgressControl fileProgressControl in flowFileStatus.Controls) { if (fileProgressControl.FilePath.Equals(filePath)) { return(fileProgressControl); } } return(null); }