private static IEnumerable <double> ReadChromPrecursorsFromMsd(MsDataFileImpl msd, IProgressMonitor monitor) { for (var i = 0; i < msd.ChromatogramCount; i++) { if (monitor.IsCanceled) { yield break; } double?precursor = null; try { int tmp; var chromKey = ChromKey.FromId(msd.GetChromatogramId(i, out tmp), false); precursor = chromKey.Precursor; } catch { // ignored } if (precursor.HasValue) { yield return(precursor.Value); } } }
public ChromatogramDataProvider(MsDataFileImpl dataFile, ChromFileInfo fileInfo, ProgressStatus status, int startPercent, int endPercent, IProgressMonitor loader) : base(fileInfo, status, startPercent, endPercent, loader) { _dataFile = dataFile; if (_dataFile.IsThermoFile) { _readMaxMinutes = 4; } int len = dataFile.ChromatogramCount; _chromIndices = new int[len]; bool fixCEOptForShimadzu = dataFile.IsShimadzuFile; int indexPrecursor = -1; double lastPrecursor = 0; for (int i = 0; i < len; i++) { int index; string id = dataFile.GetChromatogramId(i, out index); if (!ChromKey.IsKeyId(id)) { continue; } var chromKey = ChromKey.FromId(id, fixCEOptForShimadzu); if (chromKey.Precursor != lastPrecursor) { lastPrecursor = chromKey.Precursor; indexPrecursor++; } var ki = new KeyValuePair <ChromKey, int>(chromKey, index); _chromIndices[index] = indexPrecursor; _chromIds.Add(ki); } // Shimadzu can't do the necessary product m/z stepping for itself. // So, they provide the CE values in their IDs and we need to adjust // product m/z values for them to support CE optimization. if (fixCEOptForShimadzu) { FixCEOptForShimadzu(); } if (_chromIds.Count == 0) { throw new NoSrmDataException(dataFile.FilePath); } SetPercentComplete(50); }
public GlobalChromatogramExtractor(MsDataFileImpl dataFile) { _dataFile = dataFile; IndexOffset = 0; if (dataFile.ChromatogramCount > 0 && dataFile.GetChromatogramId(0, out int indexId) == TIC_CHROMATOGRAM_ID) { TicChromatogramIndex = 0; } if (dataFile.ChromatogramCount > 1 && dataFile.GetChromatogramId(1, out int indexId2) == BPC_CHROMATOGRAM_ID) { BpcChromatogramIndex = 1; } QcTraceByIndex = new SortedDictionary <int, MsDataFileImpl.QcTrace>(); foreach (var qcTrace in dataFile.GetQcTraces() ?? new List <MsDataFileImpl.QcTrace>()) { QcTraceByIndex[qcTrace.Index] = qcTrace; } }
private void ComboChromatogramOnDropDown(object sender, EventArgs e) { if (_chromatogramDatas != null) { return; } comboChromatogram.Items.Clear(); using (var msDataFileImpl = new MsDataFileImpl(Workspace.GetDataFilePath(MsDataFile.Name))) { _chromatogramDatas = new ChromatogramData[msDataFileImpl.ChromatogramCount]; for (int i = 0; i < _chromatogramDatas.Length; i++) { int indexId; comboChromatogram.Items.Add(msDataFileImpl.GetChromatogramId(i, out indexId)); } } }
public ChromatogramDataProvider(MsDataFileImpl dataFile, ChromFileInfo fileInfo, IProgressStatus status, int startPercent, int endPercent, IProgressMonitor loader) : base(fileInfo, status, startPercent, endPercent, loader) { _dataFile = dataFile; if (_dataFile.IsThermoFile) { _readMaxMinutes = 4; } int len = dataFile.ChromatogramCount; _chromIndices = new int[len]; bool fixCEOptForShimadzu = dataFile.IsShimadzuFile; int indexPrecursor = -1; var lastPrecursor = SignedMz.ZERO; for (int i = 0; i < len; i++) { int index; string id = dataFile.GetChromatogramId(i, out index); if (!ChromKey.IsKeyId(id)) { continue; } var chromKey = ChromKey.FromId(id, fixCEOptForShimadzu); if (chromKey.Precursor != lastPrecursor) { lastPrecursor = chromKey.Precursor; indexPrecursor++; } var ki = new ChromKeyProviderIdPair(chromKey, index); _chromIndices[index] = indexPrecursor; _chromIds.Add(ki); } // Shimadzu can't do the necessary product m/z stepping for itself. // So, they provide the CE values in their IDs and we need to adjust // product m/z values for them to support CE optimization. if (fixCEOptForShimadzu) { FixCEOptForShimadzu(); } if (_chromIds.Count == 0) { throw new NoSrmDataException(FileInfo.FilePath); } // CONSIDER(kaipot): Some way to support mzML files converted from MIDAS wiff files _hasMidasSpectra = (dataFile.IsABFile) && SpectraChromDataProvider.HasSpectrumData(dataFile); SetPercentComplete(50); }
public ChromatogramDataProvider(MsDataFileImpl dataFile, ChromFileInfo fileInfo, IProgressStatus status, int startPercent, int endPercent, IProgressMonitor loader) : base(fileInfo, status, startPercent, endPercent, loader) { _dataFile = dataFile; _globalChromatogramExtractor = new GlobalChromatogramExtractor(dataFile); if (_dataFile.IsThermoFile) { _readMaxMinutes = 4; } int len = dataFile.ChromatogramCount; _chromIndices = new int[len]; bool fixCEOptForShimadzu = dataFile.IsShimadzuFile; int indexPrecursor = -1; var lastPrecursor = SignedMz.ZERO; for (int i = 0; i < len; i++) { int index; string id = dataFile.GetChromatogramId(i, out index); if (!ChromKey.IsKeyId(id)) { continue; } var chromKey = ChromKey.FromId(id, fixCEOptForShimadzu); if (chromKey.Precursor != lastPrecursor) { lastPrecursor = chromKey.Precursor; indexPrecursor++; } if (chromKey.Precursor.IsNegative) { _sourceHasNegativePolarityData = true; } else { _sourceHasPositivePolarityData = true; } var ki = new ChromKeyProviderIdPair(chromKey, index); _chromIndices[index] = indexPrecursor; _chromIds.Add(ki); } // Shimadzu can't do the necessary product m/z stepping for itself. // So, they provide the CE values in their IDs and we need to adjust // product m/z values for them to support CE optimization. if (fixCEOptForShimadzu) { FixCEOptForShimadzu(); } if (_chromIds.Count == 0) { throw new NoSrmDataException(FileInfo.FilePath); } // CONSIDER: TIC and BPC are not well defined for SRM and produced chromatograms with over 100,000 points in // Agilent CE optimization data. So, keep them off for now. // foreach (int globalIndex in _globalChromatogramExtractor.GlobalChromatogramIndexes) // { // _chromIndices[globalIndex] = globalIndex; // _chromIds.Add(new ChromKeyProviderIdPair(ChromKey.FromId(_globalChromatogramExtractor.GetChromatogramId(globalIndex, out int indexId), false), globalIndex)); // } foreach (var qcTracePair in _globalChromatogramExtractor.QcTraceByIndex) { _chromIndices[qcTracePair.Key] = qcTracePair.Key; _chromIds.Add(new ChromKeyProviderIdPair(ChromKey.FromQcTrace(qcTracePair.Value), qcTracePair.Key)); } // CONSIDER(kaipot): Some way to support mzML files converted from MIDAS wiff files _hasMidasSpectra = (dataFile.IsABFile) && SpectraChromDataProvider.HasSpectrumData(dataFile); _ionMobilityUnits = dataFile.IonMobilityUnits; _hasIonMobilityCombined = dataFile.HasCombinedIonMobilitySpectra; // When true, data source provides IMS data in 3-array format, which affects spectrum ID format SetPercentComplete(50); }
public string GetChromatogramId(int index, out int indexId) { return(_dataFile.GetChromatogramId(index, out indexId)); }