/// <summary> /// Execute a local BLAST /// </summary> /// <param name="query">The query file in FASTA format</param> /// <param name="output">The name of the BLAST output file</param> public void ExecuteLocal(string query, string output, IBlastParameters args) { // Validate parameters string commandArguments = BlastTools.FormatBlastArguments(query, output, args); // Start the process ProcessStartInfo psi = new ProcessStartInfo { FileName = this.BlastExe, Arguments = commandArguments, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true }; using (Process p = Process.Start(psi)) { using (StreamReader reader = p.StandardOutput) { string resultStdOut = reader.ReadToEnd(); Console.Write(resultStdOut); } using (StreamReader error = p.StandardError) { string resultStdErr = error.ReadToEnd(); Console.Error.Write(resultStdErr); } } this.QueryFilename = query; this.DbFilename = args.Database; this.OutputFilename = output; }
/// <summary> /// Format BLAST arguments to string /// </summary> /// <returns>Arguments formatted for command-line execution</returns> public static string FormatBlastArguments(string query, string output, IBlastParameters args) { // Check if query file exists if (!File.Exists(query)) { throw new FileNotFoundException(Properties.Resource.FileNotFound, query); } StringBuilder str = new StringBuilder(); str.Append(FormatArgument("-db", InDoubleQuotes(args.Database))); str.Append(FormatArgument("-query", InDoubleQuotes(query), true)); str.Append(FormatArgument("-out", InDoubleQuotes(output), true)); if (args.GapOpen != int.MaxValue) { str.Append(FormatArgument("-gapopen", args.GapOpen.ToString(), true)); } if (args.GapExtend != int.MaxValue) { str.Append(FormatArgument("-gapextend", args.GapExtend.ToString(), true)); } if (args.Mismatch <= 0) { str.Append(FormatArgument("-penalty", args.Mismatch.ToString(), true)); } if (args.EValue != int.MaxValue) { str.Append(FormatArgument("-evalue", args.EValue.ToString(), true)); } str.Append(FormatArgument("-outfmt", args.OutputFormat.ToString(), true)); str.Append(FormatArgument("-num_threads", args.Threads.ToString(), true)); return(str.ToString()); }
/// <summary> /// When clicked, proceed to the analysis step. /// </summary> /// <param name="sender">Framework element.</param> /// <param name="e">Routed event args</param> private void OnRunClicked(object sender, RoutedEventArgs e) { // Store BLAST parameters this.blastArgs = null; if (this.blastEnabledCheckBox.IsChecked.Value) { this.blastArgs = new UniVecParameters(); this.blastArgs.Database = ((ComboBoxItem)this.comboBlastDb.SelectedItem).Content as string; this.blastArgs.NumInputSequences = Convert.ToInt32(this.textBlastMaxSequences.Text); } OpenFileArgs runArgs = new OpenFileArgs(this.input, this.sequenceCheckBox.IsChecked.Value, this.qualityScoreCheckBox.IsChecked.Value, blastArgs, ((ComboBoxItem)this.comboFastqType.SelectedItem).Content.ToString()); // Hide this wondow this.Visibility = System.Windows.Visibility.Hidden; if (this.PrepareRun != null) { this.PrepareRun(sender, runArgs); } }
public OpenFileArgs(InputSubmission input, bool runSequenceQc, bool runQualityScoreQc, IBlastParameters blast, string format) { this.InputInfo = input; this.CanRunSequenceQc = runSequenceQc; this.CanRunQualityScoreQc = runQualityScoreQc; this.BlastArgs = blast; this.FastqFormat = format; }