secondary_structure

package
v0.0.0-...-e8a583a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package secondary_structure provides the structs needed to contain information about a RNA's secondary structure

Overview of the structs

The struct that contains information of a RNA's secondary structure is `SecondaryStructure`. The field `Structures` contains a list of the main RNA secondary structures (`*MultiLoop`, `*Hairpin`, and `*SingleStrandedRegion`). `Hairpin`s and `MultiLoop`s both can optionally have a `Stem`.

A `Stem` consists of a list of `StemStructure`s. A `StemStructure` consists of a closing and enclosed base pair with the requirement that there are no base pairs between the closing and enclosed base pair.

See the declaration of the structs for detailed information on their definition.

Explanation of the energy fields of the structs

The energy fields of the structs are only used in the `SecondaryStructure` returned from the func `MinimumFreeEnergy` in the subpackage `mfe` in `poly`. The func `MinimumFreeEnergy` reads energy paramater values from files specified in the `RNAfold parameter file v2.0` file format in the `energy_params` subpackage in `poly`. This file format specifies energy values in the unit deca-cal / mol (with the `int` type).

Due to Golang's inaccuracies with adding and subtracting `float64` values, a design decision was made to specify the energy fields of the structs defined in this file in the unit deca-cal / mol (with the `int` type).

Thus, to convert to the 'standard' energy unit of kcal/mol, the energy values have to be converted to type `float32` or `float64` and divided by `100`.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hairpin

type Hairpin struct {
	Stem                                                    Stem
	SingleStrandedFivePrimeIdx, SingleStrandedThreePrimeIdx int
	Energy                                                  int // free energy in dcal / mol only from the hairpin loop (doesn't include free energy from the stem)
}

Hairpin contains all the information needed to denote a hairpin loop in a RNA's secondary structure. It consists of a `Stem` and a single stranded region that forms the loop of the structure.

Sometimes a `Hairpin` may only consist of a Stem without a single stranded region. In such cases, the `SingleStrandedFivePrimeIdx` and `SingleStrandedThreePrimeIdx` of the hairpin are set to `-1`.

The total free energy of a Hairpin can be calculated by summing the energy of the Hairpin's stem (present in the `Energy` field of the `Stem`), and the energy of the single stranded region of a Hairpin's loop (the `Energy` field of this struct).

type MultiLoop

type MultiLoop struct {
	Stem                Stem
	Substructures       []interface{}
	Energy              int // free energy (in dcal / mol) only from the multi-loop (doesn't include free energy from the substrctures or stem)
	SubstructuresEnergy int // free energy (in dcal / mol) only from the substructures of the multi-loop (doesn't include free energy from the stem or multi-loop)
}

MultiLoop contains all the information needed to denote a multi-loop in a RNA's secondary structure. It consists of a `Stem` and a list of substructures. A `Multiloop` will always contain at least one substructure. The substructures that can be present in a Multiloop are `*Hairpin`s, `*SingleStrandedRegion`s and `*MultiLoop`s.

The total free energy of a Multiloop can be calculated by summing the energy of the Multiloop's stem (present in the `Energy` field of the `Stem`), the energy of the substructures (the `Energy` field of `Substructures`), and the energy of the Multiloop (the `Energy` field of this struct).

type SecondaryStructure

type SecondaryStructure struct {
	Structures          []interface{}
	Length              int
	ExteriorLoopsEnergy int // the free energy (in dcal / mol) of the exterior loops present in the secondary structure
	Energy              int // the free energy (in dcal / mol) of the entire secondary structure
}

SecondaryStructure is composed of a list of `MultiLoop`s, `Hairpin`s, and `SingleStrandedRegion`s. Note that since Go doesn't support inheritance, we use `interface{}` as the type for the structures list, but the only types that are allowed/used are `*MultiLoop`, `*Hairpin` and `*SingleStrandedRegion`.

The free energy of the entire secondary structure (including the energy of the exterior loops of the secondary structure) is stored in the `Energy` field of the struct. Since the energy of the exterior loops of the secondary structure is not part of any of the `SecondaryStructure`'s `Structures` (and belongs to the entire SecondaryStructure struct), it is stored in the field `ExteriorLoopsEnergy`.

func SecondaryStructureFromDotBracket

