Skip to content

Commit

Permalink
add no lint to many linearfold files
Browse files Browse the repository at this point in the history
  • Loading branch information
Koeng101 committed Dec 21, 2023
1 parent 16a27dd commit 001eb52
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 33 deletions.
7 changes: 7 additions & 0 deletions lib/fold/fold.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
Package fold contains DNA and RNA folding algorithms.
We have two supported algorithms: The dynamic Zuker algorithm, and LinearFold.
These packages work, but LinearFold needs a massive cleanup effort.
*/
package fold

type SequenceFolder interface {
Expand Down
1 change: 1 addition & 0 deletions lib/fold/linearfold/linearfold.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:all
package linearfold

import (
Expand Down
19 changes: 9 additions & 10 deletions lib/fold/linearfold/linearfold_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ import (
"github.com/koeng101/dnadesign/lib/fold/mfe/energy_params"
)

func ExampleCONTRAFoldV2() {

func ExampleCONTRAfoldV2() {
result, score := CONTRAfoldV2("UGAGUUCUCGAUCUCUAAAAUCG", DefaultBeamSize)

fmt.Println(fmt.Sprintf("result: %v , score: %v", result, score))
fmt.Printf("result: %v , score: %v", result, score)
// Output: result: ....................... , score: -0.22376699999999988
}

func ExampleViennaRNAFold() {
sequence := "UCUAGACUUUUCGAUAUCGCGAAAAAAAAU"
result, score := ViennaRNAFold(sequence, DefaultTemperature, DefaultEnergyParamsSet, mfe.DefaultDanglingEndsModel, DefaultBeamSize)
fmt.Println(fmt.Sprintf("result: %v , score: %.2f", result, score))
fmt.Printf("result: %v , score: %.2f", result, score)
// Output: result: .......((((((......))))))..... , score: -3.90
}

Expand Down Expand Up @@ -73,15 +72,15 @@ func ViennaRNAFoldTest(sequence, expectedStructure string, expectedScore float64
result, score := ViennaRNAFold(sequence, temperature, energyParamsSet, danglingEndsModel, DefaultBeamSize)
// we expect the calculated score to be within 5% of the expected value
threshold := 0.05
var lower_threshold, upper_threshold float64
var lowerThreshold, upperThreshold float64
if expectedScore < 0 {
upper_threshold = expectedScore * (1 - threshold)
lower_threshold = expectedScore * (1 + threshold)
upperThreshold = expectedScore * (1 - threshold)
lowerThreshold = expectedScore * (1 + threshold)
} else {
lower_threshold = expectedScore * (1 - threshold)
upper_threshold = expectedScore * (1 + threshold)
lowerThreshold = expectedScore * (1 - threshold)
upperThreshold = expectedScore * (1 + threshold)
}
if score < lower_threshold || score > upper_threshold {
if score < lowerThreshold || score > upperThreshold {
// if result != expectedStructure || score != expectedScore {
t.Errorf("Failed to fold %v. \nExpected \nresult: %v \nscore: %v\nGot \nresult: %v \nscore: %v", sequence, expectedStructure, expectedScore, result, score)
}
Expand Down
25 changes: 17 additions & 8 deletions lib/fold/mfe/energy_params/energy_params.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:all
package energy_params

import "embed"
Expand Down Expand Up @@ -41,27 +42,35 @@ func NewEnergyParams(energyParamsSet EnergyParamsSet, temperatureInCelsius float
// pairs as the first indices followed by the unpaired bases in 5' to 3' direction.
// For example, if we have a 2x2 interior loop:
// ```
// 5'-GAUA-3'
// 3'-CGCU-5'
//
// 5'-GAUA-3'
// 3'-CGCU-5'
//
// ```
// The closing pairs for the loops are GC and UA (not AU!), and the unpaired bases
// are (in 5' to 3' direction, starting at the first pair) A U C G.
// Thus, the energy for this sequence is:
// ```
// pairs: GC UA A U C G
// interior2x2Loop[1][5][1][4][2][3]
//
// pairs: GC UA A U C G
// interior2x2Loop[1][5][1][4][2][3]
//
// ```
// (See `BasePairEncodedTypeMap` and `NucleotideEncodedIntMap` for more details
// on how pairs and unpaired nucleotides are encoded)
// Note that this sequence is symmetric so the sequence is equivalent to:
// ```
// 5'-UCGC-3'
// 3'-AUAG-5'
//
// 5'-UCGC-3'
// 3'-AUAG-5'
//
// ```
// which means the energy of the sequence is equivalent to:
// ```
// pairs: UA GC C G A U
// interior2x2Loop[5][1][1][4][2][3]
//
// pairs: UA GC C G A U
// interior2x2Loop[5][1][1][4][2][3]
//
// ```
type EnergyParams struct {

Expand Down
7 changes: 5 additions & 2 deletions lib/fold/mfe/energy_params/parse.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:all
package energy_params

import (
Expand Down Expand Up @@ -477,13 +478,15 @@ func parseFloat64(token string) float64 {
End Section: Miscellaneous Parsing Functions
*****************************************************************************/

/*****************************************************************************
/*
****************************************************************************
Section: Adding Offsets to Matrices
The following section contains funcs needed to add pre and post offsets to
`int` matrices. Please read the documentation for `newRawEnergyParams` to
understand why pre and post offsets are needed.
*****************************************************************************/
****************************************************************************
*/
type offsetType int

const (
Expand Down
9 changes: 6 additions & 3 deletions lib/fold/mfe/energy_params/scale.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:all
package energy_params

/******************************************************************************
Expand Down Expand Up @@ -79,9 +80,11 @@ func (rawEnergyParams rawEnergyParams) scaleByTemperature(temperatureInCelsius f

// Rescale Gibbs free energy according to the equation dG = dH - T * dS
// where dG is the change in Gibbs free energy
// dH is the change in enthalpy
// dS is the change in entropy
// T is the temperature
//
// dH is the change in enthalpy
// dS is the change in entropy
// T is the temperature
//
// more information: https://chemed.chem.purdue.edu/genchem/topicreview/bp/ch21/gibbs.php
func rescaleDg(dG, dH int, temperatureInCelsius float64) int {
// if temperate == measurementTemperatureInCelsius then below calculation will
Expand Down
3 changes: 1 addition & 2 deletions lib/fold/mfe/mfe.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:all
package mfe

import (
Expand Down Expand Up @@ -294,7 +295,6 @@ func stemStructureEnergy(stemStructure StemStructure, fc *foldCompound) int {
closingFivePrimeMismatch, closingThreePrimeMismatch,
enclosedThreePrimeMismatch, enclosedFivePrimeMismatch,
fc.energyParams)

}

// EvaluateStemStructure computes the energy of either a stacking pair, bulge,
Expand Down Expand Up @@ -628,7 +628,6 @@ func multiLoop(multiloop *MultiLoop, fc *foldCompound) (multiLoopEnergy, substru
multiLoopEnergy += EvaluateMultiLoopStem(stemPairType, fivePrimeMismatch,
threePrimeMismatch, fc.energyParams)
}

}

stemFivePrimeIdx, stemThreePrimeIdx := multiloop.Stem.EnclosedFivePrimeIdx, multiloop.Stem.EnclosedThreePrimeIdx
Expand Down
1 change: 1 addition & 0 deletions lib/fold/mfe/mfe_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:all
package mfe

import (
Expand Down
5 changes: 3 additions & 2 deletions lib/fold/mfe/secondary_structure/dot_bracket.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:all
package secondary_structure

import (
Expand All @@ -15,7 +16,7 @@ structure and `SecondaryStructure` of a RNA from its 'dot-bracket' notation.
'Dot-bracket' notation of a secondary structure is a string where each
character represents a base. Unpaired nucleotides are represented with a '.'
and base pairs are represented by paranthesis. '(' denotes the opening base
and base pairs are represented by parenthesis. '(' denotes the opening base
and ')' denotes the closing base of a base pair.
For example,
dot-bracket structure: . . ( ( . . ) ) . .
Expand All @@ -35,7 +36,7 @@ For example,
dot-bracket structure: . . ( ( . . ) ) . .
annotated structure: e e ( ( h h ) ) e e
index: 0 1 2 3 4 5 6 7 8 9
Note that the paranthesis surrounding one or more 'h' or 'm' characters form
Note that the parenthesis surrounding one or more 'h' or 'm' characters form
the stem of that hairpin or multiloop respectively. Thus, in the example above,
the bases at index 2, 3, 6, and 7 form the stem of the hairpin loop enclosed
by the bases at index 3 and 6.
Expand Down
1 change: 1 addition & 0 deletions lib/fold/mfe/secondary_structure/dot_bracket_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:all
package secondary_structure

import (
Expand Down
9 changes: 3 additions & 6 deletions lib/fold/mfe/secondary_structure/secondary_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Package secondary_structure provides the structs needed to contain
information about a RNA's secondary structure
Overview of the structs
# 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
Expand All @@ -16,8 +16,7 @@ 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
# 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
Expand All @@ -32,10 +31,8 @@ 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`.
*/
package secondary_structure
package secondarystructure

// SecondaryStructure is composed of a list of `MultiLoop`s, `Hairpin`s,
// and `SingleStrandedRegion`s. Note that since Go doesn't support inheritance,
Expand Down

0 comments on commit 001eb52

Please sign in to comment.