Example #1
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);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Start an alignment on selected sequences
        /// </summary>
        /// <param name="selectedSequences">List of sequences selected</param>
        /// <param name="args">Any other arguments</param>
        private void DoAlignment(List<ISequence> selectedSequences, params object[] args)
        {
            this.btnCancelAlign.Enabled = true;
            this.cancelAlignButtonState = true;

            Globals.ThisAddIn.Application.Cursor = XlMousePointer.xlWait;

            var alignerDialog = new AssemblyInputDialog(
                true,
                selectedSequences[0].Alphabet,
                args[0] as ISequenceAligner);
            var assemblyInputHelper = new WindowInteropHelper(alignerDialog);
            assemblyInputHelper.Owner = (IntPtr)Globals.ThisAddIn.Application.Hwnd;
            alignerDialog.Activated += this.OnWPFWindowActivated;
            if (alignerDialog.Show())
            {
                AlignerInputEventArgs alignerInput = alignerDialog.GetAlignmentInput();
                if (alignerInput != null) // If fetching parameters were successful
                {
                    alignerInput.Sequences = selectedSequences;
                    alignerInput.Aligner = alignerDialog.Aligner;

                    this.ChangeStatusBar(string.Format(Resources.ALIGNMENT_STATUS_BAR, Resources.ALIGNING));

                    this.alignerThread = new BackgroundWorker();
                    this.alignerThread.WorkerSupportsCancellation = true;
                    this.alignerThread.DoWork += this.OnRunAlignerAlgorithm;
                    this.alignerThread.RunWorkerCompleted += this.OnAlignerCompleted;
                    this.alignerThread.RunWorkerAsync(alignerInput);
                }
            }
        }