func SecondaryStructureFromDotBracket(dotBracketStructure string) (annotatedStructure string, secondaryStructure *SecondaryStructure, err error)

SecondaryStructureFromDotBracket returns the annotated structure and `SecondaryStructure` of a RNA sequence from its 'dot-bracket' structure.

Example
dotBracket := "..((((...))))...((........)).."

// dotBracket with index
// . . ( ( ( ( . . . )  )  )  )  .  .  .  (  (  .  .  .  .  .  .  .  .  )  )  .  .
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

actualSecondaryStructure := SecondaryStructure{
	Length:              30,
	ExteriorLoopsEnergy: 0,
	Energy:              0,
	Structures: []interface{}{
		&SingleStrandedRegion{
			FivePrimeIdx:  0,
			ThreePrimeIdx: 1,
		},
		&Hairpin{
			Stem: Stem{
				ClosingFivePrimeIdx:   2,
				EnclosedFivePrimeIdx:  5,
				EnclosedThreePrimeIdx: 9,
				ClosingThreePrimeIdx:  12,
				Structures: []StemStructure{
					StemStructure{
						ClosingFivePrimeIdx:   2,
						EnclosedFivePrimeIdx:  3,
						EnclosedThreePrimeIdx: 11,
						ClosingThreePrimeIdx:  12,
						Type:                  StackingPair, Energy: 0,
					},
					StemStructure{
						ClosingFivePrimeIdx:   3,
						EnclosedFivePrimeIdx:  4,
						EnclosedThreePrimeIdx: 10,
						ClosingThreePrimeIdx:  11,
						Type:                  StackingPair, Energy: 0,
					},
					StemStructure{
						ClosingFivePrimeIdx:   4,
						EnclosedFivePrimeIdx:  5,
						EnclosedThreePrimeIdx: 9,
						ClosingThreePrimeIdx:  10,
						Type:                  StackingPair, Energy: 0,
					},
				},
				Energy: 0,
			},
			SingleStrandedFivePrimeIdx:  6,
			SingleStrandedThreePrimeIdx: 8,
			Energy:                      0,
		},
		&SingleStrandedRegion{
			FivePrimeIdx:  13,
			ThreePrimeIdx: 15,
		},
		&Hairpin{
			Stem: Stem{
				ClosingFivePrimeIdx:   16,
				EnclosedFivePrimeIdx:  17,
				EnclosedThreePrimeIdx: 26,
				ClosingThreePrimeIdx:  27,
				Structures: []StemStructure{
					StemStructure{
						ClosingFivePrimeIdx:   16,
						EnclosedFivePrimeIdx:  17,
						EnclosedThreePrimeIdx: 26,
						ClosingThreePrimeIdx:  27,
						Type:                  StackingPair, Energy: 0,
					},
				},
				Energy: 0,
			},
			SingleStrandedFivePrimeIdx:  18,
			SingleStrandedThreePrimeIdx: 25,
			Energy:                      0,
		},
		&SingleStrandedRegion{
			FivePrimeIdx:  28,
			ThreePrimeIdx: 29,
		},
	},
}

annotatedStructure, secondaryStructure, err := SecondaryStructureFromDotBracket(dotBracket)
if err != nil {
	panic(err)
}

fmt.Println(annotatedStructure)
// check if predicted and actual structures are same
fmt.Println(isSecondaryStructuresEqual(actualSecondaryStructure, *secondaryStructure))
Output:

ee((((hhh))))eee((hhhhhhhh))ee
true
Example (GenericInteriorLoops)
dotBracket := "(..(...(....().....)...)....)"

// dotBracket with index
// ( . . ( . . . ( . .  .  .  (  )  .  .  .  .  .  )  .  .  .  )  .  .  .  .  )
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

