Package org.biopax.paxtools.pattern
Class Pattern
java.lang.Object
org.biopax.paxtools.pattern.Pattern
A pattern is a list of mapped constraints.
- Author:
- Ozgun Babur
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<MappedConst> List of mapped constraints.Indexes in a pattern can be labeled using this map.protected intHow many elements are there in a pattern match.protected Class<? extends BioPAXElement> Class of the first elements to match with this pattern. -
Constructor Summary
ConstructorsConstructorDescriptionPattern(Class<? extends BioPAXElement> startingClass, String label) Constructor with a label for the element at index 0.Pattern(Class<? extends BioPAXElement> startingClass, Constraint firstConstraint, String... label) Constructor with the first constraint and labels it uses. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Constraint constr, String... label) Creates a mapped constraint with the given generative constraint and the indexes it applies.voidAppends the constraints in the parameter pattern to the desired location.Getter for the constraint list.Class<? extends BioPAXElement> Gets the type of the initial element.booleanhasLabel(int index) Checks if the given location has a label.booleanChecks if the label is already in use.intGets the index of the given label.voidinsertPointConstraint(Constraint con, int... ind) A point constraint deals with only one element in a match, checks its validity.voidPuts the given label for the given index.voidvoidRemoves the last constraint added to the pattern.intsize()Gets the element size of the pattern.voidupdateLabel(String oldLabel, String newLabel) Changes a label.
-
Field Details
-
lastIndex
protected int lastIndexHow many elements are there in a pattern match. -
startingClass
Class of the first elements to match with this pattern. -
constraints
List of mapped constraints. -
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 elementfirstConstraint- first constraintlabel- labels for the constraint
-
Pattern
Constructor with a label for the element at index 0.- Parameters:
startingClass- type of the initial elementlabel- 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
Creates a mapped constraint with the given generative constraint and the indexes it applies. Also labels the last given index.- Parameters:
constr- constraint to addlabel- a label for the last of the given indices
-
add
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
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 addind- indices to add this point constraint
-
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
Gets the type of the initial element.- Returns:
- type of first element in a match
-
label
Puts the given label for the given index.- Parameters:
labelText- the labelindex- index to label
-
hasLabel
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
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
Changes a label. The oldLabel has to be an existing label and new label has to be a new label.- Parameters:
oldLabel- label to updatenewLabel- updated label
-