public override void ValidateResult(DeconTools.Backend.Core.ResultCollection resultColl, DeconTools.Backend.Core.IsosResult currentResult) { Check.Require(currentResult is N14N15_TResult, "Currently, this is only implemented for N14N15 results"); var n14n15result = (N14N15_TResult)currentResult; Check.Require(n14n15result.Target.IsotopicProfileLabelled != null, "Cannot validate labelled isotopic profile. Theoretical profile was not defined."); // stop, but don't throw an error if there is no labelled isotopic profile. if (n14n15result.IsotopicProfileLabeled == null) { return; } var isoN15 = n14n15result.IsotopicProfileLabeled; var scanPeaks = resultColl.Run.PeakList.Select <Peak, MSPeak>(i => (MSPeak)i).ToList(); // get i_score n14n15result.InterferenceScoreN15 = getIScore(scanPeaks, isoN15); // get fit score var fitval = getFitValue(resultColl.Run.XYData, n14n15result.Target.IsotopicProfileLabelled, isoN15); n14n15result.ScoreN15 = fitval; }
public override void MergeAndExport(DeconTools.Backend.Core.ResultCollection resultList) { Check.Require(resultList != null, "Scans merger failed. ResultCollection is null"); Check.Require(resultList.ScanResultList != null && resultList.ScanResultList.Count > 0, "Scans merger failed... there's a problem in the ScanResult List"); var sb = new StringBuilder(); var scanresult = resultList.ScanResultList[0]; // we only take the first one since we delete each scanResult after writing it out to file sb.Append(getScanNumber(scanresult.ScanSet.PrimaryScanNumber)); sb.Append(delimiter); sb.Append(DblToString(scanresult.ScanTime, 4)); sb.Append(delimiter); sb.Append(scanresult.SpectrumType); sb.Append(delimiter); sb.Append(DblToString(scanresult.BasePeak.Height, 4, true)); sb.Append(delimiter); sb.Append(DblToString(scanresult.BasePeak.XValue, 5)); sb.Append(delimiter); sb.Append(DblToString(scanresult.ScanSet.TICValue, 4, true)); sb.Append(delimiter); sb.Append(scanresult.NumPeaks); sb.Append(delimiter); sb.Append(scanresult.NumIsotopicProfiles); sw.WriteLine(sb.ToString()); resultList.ScanResultList.Clear(); // scanResult List is cleared every time. runCounter++; }
protected override void addScanResults(DeconTools.Backend.Core.ResultCollection rc) { var myconnection = (SQLiteConnection)cnn; using (var mytransaction = myconnection.BeginTransaction()) { using (var mycommand = new SQLiteCommand(myconnection)) { var frameNumParam = new SQLiteParameter(); var frameTimeParam = new SQLiteParameter(); var typeParam = new SQLiteParameter(); var bpiParam = new SQLiteParameter(); var bpiMZParam = new SQLiteParameter(); var ticParam = new SQLiteParameter(); var num_peaksParam = new SQLiteParameter(); var num_deisotopedParam = new SQLiteParameter(); var framePressureUnsmoothed = new SQLiteParameter(); var framePressureSmoothed = new SQLiteParameter(); mycommand.CommandText = "INSERT INTO T_IMS_Frames ([frame_num],[frame_time],[type],[bpi],[bpi_mz],[tic],[num_peaks],[num_deisotoped],[frame_pressure_unsmoothed],[frame_pressure_smoothed]) VALUES(?,?,?,?,?,?,?,?,?,?)"; mycommand.Parameters.Add(frameNumParam); mycommand.Parameters.Add(frameTimeParam); mycommand.Parameters.Add(typeParam); mycommand.Parameters.Add(bpiParam); mycommand.Parameters.Add(bpiMZParam); mycommand.Parameters.Add(ticParam); mycommand.Parameters.Add(num_peaksParam); mycommand.Parameters.Add(num_deisotopedParam); mycommand.Parameters.Add(framePressureUnsmoothed); mycommand.Parameters.Add(framePressureSmoothed); for (var n = 0; n < rc.ScanResultList.Count; n++) { var r = (UimfScanResult)rc.ScanResultList[n]; frameNumParam.Value = r.LCScanNum; frameTimeParam.Value = r.ScanTime; typeParam.Value = r.SpectrumType; bpiParam.Value = r.BasePeak.Height; bpiMZParam.Value = r.BasePeak.XValue; ticParam.Value = r.TICValue; num_peaksParam.Value = r.NumPeaks; num_deisotopedParam.Value = r.NumIsotopicProfiles; framePressureUnsmoothed.Value = r.FramePressureUnsmoothed; framePressureSmoothed.Value = r.FramePressureSmoothed; mycommand.ExecuteNonQuery(); } } mytransaction.Commit(); } }
public override void ExportScanResults(DeconTools.Backend.Core.ResultCollection resultList) { using (var sw = new StreamWriter(new FileStream(_filename, FileMode.Append, FileAccess.Write, FileShare.Read))) { sw.AutoFlush = true; foreach (var scanResult in resultList.ScanResultList) { var output = buildScansResultOutput(scanResult); sw.WriteLine(output); } } }
public override void Export(DeconTools.Backend.Core.ResultCollection results) { StreamWriter sw; try { sw = new StreamWriter(this.fileName); } catch (Exception ex) { throw new Exception("Error creating file " + this.fileName + ": " + ex.Message); } if (!string.Equals(PNNLOmics.Utilities.StringUtilities.DblToString(3.14159, 4, false, 0.001, false), DblToString(3.14159, 4))) { Console.WriteLine("Note: using a period for the decimal point for because the result files are CSV files"); } sw.WriteLine(headerLine); foreach (var result in results.ScanResultList) { Check.Require(result is UimfScanResult, "UIMF_Scans_Exporter only works on UIMF Scan Results"); var uimfResult = (UimfScanResult)result; var sb = new StringBuilder(); sb.Append(uimfResult.ScanSet.PrimaryScanNumber); sb.Append(delimiter); sb.Append(DblToString(uimfResult.ScanTime, 3)); sb.Append(delimiter); sb.Append(result.SpectrumType); sb.Append(delimiter); sb.Append(DblToString(uimfResult.BasePeak.Height, 4, true)); sb.Append(delimiter); sb.Append(DblToString(uimfResult.BasePeak.XValue, 5)); sb.Append(delimiter); sb.Append(DblToString(uimfResult.TICValue, 4, true)); sb.Append(delimiter); sb.Append(uimfResult.NumPeaks); sb.Append(delimiter); sb.Append(uimfResult.NumIsotopicProfiles); sb.Append(delimiter); sb.Append(DblToString(uimfResult.FramePressureUnsmoothed, 4)); sb.Append(delimiter); sb.Append(DblToString(uimfResult.FramePressureSmoothed, 4)); sw.WriteLine(sb.ToString()); } sw.Close(); }
protected override void addScanResults(DeconTools.Backend.Core.ResultCollection rc) { var myconnection = (SQLiteConnection)cnn; using (var mytransaction = myconnection.BeginTransaction()) { using (var mycommand = new SQLiteCommand(myconnection)) { var scanNumParam = new SQLiteParameter(); var scanTimeParam = new SQLiteParameter(); var typeParam = new SQLiteParameter(); var bpiParam = new SQLiteParameter(); var bpiMZParam = new SQLiteParameter(); var ticParam = new SQLiteParameter(); var num_peaksParam = new SQLiteParameter(); var num_deisotopedParam = new SQLiteParameter(); mycommand.CommandText = "INSERT INTO T_MS_ScanSummary ([scan_num],[scan_time],[type],[bpi],[bpi_mz],[tic],[num_peaks],[num_deisotoped]) VALUES(?,?,?,?,?,?,?,?)"; mycommand.Parameters.Add(scanNumParam); mycommand.Parameters.Add(scanTimeParam); mycommand.Parameters.Add(typeParam); mycommand.Parameters.Add(bpiParam); mycommand.Parameters.Add(bpiMZParam); mycommand.Parameters.Add(ticParam); mycommand.Parameters.Add(num_peaksParam); mycommand.Parameters.Add(num_deisotopedParam); for (var n = 0; n < rc.ScanResultList.Count; n++) { var item = rc.ScanResultList[n]; scanNumParam.Value = item.ScanSet.PrimaryScanNumber; scanTimeParam.Value = item.ScanTime; typeParam.Value = item.SpectrumType; bpiParam.Value = item.BasePeak.Height; bpiMZParam.Value = item.BasePeak.XValue; ticParam.Value = item.TICValue; num_peaksParam.Value = item.NumPeaks; num_deisotopedParam.Value = item.NumIsotopicProfiles; mycommand.ExecuteNonQuery(); } } mytransaction.Commit(); } }
public override void Export(DeconTools.Backend.Core.ResultCollection results) { try { sqliteWriter.CreateNewDB(fileName); } catch (Exception) { throw; } //Insert records to IMS_Frames table //Insert records in bulk mood, 500 records each time //this is significantly faster than inserting one record at a time //500 records are the maximum number sqlite3 can handle var records = new ArrayList(); var count = 0; foreach (var result in results.ScanResultList) { Check.Require(result is UimfScanResult, "UIMF_Scans_Exporter only works on UIMF Scan Results"); var uimfResult = (UimfScanResult)result; var fp = new IMS_Frames(); fp.frame_num = (ushort)uimfResult.ScanSet.PrimaryScanNumber; fp.frame_time = (float)uimfResult.ScanTime; fp.type = (ushort)uimfResult.SpectrumType; fp.bpi = uimfResult.BasePeak.Height; fp.bpi_mz = (float)uimfResult.BasePeak.XValue; fp.tic = uimfResult.TICValue; fp.num_peaks = (uint)uimfResult.NumPeaks; fp.num_deisotoped = (uint)uimfResult.NumIsotopicProfiles; fp.frame_pressure_front = (float)uimfResult.FramePressureUnsmoothed; fp.frame_pressure_back = (float)uimfResult.FramePressureSmoothed; records.Add(fp); count++; if (count == 500) { sqliteWriter.InsertIMSFrames(records); count = 0; records = new ArrayList(); } } //Insert the rest of the records to IMS_Frames table sqliteWriter.InsertIMSFrames(records); sqliteWriter.CloseDB(fileName); }
public override void Export(DeconTools.Backend.Core.ResultCollection results) { StreamWriter sw; try { sw = new StreamWriter(this.fileName); } catch (Exception) { throw; } sw.WriteLine(headerLine); writeUIMFIsosResults(sw, results); sw.Close(); }
public override void ValidateResult(DeconTools.Backend.Core.ResultCollection resultColl, DeconTools.Backend.Core.IsosResult currentResult) { if (currentResult.IsotopicProfile == null) { return; } Check.Require(currentResult != null, String.Format("{0} failed. CurrentResult has not been defined.", this.Name)); if (resultColl.Run.PeakList == null || resultColl.Run.PeakList.Count == 0) { currentResult.InterferenceScore = -1; return; } var monoPeak = currentResult.IsotopicProfile.getMonoPeak(); var lastPeak = currentResult.IsotopicProfile.Peaklist[currentResult.IsotopicProfile.Peaklist.Count - 1]; var leftMZBoundary = monoPeak.XValue - 1.1; var rightMZBoundary = lastPeak.XValue + lastPeak.Width / 2.35 * 2; // 2 sigma double interferenceVal = -1; if (UsePeakBasedInterferenceValue) { var scanPeaks = resultColl.Run.PeakList.Select <Peak, MSPeak>(i => (MSPeak)i).ToList(); interferenceVal = m_scorer.GetInterferenceScore(scanPeaks, currentResult.IsotopicProfile.Peaklist, leftMZBoundary, rightMZBoundary); } else { var startIndexOfXYData = MathUtils.BinarySearchWithTolerance(resultColl.Run.XYData.Xvalues, monoPeak.XValue - 3, 0, (resultColl.Run.XYData.Xvalues.Length - 1), 2); if (startIndexOfXYData < 0) { startIndexOfXYData = 0; } interferenceVal = m_scorer.GetInterferenceScore(resultColl.Run.XYData, currentResult.IsotopicProfile.Peaklist, leftMZBoundary, rightMZBoundary, startIndexOfXYData); } currentResult.InterferenceScore = interferenceVal; }
public override void Export(DeconTools.Backend.Core.ResultCollection results) { StreamWriter sw; try { sw = new StreamWriter(this.fileName); } catch (Exception) { throw; } sw.WriteLine(headerLine); //OriginalIntensitiesExtractor origIntensExtractor = new OriginalIntensitiesExtractor(results); //List<OriginalIntensitiesDTO> origIntensitiesCollection = origIntensExtractor.ExtractOriginalIntensities(); //writeUIMFIsosResults(sw, results, origIntensitiesCollection); sw.Close(); }
public override void ValidateResult(DeconTools.Backend.Core.ResultCollection resultColl, IsosResult currentResult) { Check.Require(currentResult != null, String.Format("{0} failed. CurrentResult has not been defined.", this.Name)); if (currentResult.IsotopicProfile == null) { return; } var monoPeak = currentResult.IsotopicProfile.getMonoPeak(); var peakToTheLeft = LookforPeakToTheLeftOfMonoPeak(monoPeak, currentResult.IsotopicProfile.ChargeState, resultColl.Run.PeakList); if (peakToTheLeft == null) { return; // no peak found... so no problem. } if (peakToTheLeft.Height > monoPeak.Height * MinRatioToGiveFlag) //if peak-to-the-left exceeds min Ratio, then flag it { currentResult.Flags.Add(new PeakToTheLeftResultFlag()); } }