actualSecondaryStructure := SecondaryStructure{
	Length:              29,
	ExteriorLoopsEnergy: 0,
	Energy:              0,
	Structures: []interface{}{
		&Hairpin{
			Stem: Stem{
				ClosingFivePrimeIdx:   0,
				EnclosedFivePrimeIdx:  12,
				EnclosedThreePrimeIdx: 13,
				ClosingThreePrimeIdx:  28,
				Structures: []StemStructure{
					StemStructure{
						ClosingFivePrimeIdx:   0,
						EnclosedFivePrimeIdx:  3,
						EnclosedThreePrimeIdx: 23,
						ClosingThreePrimeIdx:  28,
						NBUnpairedFivePrime:   2,
						NBUnpairedThreePrime:  4,
						Type:                  GenericInteriorLoop,
						Energy:                0,
					},
					StemStructure{
						ClosingFivePrimeIdx:   3,
						EnclosedFivePrimeIdx:  7,
						EnclosedThreePrimeIdx: 19,
						ClosingThreePrimeIdx:  23,
						NBUnpairedFivePrime:   3,
						NBUnpairedThreePrime:  3,
						Type:                  GenericInteriorLoop,
						Energy:                0,
					},
					StemStructure{
						ClosingFivePrimeIdx:   7,
						EnclosedFivePrimeIdx:  12,
						EnclosedThreePrimeIdx: 13,
						ClosingThreePrimeIdx:  19,
						NBUnpairedFivePrime:   4,
						NBUnpairedThreePrime:  5,
						Type:                  GenericInteriorLoop,
						Energy:                0,
					},
				},
				Energy: 0,
			},
			SingleStrandedFivePrimeIdx:  -1,
			SingleStrandedThreePrimeIdx: -1,
			Energy:                      0,
		},
	},
}

annotatedStructure, secondaryStructure, err := SecondaryStructureFromDotBracket(dotBracket)
if err != nil {
	panic(err)
}

fmt.Println(annotatedStructure)
// check if predicted and actual structures are same
fmt.Println(isSecondaryStructuresEqual(actualSecondaryStructure, *secondaryStructure))
Output:

(ii(iii(iiii()iiiii)iii)iiii)
true
Example (HairpinWithoutSingleStrandedRegion)
dotBracket := "..((())).."

// dotBracket with index
// . . ( ( ( ) ) ) . .
// 0 1 2 3 4 5 6 7 8 9

actualSecondaryStructure := SecondaryStructure{
	Length:              10,
	ExteriorLoopsEnergy: 0,
	Energy:              0,
	Structures: []interface{}{
		&SingleStrandedRegion{
			FivePrimeIdx:  0,
			ThreePrimeIdx: 1,
		},
		&Hairpin{
			Stem: Stem{
				ClosingFivePrimeIdx:   2,
				EnclosedFivePrimeIdx:  4,
				EnclosedThreePrimeIdx: 5,
				ClosingThreePrimeIdx:  7,
				Structures: []StemStructure{
					StemStructure{
						ClosingFivePrimeIdx:   2,
						EnclosedFivePrimeIdx:  3,
						EnclosedThreePrimeIdx: 6,
						ClosingThreePrimeIdx:  7,
						Type:                  StackingPair, Energy: 0,
					},
					StemStructure{
						ClosingFivePrimeIdx:   3,
						EnclosedFivePrimeIdx:  4,
						EnclosedThreePrimeIdx: 5,
						ClosingThreePrimeIdx:  6,
						Type:                  StackingPair, Energy: 0,
					},
				},
				Energy: 0,
			},
			SingleStrandedFivePrimeIdx:  -1,
			SingleStrandedThreePrimeIdx: -1,
			Energy:                      0,
		},
		&SingleStrandedRegion{
			FivePrimeIdx:  8,
			ThreePrimeIdx: 9,
		},
	},
}

annotatedStructure, secondaryStructure, err := SecondaryStructureFromDotBracket(dotBracket)
if err != nil {
	panic(err)
}

fmt.Println(annotatedStructure)
// check if predicted and actual structures are same
fmt.Println(isSecondaryStructuresEqual(actualSecondaryStructure, *secondaryStructure))
Output:

ee((()))ee
true
Example (Interior1xnLoops)
dotBracket := "(.(.(...(..).)..).)"

// dotBracket with index
// ( . ( . ( . . . ( .  .  )  .  )  .  .  )  .  )
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

