ur_rna.StructureEditor.models

## Class Bond

- java.lang.Object
- - ur_rna.StructureEditor.models.Bond

- All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Comparable<Bond>

      public class Bond
      extends java.lang.Object
      implements java.lang.Comparable<Bond>, java.lang.Cloneable

  Represents a bond between two nucleotides.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Bond.BondInfo` A class for storing the indices of bonded nucleotides instead of direct references.
    `static class` | `Bond.MultiLoopRole`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `Nuc` | `n3`
    `Nuc` | `n5`
    `BondType` | `type` S1 and S2 represent the strand indices, N1 and N2 represent the nucleotide indices within each respective strand.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Bond(Nuc n1, Nuc n2)`
    `Bond(Nuc n1, Nuc n2, BondType type)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Bond` | `clone()`
    `static int` | `compare(Bond lhs, Bond rhs)`
    `int` | `compareTo(Bond other)`
    `boolean` | `contains(Nuc test)`
    `Motif.Helix` | `getHelix()`
    `Bond.MultiLoopRole` | `getMultiLoopRole(Nuc ref)` Determine whether this bond is the "entrance" ("Trunk") to a Multi-Branch Loop by passing in another reference nucleotide that is in the same loop.
    `Nuc` | `getNuc3()`
    `Nuc` | `getNuc5()`
    `Nuc` | `getOther(Nuc n)` Given a nucleotide on one side of the bond, this returns the nucleotide on the other side.
    `RnaScene` | `getScene()`
    `BondType` | `getType()`
    `boolean` | `isFirst()`
    `boolean` | `isHybrid()` Whether this bond represents an inter-molecular bond (i.e.
    `boolean` | `isLast()`
    `boolean` | `isOrdered()` Returns true if the nucleotides are in canonical order.
    `boolean` | `isTruePair()` Returns true for any bond that is not a PseudoKnot bond or a Prohibited-Constraint Bond.
    `Nuc` | `left(Nuc ref)`
    `void` | `makeOrdered()`
    `Vec2D` | `midpoint()`
    `java.awt.geom.Point2D` | `midpoint(java.awt.geom.Point2D assignTo)` Returns the midpoint between the two nucleotides in the bond.
    `Bond` | `nextInHelix()`
    `Bond` | `nextInHelix(int direction)`
    `Vec2D` | `normal()`
    `Vec2D` | `normal(Vec2D assignTo)` Returns a Vec2D that represents the direction normal to the bond -- i.e.
    `Bond` | `prevInHelix()`
    `Nuc` | `right(Nuc ref)` Assume we are traveling around a multi-branch loop from 5' to 3'.
    `private void` | `swap()` Swap the order of the nucleotides.
    `java.lang.String` | `toString()`
    `void` | `unpair()`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### n3

          public Nuc n3

    - #### n5

          public Nuc n5

    - #### type

          public BondType type

      S1 and S2 represent the strand indices, N1 and N2 represent the nucleotide indices within each respective strand.

  - ### Constructor Detail

    - #### Bond

          public Bond(Nuc n1,
                      Nuc n2)

    - #### Bond

          public Bond(Nuc n1,
                      Nuc n2,
                      BondType type)

  - ### Method Detail

    - #### clone

          public Bond clone()

      Overrides:
        `clone` in class `java.lang.Object`

    - #### compare

          public static int compare(Bond lhs,
                                    Bond rhs)

    - #### compareTo

          public int compareTo(Bond other)

      Specified by:
        `compareTo` in interface `java.lang.Comparable<Bond>`

    - #### contains

          public boolean contains(Nuc test)

    - #### getHelix

          public Motif.Helix getHelix()

    - #### getMultiLoopRole

          public Bond.MultiLoopRole getMultiLoopRole(@Nullable
                                                     Nuc ref)

      Determine whether this bond is the "entrance" ("Trunk") to a Multi-Branch Loop by passing in another reference nucleotide that is in the same loop.
      Parameters:
        `ref` - Any other nucleotide that is in the same MultiLoop as this Nuc. This is used for reference in cases where it is ambiguous which loop is being traversed. This ONLY occurs when this nucleotide is in a SINGLE-BP helix, therefore its basepair is both the FIRST and the LAST basepair.
      Returns:
        True if this is an entrance/trunk base-pair or false if this is an exit/limb pair.

    - #### getNuc3

          public Nuc getNuc3()

    - #### getNuc5

          public Nuc getNuc5()

    - #### getOther

          @Nullable
          public Nuc getOther(Nuc n)

      Given a nucleotide on one side of the bond, this returns the nucleotide on the other side. If the given nucleotide is not on either side, this returns null.

    - #### getScene

          public RnaScene getScene()

    - #### getType

          @NotNull
          public BondType getType()

    - #### isFirst

          public boolean isFirst()

    - #### isHybrid

          public boolean isHybrid()

      Whether this bond represents an inter-molecular bond (i.e. whether the bond connects nucleotides from different RNA strands)
      Returns:
        False if both nucleotides belong to the same strand. True otherwise (i.e. the second nucleotide belongs to a different strand than the first).

    - #### isLast

          public boolean isLast()

    - #### isOrdered

          public boolean isOrdered()

      Returns true if the nucleotides are in canonical order. Canonical order is hereby defined as: Nucleotides are . All nucleotides from strand 1 are listed listed in increasing order by index (this corresponds to listing them from 5' to 3'). If there are subsequent strands, then the nucleotides from each strand are listed after those of previous strands. (E.g. all strand 1 nucleotides come before strand 2 nucleotides.) The following function returns true if N1 comes before N2 in the above ordering. I.e. `N1.strand < N2.strand` or `N1.strand == N2.strand && N1.index <= N2.index`. The function also returns true if both nucleotides are null or if N2 is null (but N1 is not).

    - #### isTruePair

          public boolean isTruePair()

      Returns true for any bond that is not a PseudoKnot bond or a Prohibited-Constraint Bond.

    - #### left

          public Nuc left(Nuc ref)

    - #### makeOrdered

          public void makeOrdered()

    - #### midpoint

          public Vec2D midpoint()

    - #### midpoint

          public java.awt.geom.Point2D midpoint(@Nullable
                                                java.awt.geom.Point2D assignTo)

      Returns the midpoint between the two nucleotides in the bond. If assignTo is NOT null, its location is set to the midpoint and it is returned by the function. Otherwise, a new Vec2D is created and returned.

    - #### nextInHelix

          public Bond nextInHelix()

    - #### nextInHelix

          public Bond nextInHelix(int direction)

    - #### normal

          public Vec2D normal()

    - #### normal

          public Vec2D normal(@Nullable
                              Vec2D assignTo)

      Returns a Vec2D that represents the direction normal to the bond -- i.e. orthogonal to the vector from n5 to n3. If the structure was drawn counter-clockwise (the default), the normal vector of the first bond in a helix will point along the direction of the helix. If the structure was drawn clockwise, the normal vector will point in the opposite direction (along the helix, but away from it). If assignTo is NOT null, its coordinates are set to the normal, and it is returned by the function. Otherwise, a new Vec2D is created and returned.

    - #### prevInHelix

          public Bond prevInHelix()

    - #### right

          public Nuc right(Nuc ref)

      Assume we are traveling around a multi-branch loop from 5' to 3'. When we reach the "entrance" branch (aka "Trunk Helix") we encounter a bond that is reversed compared to all other bonds in the loop (which all belong to "exit" branches (aka "Limb Helices") In order to keep traversing the multi-branch loop (in the same direction) we need to go from the 3' side of the bond to the 5' side. In order to simplify the logic of traversing multi-branch loops, we define the "right" nucleotide of a Bond to be - null: if Bond is internal (i.e. not at the start or end of its helix) - n3: if Bond is the first bond in its helix (i.e.: Bond == Bond.getHelix().getPair(0)) - n5: if Bond is the last bond in its helix (i.e.: Bond == Bond.getHelix().getPair(0)) The "left" nucleotide is converse: n5 and n3 are switched. Using this definition, a multi-branch loop can be traversed by calling `Nuc.getNext()` on unpaired nucleotides and jumping across branches by calling `right(Nuc)` ()} on paired Nucs. (or alternatively by calling `Nuc.getPrev()` on unpaired nucleotides and `left(Nuc)` ()}.
      Parameters:
        `ref` - Any other nucleotide that is in the same MultiLoop as this Nuc. This is used for reference in cases where it is ambiguous which loop is being traversed. This ONLY occurs when this nucleotide is in a SINGLE-BP helix, therefore its basepair is both the FIRST and the LAST basepair.

    - #### swap

          private void swap()

      Swap the order of the nucleotides. (e.g. to put then in canonical order.

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### unpair

          public void unpair()