public MassSpectrum GetMassSpectrum(MassSpectrum metaSpectrum, SpectrumList spectrumList) { MassSpectrum spectrum = new MassSpectrum(metaSpectrum, spectrumList.spectrum(metaSpectrum.Index, true)); //MassSpectrum realMetaSpectrum = ( metaSpectrum.Tag as DataGridViewRow ).Tag as MassSpectrum; //realMetaSpectrum.Element.dataProcessing = spectrum.Element.dataProcessing; //realMetaSpectrum.Element.defaultArrayLength = spectrum.Element.defaultArrayLength; return(spectrum); }
public ParseSpectraFile(string mzmlPath, HashSet <int> scanNumSet, string ext) { int currentScanNum = -1; try { MSDataFile msd = new MSDataFile(mzmlPath); SpectrumList spectrumList = msd.run.spectrumList; for (int i = 0; i < spectrumList.size(); ++i) { Spectrum spectrum = spectrumList.spectrum(i, true); if (int.Parse(spectrum.cvParams[0].value) == 2) { Match match = scanNumPattern.Match(spectrum.id); currentScanNum = int.Parse(match.Groups[1].Value); if (scanNumSet.Contains(currentScanNum)) { MZIntensityPairList mzIntensityPairs = new MZIntensityPairList(); spectrum.getMZIntensityPairs(ref mzIntensityPairs); Dictionary <float, int> originalPeakList = new Dictionary <float, int>(mzIntensityPairs.Count); foreach (MZIntensityPair mzIntensity in mzIntensityPairs) { originalPeakList[(float)mzIntensity.mz] = (int)mzIntensity.intensity; } spectraMap[currentScanNum] = originalPeakList; } } } } catch (Exception ex) { MessageBox.Show(ex.Message + ": " + currentScanNum, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }
public MassSpectrum GetMassSpectrum( MassSpectrum metaSpectrum, SpectrumList spectrumList ) { MassSpectrum spectrum = new MassSpectrum( metaSpectrum, spectrumList.spectrum( metaSpectrum.Index, true ) ); //MassSpectrum realMetaSpectrum = ( metaSpectrum.Tag as DataGridViewRow ).Tag as MassSpectrum; //realMetaSpectrum.Element.dataProcessing = spectrum.Element.dataProcessing; //realMetaSpectrum.Element.defaultArrayLength = spectrum.Element.defaultArrayLength; return spectrum; }
public MassSpectrum GetMassSpectrum( MassSpectrum metaSpectrum, SpectrumList spectrumList ) { MassSpectrum spectrum = new MassSpectrum( this, spectrumList.spectrum( metaSpectrum.Index, true ) ); spectrum.Tag = metaSpectrum.Tag; return spectrum; }
public MassSpectrum GetMassSpectrum( int index, bool getBinaryData, SpectrumList spectrumList ) { return new MassSpectrum( this, spectrumList.spectrum( index, getBinaryData ) ); }
private static bool HasDriftTimeSpectraInList(SpectrumList spectrumList) { if (spectrumList == null || spectrumList.size() == 0) return false; // Assume that if any spectra have drift times, all do using (var spectrum = spectrumList.spectrum(0, false)) { return GetDriftTimeMsec(spectrum).HasValue; } }
private static bool HasSrmSpectraInList(SpectrumList spectrumList) { if (spectrumList == null || spectrumList.size() == 0) return false; // If the first spectrum is not SRM, the others will not be either using (var spectrum = spectrumList.spectrum(0, false)) { return IsSrmSpectrum(spectrum); } }
public Tuple <List <Point3D>, BoundingBox> Get3dSpectrum() { var result = new Tuple <List <Point3D>, BoundingBox>(new List <Point3D>(), new BoundingBox { MinX = Double.MaxValue, MaxX = Double.MinValue, MinY = Double.MaxValue, MaxY = Double.MinValue }); var bounds = result.Item2; if (StartIndex == EndIndex) { var s = SpectrumList.spectrum(StartIndex, true); var mzArray = s.getMZArray().data.Storage(); var intensityArray = s.getIntensityArray().data.Storage(); var mobilityArray = s.GetIonMobilityArray(); if (mobilityArray == null) { throw new NullReferenceException("mobilityBDA"); } for (int j = 0, end = mzArray.Length; j < end; ++j) { double mz = mzArray[j]; double intensity = intensityArray[j]; double mobility = mobilityArray[j]; bounds.MinX = Math.Min(bounds.MinX, mz); bounds.MinY = Math.Min(bounds.MinY, mobility); bounds.MaxX = Math.Max(bounds.MaxX, mz); bounds.MaxY = Math.Max(bounds.MaxY, mobility); result.Item1.Add(new Point3D(mz, mobility, intensity)); } } else { for (int i = StartIndex, end = EndIndex; i <= end; ++i) { var s = SpectrumList.spectrum(i, true); var mzArray = s.getMZArray().data.Storage(); var intensityArray = s.getIntensityArray().data.Storage(); var mobilityArray = s.GetIonMobilityArray(); for (int j = 0; j < mzArray.Length; ++j) { double mz = mzArray[j]; double intensity = intensityArray[j]; double mobility = mobilityArray?.ElementAt(j) ?? (double)s.scanList.scans[0].cvParamChild(CVID.MS_ion_mobility_attribute).value; bounds.MinX = Math.Min(bounds.MinX, mz); bounds.MinY = Math.Min(bounds.MinY, mobility); bounds.MaxX = Math.Max(bounds.MaxX, mz); bounds.MaxY = Math.Max(bounds.MaxY, mobility); result.Item1.Add(new Point3D(mz, mobility, intensity)); } } } return(result); }
protected string parseMsLevel(int index) { return(spectrumList.spectrum(index).cvParamChild(CVID.MS_ms_level).value.ToString()); }