/// <summary> /// ChargeStateChildTopDownIqWorkflow /// Generates theoretical isotopic profile, XIC, and creates ChromPeakIqTargets based on peaks found /// </summary> /// <param name="result"></param> protected override void ExecuteWorkflow(IqResult result) { //Generate theoretical isotopic profile result.Target.TheorIsotopicProfile = TheorFeatureGen.GenerateTheorProfile(result.Target.EmpiricalFormula, result.Target.ChargeState); if (!Parser.CheckSequenceIntegrity(result.Target.Code)) { ShiftIsotopicProfile(result.Target.TheorIsotopicProfile, result.Target.MonoMassTheor, result.Target.ChargeState); } //Generate XIC and smooth result.IqResultDetail.Chromatogram = ChromGen.GenerateChromatogram(Run, result.Target.TheorIsotopicProfile, result.Target.ElutionTimeTheor); result.IqResultDetail.Chromatogram = ChromSmoother.Smooth(result.IqResultDetail.Chromatogram); //Look for peaks in XIC result.ChromPeakList = ChromPeakDetector.FindPeaks(result.IqResultDetail.Chromatogram); ChromPeakDetector.CalculateElutionTimes(Run, result.ChromPeakList); ChromPeakDetector.FilterPeaksOnNET(WorkflowParameters.ChromNETTolerance, result.Target.ElutionTimeTheor, result.ChromPeakList); var tempMinScanWithinTol = (int)Run.NetAlignmentInfo.GetScanForNet(result.Target.ElutionTimeTheor - WorkflowParameters.ChromNETTolerance); var tempMaxScanWithinTol = (int)Run.NetAlignmentInfo.GetScanForNet(result.Target.ElutionTimeTheor + WorkflowParameters.ChromNETTolerance); var tempCenterTol = (int)Run.NetAlignmentInfo.GetScanForNet(result.Target.ElutionTimeTheor); result.NumChromPeaksWithinTolerance = result.ChromPeakList.Count; //General peak information output written to console. Console.WriteLine("SmartPeakSelector --> NETTolerance= " + WorkflowParameters.ChromNETTolerance + "; chromMinCenterMax= " + tempMinScanWithinTol + "\t" + tempCenterTol + "" + "\t" + tempMaxScanWithinTol); Console.WriteLine("MT= " + result.Target.ID + ";z= " + result.Target.ChargeState + "; mz= " + result.Target.MZTheor.ToString("0.000") + "; ------------------------- PeaksWithinTol = " + result.ChromPeakList.Count); //Creates a ChromPeakIqTarget for each peak found foreach (ChromPeak peak in result.ChromPeakList) { var target = new ChromPeakIqTarget(new ChromPeakAnalyzerIqWorkflow(Run, WorkflowParameters)); TargetUtilities.CopyTargetProperties(result.Target, target, false); target.ChromPeak = peak; result.Target.AddTarget(target); } //Executes each grandchild ChromPeakAnalyzerIqWorkflow var children = result.Target.ChildTargets(); foreach (var child in children) { child.DoWorkflow(); } if (Utilities.SipperDataDump.OutputResults) { //Data Dump for use with Sipper children = result.Target.ChildTargets(); foreach (var child in children) { Utilities.SipperDataDump.DataDump(child, Run); } } }
protected override void ExecuteWorkflow(IqResult result) { if (ChromPeakAnalyzerIqWorkflow == null) { InitializeChromPeakAnalyzerWorkflow(); } result.Target.TheorIsotopicProfile = TheorFeatureGen.GenerateTheorProfile(result.Target.EmpiricalFormula, result.Target.ChargeState); result.IqResultDetail.Chromatogram = ChromGen.GenerateChromatogram(Run, result.Target.TheorIsotopicProfile, result.Target.ElutionTimeTheor); result.IqResultDetail.Chromatogram = ChromSmoother.Smooth(result.IqResultDetail.Chromatogram); result.ChromPeakList = ChromPeakDetector.FindPeaks(result.IqResultDetail.Chromatogram); ChromPeakDetector.CalculateElutionTimes(Run, result.ChromPeakList); ChromPeakDetector.FilterPeaksOnNET(WorkflowParameters.ChromNETTolerance, result.Target.ElutionTimeTheor, result.ChromPeakList); result.NumChromPeaksWithinTolerance = result.ChromPeakList.Count; //Creates a ChromPeakIqTarget for each peak found foreach (ChromPeak peak in result.ChromPeakList) { var target = new ChromPeakIqTarget(ChromPeakAnalyzerIqWorkflow); TargetUtilities.CopyTargetProperties(result.Target, target, false); target.ChromPeak = peak; result.Target.AddTarget(target); } //Executes each grandchild ChromPeakAnalyzerIqWorkflow var children = result.Target.ChildTargets(); var targetRemovalList = new List <IqTarget>(); foreach (var child in children) { child.DoWorkflow(); /* * //Selects grandchildren with extremely poor metric scores for removal * IqResult childResult = child.GetResult(); * if ((childResult.FitScore >= .8) || (childResult.CorrelationData.RSquaredValsMedian <= .15)) * { * targetRemovalList.Add(child); * } */ } /* * //Removes the poorly scoring grandchild ChromPeakIqTargets * foreach (IqTarget iqTarget in targetRemovalList) * { * result.RemoveResult(iqTarget.GetResult()); * result.Target.RemoveTarget(iqTarget); * } */ }
public static int Main(string[] args) { //Console.WriteLine(Process.GetCurrentProcess().Id); //while (!Debugger.IsAttached) //{ // Thread.Sleep(100); //} CommandLineApplication <ArgumentsModel> app = new CommandLineApplication <ArgumentsModel>(); IHostBuilder hostBuilder = new HostBuilder() .ConfigureLogging(builder => { builder.AddSerilog(dispose: true); }) .ConfigureServices(services => { services.AddSingleton(app.Model); services.AddSingleton <Dumper>(); }); app.FullName = "RabbitMQ Dumper"; app.VersionOption("-v|--version", () => Assembly.GetEntryAssembly().GetName().Version.ToString()); app.Conventions .UseAttributes() .SetRemainingArgsPropertyOnModel() .SetSubcommandPropertyOnModel() .SetParentPropertyOnModel() .UseOnValidateMethodFromModel() .UseOnValidationErrorMethodFromModel() .UseConstructorInjection() .UseDefaultHelpOption(); CancellationTokenSource consoleCancelled = new CancellationTokenSource(); Console.CancelKeyPress += (sender, eventArgs) => { eventArgs.Cancel = true; consoleCancelled.Cancel(); }; app.OnExecute(() => { LoggerConfiguration loggerConfiguration = new LoggerConfiguration() .Enrich.FromLogContext() .WriteTo.Console(); if (app.Model.Verbose) { loggerConfiguration.MinimumLevel.Debug(); } Log.Logger = loggerConfiguration.CreateLogger(); consoleCancelled.Token.Register(() => { Log.Logger.Warning("Ctrl+C pressed"); }); hostBuilder.ConfigureServices(services => { Type inputType = TargetUtilities.GetSourceType(app.Model.InputType); Type outputType = TargetUtilities.GetDestinationType(app.Model.OutputType); services .AddSingleton <ISource>(inputType) .AddSingleton <IDestination>(outputType); }).ConfigureServices(services => { services.AddSingleton(new ConsoleLifetime(consoleCancelled.Token)); }); using (IHost host = hostBuilder.Build()) { Dumper dumper = host.Services.GetRequiredService <Dumper>(); return((int)dumper.Run()); } }); try { return(app.Execute(args)); } catch (CommandParsingException e) { Console.Error.WriteLine($"There was an error processing the argumentsModel: {e.Message}"); return((int)DumperExitCode.ParsingFailure); } }