public override ResultItems Analyze(RawFileName rawfile, SettingsForAnalysis settingName, UIsettings fixedSettings) { //Stopwatch stopwatch = new Stopwatch(); //stopwatch.Start(); ResultItems results = GetResultItems(fixedSettings); //MsScanParameters msScanParameters = new MsScanParameters(settingName); //progress.Report("[" + rawfile.FullName + "] Start at " + stopwatch.Elapsed.TotalMinutes.ToString("0.00") + " minutes"); results.SetValue("RawFile", rawfile.BaseName); results.SetValue("User", rawfile.User); results.SetValue("MS instrument", rawfile.MsInstrument); results.SetValue("MS instrument number", rawfile.MsInstrumentDetails); results.SetValue("LC instrument", rawfile.LcInstrument); results.SetValue("LC instrument number", rawfile.LcInstrumentDetails); results.SetValue("Sample type", rawfile.SampleType); results.SetValue("Sample type details", rawfile.SampleTypeDetails); results.SetValue("File name convention followed", (!rawfile.SomethingWrongWithFileName).ToString()); // shitty hack, should be bool results.SetValue("File size (MiB)", rawfile.FileSizeMiB, 1); results.SetValue("Storage space left (GiB)", rawfile.SpaceLeftGiB, 1); if (settingName.UseBaseAnalysis) { StatusLog statusLog; using (RawFileProcessing rawfileResults = new RawFileProcessing(raw, rawfile.FullName, settingName)) { rawfile.SetDates(rawfileResults._filecreation, rawfileResults._msStart, rawfileResults._msEnd); statusLog = rawfileResults.statusLog; results.SetValue("Warning log", rawfileResults.WarningMessage); results.SetValue("MS count", rawfileResults.MsCount, 0); results.SetValue("MS TIC", rawfileResults.MsTic, 0); results.SetValue("MS TIC (high percentile)", rawfileResults.MsTicHigh, 0); results.SetValue("MS signal to noise", rawfileResults.MsS2N, 2); results.SetValue("MS ion count", rawfileResults.MsIonCount, 0); results.SetValue("CTCD or PrOSA minimum", rawfileResults.CtcdMin, 3); results.SetValue("CTCD or PrOSA maximum", rawfileResults.CtcdMax, 3); results.SetValue("Lock mass correction maximum absolute (ppm)", rawfileResults.LockMassCorrectionMaxAbsolute, 2); results.SetValue("Large injection time fluctuations", rawfileResults.LargeFluctuations, 1); //set as parameter from usrcontrol results.SetValue("Polymer01", rawfileResults.Polymer1, 1); results.SetValue("Polymer02", rawfileResults.Polymer2, 1); results.SetValue("Polymer03", rawfileResults.Polymer3, 1); results.SetValue("Polymer04", rawfileResults.Polymer4, 1); results.SetValue("Polymer05", rawfileResults.Polymer5, 1); results.SetValue("AdductNa", rawfileResults.AdductNa, 1); results.SetValue("AdductCa", rawfileResults.AdductCa, 1); results.SetValue("AdductFe", rawfileResults.AdductFe, 1); results.SetValue("AdductK", rawfileResults.AdductK, 1); results.SetValue("AdductFA", rawfileResults.AdductFA, 1); results.SetValue("AdductNH3", rawfileResults.AdductNH3, 1); results.SetValue("AdductACN", rawfileResults.AdductACN, 1); results.SetValue("Precursor 5 percent mass quantile", rawfileResults.PrecursorMass5percent, 1); results.SetValue("Precursor 95 percent mass quantile", rawfileResults.PrecursorMass95percent, 1); results.SetValue("MS2 topN", rawfileResults.TopN, 2); results.SetValue("MS2 count", rawfileResults.Ms2Count, 0); results.SetValue("MS2 TIC", rawfileResults.Ms2Tic, 0); results.SetValue("MS2 signal to noise", rawfileResults.Ms2S2N, 2); results.SetValue("MS2 ion count", rawfileResults.Ms2IonCount, 0); results.SetValue("MS2 precursor isolation width TIC", rawfileResults.Ms2IsolationWindowTic, 0); results.SetValue("MS2TIC / MS2 precursor isolation width TIC", rawfileResults.Ms2IsolationWindowTicRelative, 3); results.SetValue("MS2 count above ion threshold", rawfileResults.Ms2ScansAboveIonThreshold, 0); results.SetValue("MS2 with charge 2 in percent", rawfileResults.Ms2charge2, 2); results.SetValue("MS2 with charge 3 in percent", rawfileResults.Ms2charge3, 2); results.SetValue("MS2 with charge 4 or higher in percent", rawfileResults.Ms2charge4orMore, 2); results.SetValue("MS2 scans XIC above precursor percentage", rawfileResults.Ms2ScansAbovePrecursorPercent, 2); results.SetValue("MS2 count above ion threshold percentage", rawfileResults.Ms2ScansAboveIonThresholdPercent, 1); results.SetValue("MS2 scans with precursor as BP percentage", rawfileResults.Ms2ScansWithPrecursorBasePeakPercent, 2); } results.SetValue("LCMS start", rawfile.GetDates(0)); results.SetValue("MS start", rawfile.GetDates(1)); results.SetValue("LCMS end", rawfile.GetDates(2)); results.SetValue("MS time in minutes", rawfile.MsTime, 2); results.SetValue("LC time in minutes", rawfile.LcTime, 2); Dictionary <int, Tuple <double, double, double> > usage = rawfile.GetUsagePercent(); foreach (int day in usage.Keys) { results.SetValue("Last " + day.ToString() + " day(s) LCMS usage percent", usage[day].Item1, 1); results.SetValue("Last " + day.ToString() + " day(s) MS usage percent", usage[day].Item2, 1); results.SetValue("Last " + day.ToString() + " day(s) MS excl QC usage percent", usage[day].Item3, 1); } //status log entries foreach (StatusLogItem item in fixedSettings.statusLogItems) { if (item.CalculateMedian) { results.SetValue(item.Name, statusLog.GetMedianOf(item.Name)); } if (item.CalculateMin) { results.SetValue(item.Name + " min", statusLog.GetMinOf(item.Name)); } if (item.CalculateMax) { results.SetValue(item.Name + " max", statusLog.GetMaxOf(item.Name)); } if (item.CalculateIQR) { results.SetValue(item.Name + " IQR", statusLog.GetIqrOf(item.Name)); } } } results.SetValue("Analysis tool version", "0.0.1.21"); return(results); }
public override ResultItems Analyze(RawFileName rawfile, SettingsForAnalysis settingName, UIsettings fixedSettings) { ResultItems results = GetResultItems(fixedSettings); List <double> resultlist = new List <double>(); if (settingName.UseExternal1Analysis) { Log.Information("Started external1"); string filename = rawfile.FullName;//"f:/temp2/20190114_QE99_Evo1_DBJ_E7_LFQprot_QC4_HELA_PAC_250ng_7500_01.raw"; //get list of files and column/row names List <string> resultfiles = new List <string>(); List <string> resultnames = new List <string>(); foreach (ExternalResultParseSetting settings in fixedSettings.ExternalResults) { string resultfile = settings.ResultFile; resultfile = resultfile.Replace("{FILE}", rawfile.FullName); resultfiles.Add(resultfile); resultnames.Add(settings.Resultname); } //maybe add option to delete resultfile? try { string arguments = fixedSettings.Arguments; arguments = arguments.Replace("{FILE}", rawfile.FullName); resultlist = ExecuteProgram.GetResultsFromExternalProgram( fixedSettings.Executable, //raw.exe arguments, //"parse -x -f " + filename resultfiles.ToArray(), resultnames.ToArray(), fixedSettings.Timeout, fixedSettings.ExternalToolSepChar, !fixedSettings.AsRow); if (resultlist.Count != fixedSettings.ExternalResults.Count) { resultlist.Clear(); for (int i = 0; i < fixedSettings.ExternalResults.Count; i++) { resultlist.Add(0.0); } Log.Error("External1 result was not parsed correctly (are headers correct?)"); } Log.Information("Finished external1"); } catch { //something went wrong, adding 0s as filler and reporting error Log.Error("External1 failed"); for (int i = 0; i < fixedSettings.ExternalResults.Count; i++) { resultlist.Add(0.0); } } } else { //no analysis requested, adding 0s as filler for (int i = 0; i < fixedSettings.ExternalResults.Count; i++) { resultlist.Add(0.0); } } //set results for (int i = 0; i < fixedSettings.ExternalResults.Count; i++) { results.SetValue(fixedSettings.ExternalResults[i].Resultname, resultlist[i]); } return(results); }