Skip to content

Commit

Permalink
fixed case for single sample inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheww95 committed Aug 28, 2024
1 parent 849fe80 commit 32712d0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
5 changes: 5 additions & 0 deletions data_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func CalculateBucketSize(data_length int, minimum_bins int, bucket_increase int)
}

bucket_size := (data_length / minimum_bins)
if bucket_size == 0 {
bucket_size++
}

remainder := data_length % minimum_bins

if remainder == 0 {
Expand All @@ -48,6 +52,7 @@ func CalculateBucketSize(data_length int, minimum_bins int, bucket_increase int)
bucket_size *= bucket_increase
minimum_bins = data_length / bucket_size
}

return bucket_size, minimum_bins
}

Expand Down
28 changes: 26 additions & 2 deletions data_scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bytes"
"fmt"
"os"
"path"
"testing"
Expand Down Expand Up @@ -50,12 +49,37 @@ func TestRunData(t *testing.T) {
// Compare outputs line by line
f1, _ := os.ReadFile(test_expected_output)
f2, _ := os.ReadFile(test_output_file)
fmt.Println(string(f2))
if !bytes.Equal(f1, f2) {
t.Fatal("Input and output files to not match.")
}
}

func TestRunDataSmall(t *testing.T) {
tempdir := t.TempDir()

t.Log("Starting end to end test for distance calculations.")
test_input := "TestInputs/DistanceMatrix/Random_2_input.txt"
test_output_file := path.Join(tempdir, "output.txt")

t.Logf("Test Input: %s", test_input)
t.Logf("Test Output Temp File: %s", test_output_file)
t.Log("Creating output buffer.")
out_buffer, out_file := CreateOutputBuffer(test_output_file)

t.Log("Loading test allele profiles.")
test_data := LoadProfile(test_input)
RunData(test_data, out_buffer)
out_buffer.Flush()
out_file.Close()

// Compare outputs line by line
f2, _ := os.ReadFile(test_output_file)
output := string(f2)
if output != "1 1 0\n" {
t.Fatal("Input does not equal output.")
}
}

// Testing the redistribution of bucket indices at runtime
func TestRedistributeBuckets(t *testing.T) {
var profile_size int = 100
Expand Down

0 comments on commit 32712d0

Please sign in to comment.