/// <summary> /// Wrapper class for driving all facets of the analysis pipeline /// </summary> /// <param name="MS1MatchFilePath"></param> /// <param name="glycosylationSiteFilePath"></param> /// <param name="MS2DeconFilePath"></param> /// <param name="modelFilePath"></param> /// <param name="pythonInterpreterPath"> /// Passed along to the ScriptManager, used to locate the Python Interpreter executable /// </param> /// <param name="rscriptPath"> /// Passed along to the ScriptManager, used to locate the Rscript executable /// </param> /// <param name="scriptsRoot"> /// Passed along to the ScriptManager, used to locate the script pipeline files /// </param> public AnalysisPipeline(String MS1MatchFilePath, String glycosylationSiteFilePath, String MS2DeconFilePath, String modelFilePath = null, String outputFilePath = null, double ms1MatchingTolerance = 1e-5, double ms2MatchingTolerance = 2e-5, String proteinProspectorXMLFilePath = null, String method = "full_random_forest", String pythonInterpreterPath = null, String rscriptPath = null, String scriptsRoot = null, int numProcesses = 2, bool onlyRandomDecoys = false, int numDecoys = 20) { this.MS1MatchFilePath = MS1MatchFilePath; this.GlycosylationSiteFilePath = glycosylationSiteFilePath; this.MS2DeconFilePath = MS2DeconFilePath; this.ModelFilePath = modelFilePath; this.ResultFilePath = outputFilePath; this.ResultsTable = null; this.State = TandemGlycoPeptideTaskState.New; this.MS1MatchingTolerance = ms1MatchingTolerance; this.MS2MatchingTolerance = ms2MatchingTolerance; this.Method = method; this.ProteinProspectorXMLFilePath = proteinProspectorXMLFilePath; this.NumDecoys = numDecoys; this.NumProcesses = numProcesses; this.OnlyRandomDecoys = onlyRandomDecoys; //Make sure that all needed resources can be found this.Scripter = new ScriptManager(pythonInterpreterPath, rscriptPath, scriptsRoot); Scripter.VerifyFileSystemTargets(); }
public WebResultsViewer(ResultsRepresentation modelData) { InitializeComponent(); this.Model = modelData; this.DataProvider = BootstrapModelString(Model); this.FileName = Path.GetFileName(Model.SourceFile); BrowserCtrl.IsWebBrowserContextMenuEnabled = true; var indexURI = new Uri(Path.Combine(Application.StartupPath, "Web", "index.html")).AbsoluteUri; BrowserCtrl.ObjectForScripting = this; BrowserCtrl.Navigate(indexURI); //Set up page, feeding in data and registering native-web interfaces BrowserCtrl.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(delegate(Object o, WebBrowserDocumentCompletedEventArgs e) { JavaScriptAction(@"window.objects = window.external.DataProvider; registerDataChange(PredictionResults.parse(window.external.DataProvider), window.external.FileName); "); //Remove previously registered click handler and adds native save //function call JavaScriptAction("$('#save-results-btn .save-all-results-anchor').off('click').click(function(evt){window.external.SaveResultsToFile()})"); //JavaScriptAction("console.log = window.external.ExternLog"); }); BrowserCtrl.ScriptErrorsSuppressed = false; }
public ModelLabelView(ResultsRepresentation model) { InitializeComponent(); Model = model; Binder = new BindingSource(); MS2MatchDataGridView.AutoGenerateColumns = false; MS2MatchDataGridView.AutoSize = false; MS2MatchDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; MS2MatchDataGridView.DataSource = Binder; InitGridView(); }
/// <summary> /// Load an already generated results CSV and view it using the WebResultsViewer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ViewResultsButton_Click(object sender, EventArgs e) { Console.WriteLine("Viewing Results"); DialogResult modelFileDialogResult = openFileDialog1.ShowDialog(); if (modelFileDialogResult == DialogResult.OK) { try { ResultsRepresentation resultFile = new ResultsRepresentation(openFileDialog1.FileName); WebResultsViewer resultsView = new WebResultsViewer(resultFile); resultsView.Show(); } catch (IOException ex) { MessageBox.Show("Could not open " + openFileDialog1.FileName + ". Error: " + ex.Message); } } }
/// <summary> /// View a previously generated model file. If no model is loaded, show an open /// file dialog and set the model path, and load the model into a ModelLabelView /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ViewModelButton_Click(object sender, EventArgs e) { ResultsRepresentation model = null; try { model = new ResultsRepresentation(Controller.ModelFilePath); } catch (Exception ex) { Console.WriteLine(ex); bool didSelect = SetModelFilePath_Action(sender, e); //If the user didn't actually select a model, cancelling the dialog, do nothing if (!didSelect) { return; } model = new ResultsRepresentation(Controller.ModelFilePath); } var modelView = new ModelLabelView(model); modelView.Show(); }
/// <summary> /// Given a ResultsRepresentation, show them in a ModelLabelView /// </summary> /// <param name="preparedModelData"></param> private void ShowModelLabelView(ResultsRepresentation preparedModelData) { Console.WriteLine("Showing Model Label View"); ModelLabelView labelView = new ModelLabelView(preparedModelData); labelView.Show(); }
/// <summary> /// Given a ResultsRepresentation, show them in a WebResultsView /// </summary> /// <param name="classifierData"></param> private void ShowClassifierResultsView(ResultsRepresentation classifierData) { WebResultsViewer resultsView = new WebResultsViewer(classifierData); resultsView.Show(); }
public ClassifierResultsView(ResultsRepresentation model) : base(model) { InitializeComponent(); Console.WriteLine(); }
public ResultsRepresentation RunReclassification(String targetFilePath, String modelFilePath) { String outfile = Scripter.RunReclassifyWithModelTask(targetFilePath, modelFilePath, Method); ResultsRepresentation resultsTable = new ResultsRepresentation(outfile); this.ResultFilePath = outfile; this.ResultsTable = resultsTable; return resultsTable; }
public ResultsRepresentation RunModelBuilder() { String outfile = Scripter.RunModelBuildingPythonPipeline(this.MS1MatchFilePath, this.GlycosylationSiteFilePath, this.MS2DeconFilePath, ms1MatchingTolerance:this.MS1MatchingTolerance, ms2MatchingTolerance:this.MS2MatchingTolerance, proteinProspectorXMLFilePath: this.ProteinProspectorXMLFilePath, method:Method); ResultsRepresentation model = new ResultsRepresentation(outfile); return model; }
/// <summary> /// /// </summary> /// <returns></returns> public ResultsRepresentation RunClassification() { String outfile = Scripter.RunClassificationPythonPipeline(this.MS1MatchFilePath, this.GlycosylationSiteFilePath, this.MS2DeconFilePath, modelDataFilePath:this.ModelFilePath, ms1MatchingTolerance:this.MS1MatchingTolerance, ms2MatchingTolerance:this.MS2MatchingTolerance, proteinProspectorXMLFilePath:this.ProteinProspectorXMLFilePath, method:Method, outputFilePath:this.ResultFilePath, numProcesses: NumProcesses); this.ResultFilePath = outfile; ResultsRepresentation resultsTable = new ResultsRepresentation(outfile); this.ResultsTable = resultsTable; return resultsTable; }
/// <summary> /// Get the raw string contents of the ResultsRepresentation model as a CSV by writing /// it to a temporary file and reading it back out and returns it. /// </summary> /// <param name="model"></param> /// <returns></returns> protected string BootstrapModelString(ResultsRepresentation model) { string tempFile = Path.GetTempFileName(); StreamWriter tempWriter = new StreamWriter(File.OpenWrite(tempFile)); model.WriteToJson(tempWriter); string modelString = File.ReadAllText(tempFile); File.Delete(tempFile); return modelString; }