/// <summary> /// source和当前对象将共享rawpeaks和peakinisolationwindow /// </summary> /// <param name="source"></param> public IsobaricScan(IsobaricScan source) { this.ScanMode = source.ScanMode; this.RawPeaks = source.RawPeaks; this.PeakInIsolationWindow = source.PeakInIsolationWindow; this.Valid = source.Valid; this.ValidProbability = source.ValidProbability; this.PrecursorPercentage = source.PrecursorPercentage; }
public void WriteChannels(XmlWriter xw, List <UsedChannel> used, IsobaricScan item) { xw.WriteStartElement("Reporters"); for (int i = 0; i < used.Count; i++) { xw.WriteStartElement("Reporter"); xw.WriteAttribute("name", used[i].Name); xw.WriteAttributeFormat("mz", "{0:0.#####}", item[i].Mz); xw.WriteAttributeFormat("intensity", "{0:0.0}", item[i].Intensity); xw.WriteEndElement(); } xw.WriteEndElement(); }
protected void AppendScan(IRawFile2 rawReader, List <IsobaricScan> result, int scan, string mode, double isolationWidth) { IsobaricScan item = new IsobaricScan(); PeakList <Peak> pkl = rawReader.GetPeakList(scan, MinMz, MaxMz); if (pkl.Count < MinPeakCount) { return; } var recordScan = GetIdentificationScan(scan); item.ScanMode = mode; item.RawPeaks = pkl; item.PeakInIsolationWindow = rawReader.GetPeakInIsolationWindow(scan, isolationWidth); item.Scan = rawReader.GetScanTime(recordScan); result.Add(item); }
public void WriteIsobaricItem(XmlTextWriter w, IsobaricResult ir, IsobaricScan item) { w.WriteStartElement("IsobaricScan"); w.WriteElement("Experimental", item.Experimental); w.WriteElement("ScanMode", item.ScanMode); w.WriteElement("Scan", item.Scan.Scan); w.WriteElementFormat("RetentionTime", "{0:0.0}", item.Scan.RetentionTime); w.WriteElementFormat("IonInjectionTime", "{0:0.000}", item.Scan.IonInjectionTime); w.WriteElementFormat("PrecursorPercentage", "{0:0.000}", item.PrecursorPercentage); if (HasReporters) { WriteChannels(w, ir.UsedChannels, item); } WriteElementPeakList(w, item.RawPeaks, "RawPeaks", false); WriteElementPeakList(w, item.PeakInIsolationWindow, "PeakInIsolationWindow", true); w.WriteEndElement(); w.Flush(); }
public double GetReference(IsobaricScan item) { return((from f in References select f.GetValue(item)).Average()); }
public double GetValue(IsobaricScan item) { return(item[Index].Intensity); }
public override List <IsobaricScan> ReadFromFile(string fileName) { var result = new List <IsobaricScan>(); using (var rawReader = RawFileFactory.GetRawFileReader(fileName)) { int startScan = rawReader.GetFirstSpectrumNumber(); int endScan = rawReader.GetLastSpectrumNumber(); Progress.SetRange(startScan, endScan); for (int scan = startScan; scan <= endScan; scan++) { if (Progress.IsCancellationPending()) { throw new UserTerminatedException(); } Progress.SetPosition(scan); if (2 == rawReader.GetMsLevel(scan)) { string scanMode = rawReader.GetScanMode(scan); if (string.IsNullOrEmpty(scanMode)) { AppendScan(rawReader, result, scan, "UNKNOWN"); continue; } scanMode = scanMode.ToLower(); if (scanMode.Equals("pqd")) { AppendScan(rawReader, result, scan, "PQD"); } else if (scanMode.Equals("cid")) { //如果上一个scan是pqd,那么,现在这个cid的结果从该pqd读取。 if (result.Count > 0 && result[result.Count - 1].RawPeaks.ScanTimes[0].Scan == scan - 1 && result[result.Count - 1].RawPeaks.ScanMode == "PQD") { var lastItem = result[result.Count - 1]; var item = new IsobaricScan(lastItem); item.Scan = rawReader.GetScanTime(scan); item.ScanMode = "CID"; result.Add(item); } else//否则,从自己的peaklist中读取。 { AppendScan(rawReader, result, scan, "CID"); } } else { Console.WriteLine("Scan {0} is skipped with mode {1}", scan, scanMode); } } } } return(result); }
/// <summary> /// 从XmlReader中读取IsobaricItem信息。 /// </summary> /// <param name="reader">XmlReader</param> /// <param name="used">Used channels</param> /// <param name="readReporters">是否读取Reporter信息</param> /// <param name="readPeaks">是否读取Peak信息</param> /// <param name="accept">在读取Peak前,对IsobaricItem进行筛选</param> /// <param name="untilSucceed">如果筛选失败,是否进行读取下一个IsobaricItem</param> /// <returns></returns> public static IsobaricScan Parse(XmlReader reader, List <UsedChannel> used, bool readReporters, bool readPeaks, Predicate <IsobaricScan> accept, bool untilSucceed = false) { IsobaricScan result = null; while (reader.MoveToElement("IsobaricScan")) { XElement el = XNode.ReadFrom(reader) as XElement; var dic = el.ToDictionary(); result = new IsobaricScan(); result.Experimental = dic["Experimental"].Value; result.ScanMode = dic["ScanMode"].Value; result.Scan = new ScanTime(int.Parse(dic["Scan"].Value), double.Parse(dic["RetentionTime"].Value)); result.Scan.IonInjectionTime = double.Parse(dic["IonInjectionTime"].Value); result.PrecursorPercentage = double.Parse(dic["PrecursorPercentage"].Value); if (null != accept && !accept(result)) { result = null; if (untilSucceed) { continue; } else { break; } } if (readReporters) { result.Reporters = new Peak[used.Count]; XElement ions; if (dic.TryGetValue("Reporters", out ions)) { var ionsElement = ions.FindElements("Reporter"); if (ionsElement.Count != used.Count) { throw new Exception(string.Format("Reporter element number {0} is not equals to used channel number {1} in scan {2}", ionsElement.Count, used.Count, result.Scan)); } for (int i = 0; i < used.Count; i++) { var ionEle = ionsElement[i]; result[i] = new Peak(double.Parse(ionEle.FindAttribute("mz").Value), double.Parse(ionEle.FindAttribute("intensity").Value)); } } } if (readPeaks) { result.RawPeaks = ReadElementPeakList(dic["RawPeaks"], false); result.RawPeaks.ScanTimes.Add(result.Scan); result.PeakInIsolationWindow = ReadElementPeakList(dic["PeakInIsolationWindow"], true); } break; } return(result); }
//public static IsobaricScan FindOrCreateIsobaricItem(this IAnnotation ann, IsobaricType plexType) //{ // if (ann.Annotations.ContainsKey(IsobaricConsts.TYPE)) // { // return ann.Annotations[IsobaricConsts.TYPE] as IsobaricScan; // } // else // { // var result = new IsobaricScan(); // ann.Annotations[IsobaricConsts.TYPE] = result; // return result; // } //} public static void SetIsobaricItem(this IAnnotation ann, IsobaricScan item) { ann.Annotations[IsobaricConsts.TYPE] = item; }