Esempio n. 1
0
 /// <summary>
 /// This event is fired when user wants to assemble the sequences.
 /// This event will be raised by IAssembler. The controller class
 /// instantiates algorithm implementation to perform assembly.
 /// </summary>
 /// <param name="e">Assembly input arguments.</param>
 private void OnRunAssemblerAlgorithm(AssemblyInputEventArgs e)
 {
     if (e.Sequences != null && e.Aligner != null)
     {
         this.btnCancelAssemble.Enabled = this.cancelAssemblyButtonState = true;
         this.ChangeStatusBar(string.Format(Resources.ASSEMBLER_STATUS_BAR, Resources.ASSEMBLING));
         this.assemblerThread = new BackgroundWorker();
         this.assemblerThread.WorkerSupportsCancellation = true;
         this.assemblerThread.DoWork += this.OnAssembleStarted;
         this.assemblerThread.RunWorkerCompleted += this.OnAssemblerCompleted;
         this.assemblerThread.RunWorkerAsync(e);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// This method runs assembly on the list of sequences passed.
        /// Additionally the user is allowed to select the
        /// alignment algorithm.
        /// </summary>
        /// <param name="input">Input for the assembly process.</param>
        /// <param name="worker">The Assembly parser thread</param>
        /// <returns>IDeNovoAssembly instance.</returns>
        private static IDeNovoAssembly RunAssembly(AssemblyInputEventArgs input, BackgroundWorker worker)
        {
            double mergeThreshold = input.MergeThreshold;
            List<ISequence> sequence = input.Sequences.ToList();

            var assemble = new OverlapDeNovoAssembler();
            assemble.OverlapAlgorithm = input.Aligner;

            // Special casing for SW alignment.
            if (assemble.OverlapAlgorithm is SmithWatermanAligner)
            {
                // If we set the Threshold value lesser than the Max score, then the result will be “JUNK”.
                // So setting the threshold value to 25 approximately supports sequence length of 15,0000.
                mergeThreshold = 25;
            }

            assemble.MergeThreshold = mergeThreshold;
            assemble.OverlapAlgorithm.SimilarityMatrix = input.AlignerInput.SimilarityMatrix;

            assemble.OverlapAlgorithm.GapOpenCost = input.AlignerInput.GapCost;
            assemble.OverlapAlgorithm.GapExtensionCost = input.AlignerInput.GapExtensionCost;

            assemble.ConsensusResolver = new SimpleConsensusResolver(input.ConsensusThreshold);
            assemble.AssumeStandardOrientation = false;

            AssignAlignerParameter(assemble.OverlapAlgorithm, input.AlignerInput);

            IDeNovoAssembly assemblyOutput = assemble.Assemble(sequence);

            if (worker != null && worker.CancellationPending)
            {
                return null;
            }

            return assemblyOutput;
        }
Esempio n. 3
0
        /// <summary>
        /// Callback method from input selection model which will actually do the selected operation
        /// </summary>
        /// <param name="selectedSequences">List of sequences depending on the user selections made</param>
        /// <param name="args">Any arguments passed when calling the selection model</param>
        private void DoAssembly(List<ISequence> selectedSequences, params object[] args)
        {
            // Verify none of the sequences are protein - we cannot assembly these because we 
            // cannot align them (no complements).
            if (selectedSequences.Any(s => s.Alphabet is ProteinAlphabet))
            {
                MessageBox.Show(
                    Resources.PROTEIN_NOT_SUPPORTED,
                    Resources.CAPTION,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            Globals.ThisAddIn.Application.Cursor = XlMousePointer.xlWait;
            var assemblerDialog = new AssemblyInputDialog(false, selectedSequences[0].Alphabet);
            var assemblyInputHelper = new WindowInteropHelper(assemblerDialog);
            assemblyInputHelper.Owner = (IntPtr)Globals.ThisAddIn.Application.Hwnd;
            assemblerDialog.Activated += this.OnWPFWindowActivated;
            if (assemblerDialog.Show())
            {
                var eventArgs = new AssemblyInputEventArgs(selectedSequences, assemblerDialog.Aligner);
                eventArgs.ConsensusThreshold = assemblerDialog.ConsensusThreshold;
                eventArgs.MatchScore = assemblerDialog.MatchScore;
                eventArgs.MergeThreshold = assemblerDialog.MergeThreshold;
                eventArgs.MismatchScore = assemblerDialog.MisMatchScore;

                eventArgs.AlignerInput = assemblerDialog.GetAlignmentInput();

                if (eventArgs.AlignerInput != null) // If fetching parameters were successful
                {
                    this.OnRunAssemblerAlgorithm(eventArgs);
                }
            }
        }