Class ConstraintAdapter

java.lang.Object
org.biopax.paxtools.pattern.constraint.ConstraintAdapter
All Implemented Interfaces:
Constraint
Direct Known Subclasses:
ActivityConstraint, ActivityModificationChangeConstraint, ConstraintChain, ControlsNotParticipant, ControlToControllerER, ConversionSide, Empty, Equality, Field, HasAnID, IDConstraint, InterToPartER, LinkedPE, ModificationChangeConstraint, NonUbique, NOT, OR, Participant, ParticipatesInConv, PathConstraint, PEChainsIntersect, RelatedControl, SelfOrThis, Size, Type

public abstract class ConstraintAdapter extends Object implements Constraint
This is a base class for a Constraint. Most constraints should typically extend this class.
Author:
Ozgun Babur
  • Field Details

    • size

      protected int size
      Size of the constraint. This is defined by how many elements this constraint needs to be \ mapped to work.
    • blacklist

      protected Blacklist blacklist
      Blacklist to detect ubiquitous small molecules.
  • Constructor Details

    • ConstraintAdapter

      protected ConstraintAdapter(int size)
      Constructor with size.
      Parameters:
      size - size if the constraint.
    • ConstraintAdapter

      protected ConstraintAdapter(int size, Blacklist blacklist)
      Constructor with size.
      Parameters:
      size - size if the constraint.
      blacklist - for detecting ubiquitous small molecules
    • ConstraintAdapter

      protected ConstraintAdapter()
      Empty constructor. Note that specifying the size is not mandatory since the child constraint can override getVariableSize instead of using the size variable.
  • Method Details

    • canGenerate

      public boolean canGenerate()
      Specifies if the constraint is generative. If you override this method, then don't forget to also override getGeneratedInd, and generate methods.
      Specified by:
      canGenerate in interface Constraint
      Returns:
      true if constraint is generative
    • generate

      public Collection<BioPAXElement> generate(Match match, int... ind)
      This method has to be overridden by generative constraints.
      Specified by:
      generate in interface Constraint
      Parameters:
      match - current pattern match
      ind - mapped indices
      Returns:
      elements that satisfy this constraint
    • satisfies

      public boolean satisfies(Match match, int... ind)
      Use this method only if constraint canGenerate, and satisfaction criteria is that simple.
      Specified by:
      satisfies in interface Constraint
      Parameters:
      match - current pattern match
      ind - mapped indices
      Returns:
      true if the match satisfies this constraint
    • assertIndLength

      protected void assertIndLength(int[] ind)
      Asserts the size of teh parameter array is equal to the variable size.
      Parameters:
      ind - index array to assert its size
    • setSize

      public void setSize(int size)
      Sets the size of the constraint.
      Parameters:
      size - size of the constraint
    • getVariableSize

      public int getVariableSize()
      Gets the variable size of the constraint.
      Specified by:
      getVariableSize in interface Constraint
      Returns:
      variable size
    • getDirection

      protected ConversionDirectionType getDirection(Conversion conv, Control cont)
      Gets the direction of the Control chain the the Interaction.
      Parameters:
      conv - controlled conversion
      cont - top control
      Returns:
      the direction of the conversion related to the catalysis
    • getDirection

      protected ConversionDirectionType getDirection(Conversion conv, Pathway pathway, Control cont)
      Gets the direction of the Control chain the the Interaction.
      Parameters:
      conv - controlled conversion
      pathway - the container pathway
      cont - top control
      Returns:
      the direction of the conversion related to the catalysis
    • getDirection

      protected ConversionDirectionType getDirection(Conversion conv, Pathway pathway)
      Gets the direction of the Control chain the the Interaction.
      Parameters:
      conv - controlled conversion
      pathway - the container pathway
      Returns:
      the direction of the conversion related to the catalysis
    • getCatalysisDirection

      protected ConversionDirectionType getCatalysisDirection(Control cont)
      Gets the direction of the Control, if exists.
      Parameters:
      cont - Control to get its direction
      Returns:
      the direction of the Control
    • getControlChain

      protected List<Control> getControlChain(Control control, Interaction inter)
      Gets the chain of Control, staring from the given Control, leading to the given Interaction. Use this method only if you are sure that there is a link from the control to conversion. Otherwise a RuntimeException is thrown. This assumes that there is only one control chain towards the interaction. It not, then one of the chains will be returned.
      Parameters:
      control - top level Control
      inter - target Interaction
      Returns:
      Control chain controlling the Interaction
    • getConvParticipants

      protected Set<PhysicalEntity> getConvParticipants(Conversion conv, RelType type)
      Gets input ot output participants of the Conversion.
      Parameters:
      conv - Conversion to get participants
      type - input or output
      Returns:
      related participants
    • findDirectionInPathways

      protected ConversionDirectionType findDirectionInPathways(Conversion conv)
      Searches pathways that contains this conversion for the possible directions. If both directions exist, then the result is reversible.
      Parameters:
      conv - the conversion
      Returns:
      direction inferred from pathway membership
    • convertStepDirection

      protected ConversionDirectionType convertStepDirection(StepDirection sdir)
    • findDirectionInCatalysis

      protected ConversionDirectionType findDirectionInCatalysis(Conversion conv)
      Searches the controlling catalysis for possible direction of the conversion.
      Parameters:
      conv - the conversion
      Returns:
      direction inferred from catalysis objects
    • getDirection

      protected ConversionDirectionType getDirection(Conversion conv)