/// <summary> /// When implemented in a derived class, performs the execution of the activity. /// </summary> /// <param name="context">The execution context under which the activity executes.</param> protected override void Execute(CodeActivityContext context) { string filename = Filename.Get(context); ISequenceFormatter formatter = SequenceFormatters.FindFormatterByFileName(filename); if (formatter == null) { throw new ArgumentException("Could not determine formatter for " + filename); } if (LogOutput) { var tw = context.GetExtension <TextWriter>() ?? Console.Out; tw.WriteLine("Writing sequences to " + filename); } try { foreach (var s in Sequences.Get(context)) { formatter.Format(s); } } finally { formatter.Close(); } }
/// <summary> /// When implemented in a derived class and using the specified execution context, callback method, and user state, enqueues an asynchronous activity in a run-time workflow. /// </summary> /// <returns> /// An object. /// </returns> /// <param name="context">Information that defines the execution environment for the <see cref="T:System.Activities.AsyncCodeActivity"/>.</param><param name="callback">The method to be called after the asynchronous activity and completion notification have occurred.</param><param name="state">An object that saves variable information for an instance of an asynchronous activity.</param> protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { NcbiBlastWebHandler service = new NcbiBlastWebHandler(); // fill in the BLAST settings: var searchParams = new BlastRequestParameters { Program = Program.Get(context) ?? DefaultProgram, Database = Database.Get(context) ?? DefaultDatabase }; searchParams.ExtraParameters.Add("Expect", "1e-10"); searchParams.Sequences.AddRange(Sequences.Get(context)); // Create the request var runningTask = service.ExecuteAsync(searchParams, CancellationToken.None); context.UserState = runningTask; return(runningTask.AsApm(callback, state)); }
/// <summary> /// When implemented in a derived class, performs the execution of the activity. /// </summary> /// <returns> /// The result of the activity’s execution. /// </returns> /// <param name="context">The execution context under which the activity executes.</param> protected override IDeNovoAssembly Execute(CodeActivityContext context) { // Setup the aligner to use string alignerName = (AlignerName ?? DefaultAligner).ToLowerInvariant(); var aligner = SequenceAligners.All.FirstOrDefault(sa => sa.Name.ToLowerInvariant() == alignerName); if (aligner == null) { throw new ArgumentException("Could not find aligner: " + alignerName); } aligner.GapOpenCost = GapOpenCost; aligner.GapExtensionCost = GapExtensionCost; var smName = SimilarityMatrix ?? DefaultMatrix; SimilarityMatrix.StandardSimilarityMatrix sm; if (Enum.TryParse(smName, true, out sm)) { aligner.SimilarityMatrix = new SimilarityMatrix(sm); } // Create the assembler OverlapDeNovoAssembler assembler = new OverlapDeNovoAssembler { AssumeStandardOrientation = this.AssumeStandardOrientation, MergeThreshold = this.MergeThreshold, OverlapAlgorithm = aligner }; var consensus = assembler.Assemble(Sequences.Get(context)); Contigs.Set(context, ((IOverlapDeNovoAssembly)consensus).Contigs); return(consensus); }