Class Pattern

java.lang.Object
org.biopax.paxtools.pattern.Pattern

public class Pattern extends Object
A pattern is a list of mapped constraints.
Author:
Ozgun Babur
  • Field Details

    • lastIndex

      protected int lastIndex
      How many elements are there in a pattern match.
    • startingClass

      protected Class<? extends BioPAXElement> startingClass
      Class of the first elements to match with this pattern.
    • constraints

      protected List<MappedConst> constraints
      List of mapped constraints.
    • labelMap

      protected Map<String,Integer> labelMap
      Indexes in a pattern can be labeled using this map.
  • Constructor Details

    • Pattern

      public Pattern(Class<? extends BioPAXElement> startingClass, Constraint firstConstraint, String... label)
      Constructor with the first constraint and labels it uses. This constructor is good for patterns with a single constraint.
      Parameters:
      startingClass - type of initial element
      firstConstraint - first constraint
      label - labels for the constraint
    • Pattern

      public Pattern(Class<? extends BioPAXElement> startingClass, String label)
      Constructor with a label for the element at index 0.
      Parameters:
      startingClass - type of the initial element
      label - a label for the initial element
  • Method Details

    • removeLastConstraint

      public void removeLastConstraint()
      Removes the last constraint added to the pattern.
    • optimizeConstraintOrder

      public void optimizeConstraintOrder()
    • add

      public void add(Constraint constr, String... label)
      Creates a mapped constraint with the given generative constraint and the indexes it applies. Also labels the last given index.
      Parameters:
      constr - constraint to add
      label - a label for the last of the given indices
    • add

      public void add(Pattern p)
      Appends the constraints in the parameter pattern to the desired location. Indexes in the constraint mappings are translated so that 0 is translated to ind0, and others are translated to orig + indAppend - 1. All slots of this pattern should already be full before calling this method. This method makes room for the new variables. Labels in the parameter pattern is transferred to this pattern. If there are equivalent labels, then these slots are mapped.
      Parameters:
      p - the parameter pattern
    • insertPointConstraint

      public void insertPointConstraint(Constraint con, int... ind)
      A point constraint deals with only one element in a match, checks its validity. This method injects the parameter constraint multiple times among the list of mapped constraints, to the specified indexes.
      Parameters:
      con - constraint to add
      ind - indices to add this point constraint
    • getConstraints

      public List<MappedConst> getConstraints()
      Getter for the constraint list.
      Returns:
      constraints
    • size

      public int size()
      Gets the element size of the pattern.
      Returns:
      size inferred from lastIndex
    • getStartingClass

      public Class<? extends BioPAXElement> getStartingClass()
      Gets the type of the initial element.
      Returns:
      type of first element in a match
    • label

      public void label(String labelText, int index)
      Puts the given label for the given index.
      Parameters:
      labelText - the label
      index - index to label
    • hasLabel

      public boolean hasLabel(String labelText)
      Checks if the label is already in use.
      Parameters:
      labelText - label to check
      Returns:
      true if label exists
    • hasLabel

      public boolean hasLabel(int index)
      Checks if the given location has a label.
      Parameters:
      index - index to check
      Returns:
      true if a label exists for the given index
    • indexOf

      public int indexOf(String labelText)
      Gets the index of the given label. The label must exist, otherwise a runtime exception is thrown.
      Parameters:
      labelText - label to check
      Returns:
      index of the label
    • updateLabel

      public void updateLabel(String oldLabel, String newLabel)
      Changes a label. The oldLabel has to be an existing label and new label has to be a new label.
      Parameters:
      oldLabel - label to update
      newLabel - updated label