public const double DISPLAY_FILTER_PERCENT = 0.01; // filter peaks less than this percentage of maximum intensity public ChromatogramLoadingStatus(MsDataFileUri filePath, IEnumerable <string> replicateNames) : base(SampleHelp.GetFileName(filePath)) { Transitions = new TransitionData(); FilePath = filePath; ReplicateNames = replicateNames; }
private bool ProcessChromInfo(MsDataFileUri filePath, ChromatogramGroupInfo chromInfo, PeptidePrecursorPair pair, TransitionGroupDocNode nodeGroup, float tolerance, LibKey libKey) { Assume.IsTrue(chromInfo.BestPeakIndex != -1); var resultIndex = _document.Settings.MeasuredResults.Chromatograms.IndexOf(c => c.GetFileInfo(filePath) != null); if (resultIndex == -1) { return(true); } var chromFileInfo = _document.Settings.MeasuredResults.Chromatograms[resultIndex].GetFileInfo(filePath); Assume.IsTrue(Equals(chromFileInfo.FilePath.GetLockMassParameters(), filePath.GetLockMassParameters())); // Determine apex RT for DT measurement using most intense MS1 peak var apexRT = GetApexRT(nodeGroup, resultIndex, chromFileInfo, true) ?? GetApexRT(nodeGroup, resultIndex, chromFileInfo, false); Assume.IsTrue(chromInfo.PrecursorMz == pair.NodeGroup.PrecursorMz); // Only use the transitions currently enabled var transitionPointSets = chromInfo.TransitionPointSets.Where( tp => nodeGroup.Transitions.Any( t => (t.Mz - (tp.ExtractionWidth ?? tolerance) / 2) <= tp.ProductMz && (t.Mz + (tp.ExtractionWidth ?? tolerance) / 2) >= tp.ProductMz)) .ToArray(); for (var msLevel = 1; msLevel <= 2; msLevel++) { if (!ProcessMSLevel(filePath, msLevel, transitionPointSets, chromInfo, apexRT, nodeGroup, libKey, tolerance)) { return(false); // User cancelled } } return(true); }
private static string GetMessage(MsDataFileUri importPath, Exception x) { string message = importPath.GetSampleName() == null ? string.Format(Resources.ChromCacheBuildException_GetMessage_Failed_importing_results_file___0___, importPath.GetFilePath()) : string.Format(Resources.ChromCacheBuildException_GetMessage_Failed_importing_results_file___0____sample__1__, importPath.GetFilePath(), importPath.GetSampleName()); return TextUtil.LineSeparate(message, x.Message); }
private static string GetMessage(MsDataFileUri importPath, Exception x) { string message = importPath.GetSampleName() == null ? string.Format(Resources.ChromCacheBuildException_GetMessage_Failed_importing_results_file___0___, importPath.GetFilePath()) : string.Format(Resources.ChromCacheBuildException_GetMessage_Failed_importing_results_file___0____sample__1__, importPath.GetFilePath(), importPath.GetSampleName()); return(TextUtil.LineSeparate(message, x.Message)); }
public ScanProvider(string docFilePath, MsDataFileUri dataFilePath, ChromSource source, float[] times, TransitionFullScanInfo[] transitions, Func <MsDataFileScanIds> getMsDataFileScanIds) { DocFilePath = docFilePath; DataFilePath = dataFilePath; Source = source; Times = times; Transitions = transitions; _getMsDataFileScanIds = getMsDataFileScanIds; }
public ScanProvider(string docFilePath, MsDataFileUri dataFilePath, ChromSource source, IList <float> times, TransitionFullScanInfo[] transitions, MeasuredResults measuredResults, Func <MsDataFileScanIds> getMsDataFileScanIds) { DocFilePath = docFilePath; DataFilePath = dataFilePath; Source = source; Times = times; Transitions = transitions; _measuredResultsReference = new WeakReference <MeasuredResults>(measuredResults); _getMsDataFileScanIds = getMsDataFileScanIds; }
private MsDataFileScanIds _msDataFileScanIds; // Indexed container of MsDataFileImpl ids #endregion Fields #region Constructors public ScanProvider(string docFilePath, MsDataFileUri dataFilePath, ChromSource source, float[] times, TransitionFullScanInfo[] transitions, Func<MsDataFileScanIds> getMsDataFileScanIds) { DocFilePath = docFilePath; DataFilePath = dataFilePath; Source = source; Times = times; Transitions = transitions; _getMsDataFileScanIds = getMsDataFileScanIds; }
public static ChromatogramSet FindChromatogramSet(SrmDocument document, MsDataFileUri path) { if (document.Settings.HasResults) { foreach (var chromSet in document.Settings.MeasuredResults.Chromatograms) { if (chromSet.MSDataFilePaths.Contains(path)) return chromSet; } } return null; }
public static MsDataFileUri GetExistingDataFilePath(string cachePath, MsDataFileUri msDataFileUri) { MsDataFilePath msDataFilePath = msDataFileUri as MsDataFilePath; if (null == msDataFilePath) { return(msDataFileUri); } string dataFilePathPartIgnore; return(GetExistingDataFilePath(cachePath, msDataFilePath, out dataFilePathPartIgnore)); }
public ChromFileInfo(MsDataFileUri filePath) : base(new ChromFileInfoId()) { ChorusUrl chorusUrl = filePath as ChorusUrl; if (null != chorusUrl) { FileWriteTime = chorusUrl.FileWriteTime; RunStartTime = chorusUrl.RunStartTime; filePath = chorusUrl.SetFileWriteTime(null).SetRunStartTime(null); } FilePath = filePath; InstrumentInfoList = new MsInstrumentConfigInfo[0]; }
public override void ReadXml(XmlReader reader) { // Read tag attributes base.ReadXml(reader); UseForRetentionTimeFilter = reader.GetBoolAttribute(ATTR.use_for_retention_time_prediction, false); AnalyteConcentration = reader.GetNullableDoubleAttribute(ATTR.analyte_concentration); SampleType = SampleType.FromName(reader.GetAttribute(ATTR.sample_type)); // Consume tag reader.Read(); // Check if there is an optimization function element, and read // if if there is. IXmlElementHelper <OptimizableRegression> helper = reader.FindHelper(OPTIMIZATION_HELPERS); if (helper != null) { OptimizationFunction = helper.Deserialize(reader); } var chromFileInfos = new List <ChromFileInfo>(); var fileLoadIds = new List <string>(); while (reader.IsStartElement(EL.sample_file) || reader.IsStartElement(EL.replicate_file) || reader.IsStartElement(EL.chromatogram_file)) { // Note that the file path is actually be a URI that encodes things like lockmass correction as well as filename ChromFileInfo chromFileInfo = new ChromFileInfo(MsDataFileUri.Parse(reader.GetAttribute(ATTR.file_path))); chromFileInfo = chromFileInfo.ChangeHasMidasSpectra(reader.GetBoolAttribute(ATTR.has_midas_spectra, false)); chromFileInfos.Add(chromFileInfo); string id = reader.GetAttribute(ATTR.id) ?? GetOrdinalSaveId(fileLoadIds.Count); fileLoadIds.Add(id); reader.Read(); if (reader.IsStartElement(EL.instrument_info_list)) { reader.Skip(); reader.Read(); } } Annotations = SrmDocument.ReadAnnotations(reader); MSDataFileInfos = chromFileInfos; _fileLoadIds = fileLoadIds.ToArray(); // Consume end tag reader.ReadEndElement(); }
// Returns false on cancellation private bool ProcessFile(MsDataFileUri filePath) { var results = _document.Settings.MeasuredResults; if (!results.MSDataFilePaths.Contains(filePath)) { return(true); // Nothing to do } if (_progressStatus != null) { _progressStatus = _progressStatus.ChangeMessage(filePath.GetFileName()); } _currentDisplayedTransitionGroupDocNode = null; var tolerance = (float)_document.Settings.TransitionSettings.Instrument.MzMatchTolerance; foreach (var pair in _document.MoleculePrecursorPairs) { var nodePep = pair.NodePep; var nodeGroup = pair.NodeGroup; var libKey = nodeGroup.GetLibKey(nodePep); // Across all replicates for this precursor, note the ion mobility at max intensity for this mz for (var i = 0; i < results.Chromatograms.Count; i++) { if (_progressMonitor != null && _progressMonitor.IsCanceled) { return(false); } ChromatogramGroupInfo[] chromGroupInfos; results.TryLoadChromatogram(i, nodePep, nodeGroup, tolerance, true, out chromGroupInfos); foreach (var chromInfo in chromGroupInfos.Where(c => Equals(filePath, c.FilePath))) { if (!ProcessChromInfo(filePath, chromInfo, pair, nodeGroup, tolerance, libKey)) { return(false); // User cancelled } } } } return(true); }
public CachedChromatogramDataProvider(ChromatogramCache cache, SrmDocument document, MsDataFileUri dataFilePath, ChromFileInfo fileInfo, bool? singleMatchMz, ProgressStatus status, int startPercent, int endPercent, ILoadMonitor loader) : base(fileInfo, status, startPercent, endPercent, loader) { _cache = cache; _fileIndex = cache.CachedFiles.IndexOf(f => Equals(f.FilePath, dataFilePath)); _chromKeyIndices = cache.GetChromKeys(dataFilePath).OrderBy(v => v.LocationPoints).ToArray(); _cache.GetStatusDimensions(dataFilePath, out _maxRetentionTime, out _maxIntensity); _singleMatchMz = singleMatchMz.HasValue ? singleMatchMz.Value // Unfortunately, before the single matching status was // written into the cache file, we can only guess about its // status based on the overall document settings : document.Settings.TransitionSettings.FullScan.IsEnabled; }
public CachedChromatogramDataProvider(ChromatogramCache cache, SrmDocument document, MsDataFileUri dataFilePath, ChromFileInfo fileInfo, bool?singleMatchMz, ProgressStatus status, int startPercent, int endPercent, ILoadMonitor loader) : base(fileInfo, status, startPercent, endPercent, loader) { _cache = cache; _fileIndex = cache.CachedFiles.IndexOf(f => Equals(f.FilePath, dataFilePath)); _chromKeyIndices = cache.GetChromKeys(dataFilePath).OrderBy(v => v.LocationPoints).ToArray(); _cache.GetStatusDimensions(dataFilePath, out _maxRetentionTime, out _maxIntensity); _singleMatchMz = singleMatchMz.HasValue ? singleMatchMz.Value // Unfortunately, before the single matching status was // written into the cache file, we can only guess about its // status based on the overall document settings : document.Settings.TransitionSettings.FullScan.IsEnabled; }
public CachedChromatogramDataProvider(ChromatogramCache cache, SrmDocument document, MsDataFileUri dataFilePath, ChromFileInfo fileInfo, bool?singleMatchMz, IProgressStatus status, int startPercent, int endPercent, ILoadMonitor loader) : base(fileInfo, status, startPercent, endPercent, loader) { // Deal with older cache formats where we did not record chromatogram polarity var assumeNegativeChargesInPreV11Caches = document.MoleculeTransitionGroups.All(p => p.PrecursorMz.IsNegative); // Need a newly loaded copy to allow for concurrent loading for multiple cached files _cache = ChromatogramCache.Load(cache.CachePath, new ProgressStatus(), loader, assumeNegativeChargesInPreV11Caches); _fileIndex = cache.CachedFiles.IndexOf(f => Equals(f.FilePath, dataFilePath)); _chromKeyIndices = cache.GetChromKeys(dataFilePath).OrderBy(v => v.LocationPoints).ToArray(); foreach (var c in _chromKeyIndices.Where(i => i.Key.Precursor != 0)) { if (c.Key.Precursor.IsNegative) { _sourceHasNegativePolarityData = true; } else { _sourceHasPositivePolarityData = true; } } _cache.GetStatusDimensions(dataFilePath, out _maxRetentionTime, out _maxIntensity); _singleMatchMz = singleMatchMz.HasValue ? singleMatchMz.Value // Unfortunately, before the single matching status was // written into the cache file, we can only guess about its // status based on the overall document settings : document.Settings.TransitionSettings.FullScan.IsEnabled; }
public LibraryIonMobilityInfo GetIonMobilities(MsDataFileUri filePath) { var libraries = PeptideSettings.Libraries; LibraryIonMobilityInfo ionMobilities; if (libraries.TryGetIonMobilities(filePath, out ionMobilities)) return ionMobilities; return null; }
public LibraryRetentionTimes GetRetentionTimes(MsDataFileUri filePath) { var libraries = PeptideSettings.Libraries; LibraryRetentionTimes retentionTimes; if (libraries.TryGetRetentionTimes(filePath, out retentionTimes)) return retentionTimes; return null; }
public bool TryGetRetentionTimes(string sequence, int charge, ExplicitMods mods, MsDataFileUri filePath, out IsotopeLabelType type, out double[] retentionTimes) { var libraries = PeptideSettings.Libraries; foreach (var typedSequence in GetTypedSequences(sequence, mods)) { var key = new LibKey(typedSequence.ModifiedSequence, charge); if (libraries.TryGetRetentionTimes(key, filePath, out retentionTimes)) { type = typedSequence.LabelType; return true; } } type = IsotopeLabelType.light; retentionTimes = null; return false; }
public double[] GetAllRetentionTimes(MsDataFileUri filePath, string peptideSequence, ExplicitMods explicitMods) { var times = new List<double>(); times.AddRange(GetRetentionTimes(filePath, peptideSequence, explicitMods)); times.AddRange(GetAlignedRetentionTimes(filePath, peptideSequence, explicitMods)); return times.ToArray(); }
/// <summary> /// Finds the TransitionGroupChromInfo that matches the specified ChromatogramSet name and file path. /// </summary> public static TransitionGroupChromInfo FindChromInfo(SrmDocument document, TransitionGroupDocNode transitionGroupDocNode, string nameChromatogramSet, MsDataFileUri filePath) { ChromatogramSet chromatogramSet; int indexSet; if (!document.Settings.MeasuredResults.TryGetChromatogramSet(nameChromatogramSet, out chromatogramSet, out indexSet)) { return null; } var chromFileInfoId = chromatogramSet.FindFile(filePath); if (null == chromFileInfoId) { return null; } var results = transitionGroupDocNode.Results[indexSet]; if (null == results) { return null; } return results.FirstOrDefault(chromInfo => ReferenceEquals(chromFileInfoId, chromInfo.FileId)); }
public static bool IsRemoteChromFile(MsDataFileUri msDataFileUri) { return(msDataFileUri is ChorusUrl || ChorusResponseChromDataProvider.IsChorusResponse(msDataFileUri)); }
protected PeakEventArgs(IdentityPath groupPath, string nameSet, MsDataFileUri filePath) { GroupPath = groupPath; NameSet = nameSet; FilePath = filePath; }
public static bool IsChorusResponse(MsDataFileUri msDataFileUri) { MsDataFilePath msDataFilePath = msDataFileUri as MsDataFilePath; return(null != msDataFilePath && msDataFilePath.GetExtension() == DataSourceUtil.EXT_CHORUSRESPONSE); }
public static string GetPathSampleNamePart(MsDataFileUri msDataFileUri) { return(msDataFileUri.GetSampleName()); }
public MissingDataException(string messageFormat, MsDataFileUri importPath, Exception innerException) : base(string.Format(messageFormat, importPath.GetFilePath()), importPath, innerException) { MessageFormat = messageFormat; }
public static string GetFileName(MsDataFileUri msDataFileUri) { return(msDataFileUri.GetFileName()); }
public ChromFileInfo ChangeFilePath(MsDataFileUri prop) { return(ChangeProp(ImClone(this), im => im.FilePath = prop)); }
public ChromFileInfo GetFileInfo(MsDataFileUri filePath) { return(GetFileInfo(IndexOfPath(filePath))); }
/// <summary> /// This function will add the given replicate, from dataFile, to the given document. If the replicate /// does not exist, it will be added. If it does exist, it will be appended to. /// </summary> public static SrmDocument ImportResults(SrmDocument doc, string docPath, string replicate, MsDataFileUri dataFile, OptimizableRegression optimize, IProgressMonitor progressMonitor, out ProgressStatus status) { using (var docContainer = new ResultsMemoryDocumentContainer(null, docPath) {ProgressMonitor = progressMonitor}) { // Make sure library loading happens, which may not happen, if the doc // parameter is used as the baseline document. docContainer.SetDocument(doc, null); SrmDocument docAdded; do { doc = docContainer.Document; var listChromatograms = new List<ChromatogramSet>(); if (doc.Settings.HasResults) listChromatograms.AddRange(doc.Settings.MeasuredResults.Chromatograms); int indexChrom = listChromatograms.IndexOf(chrom => chrom.Name.Equals(replicate)); if (indexChrom != -1) { var chromatogram = listChromatograms[indexChrom]; var paths = chromatogram.MSDataFilePaths; var listFilePaths = paths.ToList(); listFilePaths.Add(dataFile); listChromatograms[indexChrom] = chromatogram.ChangeMSDataFilePaths(listFilePaths); } else { listChromatograms.Add(new ChromatogramSet(replicate, new[] {dataFile.Normalize()}, Annotations.EMPTY, optimize)); } var results = doc.Settings.HasResults ? doc.Settings.MeasuredResults.ChangeChromatograms(listChromatograms) : new MeasuredResults(listChromatograms, doc.Settings.IsResultsJoiningDisabled); docAdded = doc.ChangeMeasuredResults(results); } while (!docContainer.SetDocument(docAdded, doc, true)); status = docContainer.LastProgress; return docContainer.Document; } }
public PickedPeakEventArgs(IdentityPath groupPath, Identity transitionId, string nameSet, MsDataFileUri filePath, ScaledRetentionTime retentionTime) : base(groupPath, nameSet, filePath) { TransitionId = transitionId; RetentionTime = retentionTime; }
public bool ImportResultsFile(MsDataFileUri replicateFile, string replicateName, DateTime? importBefore, DateTime? importOnOrAfter, OptimizableRegression optimize, bool disableJoining = false) { // Skip if file write time is after importBefore or before importAfter try { var fileLastWriteTime = replicateFile.GetFileLastWriteTime(); if (importBefore != null && importBefore < fileLastWriteTime) { _out.WriteLine(Resources.CommandLine_ImportResultsFile_File_write_date__0__is_after___import_before_date__1___Ignoring___, fileLastWriteTime, importBefore); return true; } else if (importOnOrAfter != null && importOnOrAfter >= fileLastWriteTime) { _out.WriteLine(Resources.CommandLine_ImportResultsFile_File_write_date__0__is_before___import_on_or_after_date__1___Ignoring___, fileLastWriteTime, importOnOrAfter); return true; } } catch (Exception e) { _out.WriteLine(Resources.CommandLine_ImportResultsInDir_Error__Could_not_get_last_write_time_for_file__0__, replicateFile); _out.WriteLine(e); return false; } _out.WriteLine(Resources.CommandLine_ImportResultsFile_Adding_results___); // Hack for un-readable RAW files from Thermo instruments. if(!CanReadFile(replicateFile)) { _out.WriteLine(Resources.CommandLine_ImportResultsFile_Warning__Cannot_read_file__0____Ignoring___, replicateFile); return true; } //This function will also detect whether the replicate exists in the document ProgressStatus status; SrmDocument newDoc; IProgressMonitor progressMonitor = new CommandProgressMonitor(_out, new ProgressStatus(string.Empty)); try { if (disableJoining) _doc = _doc.ChangeSettingsNoDiff(_doc.Settings.ChangeIsResultsJoiningDisabled(true)); newDoc = ImportResults(_doc,_skylineFile, replicateName, replicateFile, optimize, progressMonitor, out status); } catch (Exception x) { _out.WriteLine(Resources.CommandLine_ImportResultsFile_Error__Failed_importing_the_results_file__0__, replicateFile); _out.WriteLine(x.Message); return false; } status = status ?? new ProgressStatus(string.Empty).Complete(); if (status.IsError && status.ErrorException != null) { if (status.ErrorException is MissingDataException) { _out.WriteLine(Resources.CommandLine_ImportResultsFile_Warning__Failed_importing_the_results_file__0____Ignoring___, replicateFile); _out.WriteLine(status.ErrorException.Message); return true; } _out.WriteLine(Resources.CommandLine_ImportResultsFile_Error__Failed_importing_the_results_file__0__, replicateFile); _out.WriteLine(status.ErrorException.Message); return false; } if (!status.IsComplete || ReferenceEquals(_doc, newDoc)) { _out.WriteLine(Resources.CommandLine_ImportResultsFile_Error__Failed_importing_the_results_file__0__, replicateFile); return false; } _doc = newDoc; _out.WriteLine(Resources.CommandLine_ImportResultsFile_Results_added_from__0__to_replicate__1__, replicateFile.GetFileName(), replicateName); //the file was imported successfully _importCount++; return true; }
public MissingDataException(string messageFormat, MsDataFileUri importPath) : base(string.Format(messageFormat, importPath), importPath) { MessageFormat = messageFormat; }
public DataFileException(string message, MsDataFileUri importPath, Exception innerException) : base(message, innerException) { ImportPath = importPath; }
public ChromCacheBuildException(MsDataFileUri importPath, Exception innerException) : base(GetMessage(importPath, innerException), innerException) { ImportPath = importPath; }
private bool ProcessMSLevel(MsDataFileUri filePath, int msLevel, IEnumerable <ChromatogramInfo> transitionPointSets, ChromatogramGroupInfo chromInfo, double?apexRT, TransitionGroupDocNode nodeGroup, LibKey libKey, float tolerance) { var transitions = new List <TransitionFullScanInfo>(); var chromSource = (msLevel == 1) ? ChromSource.ms1 : ChromSource.fragment; IList <float> times = null; foreach (var tranPointSet in transitionPointSets.Where(t => t.Source == chromSource)) { transitions.Add(new TransitionFullScanInfo { //Name = tranPointSet.Header., Source = chromSource, TimeIntensities = tranPointSet.TimeIntensities, PrecursorMz = chromInfo.PrecursorMz, ProductMz = tranPointSet.ProductMz, ExtractionWidth = tranPointSet.ExtractionWidth, //Id = nodeTran.Id }); times = tranPointSet.Times; } if (!transitions.Any()) { return(true); // Nothing to do at this ms level } IScanProvider scanProvider = new ScanProvider(_documentFilePath, filePath, chromSource, times, transitions.ToArray(), _document.Settings.MeasuredResults, () => _document.Settings.MeasuredResults.LoadMSDataFileScanIds(filePath)); // Across all spectra at the peak retention time, find the one with max total // intensity for the mz's of interest (ie the isotopic distribution) and note its ion mobility. var scanIndex = MsDataFileScanHelper.FindScanIndex(times, apexRT.Value); _msDataFileScanHelper.UpdateScanProvider(scanProvider, 0, scanIndex); _msDataFileScanHelper.MsDataSpectra = null; // Reset scanIndex = _msDataFileScanHelper.GetScanIndex(); _msDataFileScanHelper.ScanProvider.SetScanForBackgroundLoad(scanIndex); lock (this) { while (_msDataFileScanHelper.MsDataSpectra == null && _dataFileScanHelperException == null) { if (_progressMonitor != null && _progressMonitor.IsCanceled) { return(false); } Monitor.Wait(this, 500); // Let background loader do its thing } } if (_dataFileScanHelperException != null) { throw new IOException(TextUtil.LineSeparate(Resources.DriftTimeFinder_HandleLoadScanException_Problem_using_results_to_populate_drift_time_library__, _dataFileScanHelperException.Message), _dataFileScanHelperException); } if (_progressMonitor != null && !ReferenceEquals(nodeGroup, _currentDisplayedTransitionGroupDocNode)) { // Do this after scan load so first group after file switch doesn't seem laggy _progressStatus = _progressStatus.ChangeMessage(TextUtil.LineSeparate(filePath.GetFileName(), nodeGroup.ToString())). UpdatePercentCompleteProgress(_progressMonitor, _currentStep++, _totalSteps); _currentDisplayedTransitionGroupDocNode = nodeGroup; } EvaluateBestIonMobilityValue(msLevel, libKey, tolerance, transitions); return(true); }
public NoCentroidedDataException(MsDataFileUri importPath, Exception innerException) : base(Resources.NoCentroidedDataException_NoCentroidedDataException_No_centroided_data_available_for_file___0_____Adjust_your_Full_Scan_settings_, importPath, innerException) { }
public int IndexOfPath(MsDataFileUri filePath) { return(MSDataFileInfos.IndexOf(info => Equals(filePath, info.FilePath))); }
public NoFullScanFilteringException(MsDataFileUri importPath) : base(Resources.NoFullScanFilteringException_NoFullScanFilteringException_The_file__0__does_not_contain_SRM_MRM_chromatograms__To_extract_chromatograms_from_its_spectra__go_to_Settings___Transition_Settings___Full_Scan_and_choose_options_appropriate_to_the_acquisition_method_used_, importPath) { }
public double[] GetAlignedRetentionTimes(MsDataFileUri filePath, string peptideSequence, ExplicitMods explicitMods) { string basename = filePath.GetFileNameWithoutExtension(); var fileAlignments = DocumentRetentionTimes.FileAlignments.Find(basename); return GetAlignedRetentionTimes(new RetentionTimeAlignmentIndices(fileAlignments), peptideSequence, explicitMods); }
public ChromatogramLoadingStatus ChangeFilePath(MsDataFileUri filePath) { return(ChangeProp(ImClone(this), s => s.FilePath = filePath)); }
public double[] GetBestRetentionTimes(PeptideDocNode nodePep, MsDataFileUri filePath) { if (!nodePep.IsProteomic) return new double[0]; // No retention time prediction for small molecules string lookupSequence = nodePep.SourceUnmodifiedTextId; var lookupMods = nodePep.SourceExplicitMods; if (filePath != null) { var times = GetRetentionTimes(filePath, lookupSequence, lookupMods); if (times.Length > 0) return times; times = GetAllRetentionTimes(filePath, lookupSequence, lookupMods); if (times.Length > 0) return times; } return GetUnalignedRetentionTimes(lookupSequence, lookupMods); }
public static string GetFileName(MsDataFileUri msDataFileUri) { return msDataFileUri.GetFileName(); }
public double[] GetRetentionTimes(MsDataFileUri filePath, string peptideSequence, ExplicitMods explicitMods, RetentionTimeAlignmentIndex alignmentIndex = null) { string basename = filePath.GetFileNameWithoutExtension(); var source = DocumentRetentionTimes.RetentionTimeSources.Find(basename); if (source == null) { return new double[0]; } var library = PeptideSettings.Libraries.GetLibrary(source.Library); if (library == null) { return new double[0]; } var modifiedSequences = GetTypedSequences(peptideSequence, explicitMods) .Select(typedSequence => typedSequence.ModifiedSequence); int? index = (alignmentIndex != null ? alignmentIndex.FileIndex : null); var times = library.GetRetentionTimesWithSequences(source.Name, modifiedSequences, ref index).ToArray(); if (alignmentIndex != null) alignmentIndex.FileIndex = index; return times; }
public NoFullScanDataException(MsDataFileUri importPath) : base(Resources.NoFullScanDataException_NoFullScanDataException_No_scans_in__0__match_the_current_filter_settings_, importPath) { }
// This is a hack for un-readable RAW files from Thermo instruments. // These files are usually 78KB. Presumably they are // temporary files that, for some reason, do not get deleted. private bool CanReadFile(MsDataFileUri msDataFileUri) { MsDataFilePath msDataFilePath = msDataFileUri as MsDataFilePath; if (null == msDataFilePath) { return true; } string replicatePath = msDataFilePath.FilePath; if (!File.Exists(replicatePath) && !Directory.Exists(replicatePath)) { _out.WriteLine(Resources.CommandLine_CanReadFile_Error__File_does_not_exist___0__,replicatePath); return false; } // Make sure this is a Thermo RAW file FileInfo fileInfo = new FileInfo(replicatePath); // We will not do this check for a directory source if(!fileInfo.Exists) { return true; } if(DataSourceUtil.GetSourceType(fileInfo) != DataSourceUtil.TYPE_THERMO_RAW) { return true; } // We will not do this chech for files over 100KB if(fileInfo.Length > (100 * 1024)) { return true; } // Try to read the file try { using (new MsDataFileImpl(replicatePath)) { } } catch(Exception e) { _out.WriteLine(e.Message); return false; } return true; }
public static MsDataFileUri GetExistingDataFilePath(string cachePath, MsDataFileUri msDataFileUri) { MsDataFilePath msDataFilePath = msDataFileUri as MsDataFilePath; if (null == msDataFilePath) { return msDataFileUri; } string dataFilePathPartIgnore; return GetExistingDataFilePath(cachePath, msDataFilePath, out dataFilePathPartIgnore); }
public bool ImportResultsFile(MsDataFileUri replicateFile, string replicateName, DateTime? importBefore, DateTime? importOnOrAfter, OptimizableRegression optimize, bool append, bool disableJoining) { if (string.IsNullOrEmpty(replicateName)) replicateName = replicateFile.GetFileNameWithoutExtension(); if(_doc.Settings.HasResults && _doc.Settings.MeasuredResults.ContainsChromatogram(replicateName)) { if (!append) { // CONSIDER: Error? Check if the replicate contains the file? // It does not seem right to just continue on to export a report // or new method without the results added. _out.WriteLine(Resources.CommandLine_ImportResultsFile_Warning__The_replicate__0__already_exists_in_the_given_document_and_the___import_append_option_is_not_specified___The_replicate_will_not_be_added_to_the_document_, replicateName); return true; } // If we are appending to an existing replicate in the document // make sure this file is not already in the replicate. ChromatogramSet chromatogram; int index; _doc.Settings.MeasuredResults.TryGetChromatogramSet(replicateName, out chromatogram, out index); string replicateFileString = replicateFile.ToString(); if (chromatogram.MSDataFilePaths.Any(filePath=>StringComparer.OrdinalIgnoreCase.Equals(filePath, replicateFileString))) { _out.WriteLine(Resources.CommandLine_ImportResultsFile__0______1___Note__The_file_has_already_been_imported__Ignoring___, replicateName, replicateFile); return true; } } return ImportResultsFile(replicateFile, replicateName, importBefore, importOnOrAfter, optimize, disableJoining); }
public ChromFileInfoId FindFile(MsDataFileUri filePath) { return GetFileId(IndexOfPath(filePath)); }
public NoSrmDataException(MsDataFileUri importPath) : base(Resources.NoSrmDataException_NoSrmDataException_No_SRM_MRM_data_found_in__0__, importPath) { }
public ChromFileInfo GetFileInfo(MsDataFileUri filePath) { return GetFileInfo(IndexOfPath(filePath)); }
public SpectrumFilter(SrmDocument document, MsDataFileUri msDataFileUri, IFilterInstrumentInfo instrumentInfo, IRetentionTimePredictor retentionTimePredictor = null, bool firstPass = false) { _fullScan = document.Settings.TransitionSettings.FullScan; _instrument = document.Settings.TransitionSettings.Instrument; _acquisitionMethod = _fullScan.AcquisitionMethod; if (instrumentInfo != null) { _isWatersFile = instrumentInfo.IsWatersFile; } IsFirstPass = firstPass; var comparer = PrecursorTextId.PrecursorTextIdComparerInstance; var dictPrecursorMzToFilter = new SortedDictionary <PrecursorTextId, SpectrumFilterPair>(comparer); if (EnabledMs || EnabledMsMs) { if (EnabledMs) { _isHighAccMsFilter = !Equals(_fullScan.PrecursorMassAnalyzer, FullScanMassAnalyzerType.qit); if (!firstPass) { var key = new PrecursorTextId(SignedMz.ZERO, null, ChromExtractor.summed); // TIC dictPrecursorMzToFilter.Add(key, new SpectrumFilterPair(key, PeptideDocNode.UNKNOWN_COLOR, dictPrecursorMzToFilter.Count, _instrument.MinTime, _instrument.MaxTime, null, null, 0, _isHighAccMsFilter, _isHighAccProductFilter)); key = new PrecursorTextId(SignedMz.ZERO, null, ChromExtractor.base_peak); // BPC dictPrecursorMzToFilter.Add(key, new SpectrumFilterPair(key, PeptideDocNode.UNKNOWN_COLOR, dictPrecursorMzToFilter.Count, _instrument.MinTime, _instrument.MaxTime, null, null, 0, _isHighAccMsFilter, _isHighAccProductFilter)); } } if (EnabledMsMs) { _isHighAccProductFilter = !Equals(_fullScan.ProductMassAnalyzer, FullScanMassAnalyzerType.qit); if (_fullScan.AcquisitionMethod == FullScanAcquisitionMethod.DIA && _fullScan.IsolationScheme.IsAllIons) { if (instrumentInfo != null) { _isWatersMse = _isWatersFile; _isAgilentMse = instrumentInfo.IsAgilentFile; } _mseLevel = 1; } } Func <double, double> calcWindowsQ1 = _fullScan.GetPrecursorFilterWindow; Func <double, double> calcWindowsQ3 = _fullScan.GetProductFilterWindow; _minTime = _instrument.MinTime; _maxTime = _instrument.MaxTime; bool canSchedule = CanSchedule(document, retentionTimePredictor); // TODO: Figure out a way to turn off time sharing on first SIM scan so that // times can be shared for MS1 without SIM scans _isSharedTime = !canSchedule; // If we're using bare measured drift times from spectral libraries, go get those now var libraryIonMobilityInfo = document.Settings.PeptideSettings.Prediction.UseLibraryDriftTimes ? document.Settings.GetIonMobilities(msDataFileUri) : null; foreach (var nodePep in document.Molecules) { if (firstPass && !retentionTimePredictor.IsFirstPassPeptide(nodePep)) { continue; } foreach (TransitionGroupDocNode nodeGroup in nodePep.Children) { if (nodeGroup.Children.Count == 0) { continue; } double? minTime = _minTime, maxTime = _maxTime; double? startDriftTimeMsec = null, endDriftTimeMsec = null; double windowDT; double highEnergyDriftTimeOffsetMsec = 0; DriftTimeInfo centerDriftTime = document.Settings.PeptideSettings.Prediction.GetDriftTime( nodePep, nodeGroup, libraryIonMobilityInfo, out windowDT); if (centerDriftTime.DriftTimeMsec(false).HasValue) { startDriftTimeMsec = centerDriftTime.DriftTimeMsec(false) - windowDT / 2; // Get the low energy drift time endDriftTimeMsec = startDriftTimeMsec + windowDT; highEnergyDriftTimeOffsetMsec = centerDriftTime.HighEnergyDriftTimeOffsetMsec; } if (canSchedule) { if (RetentionTimeFilterType.scheduling_windows == _fullScan.RetentionTimeFilterType) { double?centerTime = null; double windowRT = 0; if (retentionTimePredictor != null) { centerTime = retentionTimePredictor.GetPredictedRetentionTime(nodePep); } else { var prediction = document.Settings.PeptideSettings.Prediction; if (prediction.RetentionTime == null || !prediction.RetentionTime.IsAutoCalculated) { centerTime = document.Settings.PeptideSettings.Prediction.PredictRetentionTimeForChromImport( document, nodePep, nodeGroup, out windowRT); } } // Force the center time to be at least zero if (centerTime.HasValue && centerTime.Value < 0) { centerTime = 0; } if (_fullScan.RetentionTimeFilterLength != 0) { windowRT = _fullScan.RetentionTimeFilterLength * 2; } if (centerTime != null) { double startTime = centerTime.Value - windowRT / 2; double endTime = startTime + windowRT; minTime = Math.Max(minTime ?? 0, startTime); maxTime = Math.Min(maxTime ?? double.MaxValue, endTime); } } else if (RetentionTimeFilterType.ms2_ids == _fullScan.RetentionTimeFilterType) { var times = document.Settings.GetBestRetentionTimes(nodePep, msDataFileUri); if (times.Length > 0) { minTime = Math.Max(minTime ?? 0, times.Min() - _fullScan.RetentionTimeFilterLength); maxTime = Math.Min(maxTime ?? double.MaxValue, times.Max() + _fullScan.RetentionTimeFilterLength); } } } SpectrumFilterPair filter; string textId = nodePep.RawTextId; // Modified Sequence for peptides, or some other string for custom ions var mz = new SignedMz(nodeGroup.PrecursorMz, nodeGroup.PrecursorCharge < 0); var key = new PrecursorTextId(mz, textId, ChromExtractor.summed); if (!dictPrecursorMzToFilter.TryGetValue(key, out filter)) { filter = new SpectrumFilterPair(key, nodePep.Color, dictPrecursorMzToFilter.Count, minTime, maxTime, startDriftTimeMsec, endDriftTimeMsec, highEnergyDriftTimeOffsetMsec, _isHighAccMsFilter, _isHighAccProductFilter); dictPrecursorMzToFilter.Add(key, filter); } if (!EnabledMs) { filter.AddQ3FilterValues(from TransitionDocNode nodeTran in nodeGroup.Children select nodeTran.Mz, calcWindowsQ3); } else if (!EnabledMsMs) { filter.AddQ1FilterValues(GetMS1MzValues(nodeGroup), calcWindowsQ1); } else { filter.AddQ1FilterValues(GetMS1MzValues(nodeGroup), calcWindowsQ1); filter.AddQ3FilterValues(from TransitionDocNode nodeTran in nodeGroup.Children where !nodeTran.IsMs1 select nodeTran.Mz, calcWindowsQ3); } } } _filterMzValues = dictPrecursorMzToFilter.Values.ToArray(); var listChromKeyFilterIds = new List <ChromKey>(); foreach (var spectrumFilterPair in _filterMzValues) { spectrumFilterPair.AddChromKeys(listChromKeyFilterIds); } _productChromKeys = listChromKeyFilterIds.ToArray(); // Sort a copy of the filter pairs by maximum retention time so that we can detect when // filters are no longer active. _filterRTValues = new SpectrumFilterPair[_filterMzValues.Length]; Array.Copy(_filterMzValues, _filterRTValues, _filterMzValues.Length); Array.Sort(_filterRTValues, CompareByRT); } InitRTLimits(); }
public int IndexOfPath(MsDataFileUri filePath) { return MSDataFileInfos.IndexOf(info => Equals(filePath, info.FilePath)); }
private string GetGraphChromStrings(int iResult, ChromFileInfoId fileId, out MsDataFileUri filePath) { filePath = null; if (iResult != -1) { var settings = DocumentUI.Settings; if (settings.HasResults && iResult < settings.MeasuredResults.Chromatograms.Count) { var chromatogramSet = settings.MeasuredResults.Chromatograms[iResult]; if (fileId != null) filePath = chromatogramSet.GetFileInfo(fileId).FilePath; return chromatogramSet.Name; } } return null; }
public ChromFileInfo(MsDataFileUri filePath) : base(new ChromFileInfoId()) { ChorusUrl chorusUrl = filePath as ChorusUrl; if (null != chorusUrl) { FileWriteTime = chorusUrl.FileWriteTime; RunStartTime = chorusUrl.RunStartTime; filePath = chorusUrl.SetFileWriteTime(null).SetRunStartTime(null); } FilePath = filePath; InstrumentInfoList = new MsInstrumentConfigInfo[0]; }
public DataFileException(string message, MsDataFileUri importPath) : base(message) { ImportPath = importPath; }
public ChromFileInfo ChangeFilePath(MsDataFileUri prop) { return ChangeProp(ImClone(this), im => im.FilePath = prop); }
public SelectedScanEventArgs(MsDataFileUri dataFile, double retentionTime, Identity transitionId) { DataFile = dataFile; RetentionTime = retentionTime; TransitionId = transitionId; }
public double[] GetRetentionTimesNotAlignedTo(MsDataFileUri fileNotAlignedTo, string peptideSequence, ExplicitMods explicitMods) { var times = new List<double>(); string basename = fileNotAlignedTo.GetFileNameWithoutExtension(); var fileAlignments = DocumentRetentionTimes.FileAlignments.Find(basename); var modifiedSequences = GetTypedSequences(peptideSequence, explicitMods) .Select(typedSequence => typedSequence.ModifiedSequence).ToArray(); foreach (var library in PeptideSettings.Libraries.Libraries) { if (null == library) { continue; } foreach (var source in library.ListRetentionTimeSources()) { if (MeasuredResults.IsBaseNameMatch(source.Name, basename)) { continue; } if (null != fileAlignments) { if (null != fileAlignments.RetentionTimeAlignments.Find(source.Name)) { continue; } } int? indexIgnore = null; times.AddRange(library.GetRetentionTimesWithSequences(source.Name, modifiedSequences, ref indexIgnore)); } } return times.ToArray(); }
public static string GetPathSampleNamePart(MsDataFileUri msDataFileUri) { return msDataFileUri.GetSampleName(); }
public ChromFileInfoId FindFile(MsDataFileUri filePath) { return(GetFileId(IndexOfPath(filePath))); }