/// <summary>
        /// This method wraps up the body of XML with the appropriate header and footer.
        /// </summary>
        /// <param name="mainPattern">The first pattern found in our pattern tree.</param>
        /// <param name="DefinitionName">Name of definition we want this structure to be called.</param>
        /// <returns></returns>
        public static string BuildPatternXML(PatternBase mainPattern, string DefinitionName) 
        {
            return
                string.Format(PATTERN_XML_HEADER_FOOTER,
                                                DefinitionName,
                                                mainPattern.ElementXML());

        }
Example #2
0
        private void CreatePattern(Type patternType, ParameterizableConfigurationElement patternConfiguration, Data.Matcher matcher)
        {
            PatternBase pattern = ConfigurableBase.CreateConfigurableItem <PatternBase>(patternType, patternConfiguration != null ? patternConfiguration.Parameters : null);

            pattern.Configuration = ConfigurationFactory.GetConfiguration(patternConfiguration, matcher);

            _patterns.Add(pattern);
        }
        /// <summary>
        /// Re-initialize all components in this child UI.
        /// This method also checks whether or not the selected pattern is a complex type. 
        /// If yes, the data form will render a special tag to accomodate the complex type settings.
        /// </summary>
        /// <param name="p">The selected Pattern</param>
        public void RebuildPanel(PatternBase p)
        {
            this.PnlPatternSetter.CommandButtonsVisibility = DataFormCommandButtonsVisibility.Commit;
            this.PnlPatternSetter.CurrentItem = p;

            #region Checks whether the selected pattern is a complex type

            #region if pattern is ["Position Weighted Matrix"]
            if (p is PWM)
            {
                pcv = new PagedCollectionView((p as PWM).RowElements);
                DataContext = pcv;
                SubElementView.Header = "PWM row elements";
                SubPanelDF.Header = "Add a PWM row here.";
            }
            #endregion

            #region else if pattern is a ["Block"]
            else if (p is BioPatMLEditor.PatternControls.PatternModels.Block)
            {
                pcv = new PagedCollectionView((p as BioPatMLEditor.PatternControls.PatternModels.Block).BlockElements);
                DataContext = pcv;
                SubPanelDF.Header = "Add your Block(s) here.";
                SubElementView.Header = "Block sequences";
            }
            #endregion

            #region else if pattern is a ["Composition"]
            else if (p is Composition)
            {
                pcv = new PagedCollectionView((p as Composition).compElements);
                DataContext = pcv;
                SubPanelDF.Header = "Add your Symbol & Weight here.";
                SubElementView.Header = "Symbol Weights";
            }
            #endregion

            #region else if pattern is a ["Repeat"]
            else if (p is Repeat)
            {
                pcv = new PagedCollectionView((p as Repeat).RepeatPairs);
                DataContext = pcv;
                SubElementView.Header = "Pairings";
                SubPanelDF.Header = "Add your pairings here.";
            }
            #endregion

            #region Otherwise just another ordinary pattern, not a complex one.
            else
                //Patterns with no sub elements
                SubElementView.Visibility = System.Windows.Visibility.Collapsed;
            #endregion

            #endregion
        }
        internal PatternTestAdapter(NameValueCollection config, ResourceInformation input, List <FoundMatchBase> expectedOutput)
        {
            _pattern = Activator.CreateInstance <T>();

            if (config != null)
            {
                NameValueConfigurationCollection properConfig = new NameValueConfigurationCollection();
                foreach (string key in config.AllKeys)
                {
                    properConfig.Add(new NameValueConfigurationElement(key, config[key]));
                }
                _pattern.Configure(properConfig);
            }
            _input          = input;
            _expectedOutput = expectedOutput;
        }
		/// <summary>
		/// Re-initialize all components in this child UI.
		/// This method also checks whether or not the selected pattern is a complex type. 
		/// If yes, the data form will render a special tag to accomodate the complex type settings.
		/// </summary>
		/// <param name="p">The selected Pattern</param>
		public void RebuildPanel ( PatternBase p ) {
			this.PnlPatternSetter.CommandButtonsVisibility = DataFormCommandButtonsVisibility.Commit;
			this.PnlPatternSetter.CurrentItem = p;
			MainView.IsSelected = true;

			if ( p == null ) {
				SubElementView.Visibility = System.Windows.Visibility.Collapsed;
			}

			else if ( p is PWM ) {
				pcv = new PagedCollectionView( ( p as PWM ).RowElements );
				DataContext = pcv;
				SubElementView.Visibility = System.Windows.Visibility.Visible;
				SubElementView.Header = "PWM row elements";
				SubPanelDF.Header = "Add a PWM row here.";
			}

			else if ( p is BioPatMLEditor.PatternControls.PatternModels.Block ) {
				pcv = new PagedCollectionView( ( p as BioPatMLEditor.PatternControls.PatternModels.Block ).children );
				DataContext = pcv;
				SubElementView.Visibility = System.Windows.Visibility.Visible;
				SubPanelDF.Header = "Add your Block(s) here.";
				SubElementView.Header = "Block sequences";
			}

			else if ( p is Composition ) {
				pcv = new PagedCollectionView( ( p as Composition ).children );
				DataContext = pcv;
				SubElementView.Visibility = System.Windows.Visibility.Visible;
				SubPanelDF.Header = "Add your Symbol & Weight here.";
				SubElementView.Header = "Symbol Weights";
			}

			else if ( p is Repeat ) {
				pcv = new PagedCollectionView( ( p as Repeat ).RepeatPairs );
				DataContext = pcv;
				SubElementView.Visibility = System.Windows.Visibility.Visible;
				SubElementView.Header = "Pairings";
				SubPanelDF.Header = "Add your pairings here.";
			}

			else {
				//Patterns with no sub elements
				SubElementView.Visibility = System.Windows.Visibility.Collapsed;
			}
		}
Example #6
0
        public static bool AreMacthesFound(
            string input,
            PatternBase pattern)
        {
            bool AreMatchesWithPattern = false;

            switch (pattern.PatternType)
            {
            case PatternMatchType.StartsWith:
                AreMatchesWithPattern = input.StartsWith(pattern.PatternText, StringComparison.InvariantCultureIgnoreCase);
                break;

            case PatternMatchType.RegEx:
                AreMatchesWithPattern = Regex.IsMatch(input, pattern.PatternText);
                break;

            case PatternMatchType.PresentsAnywhere:
                AreMatchesWithPattern = input.ToLower().IndexOf(pattern.PatternText.ToLower(), 0) >= 0;
                break;
            }

            return(AreMatchesWithPattern);
        }