private void btnLoadRawCSMSL_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { STimer = DateTime.Now; if (Path.GetExtension(openFileDialog1.FileName).ToLower() == ".raw") { raw = new ThermoRawReader(openFileDialog1.FileName); lblRawInfo.Text = "Raw information\n" + "Last scan:" + raw.NumberOfScans.ToString() + "\n" + "Initial Time:" + DateTime.Now.Subtract(STimer).TotalSeconds.ToString("0.00") + " s"; btnBackward_CSMSL.Enabled = true; btnForward_CSMSL.Enabled = true; btnRead_CSMSL.Enabled = true; } else if (Path.GetExtension(openFileDialog1.FileName).ToLower() == ".mzxml") { raw = new mzXMLRawReader(openFileDialog1.FileName); DateTime starTime = DateTime.Now; for (int i = 1; i <= 1000; i++) { MSScan S1 = raw.ReadScan(i); } double Total = DateTime.Now.Subtract(starTime).TotalSeconds; } else { MessageBox.Show("File not supported"); } } }
private static string SendScanViaNamedPipe(MSScan argMSScan) { System.Runtime.Serialization.IFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); MemoryStream memStream = new MemoryStream(); f.Serialize(memStream, argMSScan); byte[] WriteBuffer = memStream.ToArray(); string responseMsg = ""; CSNamedPipe.NativeNamedPipeClient.Run(@"\\.\pipe\MSScan", WriteBuffer, out responseMsg); return(responseMsg); }
private void btnReader_Click(object sender, EventArgs e) { RawReader raw = new RawReader(txtFileName.Text, enumRawDataType.raw); for (int i = 1; i < 2000; i++) { MSScan s = raw.ReadScan(i); Console.WriteLine(i.ToString()); } //ReadScan(Convert.ToInt32(txtScanNo.Text)); raw = null; GC.Collect(); }
private void btnRead_Click(object sender, EventArgs e) { if (rawReader == null) { MessageBox.Show("Load Raw data first"); return; } if (txtScanNo.Text == "") { MessageBox.Show("Input Scan number"); return; } txtPeaks.Text = ""; int ScanNo = Convert.ToInt32(txtScanNo.Text); GlypID.Peaks.clsPeakProcessorParameters _peakParameter = new GlypID.Peaks.clsPeakProcessorParameters(); GlypID.HornTransform.clsHornTransformParameters _transformParameters = new GlypID.HornTransform.clsHornTransformParameters(); _transformParameters.UseAbsolutePeptideIntensity = chkPeptideMinAbso.Checked; _transformParameters.AbsolutePeptideIntensity = 0.0; if (_transformParameters.UseAbsolutePeptideIntensity) { _transformParameters.AbsolutePeptideIntensity = Convert.ToDouble(txtPeptideMinAbso.Text); } _transformParameters.MaxCharge = Convert.ToInt16(txtMaxCharge.Text); _transformParameters.PeptideMinBackgroundRatio = Convert.ToDouble(txtPeptideMinRatio.Text); _peakParameter.SignalToNoiseThreshold = Convert.ToDouble(txtSN.Text); _peakParameter.PeakBackgroundRatio = Convert.ToDouble(txtPeakPeakBackgroundRatioRatio.Text); rawReader.SetPeakProcessorParameter(_peakParameter); rawReader.SetTransformParameter(_transformParameters); for (int i = 0; i <= 10; i++) { MSScan GMSScan = rawReader.ReadScan(ScanNo); List <MSPeak> deIsotopedPeaks = GMSScan.MSPeaks; deIsotopedPeaks.Sort(); txtPeaks.Text = "Scan Number" + ScanNo.ToString() + Environment.NewLine; txtPeaks.Text = txtPeaks.Text + "MSLevel:" + GMSScan.MsLevel.ToString() + "\t\tNumber Peaks" + deIsotopedPeaks.Count.ToString() + Environment.NewLine; txtPeaks.Text = txtPeaks.Text + "MonoisotopicMZ\tMonoIntensity\tCharge" + Environment.NewLine; foreach (MSPeak p in deIsotopedPeaks) { txtPeaks.Text = txtPeaks.Text + p.MonoisotopicMZ.ToString("0.0000") + "\t\t" + p.MonoIntensity.ToString() + "\t\t" + p.ChargeState.ToString() + Environment.NewLine; } } }
private void ZedGraphDisplay(MSScan argScan) { GraphPane GP = zedGraphControl1.GraphPane; GP.XAxis.Title.Text = "m/z"; GP.YAxis.Title.Text = "Intensity"; PointPairList pplRaw = new PointPairList(); for (int i = 0; i < argScan.MZs.Length; i++) { pplRaw.Add(argScan.MZs[i], argScan.Intensities[i]); } PointPairList pplPeak = new PointPairList(); for (int i = 0; i < argScan.MSPeaks.Count; i++) { pplPeak.Add(argScan.MSPeaks[i].MonoisotopicMZ,argScan.MSPeaks[i].MonoIntensity); } GP.AddBar("Raw", pplRaw, Color.Black); GP.AddBar("Peak", pplPeak, Color.Blue); zedGraphControl1.AxisChange(); }
private void ReadandDisplayScan(int argMSScan) { if (raw != null) { scan = raw.ReadScan(argMSScan); StringBuilder SB = new StringBuilder(); SB.Append("Scan Num:" + scan.ScanNo + Environment.NewLine); SB.Append("Scan Time:" + scan.Time + Environment.NewLine); SB.Append("Scan header:" + scan.ScanHeader + Environment.NewLine); SB.Append("Scan range:" + scan.MinMZ + "~" + scan.MaxMZ + Environment.NewLine); SB.Append("Scan MS Level:" + scan.MsLevel + Environment.NewLine); SB.Append("Scan is FT Scan:" + scan.IsFTScan + Environment.NewLine); SB.Append("Scan is CID:" + scan.IsCIDScan + Environment.NewLine + Environment.NewLine); if (scan.MsLevel == 2) { SB.Append("Parent Scan Num:" + scan.ParentScanNo + Environment.NewLine); SB.Append("Precursor M/Z:" + scan.ParentMZ + Environment.NewLine); SB.Append("Precursor Charge:" + scan.ParentCharge + Environment.NewLine); SB.Append("Precursor mono mass:" + scan.ParentMonoMW + Environment.NewLine + Environment.NewLine); } if (scan.IsHCDScan) { HCDInfo HCD = ((ThermoRawReader) raw).GetHCDInfo(argMSScan); SB.Append("HCD Score:" + HCD.HCDScore.ToString("0.00")+Environment.NewLine); SB.Append("HCD Glycan Type:" + HCD.GlycanType + Environment.NewLine); } SB.Append("MS Peaks:" + scan.MSPeaks.Count + Environment.NewLine); SB.Append("DeisotopeMZ\tPeak Intensity\tMost intense Mz\tMost intense int\t Cluster int"+Environment.NewLine); foreach (MSPeak peak in scan.MSPeaks) { SB.Append(peak.DeisotopeMz + "\t\t" + peak.MonoIntensity + "\t\t" + peak.MostIntenseMass + "\t\t" + peak.MostIntenseIntensity + "\t\t" + peak.ClusterIntensity + Environment.NewLine); } SB.Append(Environment.NewLine + Environment.NewLine + "MZs:" + scan.MZs.Length + Environment.NewLine); for (int i = 0; i < scan.MZs.Length; i++) { SB.Append("[" + i.ToString() + "]" + scan.MZs[i].ToString("0.0000") + "\t" + scan.Intensities[i].ToString("0.0000") + Environment.NewLine); } txtPeaks_CSMSL.Text = SB.ToString(); ZedGraphDisplay(scan); } }
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 BackgroundFilter(MSScan argScan) { _msScan = argScan; }
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); }
/// <summary> /// /// </summary> /// <param name="args"> /// Arg0: FilePath /// Arg1: FileType switch /// raw /// mzxml /// Arg2: Function switch /// R:ReadScan /// N:Number of Scan /// H: Get HCD info /// C: Checked if it is CID scan /// S: Scan header Description /// M: Get MS Level /// Arg3: /// Switch R: int scan number /// Switch N: none /// /// Arg4: PeakProcessorParameter _singleToNoiseRatio /// Arg5: PeakProcessorParameter _peakBackgroundRatio /// Arg6: TransformParameter _peptideMinBackgroundRatio /// Arg7: TransformParameter _maxCharge /// </param> /// static int Main(string[] args) { string FunctionSwitch;// = args[2].ToLower(); GlypID.Readers.clsRawData Raw; //Debug //End Debug try { do { Console.WriteLine( "@@\nR:ReadScan\n" + "N:Number of Scan\n" + "H: Get HCD info\n" + "C: Checked if it is CID scan\n" + "S: Scan header Description\n" + "M: Get MS Level\n" + "Q: Quit\n" + "Please select function:"); FunctionSwitch = Console.In.ReadLine().ToLower().Substring(0, 1); if (FunctionSwitch == "q") { return(0); } else { Console.WriteLine("Please input file location:"); string _fullFilePath = Console.In.ReadLine(); Console.WriteLine("FIle Type(r: Raw, x:mzXML)"); if (Console.In.ReadLine().ToLower().StartsWith("x")) { Raw = new GlypID.Readers.clsRawData(_fullFilePath, GlypID.Readers.FileType.MZXMLRAWDATA); } else { Raw = new GlypID.Readers.clsRawData(_fullFilePath, GlypID.Readers.FileType.FINNIGAN); } //PipeClient pipeClt = new PipeClient(); //pipeClt.Connect("\\\\.\\pipe\\GlypIDPipe"); if (FunctionSwitch == "r")//Read Scan { Console.WriteLine("Please input scan num:"); int ScanNo = Convert.ToInt32(Console.In.ReadLine()); Console.WriteLine("Please input Single to Noise ratio (default:3.0):"); double parsedResult = 3.0; double _singleToNoiseRatio = 3.0; if (double.TryParse(Console.In.ReadLine(), out parsedResult)) { _singleToNoiseRatio = parsedResult; } Console.WriteLine("Please input Peak background ratio (default:5.0):"); parsedResult = 5.0; double _peakBackgroundRatio = 5.0; if (double.TryParse(Console.In.ReadLine(), out parsedResult)) { _peakBackgroundRatio = parsedResult; } Console.WriteLine("Please input Minimum background ratio (default:5.0):"); parsedResult = 5.0; double _peptideMinBackgroundRatio = 5.0; if (double.TryParse(Console.In.ReadLine(), out parsedResult)) { _peptideMinBackgroundRatio = parsedResult; } Console.WriteLine("Please input Max charge (defatlt:10):"); short paredCharge = 10; short _maxCharge = 10; if (short.TryParse(Console.In.ReadLine(), out paredCharge)) { _maxCharge = paredCharge; } Console.WriteLine("Reading Scan"); MSScan scan = GetScanFromFile(ScanNo, _singleToNoiseRatio, _peakBackgroundRatio, _peptideMinBackgroundRatio, _maxCharge, Raw); string responseMsg = SendScanViaNamedPipe(scan); //scan = null; //if (pipeClt.Connected) //{ // while (!pipeClt.SendMessage(memStream.ToArray())) ; // Console.WriteLine("Named pipe sent"); // pipeClt.Disconnect(); //} //else //{ // throw new Exception("Named Pipe not found"); //} Console.WriteLine("ANS:Read Scan: " + ScanNo + " finish;MSScan bytes-" + responseMsg); } else if (FunctionSwitch == "n") //Get total scans { Console.WriteLine("ANS:" + Raw.GetNumScans().ToString()); } else if (FunctionSwitch == "h") //Check HCD { Console.WriteLine("Please input scan num:"); int ScanNo = Convert.ToInt32(Console.In.ReadLine()); HCDInfo HCDinfo = GetHCDInfo(Raw, ScanNo); if (HCDinfo != null) { Console.WriteLine("ANS:" + HCDinfo.ScanNum.ToString() + ";" + HCDinfo.GlycanType.ToString() + ";" + HCDinfo.HCDScore.ToString()); } else { Console.WriteLine("ANS:" + "false"); } } else if (FunctionSwitch == "c") //Check CID { Console.WriteLine("Please input scan num:"); int ScanNo = Convert.ToInt32(Console.In.ReadLine()); if (Raw.IsCIDScan(ScanNo) == true) { Console.WriteLine("ANS:" + "true"); } else { Console.WriteLine("ANS:" + "false"); } } else if (FunctionSwitch == "s") //Check description { Console.WriteLine("Please input scan num:"); int ScanNo = Convert.ToInt32(Console.In.ReadLine()); string description = Raw.GetScanDescription(ScanNo); Console.WriteLine("ANS:" + description); } else if (FunctionSwitch == "m")//Get MS Level { Console.WriteLine("Please input scan num:"); int ScanNo = Convert.ToInt32(Console.In.ReadLine()); Console.WriteLine("ANS:" + Raw.GetMSLevel(ScanNo)); } else { Console.WriteLine("Function error"); } } } while (true); } catch (Exception e) { Console.WriteLine(e.Message); return(-1); } //if (args == null || args.Length == 0) //{ // Console.WriteLine("args is null"); // Check for null array // return -1; //} //if (FunctionSwitch == "r" && args.Length != 8) //{ // Console.WriteLine("args is not enough"); // Check for null array // return -1; //} //else //{ // string _fullFilePath = Console.In.ReadLine(); // Console.WriteLine("Init GlypID"); // if (args[1].ToLower() == "raw") // { // Raw = new GlypID.Readers.clsRawData(_fullFilePath, GlypID.Readers.FileType.FINNIGAN); // } // else // { // Raw = new GlypID.Readers.clsRawData(_fullFilePath, GlypID.Readers.FileType.MZXMLRAWDATA); // } // if (FunctionSwitch == "n") //Get Total scans // { // Console.WriteLine(Raw.GetNumScans().ToString()); // return Raw.GetNumScans(); // } // else if (FunctionSwitch == "m") //Get MS Level // { // int ScanNo = Convert.ToInt32(args[3]); // return Raw.GetMSLevel(ScanNo); // } // else if (FunctionSwitch == "c") //IsCID Scan // { // int ScanNo = Convert.ToInt32(args[3]); // if (Raw.IsCIDScan(ScanNo) == true) // { // return 1; // } // return 0; // } // else if (FunctionSwitch == "s") //Get Description // { // int ScanNo = Convert.ToInt32(args[3]); // //Console.WriteLine("Get Description info"); // string description = Raw.GetScanDescription(ScanNo); // Console.WriteLine(description); // //System.Runtime.Serialization.IFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); // //MemoryStream memStream = new MemoryStream(); // //f.Serialize(memStream, description); // //PipeClient pipeClt = new PipeClient(); // //pipeClt.Connect("\\\\.\\pipe\\GlypIDPipe"); // //if (pipeClt.Connected) // //{ // // while (!pipeClt.SendMessage(memStream.ToArray())) ; // // Console.WriteLine("Named pipe sent"); // //} // //else // //{ // // throw new Exception("Named Pipe not found"); // //} // return 1; // } // else if (FunctionSwitch == "h") //Get HCD // { // int ScanNo = Convert.ToInt32(args[3]); // HCDInfo HCDinfo = GetHCDInfo(Raw, ScanNo); // //Console.WriteLine("Get HCD info"); // //System.Runtime.Serialization.IFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); // //PipeClient pipeClt = new PipeClient(); // //pipeClt.Connect("\\\\.\\pipe\\GlypIDPipeHCD"); // if (HCDinfo != null) // { // Console.WriteLine(HCDinfo.ScanNum.ToString() + ";" + // HCDinfo.GlycanType.ToString() + ";" + // HCDinfo.HCDScore.ToString()); // //MemoryStream memStream = new MemoryStream(); // //f.Serialize(memStream, HCDinfo); // //if (pipeClt.Connected) // //{ // // while (!pipeClt.SendMessage(memStream.ToArray())) ; // // Console.WriteLine("Named pipe sent"); // //} // //else // //{ // // throw new Exception("Named Pipe not found"); // //} // return 1; // } // else // { // //if (pipeClt.Connected) // //{ // // while (!pipeClt.SendMessage(Encoding.ASCII.GetBytes("No HCD Info found"))) ; // // Console.WriteLine("Named pipe sent"); // //} // //else // //{ // // throw new Exception("Named Pipe not found"); // //} // return -1; // } // } // else //ReadScan // { // int ScanNo = Convert.ToInt32(args[3]); // double _singleToNoiseRatio = Convert.ToDouble(args[4]); // double _peakBackgroundRatio = Convert.ToDouble(args[5]); // double _peptideMinBackgroundRatio = Convert.ToDouble(args[6]); // short _maxCharge = Convert.ToInt16(args[7]); // Console.WriteLine("Read Scan"); // MSScan scan = GetScanFromFile(ScanNo, _singleToNoiseRatio, _peakBackgroundRatio, _peptideMinBackgroundRatio, _maxCharge); // System.Runtime.Serialization.IFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); // MemoryStream memStream = new MemoryStream(); // f.Serialize(memStream, scan); // PipeClient pipeClt = new PipeClient(); // pipeClt.Connect("\\\\.\\pipe\\GlypIDPipe"); // if (pipeClt.Connected) // { // while (!pipeClt.SendMessage(memStream.ToArray())) ; // Console.WriteLine("Named pipe sent"); // } // else // { // throw new Exception("Named Pipe not found"); // } // /*NamedPipeClientStream PipeClient = new NamedPipeClientStream(".", "ReadMSScan", PipeDirection.Out); // PipeClient.Connect(); // f.Serialize(PipeClient, scan); // PipeClient.Close();*/ // Console.WriteLine("Read Scan: " + args[3] + " finish"); // } // //End Read Scan // return 1; //} }
public PeakPickingFilter(MSScan argScan) { _msScan = argScan; }
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 Image GetAnnotatedImage(string argPeptide, MSScan argScan, List <MSPoint> argPeaks, GlycanStructure argStructure) { float MaxX = argStructure.Root.FetchAllGlycanNode().OrderByDescending(o => o.IDMass).ToList()[0].IDMass; if (MaxX + 100 > 2000.0) { MaxX = 2000.0f; } else { MaxX = MaxX + 100; } ZedGraph.GraphPane Pane = new ZedGraph.GraphPane(new RectangleF(0.0f, 0.0f, 2000.0f, 1500.0f), argScan.ScanNo.ToString(), "Mass", "Intensity"); //ZedGraph.MasterPane Pane = new ZedGraph.MasterPane(argTitle,new RectangleF(0.0f, 0.0f, 2400.0f, 1800.0f) ); Pane.XAxis.MajorTic.IsInside = false; Pane.XAxis.MinorTic.IsInside = false; Pane.Legend.IsVisible = false; ZedGraph.PointPairList Peaks = new ZedGraph.PointPairList(); double MaxIntensity = 0.0; ///////////////// //Peaks //////////////// foreach (MSPoint p in argPeaks) { if (p.Intensity > MaxIntensity && p.Mass <= MaxX) { MaxIntensity = p.Intensity; } } foreach (MSPoint p in argPeaks) { if (p.Mass <= MaxX) { Peaks.Add(p.Mass, (p.Intensity / MaxIntensity) * 100.0); } } Pane.AddStick("Peaks", Peaks, Color.Red); ////////////////// //Y1 text object ////////////////// /* ZedGraph.TextObj txtY1 = new ZedGraph.TextObj("Y1", argStructure.Y1.MZ, 102); * txtY1.FontSpec.Size = txtY1.FontSpe.cSize*0.5f; * txtY1.FontSpec.Border.IsVisible = false; * Pane.GraphObjList.Insert(0, txtY1);*/ ///////////////// //Structure //////////////// GlycansDrawer GS; double previousBoundary = 0; foreach (GlycanTreeNode t in argStructure.Root.FetchAllGlycanNode().OrderBy(o => o.IDMass).ToList()) { GS = new GlycansDrawer(t.IUPACFromRoot, false); double glycopeptideMZ = t.IDMass; //double glycopeptideMZ =argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfHexNac * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.HexNAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfHex*GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.Hex, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfDeHex * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.DeHex, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfNeuAc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfNeuGc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuGc, FGS.Charge); Image imgStructure = GlycanImage.RotateImage(GS.GetImage(), 270); ZedGraph.TextObj txtGlycanMz = new ZedGraph.TextObj(glycopeptideMZ.ToString("0.000"), 100, 131); double PositionX = glycopeptideMZ; if (previousBoundary >= PositionX) { PositionX = previousBoundary + 20; } if (imgStructure.Width > txtGlycanMz.Location.Width) { previousBoundary = imgStructure.Width + PositionX; } else { previousBoundary = (float)txtGlycanMz.Location.Width + PositionX; } ZedGraph.ImageObj glycan = new ZedGraph.ImageObj(imgStructure, PositionX, 130, imgStructure.Width + 20, imgStructure.Height); glycan.IsScaled = false; glycan.Location.AlignV = ZedGraph.AlignV.Bottom; txtGlycanMz.Location.X = glycan.Location.X + (float)glycan.Image.Width / 2 - (float)txtGlycanMz.Location.Width / 2; txtGlycanMz.FontSpec.Size = txtGlycanMz.FontSpec.Size * 0.3f; txtGlycanMz.FontSpec.Border.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMz); Pane.GraphObjList.Add(glycan); double interval = 100000; int idx = 0; for (int i = 0; i < Peaks.Count; i++) { if (Math.Abs(Peaks[i].X - glycopeptideMZ) < interval) { interval = Math.Abs((float)Peaks[i].X - glycopeptideMZ); idx = i; } } string mzLabelwPPM = Peaks[idx].X.ToString("0.000");// + "\n(" + Math.Abs(glycopeptideMZ - (float)Peaks[idx].X).ToString("0") + "da)"; ZedGraph.TextObj PeakLabel = new ZedGraph.TextObj(mzLabelwPPM, Peaks[idx].X, Peaks[idx].Y + 3.0); PeakLabel.FontSpec.Size = PeakLabel.FontSpec.Size * 0.3f; PeakLabel.FontSpec.Border.IsVisible = false; PeakLabel.FontSpec.Fill.IsVisible = false; Pane.GraphObjList.Add(PeakLabel); } Pane.AxisChange(); Pane.YAxis.Scale.Max = 145; Pane.XAxis.Scale.Min = Convert.ToInt32(argStructure.Y1.Mass - 100); Pane.XAxis.Scale.Max = Peaks[Peaks.Count - 1].X + 100; //////////// //Glycan Structure //////////// GS = new GlycansDrawer(argStructure.IUPACString, false); Image imgStruc = RotateImage(GS.GetImage(), 180); ZedGraph.ImageObj fullStructure = new ZedGraph.ImageObj(imgStruc, Pane.XAxis.Scale.Min + 20, 140, imgStruc.Width + 20, imgStruc.Height); fullStructure.IsScaled = false; Pane.GraphObjList.Add(fullStructure); /////////////// //Glycan M/Z ////////////// double glycopeptidemz = GlycanMass.GetGlycanMasswithCharge(argStructure.Root.GlycanType, argStructure.Charge) + argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, argStructure.Charge); ZedGraph.TextObj txtGlycanMZ = new ZedGraph.TextObj("\n Precursor:" + argScan.ParentMZ.ToString("0.000") + "(" + argScan.ParentCharge.ToString() + ")" + "\nPeptide Sequence:" + argPeptide , Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2, 140); txtGlycanMZ.FontSpec.Size = txtGlycanMZ.FontSpec.Size * 0.3f; txtGlycanMZ.FontSpec.Border.IsVisible = false; txtGlycanMZ.FontSpec.Fill.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMZ); Image tmp = (Image)Pane.GetImage(); return(tmp); }
// Use this for initialization void Awake() { radius = 80; mInstance = this; mMatList = new List <byte>(); }
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; } }
public override void Start() { base.Start(); _msScaner = gameObject.AddComponent <MSScan> (); }
public YxList(MSScan argScan, List <ProteinInfo> argProtInfo, float argTorelance) { _scan = argScan; _pInfo = argProtInfo; _torelance = argTorelance; }
private void btnLoad_Click(object sender, EventArgs e) { openFileDialog1.Filter = "Raw files (*.RAW,*.mzXML)|*.RAW;*.mzXML"; openFileDialog1.RestoreDirectory = true; if (txtScanNo.Text == "" || txtPeptideSeq.Text == "") { MessageBox.Show("Please fill the information"); return; } if (openFileDialog1.ShowDialog() == DialogResult.OK) { _torelance = Convert.ToSingle(txtPeaKTol.Text); _precursorTorelance = Convert.ToSingle(txtPrecusorTol.Text); dtTrees.Rows.Clear(); int ScanNo = 0; if (Int32.TryParse(txtScanNo.Text, out ScanNo) == false) { MessageBox.Show("Input Scan Number Error"); return; } if (Path.GetExtension(openFileDialog1.FileName).ToLower() == ".raw") { ThermoRawReader RawReader = new COL.MassLib.ThermoRawReader(openFileDialog1.FileName); /*GlypID.Peaks.clsPeakProcessorParameters clsParameters = new GlypID.Peaks.clsPeakProcessorParameters(); * clsParameters.SignalToNoiseThreshold = 0.0f; * clsParameters.PeakBackgroundRatio = 0.01f;*/ //RawReader.SetPeakProcessorParameter(2, 2); scan = RawReader.ReadScan(ScanNo); } else { //scan = new mzXMLReader(openFileDialog1.FileName).ReadScan(ScanNo); } int NoNeuAc = 0; int NoNeuGc = 0; if (rdoNeuAc.Checked) { NoNeuAc = Convert.ToInt32(txtSia.Text); } else { NoNeuGc = Convert.ToInt32(txtSia.Text); } List <int> SequenceParameters = new List <int>(); SequenceParameters.Add(Convert.ToInt32(txtTopPeaks_i.Text)); SequenceParameters.Add(Convert.ToInt32(txtTopDiagPeaks_j.Text)); SequenceParameters.Add(Convert.ToInt32(txtTopCorePeaks_k.Text)); SequenceParameters.Add(Convert.ToInt32(txtTopBrancingPeaks_l.Text)); SequenceParameters.Add(Convert.ToInt32(txtMaxGlycansToCompleteStruct_m.Text)); GS = new GlycanSequencing_MultipleScoring(scan, scan.ParentCharge, Convert.ToInt32(txtHex.Text), Convert.ToInt32(txtHexNAc.Text), Convert.ToInt32(txtdeHex.Text), NoNeuAc, NoNeuGc, @"D:\tmp", true, 0.8f, 10, SequenceParameters, Peptides.ReadFastaFile(txtPeptideSeq.Text)); GS.NumbersOfPeaksForSequencing = 140; GS.UseAVGMass = true; //GS.DebugMode(@"E:\temp\SeqTmp\"); GS.CreatePrecursotMZ = true; GS.RewardForCompleteStructure = 3; GS.StartSequencing(); GS.GetTopRankScoreStructre(1); //lstPeak.Items.Add("Top " + GS.FilteredPeaks.Count.ToString() + " peaks"); //lstPeak.Items.Add("m/z / normailzed intensity "); //foreach (MSPoint p in GS.FilteredPeaks) //{ // lstPeak.Items.Add(p.Mass.ToString("0.0000") +"/" + p.Intensity.ToString("0.0000")); //} bool isFullSeq = false; ReportStructure = GS.SequencedStructures; if (ReportStructure.Count == 0) { MessageBox.Show("No Structure Found"); return; } if (GS.FullSequencedStructures.Count != 0) { ReportStructure = GS.FullSequencedStructures; isFullSeq = true; } AminoAcidMass AA = new AminoAcidMass(); for (int i = 0; i < ReportStructure.Count; i++) { GlycanStructure gt = ReportStructure[i]; DataRow row = dtTrees.NewRow(); //row.Add(new Object[] (gt.Mass.ToString("0.0000"), gt.Score.ToString("0.0000"),gt.GetIUPACString())); row["ID"] = i.ToString(); row["Glycan Mass"] = gt.GlycanAVGMonoMass.ToString("0.0000"); row["Y1"] = gt.Y1.Mass.ToString("0.0000");; row["Core Score"] = Convert.ToSingle((gt.CoreScore).ToString("0.00")); row["Branch Score"] = Convert.ToSingle((gt.BranchScore).ToString("0.00")); row["Append Glycan Score"] = Convert.ToSingle((gt.InCompleteScore).ToString("0.00")); if (gt.IsCompleteByPrecursorDifference) { row["PPM"] = Convert.ToSingle( MassUtility.GetMassPPM( gt.GlycanMonoMass + AA.GetMonoMW(gt.PeptideSequence, true) + GetGlycanMassByGlycanString(gt.RestGlycanString), GS.PrecusorMonoMass) .ToString("0.00")); } else { row["PPM"] = Convert.ToSingle( MassUtility.GetMassPPM( gt.GlycanMonoMass + AA.GetMonoMW(gt.PeptideSequence, true), GS.PrecusorMonoMass).ToString("0.00")); } row["Peptide"] = gt.PeptideSequence; row["Append Glycan"] = gt.RestGlycanString; row["IUPAC"] = gt.IUPACString; GlycansDrawer GDRaw = new GlycansDrawer(gt.IUPACString, false); Image tmpImg = GDRaw.GetImage(); row["Structure"] = tmpImg; dtTrees.Rows.Add(row); } ////GS.SequencStructures[0].TheoreticalFragment dtTrees.DefaultView.Sort = "Glycan Mass DESC"; for (int i = 0; i < dgView.Rows.Count; i++) { this.dgView.AutoResizeRow(i); if (Convert.ToSingle(dgView.Rows[i].Cells["PPM"].Value) <= Convert.ToSingle(txtPrecusorTol.Text)) { dgView.Rows[i].DefaultCellStyle.BackColor = Color.Red; } } } }