-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove restriction of 10 alleles max in multiallelic sites (#11)
* remove restriction of 10 alleles max in multiallelic sites * fix haploid with allele > 9, add test * improve strictness of bi-allelic check, add clarifying comments * rune comparison is 15-20x faster than string, even with casts * add go.mod and go.sum
- Loading branch information
Showing
5 changed files
with
231 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// Benchmark for comparing a rune element with a rune variable | ||
func BenchmarkRuneEquality(b *testing.B) { | ||
// Sample rune slice and a rune variable to compare with | ||
data := []rune{'a', 'b', 'c'} | ||
compareRune := 'a' | ||
|
||
b.ResetTimer() // Reset the timer to exclude setup time | ||
for i := 0; i < b.N; i++ { | ||
for _, r := range data { | ||
if r == compareRune { | ||
// Perform some action if equal | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Benchmark for comparing a rune element cast to a string with a string variable | ||
func BenchmarkStringEquality(b *testing.B) { | ||
// Sample rune slice and a string variable to compare with | ||
data := []rune{'a', 'b', 'c'} | ||
compareString := "a" | ||
|
||
b.ResetTimer() // Reset the timer to exclude setup time | ||
for i := 0; i < b.N; i++ { | ||
for _, r := range data { | ||
if string(r) == compareString { | ||
// Perform some action if equal | ||
} | ||
} | ||
} | ||
} | ||
|
||
func BenchmarkStringToRuneEquality(b *testing.B) { | ||
// Sample rune slice and a string variable to compare with | ||
data := []string{"a", "b", "c"} | ||
compareRune := 'a' | ||
|
||
b.ResetTimer() // Reset the timer to exclude setup time | ||
for i := 0; i < b.N; i++ { | ||
for _, r := range data { | ||
if rune(r[0]) == compareRune { | ||
// Perform some action if equal | ||
} | ||
} | ||
} | ||
} | ||
|
||
func BenchmarkStringToStringEquality(b *testing.B) { | ||
// Sample rune slice and a string variable to compare with | ||
data := []string{"a", "b", "c"} | ||
compareString := "a" | ||
|
||
b.ResetTimer() // Reset the timer to exclude setup time | ||
for i := 0; i < b.N; i++ { | ||
for _, r := range data { | ||
if string(r[0]) == compareString { | ||
// Perform some action if equal | ||
} | ||
} | ||
} | ||
} | ||
|
||
func BenchmarkGenotypeToStringEquality(b *testing.B) { | ||
// Sample rune slice and a string variable to compare with | ||
data := []string{"0|1", "1|0", "0|1"} | ||
compareString := "0" | ||
|
||
b.ResetTimer() // Reset the timer to exclude setup time | ||
for i := 0; i < b.N; i++ { | ||
for _, r := range data { | ||
if string(r[0]) == compareString { | ||
// Perform some action if equal | ||
} | ||
} | ||
} | ||
} | ||
|
||
func BenchmarkGenotypeToRuneEquality(b *testing.B) { | ||
// Sample rune slice and a string variable to compare with | ||
data := []string{"0|1", "1|0", "0|1"} | ||
compareString := "0" | ||
|
||
b.ResetTimer() // Reset the timer to exclude setup time | ||
for i := 0; i < b.N; i++ { | ||
for _, r := range data { | ||
if rune(r[0]) == rune(compareString[0]) { | ||
// Perform some action if equal | ||
} | ||
} | ||
} | ||
} | ||
|
||
func BenchmarkGenotypeToRuneEqualityWithLengthTest(b *testing.B) { | ||
data := []string{"0|1", "1|0", "0|1"} | ||
compareString := "0" | ||
|
||
b.ResetTimer() // Reset the timer to exclude setup time | ||
for i := 0; i < b.N; i++ { | ||
if len(compareString) == 1 { | ||
for _, r := range data { | ||
if rune(r[0]) == rune(compareString[0]) { | ||
// Perform some action if equal | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/bystrogenomics/bystro-vcf | ||
|
||
go 1.20 | ||
|
||
require github.com/akotlar/bystro-utils v0.0.0-20180921004542-b5183a523f20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/akotlar/bystro-utils v0.0.0-20180921004542-b5183a523f20 h1:DTPJA8O7qs7Dc+YRg9wZusDy/SoVHqn9udRQlr+TSFA= | ||
github.com/akotlar/bystro-utils v0.0.0-20180921004542-b5183a523f20/go.mod h1:BHUTiQAFM7OSW8+09I/OwWMhgbsonqQ6J8jTlnpOPnk= |
Oops, something went wrong.