actualSecondaryStructure := SecondaryStructure{
	Length:              19,
	ExteriorLoopsEnergy: 0,
	Energy:              0,
	Structures: []interface{}{
		&Hairpin{
			Stem: Stem{
				ClosingFivePrimeIdx:   0,
				EnclosedFivePrimeIdx:  8,
				EnclosedThreePrimeIdx: 11,
				ClosingThreePrimeIdx:  18,
				Structures: []StemStructure{
					StemStructure{
						ClosingFivePrimeIdx:   0,
						EnclosedFivePrimeIdx:  2,
						EnclosedThreePrimeIdx: 16,
						ClosingThreePrimeIdx:  18,
						NBUnpairedFivePrime:   1,
						NBUnpairedThreePrime:  1,
						Type:                  Interior1x1Loop,
						Energy:                0,
					},
					StemStructure{
						ClosingFivePrimeIdx:   2,
						EnclosedFivePrimeIdx:  4,
						EnclosedThreePrimeIdx: 13,
						ClosingThreePrimeIdx:  16,
						NBUnpairedFivePrime:   1,
						NBUnpairedThreePrime:  2,
						Type:                  Interior2x1Loop,
						Energy:                0,
					},
					StemStructure{
						ClosingFivePrimeIdx:   4,
						EnclosedFivePrimeIdx:  8,
						EnclosedThreePrimeIdx: 11,
						ClosingThreePrimeIdx:  13,
						NBUnpairedFivePrime:   3,
						NBUnpairedThreePrime:  1,
						Type:                  Interior1xnLoop,
						Energy:                0,
					},
				},
				Energy: 0,
			},
			SingleStrandedFivePrimeIdx:  9,
			SingleStrandedThreePrimeIdx: 10,
			Energy:                      0,
		},
	},
}

annotatedStructure, secondaryStructure, err := SecondaryStructureFromDotBracket(dotBracket)
if err != nil {
	panic(err)
}

fmt.Println(annotatedStructure)
// check if predicted and actual structures are same
fmt.Println(isSecondaryStructuresEqual(actualSecondaryStructure, *secondaryStructure))
Output:

(i(i(iii(hh)i)ii)i)
true
Example (Interior2xnLoops)
dotBracket := "(..(...(..(..)....)..)..)"

// dotBracket with index
// ( . . ( . . . ( . .  (  .  .  )  .  .  .  .  )  .  .  )  .  .  )
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

actualSecondaryStructure := SecondaryStructure{
	Length:              25,
	ExteriorLoopsEnergy: 0,
	Energy:              0,
	Structures: []interface{}{
		&Hairpin{
			Stem: Stem{
				ClosingFivePrimeIdx:   0,
				EnclosedFivePrimeIdx:  10,
				EnclosedThreePrimeIdx: 13,
				ClosingThreePrimeIdx:  24,
				Structures: []StemStructure{
					StemStructure{
						ClosingFivePrimeIdx:   0,
						EnclosedFivePrimeIdx:  3,
						EnclosedThreePrimeIdx: 21,
						ClosingThreePrimeIdx:  24,
						NBUnpairedFivePrime:   2,
						NBUnpairedThreePrime:  2,
						Type:                  Interior2x2Loop,
						Energy:                0,
					},
					StemStructure{
						ClosingFivePrimeIdx:   3,
						EnclosedFivePrimeIdx:  7,
						EnclosedThreePrimeIdx: 18,
						ClosingThreePrimeIdx:  21,
						NBUnpairedFivePrime:   3,
						NBUnpairedThreePrime:  2,
						Type:                  Interior2x3Loop,
						Energy:                0,
					},
					StemStructure{
						ClosingFivePrimeIdx:   7,
						EnclosedFivePrimeIdx:  10,
						EnclosedThreePrimeIdx: 13,
						ClosingThreePrimeIdx:  18,
						NBUnpairedFivePrime:   2,
						NBUnpairedThreePrime:  4,
						Type:                  GenericInteriorLoop,
						Energy:                0,
					},
				},
				Energy: 0,
			},
			SingleStrandedFivePrimeIdx:  11,
			SingleStrandedThreePrimeIdx: 12,
			Energy:                      0,
		},
	},
}

annotatedStructure, secondaryStructure, err := SecondaryStructureFromDotBracket(dotBracket)
if err != nil {
	panic(err)
}

fmt.Println(annotatedStructure)
// check if predicted and actual structures are same
fmt.Println(isSecondaryStructuresEqual(actualSecondaryStructure, *secondaryStructure))
Output:

