Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Golang version #401

Merged
merged 10 commits into from
Dec 12, 2023
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.21
- name: Checkout code
uses: actions/checkout@v2
- name: Generate coverage report
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.21
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.18.x,]
go-version: [1.21.x,]
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/TimothyStiles/poly

go 1.18
go 1.21

require (
github.com/google/go-cmp v0.5.8
Expand All @@ -9,14 +9,14 @@ require (
github.com/mroth/weightedrand v0.4.1
github.com/pmezard/go-difflib v1.0.0
github.com/sergi/go-diff v1.2.0
github.com/spaolacci/murmur3 v1.1.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this moved to be a direct dependency?

Copy link
Collaborator

@TimothyStiles TimothyStiles Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure @carreter. It's used only in the mash package similar to how blake3 is only used in the seqhash package. Both are direct dependencies here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah had to double check but murmur3 should have been a direct dependency to begin with @carreter. Good to merge?

golang.org/x/exp v0.0.0-20230310171629-522b1b587ee0
lukechampine.com/blake3 v1.1.5
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mattn/go-sqlite3 v1.14.13 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
)

require (
Expand Down
5 changes: 2 additions & 3 deletions io/slow5/slow5_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package slow5
import (
"errors"
"io"
"io/ioutil"
"os"
"testing"
)
Expand Down Expand Up @@ -190,11 +189,11 @@ func TestWrite(t *testing.T) {
}

// Compare both files
example, err := ioutil.ReadFile("data/example.slow5")
example, err := os.ReadFile("data/example.slow5")
if err != nil {
t.Errorf("Failed to read example file: %s", err)
}
testWrite, err := ioutil.ReadFile("data/test_write.slow5")
testWrite, err := os.ReadFile("data/test_write.slow5")
if err != nil {
t.Errorf("Failed to read test file: %s", err)
}
Expand Down
6 changes: 3 additions & 3 deletions random/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func ProteinSequence(length int, seed int64) (string, error) {

// https://en.wikipedia.org/wiki/Amino_acid#Table_of_standard_amino_acid_abbreviations_and_properties
var aminoAcidsAlphabet = []rune("ACDEFGHIJLMNPQRSTVWY")
rand.Seed(seed)
randomSource := rand.New(rand.NewSource(seed))

randomSequence := make([]rune, length)

Expand All @@ -31,7 +31,7 @@ func ProteinSequence(length int, seed int64) (string, error) {
//* is the standard abbreviation for the stop codon. That's a signal for the ribosome to stop the translation and because of that a protein sequence is finished with *
randomSequence[peptide] = '*'
} else {
randomIndex := rand.Intn(len(aminoAcidsAlphabet))
randomIndex := randomSource.Intn(len(aminoAcidsAlphabet))
randomSequence[peptide] = aminoAcidsAlphabet[randomIndex]
}
}
Expand All @@ -51,7 +51,7 @@ func RNASequence(length int, seed int64) (string, error) {

func randomNucelotideSequence(length int, seed int64, alphabet []rune) string {
alphabetLength := len(alphabet)
rand.Seed(seed)
rand := rand.New(rand.NewSource(seed))

randomSequence := make([]rune, length)
for basepair := range randomSequence {
Expand Down
9 changes: 6 additions & 3 deletions synthesis/codon/codon.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ func (table *TranslationTable) OptimizeSequence(aminoAcids string, randomState .
}

// weightedRand library insisted setting seed like this. Not sure what environmental side effects exist.
var randomSource rand.Source
if len(randomState) > 0 {
rand.Seed(int64(randomState[0]))
randomSource = rand.NewSource(int64(randomState[0]))
carreter marked this conversation as resolved.
Show resolved Hide resolved
} else {
rand.Seed(time.Now().UTC().UnixNano())
randomSource = rand.NewSource(time.Now().UTC().UnixNano())
}
rand := rand.New(randomSource)

var codons strings.Builder
codonChooser := table.Choosers
Expand All @@ -163,8 +165,9 @@ func (table *TranslationTable) OptimizeSequence(aminoAcids string, randomState .
if !ok {
return "", invalidAminoAcidError{aminoAcid}
}
codon := chooser.PickSource(rand)

codons.WriteString(chooser.Pick().(string))
codons.WriteString(codon.(string))
}

return codons.String(), nil
Expand Down
Loading