Beispiel #1
0
        /// <summary>
        /// This method Subtracts two query regions.
        /// </summary>
        /// <param name="sender">btnSubtract instance.</param>
        /// <param name="e">Event data</param>
        private void OnSubtractClick(object sender, RibbonControlEventArgs e)
        {
            this.ResetStatus();

            var inputs = new InputSelection();
            inputs.MinimumSequenceCount = 2;
            inputs.MaximumSequenceCount = 2;
            inputs.SequenceLabels = new[]
                                    {
                                        Resources.InputSelection_SequenceLabel_BED1,
                                        Resources.InputSelection_SequenceLabel_BED2,
                                        Resources.Export_BED_SequenceRangeString
                                    };
            inputs.GetInputSequenceRanges(this.DoBEDSubtract, false, true, true);
        }
Beispiel #2
0
        /// <summary>
        /// Manipulate the address like:
        /// If user enters a comma manually, address till that point is considered as fixed and wont be manipulated
        /// When user changes the active sheet, any sheet references which is in the non-fixed part of the address will be replaced with current sheet reference
        /// </summary>
        /// <param name="activatedSheet">current worksheet</param>
        void Application_SheetActivate(object activatedSheet)
        {
            Worksheet activeSheet = activatedSheet as Worksheet;

            lastsheetName    = currentSheetName;
            currentSheetName = activeSheet.Name;

            string address = selectionText.Text;

            if (address.Length > 0 && currentSheetName != lastsheetName)                    // check if activate fired on same sheet
            {
                if (address[address.Length - 1] != ',' && address.Length > lastManualComma) // if last char is not a comma
                {
                    string savedAddress = address.Substring(0, lastManualComma);            // address till the point where user entered a comma manually

                    // get address part after the manual comma
                    if (address[lastManualComma] == ',' && lastManualComma != 0)
                    {
                        address = address.Substring(lastManualComma + 1);
                    }
                    else
                    {
                        address = address.Substring(lastManualComma);
                    }

                    int lastComma = address.LastIndexOf(',', address.Length - 1);

                    while (lastComma != -1)
                    {
                        string lastSheetInAddress;
                        int    sheetNameEndIndex = address.LastIndexOf('!');
                        if (sheetNameEndIndex != -1)
                        {
                            lastSheetInAddress = address.Substring(lastComma + 1, sheetNameEndIndex - (lastComma + 1)); // last sheet name in the address
                            if (string.IsNullOrEmpty(lastSheetInAddress))
                            {
                                break;
                            }

                            // replace sheetname with current sheetname if no comma is added before navigating to new sheet
                            address   = address.Substring(0, lastComma) + "," + currentSheetName + address.Substring(lastComma + 1 + lastsheetName.Length);
                            lastComma = address.LastIndexOf(',', lastComma - 1);
                        }
                    }
                    if (lastComma == -1) // check first item in address
                    {
                        int sheetNameEndIndex;
                        if (address.Contains(","))
                        {
                            sheetNameEndIndex = address.LastIndexOf('!', address.IndexOf(','));
                        }
                        else
                        {
                            sheetNameEndIndex = address.LastIndexOf('!');
                        }

                        if (sheetNameEndIndex != -1)
                        {
                            string lastSheetInAddress = address.Substring(0, sheetNameEndIndex);
                            address = currentSheetName + address.Substring(lastSheetInAddress.Length);
                        }
                    }

                    // join the saved address and the manipulated address and write back
                    selectionText.Text = savedAddress + ((savedAddress.Length > 0) ? "," : "") + address;

                    // try to show a selection on the manipulated regions so that user comes to know what just happened.
                    try
                    {
                        Range unionOfSelection = null;

                        foreach (Range rangeToSelect in InputSelection.GetRanges(address))
                        {
                            if (unionOfSelection == null)
                            {
                                unionOfSelection = rangeToSelect;
                            }
                            else
                            {
                                unionOfSelection = Globals.ThisAddIn.Application.Union(unionOfSelection, rangeToSelect);
                            }
                        }

                        Globals.ThisAddIn.Application.EnableEvents = false;
                        unionOfSelection.Select();
                    }
                    catch
                    {
                        // Ignore if we cannot parse the text as it might be tampered manually by user.
                    }
                    finally
                    {
                        Globals.ThisAddIn.Application.EnableEvents = true;
                    }
                }
            }
            else
            {
                // If nothing is selected, auto detect any active selection on the activated sheet.
                selectionText.Text = InputSelection.GetRangeAddress(Globals.ThisAddIn.Application.Selection);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Export data from sheets to a particulat sequence file format
        /// </summary>
        private void OnExportClick(object sender, RibbonControlEventArgs e)
        {
            var formatter = ((sender as RibbonButton).Tag as ISequenceFormatter);
            if (formatter is FastAFormatter || formatter is FastQFormatter || formatter is GenBankFormatter
                || formatter is GffFormatter)
            {
                var sequenceSelection = new InputSelection();

                if (formatter is GenBankFormatter)
                {
                    sequenceSelection.MaximumSequenceCount = 1;
                    sequenceSelection.MinimumSequenceCount = 1;
                }

                sequenceSelection.GetSequencesForExport(this.DoExportSequence, formatter);
            }
            else
            {
                // as its not a ISequenceFormatter try to cast it to ISequenceRangeFormatter
                var rangeformatter = ((sender as RibbonButton).Tag as ISequenceRangeFormatter);

                if (rangeformatter is ISequenceRangeFormatter)
                {
                    var sequenceSelection = new InputSelection();
                    sequenceSelection.SequenceLabels = new[] { Resources.Export_BED_SequenceRangeString };
                    sequenceSelection.MaximumSequenceCount = 1;
                    sequenceSelection.PromptForSequenceName = false;
                    sequenceSelection.GetInputSequenceRanges(
                        this.DoExportRangeSequence,
                        false,
                        false,
                        false,
                        rangeformatter);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// This method is called when the user wants to use NCBI\EBI databases
        /// for a search operation. This methos pops-up a UI where the user
        /// can configure the parameters required to run NCBI\EBI.
        /// </summary>
        /// <param name="sender">ExecuteBlast button.</param>
        /// <param name="e">Event data</param>
        private void OnExecuteBlastSearch(object sender, RibbonControlEventArgs e)
        {
            this.ResetStatus();
            this.webserviceName = (sender as RibbonButton).Tag as string;

            var inputs = new InputSelection();
            inputs.SequenceLabels = new[] { Resources.InputSelection_SequenceLabel_Blast };
            inputs.MinimumSequenceCount = 1;
            inputs.GetInputSequences(this.OnExecuteSearch, false);
        }
Beispiel #5
0
        /// <summary>
        /// This method is called when the user wants to start an assembler operation.
        /// </summary>
        private void OnAssembleClick(object sender, RibbonControlEventArgs e)
        {
            this.ResetStatus();

            var inputs = new InputSelection();
            inputs.MinimumSequenceCount = 2;
            inputs.GetInputSequences(this.DoAssembly, false);
        }
Beispiel #6
0
        /// <summary>
        /// This method is called when the user wants to start a alignment operation.
        /// This method extracts the sequences present in the selected excel sheets
        /// and runs alignment on them.
        /// </summary>
        /// <param name="sender">Align button</param>
        /// <param name="e">Event data</param>
        private void OnAlignmentButtonClicked(object sender, RibbonControlEventArgs e)
        {
            this.ResetStatus();
            var aligner = (sender as RibbonButton).Tag as ISequenceAligner;

            var inputs = new InputSelection();
            inputs.MinimumSequenceCount = 2;
            if (aligner is IPairwiseSequenceAligner)
            {
                inputs.MaximumSequenceCount = 2;
            }

            inputs.GetInputSequences(this.DoAlignment, false, aligner);
        }
Beispiel #7
0
 /// <summary>
 /// Create a Venn diagram out of two/three SequenceRangeGrouping objects.
 /// This method gets the user input for creating the diagram
 /// </summary>
 private void OnVennDiagramClick(object sender, RibbonControlEventArgs e)
 {
     var inputs = new InputSelection();
     inputs.MinimumSequenceCount = 2;
     inputs.MaximumSequenceCount = 3;
     inputs.PromptForSequenceName = false;
     inputs.SequenceLabels = new[]
                             {
                                 Resources.InputSelection_SequenceLabel_Venn1,
                                 Resources.InputSelection_SequenceLabel_Venn2,
                                 Resources.InputSelection_SequenceLabel_Venn3
                             };
     inputs.GetInputSequenceRanges(this.DoDrawVenn, false, false, false);
 }