(ii(iii(ii(hh)iiii)ii)ii)
true
Example (InteriorBulge)
dotBracket := "(((.).....).)"

// dotBracket with index
// ( ( ( . ) . . . . .  )  .  )
// 0 1 2 3 4 5 6 7 8 9 10 11 12

actualSecondaryStructure := SecondaryStructure{
	Length:              13,
	ExteriorLoopsEnergy: 0,
	Energy:              0,
	Structures: []interface{}{
		&Hairpin{
			Stem: Stem{
				ClosingFivePrimeIdx:   0,
				EnclosedFivePrimeIdx:  2,
				EnclosedThreePrimeIdx: 4,
				ClosingThreePrimeIdx:  12,
				Structures: []StemStructure{
					StemStructure{
						ClosingFivePrimeIdx:   0,
						EnclosedFivePrimeIdx:  1,
						EnclosedThreePrimeIdx: 10,
						ClosingThreePrimeIdx:  12,
						NBUnpairedFivePrime:   0,
						NBUnpairedThreePrime:  1,
						Type:                  Bulge,
						Energy:                0,
					},
					StemStructure{
						ClosingFivePrimeIdx:   1,
						EnclosedFivePrimeIdx:  2,
						EnclosedThreePrimeIdx: 4,
						ClosingThreePrimeIdx:  10,
						NBUnpairedFivePrime:   0,
						NBUnpairedThreePrime:  5,
						Type:                  Bulge,
						Energy:                0,
					},
				},
				Energy: 0,
			},
			SingleStrandedFivePrimeIdx:  3,
			SingleStrandedThreePrimeIdx: 3,
			Energy:                      0,
		},
	},
}

annotatedStructure, secondaryStructure, err := SecondaryStructureFromDotBracket(dotBracket)
if err != nil {
	panic(err)
}

fmt.Println(annotatedStructure)
// check if predicted and actual structures are same
fmt.Println(isSecondaryStructuresEqual(actualSecondaryStructure, *secondaryStructure))
Output:

(((h)iiiii)i)
true
Example (MultiLoop)
dotBracket := "..(..((((...))))...((........))..)."

// dotBracket with index
// . . ( . . ( ( ( ( .  .  .  )  )  )  )  .  .  .  (  (  .  .  .  .  .  .  .  .  )  )  .  .  )  .
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

actualSecondaryStructure := SecondaryStructure{
	Length:              35,
	ExteriorLoopsEnergy: 0,
	Energy:              0,
	Structures: []interface{}{
		&SingleStrandedRegion{
			FivePrimeIdx:  0,
			ThreePrimeIdx: 1,
		},
		&MultiLoop{
			Energy: 0,
			Stem: Stem{
				ClosingFivePrimeIdx:   2,
				EnclosedFivePrimeIdx:  -1,
				EnclosedThreePrimeIdx: -1,
				ClosingThreePrimeIdx:  33,
				Structures:            []StemStructure{},
				Energy:                0,
			},
			Substructures: []interface{}{
				&SingleStrandedRegion{
					FivePrimeIdx:  3,
					ThreePrimeIdx: 4,
				},
				&Hairpin{
					Stem: Stem{
						ClosingFivePrimeIdx:   5,
						EnclosedFivePrimeIdx:  8,
						EnclosedThreePrimeIdx: 12,
						ClosingThreePrimeIdx:  15,
						Structures: []StemStructure{
							StemStructure{
								ClosingFivePrimeIdx:   5,
								EnclosedFivePrimeIdx:  6,
								EnclosedThreePrimeIdx: 14,
								ClosingThreePrimeIdx:  15,
								Type:                  StackingPair, Energy: 0,
							},
							StemStructure{
								ClosingFivePrimeIdx:   6,
								EnclosedFivePrimeIdx:  7,
								EnclosedThreePrimeIdx: 13,
								ClosingThreePrimeIdx:  14,
								Type:                  StackingPair, Energy: 0,
							},
							StemStructure{
								ClosingFivePrimeIdx:   7,
								EnclosedFivePrimeIdx:  8,
								EnclosedThreePrimeIdx: 12,
								ClosingThreePrimeIdx:  13,
								Type:                  StackingPair, Energy: 0,
							},
						},
						Energy: 0,
					},
					SingleStrandedFivePrimeIdx:  9,
					SingleStrandedThreePrimeIdx: 11,
					Energy:                      0,
				},
				&SingleStrandedRegion{
					FivePrimeIdx:  16,
					ThreePrimeIdx: 18,
				},
				&Hairpin{
					Stem: Stem{
						ClosingFivePrimeIdx:   19,
						EnclosedFivePrimeIdx:  20,
						EnclosedThreePrimeIdx: 29,
						ClosingThreePrimeIdx:  30,
						Structures: []StemStructure{
							StemStructure{
								ClosingFivePrimeIdx:   19,
								EnclosedFivePrimeIdx:  20,
								EnclosedThreePrimeIdx: 29,
								ClosingThreePrimeIdx:  30,
								Type:                  StackingPair, Energy: 0,
							},
						},
						Energy: 0,
					},
					SingleStrandedFivePrimeIdx:  21,
					SingleStrandedThreePrimeIdx: 28,
					Energy:                      0,
				},
				&SingleStrandedRegion{
					FivePrimeIdx:  31,
					ThreePrimeIdx: 32,
				},
			},
		},
		&SingleStrandedRegion{
			FivePrimeIdx:  34,
			ThreePrimeIdx: 34,
		},
	},
}

