From 8c1d5c09bf63e25d80dcdf7ace6b641752d6a9ec Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 5 Sep 2024 10:34:26 -0700 Subject: [PATCH] lint fix. (#445) * lint fix to use string interpolation. * more string interpolation. * more string interpolation. --- io/slow5/slow5_test.go | 2 +- seqhash/seqhash_test.go | 12 ++++++------ synthesis/fix/synthesis_test.go | 8 ++++---- synthesis/fragment/fragment_test.go | 14 +++++++------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/io/slow5/slow5_test.go b/io/slow5/slow5_test.go index 950faf740..8a85c167f 100644 --- a/io/slow5/slow5_test.go +++ b/io/slow5/slow5_test.go @@ -103,7 +103,7 @@ func testParseReadsHelper(t *testing.T, fileTarget string, errorMessage string) } } if len(targetErr) == 0 { - t.Errorf(errorMessage) + t.Errorf("Test failed: %s", errorMessage) } } diff --git a/seqhash/seqhash_test.go b/seqhash/seqhash_test.go index 1abd279d7..41989d6e9 100644 --- a/seqhash/seqhash_test.go +++ b/seqhash/seqhash_test.go @@ -35,33 +35,33 @@ func TestHash(t *testing.T) { // Test circular double stranded hashing seqhash, _ := Hash("TTAGCCCAT", "DNA", true, true) if seqhash != "v1_DCD_a376845b679740014f3eb501429b45e592ecc32a6ba8ba922cbe99217f6e9287" { - t.Errorf("Circular double stranded hashing failed. Expected v1_DCD_a376845b679740014f3eb501429b45e592ecc32a6ba8ba922cbe99217f6e9287, got: " + seqhash) + t.Errorf("Circular double stranded hashing failed. Expected v1_DCD_a376845b679740014f3eb501429b45e592ecc32a6ba8ba922cbe99217f6e9287, got: %s", seqhash) } // Test circular single stranded hashing seqhash, _ = Hash("TTAGCCCAT", "DNA", true, false) if seqhash != "v1_DCS_ef79b6e62394e22a176942dfc6a5e62eeef7b5281ffcb2686ecde208ec836ba4" { - t.Errorf("Circular single stranded hashing failed. Expected v1_DCS_ef79b6e62394e22a176942dfc6a5e62eeef7b5281ffcb2686ecde208ec836ba4, got: " + seqhash) + t.Errorf("Circular single stranded hashing failed. Expected v1_DCS_ef79b6e62394e22a176942dfc6a5e62eeef7b5281ffcb2686ecde208ec836ba4, got: %s", seqhash) } // Test linear double stranded hashing seqhash, _ = Hash("TTAGCCCAT", "DNA", false, true) if seqhash != "v1_DLD_c2c9fc44df72035082a152e94b04492182331bc3be2f62729d203e072211bdbf" { - t.Errorf("Linear double stranded hashing failed. Expected v1_DLD_c2c9fc44df72035082a152e94b04492182331bc3be2f62729d203e072211bdbf, got: " + seqhash) + t.Errorf("Linear double stranded hashing failed. Expected v1_DLD_c2c9fc44df72035082a152e94b04492182331bc3be2f62729d203e072211bdbf, got: %s", seqhash) } // Test linear single stranded hashing seqhash, _ = Hash("TTAGCCCAT", "DNA", false, false) if seqhash != "v1_DLS_063ea37d1154351639f9a48546bdae62fd8a3c18f3d3d3061060c9a55352d967" { - t.Errorf("Linear single stranded hashing failed. Expected v1_DLS_063ea37d1154351639f9a48546bdae62fd8a3c18f3d3d3061060c9a55352d967, got: " + seqhash) + t.Errorf("Linear single stranded hashing failed. Expected v1_DLS_063ea37d1154351639f9a48546bdae62fd8a3c18f3d3d3061060c9a55352d967, got: %s", seqhash) } // Test RNA Seqhash seqhash, _ = Hash("TTAGCCCAT", "RNA", false, false) if seqhash != "v1_RLS_063ea37d1154351639f9a48546bdae62fd8a3c18f3d3d3061060c9a55352d967" { - t.Errorf("Linear single stranded hashing failed. Expected v1_RLS_063ea37d1154351639f9a48546bdae62fd8a3c18f3d3d3061060c9a55352d967, got: " + seqhash) + t.Errorf("Linear single stranded hashing failed. Expected v1_RLS_063ea37d1154351639f9a48546bdae62fd8a3c18f3d3d3061060c9a55352d967, got: %s", seqhash) } // Test Protein Seqhash seqhash, _ = Hash("MGC*", "PROTEIN", false, false) if seqhash != "v1_PLS_922ec11f5227ce77a42f07f565a7a1a479772b5cf3f1f6e93afc5ecbc0fd5955" { - t.Errorf("Linear single stranded hashing failed. Expected v1_PLS_922ec11f5227ce77a42f07f565a7a1a479772b5cf3f1f6e93afc5ecbc0fd5955, got: " + seqhash) + t.Errorf(`Linear single stranded hashing failed. Expected v1_PLS_922ec11f5227ce77a42f07f565a7a1a479772b5cf3f1f6e93afc5ecbc0fd5955, got: %s`, seqhash) } } diff --git a/synthesis/fix/synthesis_test.go b/synthesis/fix/synthesis_test.go index 6ca7ea088..de726c29d 100644 --- a/synthesis/fix/synthesis_test.go +++ b/synthesis/fix/synthesis_test.go @@ -48,11 +48,11 @@ func BenchmarkCds(b *testing.B) { for _, cutSite := range []string{"GAAGAC", "GGTCTC", "GCGATG", "CGTCTC", "GCTCTTC", "CACCTGC"} { if strings.Contains(optimizedSeq, cutSite) { fmt.Println(changes) - b.Errorf("phusion" + " contains " + cutSite) + b.Errorf("phusion contains %s", cutSite) } if strings.Contains(transform.ReverseComplement(optimizedSeq), cutSite) { fmt.Println(changes) - b.Errorf("phusion" + " reverse complement contains " + cutSite) + b.Errorf("phusion reverse complement contains %s", cutSite) } } } @@ -84,10 +84,10 @@ func TestCds(t *testing.T) { for _, cutSite := range []string{"GAAGAC", "GGTCTC", "GCGATG", "CGTCTC", "GCTCTTC", "CACCTGC"} { if strings.Contains(optimizedSeq, cutSite) { - t.Errorf("phusion" + " contains " + cutSite) + t.Errorf("phusion contains %s", cutSite) } if strings.Contains(transform.ReverseComplement(optimizedSeq), cutSite) { - t.Errorf("phusion" + " reverse complement contains " + cutSite) + t.Errorf("phusion reverse complement contains %s", cutSite) } } diff --git a/synthesis/fragment/fragment_test.go b/synthesis/fragment/fragment_test.go index ab3f0c153..f21b3d3d1 100644 --- a/synthesis/fragment/fragment_test.go +++ b/synthesis/fragment/fragment_test.go @@ -9,7 +9,7 @@ func TestFragment(t *testing.T) { _, _, err := Fragment(gene, 90, 110, []string{}) if err != nil { - t.Errorf(err.Error()) + t.Error(err.Error()) } } @@ -18,7 +18,7 @@ func TestUnfragmentable(t *testing.T) { polyA := "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" _, _, err := Fragment(polyA, 40, 80, []string{}) if err == nil { - t.Errorf("polyA should fail to fragment") + t.Error("polyA should fail to fragment") } } @@ -27,12 +27,12 @@ func TestFragmentSizes(t *testing.T) { lacZ := "ATGACCATGATTACGCCAAGCTTGCATGCCTGCAGGTCGACTCTAGAGGATCCCCGGGTACCGAGCTCGAATTCACTGGCCGTCGTTTTACAACGTCGTGACTGGGAAAACCCTGGCGTTACCCAACTTAATCGCCTTGCAGCACATCCCCCTTTCGCCAGCTGGCGTAATAGCGAAGAGGCCCGCACCGATCGCCCTTCCCAACAGTTGCGCAGCCTGAATGGCGAATGGCGCCTGATGCGGTATTTTCTCCTTACGCATCTGTGCGGTATTTCACACCGCATATGGTGCACTCTCAGTACAATCTGCTCTGATGCCGCATAG" _, _, err := Fragment(lacZ, 105, 95, []string{}) if err == nil { - t.Errorf("Fragment should fail when minFragmentSize > maxFragmentSize") + t.Error("Fragment should fail when minFragmentSize > maxFragmentSize") } _, _, err = Fragment(lacZ, 7, 95, []string{}) if err == nil { - t.Errorf("Fragment should fail when minFragmentSize < 8") + t.Error("Fragment should fail when minFragmentSize < 8") } } @@ -51,7 +51,7 @@ func TestLongFragment(t *testing.T) { gene := "GGAGGGTCTCAATGCTGGACGATCGCAAATTCAGCGAACAGGAGCTGGTCCGTCGCAACAAATACAAAACGCTGGTCGAGCAAAACAAAGACCCGTACAAGATTACGAACTGGAAACGCAATACCACCCTGCTGAAACTGAATGAGAAATACAAAGACTATAGCAAGGAGGACCTGTTGAACCTGAATCAAGAACTGGTCGTTGTTGCAGGTCGTATCAAACTGTATCGTGAAGCCGGTAAAAAAGCTGCCTTTGTGAACATTGATGATCAAGACTCCTCTATTCAGTTGTACGTGCGCCTGGATGAGATCGGTGATCAGAGCTTCGAGGATTTCCGCAATTTCGACCTGGGTGACATCATTGGTGTTAAAGGTATCATGATGCGCACCGACCACGGCGAGTTGAGCATCCGTTGTAAGGAAGTCGTGCTGCTGAGCAAGGCCCTGCGTCCGCTGCCGGATAAACACGCGGGCATTCAGGATATTGAGGAAAAGTACCGCCGTCGCTATGTGGACCTGATTATGAATCACGACGTGCGCAAGACGTTCCAGGCGCGTACCAAGATCATTCGTACCTTGCAAAACTTTCTGGATAATAAGGGTTACATGGAGGTCGAAACCCCGATCCTGCATAGCCTGAAGGGTGGCGCGAGCGCGAAACCGTTTATTACCCACTACAATGTGCTGAATACGGATGTGTATCTGCGTATCGCGACCGAGCTGCACCTGAAACGCCTGATTGTTGGCGGTTTCGAGGGTGTGTATGAGATCGGTCGCATCTTTCGCAATGAAGGTATGTCCACGCGTCACAATCCGGAATTCACGTCTATCGAACTGTATGTCGCCTATGAGGACATGTTCTTTTTGATGGATCTGACCGAAGAGATTTTTCGCGTTTGTAATGCCGCAGTCAACAGCTCCAGCATCATTGAGTATAACAACGTGAAAATTGACCTGAGCAAGCCGTTTAAGCGCCTGCATATGGTTGACGGTATTAAACAGGTGACCGGCGTCGACTTCTGGCAGGAGATGACGGTCCAACAGGCTCTGGAGCTGGCCAAAAAGCATAAAGTGCACGTTGAAAAACATCAAGAGTCTGTTGGTCACATTATCAATTTGTTCTATGAGGAGTTCGTGGAGTCCACGATTGTTGAGCCGACGTTCGTGTACGGTCACCCGAAGGAAATCTCTCCGCTGGCTAAGAGCAATCCGTCTGACCCGCGTTTCACGGACCGTTTCGAGCTGTTCATTCTGGGTCGTGAGTATGCGAATGCGTTTAGCGAGCTGAATGACCCGATTGACCAGTACGAACGCTTCAAGGCTCAGATTGAGGAGGAAAGCAAGGGCAACGATGAAGCCAACGACATGGACATTGATTTCATCGAGGCTCTGGAACACGCCATGCCGCCGACCGCGGGTATTGGTATCGGCATTGATCGCTTGGTTATGCTGCTGACGAATAGCGAATCCATCAAAGACGTGCTGTTGTTCCCGCAAATGAAGCCGCGCGAATGAAGAGCTTAGAGACCCGCT" frags, _, err := Fragment(gene, 79, 94, []string{}) if err != nil { - t.Errorf(err.Error()) + t.Error(err.Error()) } for _, frag := range frags { if len(frag) > 94 { @@ -72,7 +72,7 @@ func TestCheckLongRegresssion(t *testing.T) { } } if foundGTCT { - t.Errorf("Should not have found GTCT since it is the reverse complement of AGAC") + t.Error("Should not have found GTCT since it is the reverse complement of AGAC") } } @@ -92,6 +92,6 @@ func TestFragmentWithOverhangs(t *testing.T) { _, _, err := FragmentWithOverhangs(gene, 90, 110, []string{}, defaultOverhangs) if err != nil { - t.Errorf(err.Error()) + t.Error(err.Error()) } }