private void ListFragementStructure(GlycanStructure argStructure) { //dgDetail DataTable dtDetail = new DataTable(); DataColumn dcID = new DataColumn("ID", Type.GetType("System.Int32")); DataColumn dcMass = new DataColumn("Mass", Type.GetType("System.Single")); DataColumn dcScore = new DataColumn("Score", Type.GetType("System.Single")); DataColumn dcStructure = new DataColumn("Structure", typeof(Image)); dtDetail.Columns.Add(dcID); dtDetail.Columns.Add(dcMass); dtDetail.Columns.Add(dcScore); dtDetail.Columns.Add(dcStructure); //dgDetail.DataSource = dtDetail; //dgDetail.Columns[0].Width = 30; //dgDetail.Columns[1].Width = 70; //dgDetail.Columns[2].Width = 50; //dgDetail.Columns[3].Width = 315; dtDetail.DefaultView.Sort = "Mass"; int idx = 0; float TotalScore = 0.0f; GlycansDrawer GDRaw; foreach (GlycanTreeNode frm in argStructure.TheoreticalFragment) { DataRow row = dtDetail.NewRow(); row[0] = idx; float glycanmass = COL.GlycoLib.GlycanMass.GetGlycanMasswithCharge(frm.GlycanType, argStructure.Charge) + argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, argStructure.Charge); int closepeakidx = MassUtility.GetClosestMassIdx(scan.MSPeaks, glycanmass); row[1] = glycanmass; if (MassUtility.GetMassPPM(glycanmass, scan.MSPeaks[closepeakidx].MonoisotopicMZ) < _torelance) { row[2] = scan.MSPeaks[closepeakidx].MonoIntensity / scan.MaxIntensity; } else { row[2] = 0.0f; } GDRaw = new GlycansDrawer(frm.GetIUPACString(), false); row[3] = GDRaw.GetImage(); idx++; dtDetail.Rows.Add(row); TotalScore = TotalScore + Convert.ToSingle(row[2]); } DataRow dtrow = dtDetail.NewRow(); dtrow[0] = idx; dtrow[1] = GlycanMass.GetGlycanMasswithCharge(argStructure.Root.GlycanType, argStructure.Charge) + argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, argStructure.Charge); dtrow[2] = TotalScore; GDRaw = new GlycansDrawer(argStructure.IUPACString, false); dtrow[3] = GDRaw.GetImage(); dtDetail.Rows.Add(dtrow); }
/// <summary> /// Scan No,Charge,Peptide Seq, MaxMz,Y1Mz,Y1Intensity,Y2Mz,Y2Intensity,Y3Mz,Y3Intensity,Y4Mz,Y4Intensity /// </summary> /// <returns></returns> public List <string> Process(int argMissCleavage) { List <string> result = new List <string>(); AminoAcidMass AAMW = new AminoAcidMass(); foreach (ProteinInfo p in _pInfo) { p.CreateCleavage(argMissCleavage); List <string> Glycopeptide = p.Glycopeptide(0); foreach (string Pep in Glycopeptide) { for (int i = 0; i <= 2; i++) { float PeptideMass = AAMW.GetMonoMW(Pep, true); List <float> Peakmz = GetPeakCluster(PeptideMass, _scan.ParentCharge - i); List <int> ClosePeakIdx = new List <int>(); int foundpeak = 0; double MaxIntensity = 0.0; double MaxMz = 0.0; foreach (float peak in Peakmz) { int closepeakidx = MassUtility.GetClosestMassIdx(_scan.MSPeaks, peak); ClosePeakIdx.Add(closepeakidx); if (MassUtility.GetMassPPM(peak, _scan.MSPeaks[closepeakidx].MonoMass) < _torelance) { if (_scan.MSPeaks[closepeakidx].MonoIntensity > MaxIntensity) { MaxIntensity = _scan.MSPeaks[closepeakidx].MonoIntensity; MaxMz = _scan.MSPeaks[closepeakidx].MonoMass; } foundpeak++; } } if (foundpeak >= 3) { string tmp = _scan.ScanNo + "," + Convert.ToString(_scan.ParentCharge - i) + "," + Pep + "," + MaxMz.ToString() + ","; for (int j = 0; j < 4; j++) { if (MassUtility.GetMassPPM(_scan.MSPeaks[ClosePeakIdx[j]].MonoMass, Peakmz[j]) < _torelance) { tmp = tmp + _scan.MSPeaks[ClosePeakIdx[j]].MonoMass + "," + (_scan.MSPeaks[ClosePeakIdx[j]].MonoIntensity / MaxIntensity) + ","; } else { tmp = tmp + ",,"; } } result.Add(tmp); } } } } return(result); }
private void btnGetPeaks_Click(object sender, EventArgs e) { if (raw != null) { int ScanNo = 1; if (!int.TryParse(txtScanNo_CSMSL.Text, out ScanNo)) { MessageBox.Show("Fill number in Scan number"); return; } MSScan scan = raw.ReadScan(ScanNo); int ClosedIdx = MassUtility.GetClosestMassIdx(scan.MZs, Convert.ToSingle(txtTargetMZ.Text)); List<int> Peaks = FindPeakIdx(scan.MZs, ClosedIdx, Convert.ToInt32(txtCharge.Text), Convert.ToSingle(txtPPM_CSMSL.Text)); string optStr = ""; for (int i = 0; i < Peaks.Count; i++) { optStr = optStr + "[" + Peaks[i] + "]" + scan.MZs[Peaks[i]] + "\t " + scan.Intensities[Peaks[i]] + Environment.NewLine; } txtPeak.Text = optStr; } }
public YxFinder(List <MSPeak> argSpectrum, float argY1, int argCharge, float argTolerance) { _y1 = argY1; _YxCount = 0; _charge = argCharge; GeneratedYxPeak(); _YxMzIdx = new float[5]; for (int i = 0; i <= 4; i++) { _YxMzIdx[i] = -1; } for (int i = 1; i <= 4; i++) { int idx = MassUtility.GetClosestMassIdx(argSpectrum, _YxMz[i]); if (MassUtility.GetMassPPM(argSpectrum[idx].MonoMass, _YxMz[i]) < argTolerance) { _YxMzIdx[i] = idx; _YxCount++; } } }
private static MSScan GetScanFromFile(int argScanNo, double argSingleToNoise, double argPeakBackground, double argPeptideBackground, short argMaxCharge, GlypID.Readers.clsRawData Raw) { float[] _cidMzs = null; float[] _cidIntensities = null; GlypID.Peaks.clsPeak[] _cidPeaks = new GlypID.Peaks.clsPeak[1]; GlypID.Peaks.clsPeak[] _parentPeaks = new GlypID.Peaks.clsPeak[1]; GlypID.HornTransform.clsHornTransform mobjTransform = new GlypID.HornTransform.clsHornTransform(); GlypID.HornTransform.clsHornTransformParameters mobjTransformParameters = new GlypID.HornTransform.clsHornTransformParameters(); GlypID.HornTransform.clsHornTransformResults[] _transformResult; GlypID.Peaks.clsPeakProcessor cidPeakProcessor = new GlypID.Peaks.clsPeakProcessor(); GlypID.Peaks.clsPeakProcessorParameters cidPeakParameters = new GlypID.Peaks.clsPeakProcessorParameters(); GlypID.Peaks.clsPeakProcessor parentPeakProcessor = new GlypID.Peaks.clsPeakProcessor(); GlypID.Peaks.clsPeakProcessorParameters parentPeakParameters = new GlypID.Peaks.clsPeakProcessorParameters(); //Start Read Scan MSScan scan = new MSScan(argScanNo); Raw.GetSpectrum(argScanNo, ref _cidMzs, ref _cidIntensities); scan.MsLevel = Raw.GetMSLevel(Convert.ToInt32(argScanNo)); double min_peptide_intensity = 0; scan.Time = Raw.GetScanTime(scan.ScanNo); scan.ScanHeader = Raw.GetScanDescription(scan.ScanNo); if (scan.MsLevel != 1) { float[] _parentRawMzs = null; float[] _parentRawIntensitys = null; string Header = Raw.GetScanDescription(argScanNo); cidPeakProcessor.ProfileType = GlypID.enmProfileType.CENTROIDED; if (Header.Substring(Header.IndexOf("+") + 1).Trim().StartsWith("p")) { cidPeakProcessor.ProfileType = GlypID.enmProfileType.PROFILE; } // cidPeakProcessor.DiscoverPeaks(ref _cidMzs, ref _cidIntensities, ref _cidPeaks, // Convert.ToSingle(mobjTransformParameters.MinMZ), Convert.ToSingle(mobjTransformParameters.MaxMZ), false); for (int chNum = 0; chNum < _cidMzs.Length; chNum++) { scan.MSPeaks.Add(new MSPeak( Convert.ToSingle(_cidMzs[chNum]), Convert.ToSingle(_cidIntensities[chNum]))); } //for (int chNum = 0; chNum < _cidMzs.Length; chNum++) //{ // scan.MSPeaks.Add(new MSPeak( // Convert.ToSingle(_cidMzs[chNum]), // Convert.ToSingle(_cidIntensities[chNum]))); //} // Get parent information scan.ParentScanNo = Raw.GetParentScan(scan.ScanNo); Raw.GetSpectrum(scan.ParentScanNo, ref _parentRawMzs, ref _parentRawIntensitys); parentPeakProcessor.ProfileType = GlypID.enmProfileType.PROFILE; parentPeakProcessor.DiscoverPeaks(ref _parentRawMzs, ref _parentRawIntensitys, ref _parentPeaks, Convert.ToSingle(mobjTransformParameters.MinMZ), Convert.ToSingle(mobjTransformParameters.MaxMZ), true); float _parentBackgroundIntensity = (float)parentPeakProcessor.GetBackgroundIntensity(ref _parentRawIntensitys); _transformResult = new GlypID.HornTransform.clsHornTransformResults[1]; bool found = false; if (Raw.IsFTScan(scan.ParentScanNo)) { // High resolution data found = mobjTransform.FindPrecursorTransform(Convert.ToSingle(_parentBackgroundIntensity), Convert.ToSingle(min_peptide_intensity), ref _parentRawMzs, ref _parentRawIntensitys, ref _parentPeaks, Convert.ToSingle(scan.ParentMZ), ref _transformResult); } if (!found)//de-isotope fail { // Low resolution data or bad high res spectra short cs = Raw.GetMonoChargeFromHeader(scan.ScanNo); double monoMZ = Raw.GetMonoMzFromHeader(scan.ScanNo); List <float> ParentMzs = new List <float>(_parentRawMzs); int CloseIdx = MassUtility.GetClosestMassIdx(ParentMzs, Convert.ToSingle(monoMZ)); if (cs > 0) { short[] charges = new short[1]; charges[0] = cs; mobjTransform.AllocateValuesToTransform(Convert.ToSingle(scan.ParentMZ), Convert.ToInt32(_parentRawIntensitys[CloseIdx]), ref charges, ref _transformResult); } else { // instrument has no charge just store 2 and 3. short[] charges = new short[2]; charges[0] = 2; charges[1] = 3; mobjTransform.AllocateValuesToTransform(Convert.ToSingle(scan.ParentMZ), Convert.ToInt32(_parentRawIntensitys[CloseIdx]), ref charges, ref _transformResult); } } if (_transformResult[0].mint_peak_index == -1) //De-isotope parent scan { //Get parent info MSScan _parentScan = GetScanFromFile(scan.ParentScanNo, argSingleToNoise, argPeakBackground, argPeptideBackground, argMaxCharge, Raw); float[] _MSMzs = null; float[] _MSIntensities = null; Raw.GetSpectrum(scan.ParentScanNo, ref _MSMzs, ref _MSIntensities); // Now find peaks parentPeakParameters.SignalToNoiseThreshold = 0; parentPeakParameters.PeakBackgroundRatio = 0.01; parentPeakProcessor.SetOptions(parentPeakParameters); parentPeakProcessor.ProfileType = GlypID.enmProfileType.PROFILE; parentPeakProcessor.DiscoverPeaks(ref _MSMzs, ref _MSIntensities, ref _cidPeaks, Convert.ToSingle(mobjTransformParameters.MinMZ), Convert.ToSingle(mobjTransformParameters.MaxMZ), true); //Look for charge and mono. float[] monoandcharge = FindChargeAndMono(_cidPeaks, Convert.ToSingle(Raw.GetParentMz(scan.ScanNo)), scan.ScanNo, Raw); //scan.ParentMonoMW = _parentScan.MSPeaks[ClosedIdx].MonoMass; //scan.ParentAVGMonoMW = _parentScan.MSPeaks[ClosedIdx].; scan.ParentMZ = monoandcharge[0]; if (monoandcharge[1] == 0.0f) { scan.ParentCharge = Convert.ToInt32(Raw.GetMonoChargeFromHeader(scan.ParentScanNo)); } else { scan.ParentCharge = Convert.ToInt32(monoandcharge[1]); } scan.ParentMonoMW = (monoandcharge[0] - Atoms.ProtonMass) * monoandcharge[1]; } else { scan.ParentMonoMW = (float)_transformResult[0].mdbl_mono_mw; scan.ParentAVGMonoMW = (float)_transformResult[0].mdbl_average_mw; scan.ParentMZ = (float)_transformResult[0].mdbl_mz; scan.ParentCharge = (int)_transformResult[0].mshort_cs; } scan.IsCIDScan = Raw.IsCIDScan(argScanNo); scan.IsFTScan = Raw.IsFTScan(argScanNo); Array.Clear(_transformResult, 0, _transformResult.Length); Array.Clear(_cidPeaks, 0, _cidPeaks.Length); Array.Clear(_cidMzs, 0, _cidMzs.Length); Array.Clear(_cidIntensities, 0, _cidIntensities.Length); Array.Clear(_parentRawMzs, 0, _parentRawMzs.Length); Array.Clear(_parentRawIntensitys, 0, _parentRawIntensitys.Length); } else //MS Scan { scan.ParentMZ = 0.0f; double mdbl_current_background_intensity = 0; // Now find peaks parentPeakParameters.SignalToNoiseThreshold = argSingleToNoise; parentPeakParameters.PeakBackgroundRatio = argPeakBackground; parentPeakProcessor.SetOptions(parentPeakParameters); parentPeakProcessor.ProfileType = GlypID.enmProfileType.PROFILE; parentPeakProcessor.DiscoverPeaks(ref _cidMzs, ref _cidIntensities, ref _cidPeaks, Convert.ToSingle(mobjTransformParameters.MinMZ), Convert.ToSingle(mobjTransformParameters.MaxMZ), true); mdbl_current_background_intensity = parentPeakProcessor.GetBackgroundIntensity(ref _cidIntensities); // Settings min_peptide_intensity = mdbl_current_background_intensity * mobjTransformParameters.PeptideMinBackgroundRatio; if (mobjTransformParameters.UseAbsolutePeptideIntensity) { if (min_peptide_intensity < mobjTransformParameters.AbsolutePeptideIntensity) { min_peptide_intensity = mobjTransformParameters.AbsolutePeptideIntensity; } } mobjTransformParameters.PeptideMinBackgroundRatio = argPeptideBackground; mobjTransformParameters.MaxCharge = argMaxCharge; mobjTransform.TransformParameters = mobjTransformParameters; // Now perform deisotoping _transformResult = new GlypID.HornTransform.clsHornTransformResults[1]; mobjTransform.PerformTransform(Convert.ToSingle(mdbl_current_background_intensity), Convert.ToSingle(min_peptide_intensity), ref _cidMzs, ref _cidIntensities, ref _cidPeaks, ref _transformResult); // for getting results for (int chNum = 0; chNum < _transformResult.Length; chNum++) { double sumintensity = 0.0; double mostIntenseIntensity = 0.0; for (int i = 0; i < _transformResult[chNum].marr_isotope_peak_indices.Length; i++) { sumintensity = sumintensity + _cidPeaks[_transformResult[chNum].marr_isotope_peak_indices[i]].mdbl_intensity; if (Math.Abs(_transformResult[chNum].mdbl_most_intense_mw - (_cidPeaks[_transformResult[chNum].marr_isotope_peak_indices[i]].mdbl_mz * _transformResult[chNum].mshort_cs - Atoms.ProtonMass * _transformResult[chNum].mshort_cs)) < 1.0 / _transformResult[chNum].mshort_cs) { mostIntenseIntensity = _cidPeaks[_transformResult[chNum].mint_peak_index].mdbl_intensity; } } scan.MSPeaks.Add(new MSPeak( Convert.ToSingle(_transformResult[chNum].mdbl_mono_mw), _transformResult[chNum].mint_mono_intensity, _transformResult[chNum].mshort_cs, Convert.ToSingle(_transformResult[chNum].mdbl_mz), Convert.ToSingle(_transformResult[chNum].mdbl_fit), Convert.ToSingle(_transformResult[chNum].mdbl_most_intense_mw), mostIntenseIntensity, sumintensity )); } Array.Clear(_transformResult, 0, _transformResult.Length); Array.Clear(_cidPeaks, 0, _cidPeaks.Length); Array.Clear(_cidMzs, 0, _cidMzs.Length); Array.Clear(_cidIntensities, 0, _cidIntensities.Length); } return(scan); }
private void bgWorker_Process_DoWork(object sender, DoWorkEventArgs e) { AAMW = new AminoAcidMass(); this.lblStatus.SafeBeginInvoke(new Action(() => lblStatus.Text = "Begin initial raw file")); Raw = new ThermoRawReader(_rawFile); this.lblStatus.SafeBeginInvoke(new Action(() => lblStatus.Text = "Initial raw file completed")); List <GlycanSequencing> lstGS = new List <GlycanSequencing>(); if (_UseGlycanList) { _GlycanCompounds = ReadGlycanListFromFile.ReadGlycanList(_glycanFile, false, _Human, false); _MassGlycanMapping = new Dictionary <double, GlycanCompound>(); _GlycanCompoundMassList = new List <float>(); foreach (GlycanCompound G in _GlycanCompounds) { if (!_MassGlycanMapping.ContainsKey(G.AVGMass)) { _MassGlycanMapping.Add(G.AVGMass, G); _GlycanCompoundMassList.Add((float)G.AVGMass); } } } for (int i = 0; i < lstScans.Count; i++) { int ScanNo = lstScans[i]; if (Raw.GetMsLevel(ScanNo) == 1) { CurrentScan = ScanNo; int ProcessReport = Convert.ToInt32((i / (float)lstScans.Count) * 100); //Console.WriteLine("Scan:" + ScanNo.ToString()+"\t Peptide:" + Peptide + " completed"); bgWorker_Process.ReportProgress(ProcessReport); this.lblStatus.SafeBeginInvoke(new Action(() => lblStatus.Text = "MS scan pass:"******"Scan:" + ScanNo.ToString()+"\t Peptide:" + Peptide + " completed"); bgWorker_Process.ReportProgress(ProcessReport); this.lblStatus.SafeBeginInvoke(new Action(() => lblStatus.Text = "Not CID scan pass:"******"ms2")+4, _scan.ScanHeader.IndexOf("@") - _scan.ScanHeader.IndexOf("ms2")-3) + "hcd"; do { CheckScanNO++; // if (Raw.GlypIDReader.GetScanDescription(CheckScanNO).Contains(ScanHeader)) // { // HCDScanNo = CheckScanNO; // HCD = new HCDInfo(Raw.GlypIDReader, HCDScanNo); // break; // } if (Raw.GetHCDInfo(CheckScanNO) != null) { HCD = Raw.GetHCDInfo(CheckScanNO); break; } } while (Raw.GetMsLevel(CheckScanNO) != 1); //Check Until hit Next Full MS //CA: Complex Asialyated, CS:Complex Sialylated, HM:High mannose, HY:Hybrid and NA } if (HCD != null) { Console.WriteLine("CID Scan No:" + ScanNo.ToString() + "\tHCD Scan No:" + HCDScanNo.ToString() + "\tGlycanType:" + HCD.GlycanType.ToString()); } this.lblStatus.SafeBeginInvoke(new Action(() => lblStatus.Text = "Sequencing:" + ScanNo.ToString())); foreach (string Peptide in _Peptides) { float PeptideMass = AAMW.GetMonoMW(Peptide, true); for (int j = PrecursorCharge - 1; j <= PrecursorCharge; j++) { int Y1ChargeSt = j; if (j == 0) { continue; } float PredictedY1 = 0.0f; PredictedY1 = (float)(PeptideMass + GlycanMass.GetGlycanAVGMass(Glycan.Type.HexNAc) + COL.MassLib.Atoms.ProtonMass * Y1ChargeSt) / Y1ChargeSt; GlycanSequencing GS = null; if (_UseGlycanList) { float GlycanMonoMass = (_scan.ParentMZ - Atoms.ProtonMass) * _scan.ParentCharge - AAMW.GetAVGMonoMW(Peptide, true); float PrecursorMono = _scan.ParentMonoMW; //if (_scan.ParentAVGMonoMW != 0.0) //{ // GlycanMonoMass = _scan.ParentAVGMonoMW - PeptideMass + (Atoms.HydrogenAVGMass * 2 + Atoms.OxygenAVGMass); // PrecursorMono = _scan.ParentAVGMonoMW; //} //else //{ // GlycanMonoMass = (_scan.ParentMZ - Atoms.ProtonMass) * _scan.ParentCharge - PeptideMass + (Atoms.HydrogenAVGMass * 2 + Atoms.OxygenAVGMass); // PrecursorMono = _scan.ParentMonoMW; //} List <GlycanCompound> ClosedGlycans = new List <GlycanCompound>(); foreach (float gMass in _GlycanCompoundMassList) { if (Math.Abs(gMass - GlycanMonoMass) < 100.0f) { ClosedGlycans.Add(_GlycanCompounds[MassUtility.GetClosestMassIdx(_GlycanCompoundMassList, gMass)]); } } //if (HCD != null) //{ // if ((HCD.GlycanType == GlypID.enmGlycanType.CA && ClosedGlycan.NoOfSia>0) || // (HCD.GlycanType == GlypID.enmGlycanType.HM && (ClosedGlycan.NoOfSia!=0||ClosedGlycan.NoOfHexNAc!=2 || ClosedGlycan.NoOfDeHex!=0) ) || // (HCD.GlycanType == GlypID.enmGlycanType.CS && ClosedGlycan.NoOfSia==0)) // { // continue; // } //} //if (Math.Abs(ClosedGlycan.AVGMass - GlycanMonoMass) <= _MSMSTol) foreach (GlycanCompound ClosedGlycan in ClosedGlycans) { if (_Human) //NeuAc { int NoOfSia = ClosedGlycan.NoOfSia; int NoOfDeHex = ClosedGlycan.NoOfDeHex; if (HCD != null && HCD.GlycanType == COL.MassLib.enumGlycanType.CA && ClosedGlycan.NoOfSia > 0) { NoOfDeHex = NoOfDeHex + NoOfSia * 2; NoOfSia = 0; } GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, ClosedGlycan.NoOfHex, ClosedGlycan.NoOfHexNAc, NoOfDeHex, NoOfSia, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol); } else //NeuGc { GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, ClosedGlycan.NoOfHex, ClosedGlycan.NoOfHexNAc, ClosedGlycan.NoOfDeHex, 0, ClosedGlycan.NoOfSia, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol); } GS.NumbersOfPeaksForSequencing = 140; GS.UseAVGMass = _AverageMass; GS.CreatePrecursotMZ = true; if (!_CompletedOnly) { GS.RewardForCompleteStructure = 0.0f; } if (HCD != null) { GS.GlycanType = HCD.GlycanType; } GS.StartSequencing(); if (_CompletedOnly && GS.FullSequencedStructures.Count == 0) { continue; } lstGS.Add(GS); CurrentScan = ScanNo; CurrentPeptide = GS.PeptideSeq; int ProcessReport = Convert.ToInt32((i / (float)lstScans.Count) * 100); //Console.WriteLine("Scan:" + ScanNo.ToString()+"\t Peptide:" + Peptide + " completed"); bgWorker_Process.ReportProgress(ProcessReport); } } else // no list { if (_Human) //NeuAc { if (HCD != null) { //CA: Complex Asialyated, CS:Complex Sialylated, HM:High mannose, HY:Hybrid and NA if (HCD.GlycanType == enumGlycanType.CA) { GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, 0, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol); } else if (HCD.GlycanType == enumGlycanType.HM) { GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, 2, 0, 0, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol); } else { GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, _NoSia, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol); } } else { GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, _NoSia, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol); } } else //NeuGc { if (HCD != null) { //CA: Complex Asialyated, CS:Complex Sialylated, HM:High mannose, HY:Hybrid and NA if (HCD.GlycanType == enumGlycanType.CA) { GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, 0, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol); } else if (HCD.GlycanType == enumGlycanType.HM) { GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, 2, 0, 0, 0, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol); } else { GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, 0, _NoSia, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol); } } else { GS = new GlycanSequencing(_scan, Peptide, true, Y1ChargeSt, _NoHex, _NoHexNAc, _NoDeHex, 0, _NoSia, @"d:\tmp", _NGlycan, _MSMSTol, _PrecursorTol); } } GS.NumbersOfPeaksForSequencing = 140; GS.UseAVGMass = _AverageMass; GS.CreatePrecursotMZ = true; if (!_CompletedOnly) { GS.RewardForCompleteStructure = 0.0f; } if (HCD != null) { GS.GlycanType = HCD.GlycanType; } GS.StartSequencing(); if (_CompletedOnly && GS.FullSequencedStructures.Count == 0) { continue; } lstGS.Add(GS); CurrentScan = ScanNo; CurrentPeptide = GS.PeptideSeq; int ProcessReport = Convert.ToInt32((i / (float)lstScans.Count) * 100); //Console.WriteLine("Scan:" + ScanNo.ToString()+"\t Peptide:" + Peptide + " completed"); bgWorker_Process.ReportProgress(ProcessReport); } } //Foreach charge } //Foreach peptide if (lstGS.Count > 0) { GenerateReportBody(lstGS); } }//Foreach Scan }
public static void Processing(ref MultiGlycanESI argMultiGlycan) { try { List <string> identifiedGlycan = argMultiGlycan.IdentifiedGlycanCompounds.Select(x => x.GlycanKey).Distinct().ToList(); Dictionary <string, List <int> > dictGlycanKeySearchRange = new Dictionary <string, List <int> >(); int LastScan = argMultiGlycan.RawReader.NumberOfScans; foreach (string glycanKey in identifiedGlycan) { List <int> identifedScans = argMultiGlycan.MatchedPeakInScan.Where(x => x.GlycanComposition.GlycanKey == glycanKey) .Select(y => y.ScanNum) .ToList(); identifedScans.Sort(); int frontEdge = identifedScans[0]; double FirstIdentifiedTime = argMultiGlycan.RawReader.ReadScan(frontEdge).Time; while (frontEdge > 1) { frontEdge -= 1; if (argMultiGlycan.RawReader.GetMsLevel(frontEdge) != 1) { continue; } MSScan s = argMultiGlycan.RawReader.ReadScan(frontEdge); if (FirstIdentifiedTime - s.Time > 5) { break; } } int backEdge = identifedScans[identifedScans.Count - 1]; double LastIdentifedTime = argMultiGlycan.RawReader.ReadScan(backEdge).Time; while (backEdge < LastScan) { backEdge += 1; if (argMultiGlycan.RawReader.GetMsLevel(backEdge) != 1) { continue; } MSScan s = argMultiGlycan.RawReader.ReadScan(backEdge); if (s.Time - LastIdentifedTime > 5) { break; } } dictGlycanKeySearchRange.Add(glycanKey, new List <int>() { frontEdge, backEdge }); } List <MSScan> msScans = new List <MSScan>(); string previousGlycanKey = ""; foreach (GlycanCompound g in argMultiGlycan.GlycanList.OrderBy(x => x.GlycanKey)) { if (!identifiedGlycan.Contains(g.GlycanKey)) { continue; } if (previousGlycanKey != g.GlycanKey) { msScans.Clear(); //Read Scans int startScan = dictGlycanKeySearchRange[g.GlycanKey][0] >= 1 ? dictGlycanKeySearchRange[g.GlycanKey][0] : 1; int endScan = dictGlycanKeySearchRange[g.GlycanKey][1] <= LastScan ? dictGlycanKeySearchRange[g.GlycanKey][1] : LastScan; msScans.AddRange(argMultiGlycan.RawReader.ReadScanWMSLevel(startScan, endScan, 1)); previousGlycanKey = g.GlycanKey; } //FindPeaks int charge = g.Charge; List <List <MSScan> > scanSectionsContainPeaks = new List <List <MSScan> >(); for (int i = 0; i < msScans.Count; i++) { MSScan scan = msScans[i]; int closedIdx = MassUtility.GetClosestMassIdx(scan.MZs, (float)g.MZ); if (MassUtility.GetMassPPM(scan.MZs[closedIdx], g.MZ) <= argMultiGlycan.MassPPM) { List <int> peaks = FindPeakIdx(scan.MZs, closedIdx, charge, argMultiGlycan.IsotopePPM); if (peaks.Count - peaks.IndexOf(closedIdx) < argMultiGlycan.MininumIsotopePeakCount) { continue; } //Found peaks if (scanSectionsContainPeaks.Count > 0) { MSScan lastSectionLastScan = scanSectionsContainPeaks.Last().Last(); if (scan.Time - lastSectionLastScan.Time > 2.5) { scanSectionsContainPeaks.Add(new List <MSScan>() { scan }); } else { scanSectionsContainPeaks.Last().Add(scan); } } else { scanSectionsContainPeaks.Add(new List <MSScan>() { scan }); } } } //If scans can form an elution profile add to identifed result; foreach (List <MSScan> sectionScans in scanSectionsContainPeaks) { if (sectionScans.Count < 3) { continue; } else { //Add matched peak foreach (MSScan s in sectionScans) { int PeakIdx = MassUtility.GetClosestMassIdx(s.MZs, (float)g.MZ); MatchedGlycanPeak mPeak = new MatchedGlycanPeak(s.ScanNo, s.Time, s.MSPeaks[PeakIdx], g); List <int> peaks = FindPeakIdx(s.MZs, PeakIdx, charge, argMultiGlycan.IsotopePPM); int startIdx = peaks.IndexOf(PeakIdx); List <MSPoint> lstIsotopes = new List <MSPoint>(); for (int i = startIdx; i < peaks.Count; i++) { lstIsotopes.Add(new MSPoint(s.MZs[peaks[i]], s.Intensities[peaks[i]])); } mPeak.MSPoints = lstIsotopes; if (!argMultiGlycan.MatchedPeakInScan.Contains(mPeak)) { argMultiGlycan.MatchedPeakInScan.Add(mPeak); } } } } } //foreach (GlycanCompound g in argMultiGlycan.IdentifiedGlycanCompounds) //{ // processed = g; // //Search Peak in front of the peak // ThermoRawReader raw = (ThermoRawReader)argMultiGlycan.RawReader; // List<int> identifedScans = argMultiGlycan.MatchedPeakInScan.Where(x => x.GlycanComposition == g).Select(y => y.ScanNum).ToList(); // for (int i = 0; i < identifedScans.Count; i++) // { // int identifiedScanNum = identifedScans[i]; // while (true) // { // identifiedScanNum -= 1; // if (identifiedScanNum < 1 || raw.GetRetentionTime(identifedScans[i]) - raw.GetRetentionTime(identifiedScanNum) > argMultiGlycan.MaxLCFrontMin) // { // break; // } // if (raw.GetMsLevel((identifiedScanNum)) != 1) // { // continue; // } // MSScan scan = raw.ReadScan(identifiedScanNum); // int PeakIdx = MassUtility.GetClosestMassIdx(scan.MZs, (float)g.MZ); // if (MassUtility.GetMassPPM(scan.MZs[PeakIdx], g.MZ) > argMultiGlycan.MassPPM) // { // continue; // } // //Find isotope cluster // List<MSPoint> lstIsotopes = new List<MSPoint>(); // lstIsotopes.Add(new MSPoint(scan.MZs[PeakIdx],scan.Intensities[PeakIdx])); // float targetMZ = (float)g.MZ; // do // { // targetMZ += 1.0f/g.Charge; // PeakIdx = MassUtility.GetClosestMassIdx(scan.MZs, targetMZ); // if (MassUtility.GetMassPPM(scan.MZs[PeakIdx], targetMZ) <= argMultiGlycan.MassPPM) // { // lstIsotopes.Add(new MSPoint(scan.MZs[PeakIdx],scan.Intensities[PeakIdx])); // } // else // { // break; // } // } while (true); // if (lstIsotopes.Count < argMultiGlycan.MininumIsotopePeakCount) // { // continue; // } // MatchedGlycanPeak mPeak = new MatchedGlycanPeak(scan.ScanNo, scan.Time, scan.MSPeaks[PeakIdx], g); // mPeak.MSPoints = lstIsotopes; // if (!argMultiGlycan.MatchedPeakInScan.Contains(mPeak)) // { // argMultiGlycan.MatchedPeakInScan.Add(mPeak); // } // } // identifiedScanNum = identifedScans[i]; // while (true) // { // identifiedScanNum += 1; // if (identifiedScanNum > raw.NumberOfScans || raw.GetRetentionTime(identifiedScanNum) - raw.GetRetentionTime(identifedScans[i]) > argMultiGlycan.MaxLCBackMin) // { // break; // } // if (raw.GetMsLevel((identifiedScanNum)) != 1) // { // continue; // } // MSScan scan = raw.ReadScan(identifiedScanNum); // int PeakIdx = MassUtility.GetClosestMassIdx(scan.MZs, (float)g.MZ); // if (MassUtility.GetMassPPM(scan.MZs[PeakIdx], g.MZ) > argMultiGlycan.MassPPM) // { // continue; // } // //Find isotope cluster // List<MSPoint> lstIsotopes = new List<MSPoint>(); // lstIsotopes.Add(new MSPoint(scan.MZs[PeakIdx], scan.Intensities[PeakIdx])); // float targetMZ = (float)g.MZ; // do // { // targetMZ += 1.0f / g.Charge; // PeakIdx = MassUtility.GetClosestMassIdx(scan.MZs, targetMZ); // if (MassUtility.GetMassPPM(scan.MZs[PeakIdx], targetMZ) <= argMultiGlycan.MassPPM) // { // lstIsotopes.Add(new MSPoint(scan.MZs[PeakIdx], scan.Intensities[PeakIdx])); // } // else // { // break; // } // } while (true); // if (lstIsotopes.Count < argMultiGlycan.MininumIsotopePeakCount) // { // continue; // } // MatchedGlycanPeak mPeak = new MatchedGlycanPeak(scan.ScanNo, scan.Time, scan.MSPeaks[PeakIdx], g); // mPeak.MSPoints = lstIsotopes; // if (!argMultiGlycan.MatchedPeakInScan.Contains(mPeak)) // { // argMultiGlycan.MatchedPeakInScan.Add(mPeak); // } // } // } //} } catch (Exception ex) { throw ex; } }