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
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
4 changes: 2 additions & 2 deletions random/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// 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 @@
//* 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 randomNucelotideSequence(length int, seed int64, alphabet []rune) string {
alphabetLength := len(alphabet)
rand.Seed(seed)

Check failure on line 54 in random/random.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator. (staticcheck)

randomSequence := make([]rune, length)
for basepair := range randomSequence {
Expand Down
7 changes: 5 additions & 2 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,6 +165,7 @@ func (table *TranslationTable) OptimizeSequence(aminoAcids string, randomState .
if !ok {
return "", invalidAminoAcidError{aminoAcid}
}
chooser.PickSource(rand)

codons.WriteString(chooser.Pick().(string))
}
Expand Down
Loading