annotatedStructure, secondaryStructure, err := SecondaryStructureFromDotBracket(dotBracket)
if err != nil {
	panic(err)
}

fmt.Println(annotatedStructure)
// check if predicted and actual structures are same
fmt.Println(isSecondaryStructuresEqual(actualSecondaryStructure, *secondaryStructure))
Output:

ee(mm((((hhh))))mmm((hhhhhhhh))mm)e
true
Example (StemWithoutEnclosedPair)
dotBracket := ".(.)."

// dotBracket with index
// . ( . ) .
// 0 1 2 3 4

actualSecondaryStructure := SecondaryStructure{
	Length:              5,
	ExteriorLoopsEnergy: 0,
	Energy:              0,
	Structures: []interface{}{
		SingleStrandedRegion{
			FivePrimeIdx:  0,
			ThreePrimeIdx: 0,
		},
		Hairpin{
			Stem: Stem{
				ClosingFivePrimeIdx:   1,
				EnclosedFivePrimeIdx:  -1,
				EnclosedThreePrimeIdx: -1,
				ClosingThreePrimeIdx:  3,
				Structures:            []StemStructure{},
				Energy:                0,
			},
			SingleStrandedFivePrimeIdx:  2,
			SingleStrandedThreePrimeIdx: 2,
			Energy:                      0,
		},
		SingleStrandedRegion{
			FivePrimeIdx:  4,
			ThreePrimeIdx: 4,
		},
	},
}

annotatedStructure, secondaryStructure, err := SecondaryStructureFromDotBracket(dotBracket)
if err != nil {
	panic(err)
}

fmt.Println(annotatedStructure)
// check if predicted and actual structures are same
fmt.Println(isSecondaryStructuresEqual(actualSecondaryStructure, *secondaryStructure))
Output:

e(h)e
true

type SingleStrandedRegion

type SingleStrandedRegion struct {
	FivePrimeIdx, ThreePrimeIdx int
}

SingleStrandedRegion contains all the information needed to denote a single stranded region in a RNA's secondary structure. At the minimum, a `SingleStrandedRegion` consists of of a single unpaired nucleotide. In such a case, `FivePrimeIdx` == `ThreePrimeIdx`.

type Stem

type Stem struct {
	ClosingFivePrimeIdx, EnclosedFivePrimeIdx   int
	EnclosedThreePrimeIdx, ClosingThreePrimeIdx int
	Structures                                  []StemStructure
	Energy                                      int // free energy (in dcal / mol) all the substructures present in the stem
}

Stem contains all the information needed to denote the stems of a `Hairpin` or `Multiloop`. It is not a "top-level" structure of a RNA and only exists as part of a `Hairpin` or `Multiloop`. The closing pairs denote where the stem starts and enclosed pairs where the stem ends. The actual stem consists of a list of `StemStructure`s.

