/// <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 ISequenceAlignment Execute(CodeActivityContext context) { 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); } ISequenceAlignment result; if (GapOpenCost == GapExtensionCost || GapExtensionCost == 0) { result = aligner.AlignSimple(new[] { FirstSequence.Get(context), SecondSequence.Get(context) }).First(); } else { result = aligner.Align(new[] { FirstSequence.Get(context), SecondSequence.Get(context) }).First(); } IPairwiseSequenceAlignment pwAlignment = result as IPairwiseSequenceAlignment; if (pwAlignment != null) { if (pwAlignment.PairwiseAlignedSequences.Count > 0) { FirstResult.Set(context, pwAlignment.PairwiseAlignedSequences[0].FirstSequence); SecondResult.Set(context, pwAlignment.PairwiseAlignedSequences[0].SecondSequence); Consensus.Set(context, pwAlignment.PairwiseAlignedSequences[0].Consensus); } } return(result); }
// same algorithm as above /// <exception cref="NotComputedException"></exception> public FirstResult Sequence(IEnumerable <Symbol> syms) { _ = Algo.Nullable ?? throw new NotComputedException(nameof(Algo.Nullable)); var result = new FirstResult(); foreach (var Bi in syms) { if (Bi.Type == Symbol.Types.Terminal) { result.Add(Bi); break; } else { result.UnionWith(this[Bi]); } if (!Algo.Nullable[Bi]) { break; } } return(result); }
public void ClickFirstResult() => FirstResult.Click();