Note that a `Stem` may not contain any stem structures. This occurs in cases where there is only one base pair that delimits a `Hairpin` or `MultiLoop`. For example, dot-bracket structure: . . . ( . . . ) . . annotated structure: e e e ( h h h ) e e index: 0 1 2 3 4 5 6 7 8 9 would be a Hairpin (with a Stem with the closing base pair at indexs 3 and 7) whose stem don't contain any structures.

For example, dot-bracket structure: . . ( . . . ( ( . . ) ) . . ) . . annotated structure: . . ( m m m ( ( h h ) ) m m ) e e index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 would be a Multiloop (with a Stem with the closing base pair at indexs 2 and 14) whose stem don't contain any structures. In such cases, the stem will only have its `ClosingFivePrimeIdx` and `ClosingThreePrimeIdx` set. The `EnclosedFivePrimeIdx` and `EnclosedThreePrimeIdx` will be set to -1, and the list of `StemStructures` will be empty.

type StemStructure

type StemStructure struct {
	ClosingFivePrimeIdx, EnclosedFivePrimeIdx   int
	EnclosedThreePrimeIdx, ClosingThreePrimeIdx int
	NBUnpairedFivePrime, NBUnpairedThreePrime   int // the number of unpaired nucleotides on the five and three prime ends
	Type                                        StemStructureType
	Energy                                      int // free energy of the `StemStructure` in dcal / mol
}

StemStructure contains all the information needed to denote the substructures present in a `Stem`. A `StemStructure` always consists of a closing and enclosed base pair with the requirement that there are no base pairs between the closing and enclosed base pair.

A `StemStructure` is classified into a `StemStructureType` based on the number of unpaired nucleotides between the closing and enclosed base pairs. (See (*StemStructure).setStructureType for more details)

func NewStemStructure

func NewStemStructure(closingFivePrimeIdx, closingThreePrimeIdx,
	enclosedFivePrimeIdx, enclosedThreePrimeIdx int) StemStructure

NewStemStructure is a wrapper to create a `StemStructure` and call the functions (`(*StemStructure).setStructureType`) required to initialize the struct.

type StemStructureType

type StemStructureType int

StemStructureType denotes the type of a `StemStructure`.

const (
	// StackingPair is the type of a `StemStructure` where there are no unpaired
	// nucleotides between the closing and enclosed base pairs of the
	// `StemStructure`.
	StackingPair StemStructureType = iota
	// Bulge is the type of a `StemStructure` where there is more than one
	// unpaired nucleotide on one 'side' of the `StemStructure` and no unpaired
	// nucleotides on the other 'side'.
	Bulge
	// Interior1x1Loop is the type of a `StemStructure` where there is one
	// unpaired nucleotide on both 'sides' of the `StemStructure`.
	Interior1x1Loop
	// Interior2x1Loop is the type of a `StemStructure` where there are two
	// unpaired nucleotides on one 'side' and one unpaired nucleotides on the
	// other 'side' of the `StemStructure`.
	Interior2x1Loop
	// Interior1xnLoop is the type of a `StemStructure` where there is one
	// unpaired nucleotides on one 'side' and more than two unpaired nucleotides
	// on the other 'side' of the `StemStructure`.
	Interior1xnLoop
	// Interior2x2Loop is the type of a `StemStructure` where there are two
	// unpaired nucleotides on both 'sides' of the `StemStructure`.
	Interior2x2Loop
	// Interior2x3Loop is the type of a `StemStructure` where there are two
	// unpaired nucleotides on one 'side' and three unpaired nucleotides on the
	// other 'side' of the `StemStructure`.
	Interior2x3Loop
	// GenericInteriorLoop is the type of a `StemStructure` which is not denoted
	// by `StackingPair`, `Bulge`, `Interior1x1Loop`, `Interior2x1Loop`,
	// `Interior1xnLoop`, `Interior2x2Loop`, or `Interior2x3Loop`.
	// Thus, the `StemStructure` can be one of:
	// * two unpaired nucleotides on one 'side' and more than three on the other
	//   (2x4, 2x5, ..., 2xn interior loops)
	// * three unpaired nucleotides on one 'side' and three or more on the other
	//   (3x3, 3x4, ..., 3xn interior loops)
	GenericInteriorLoop
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL