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

docs/test: added package godoc with a few small tests #1058

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions interval/lift/lift.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package lift provides an interface and utilities for working with genomic regions and offer flexibility to modify their coordinates.
package lift

import (
Expand Down
27 changes: 27 additions & 0 deletions interval/lift/lift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/vertgenlab/gonomics/bed"
"github.com/vertgenlab/gonomics/interval"
)

var ReadingTests = []struct {
Expand All @@ -22,3 +23,29 @@ func TestReading(t *testing.T) {
}
}
}

func TestIntervalSliceToLift(t *testing.T) {
// Create intervals where some implement Lift, others don't
intervals := []interval.Interval{
bed.Bed{Chrom: "chr1", ChromStart: 1, ChromEnd: 30},
bed.Bed{Chrom: "chr2", ChromStart: 300, ChromEnd: 400},
}
lifts := IntervalSliceToLift(intervals)
expected := []Lift{
bed.Bed{Chrom: "chr1", ChromStart: 1, ChromEnd: 30},
bed.Bed{Chrom: "chr2", ChromStart: 300, ChromEnd: 400},
}
if !allAreEqual(lifts, expected) {
t.Errorf("Error: IntervalSliceToLift(intervals, expected) do not equal.\n")
}
}

func TestMatchOverlapLen(t *testing.T) {
var one bed.Bed = bed.Bed{Chrom: "chr1", ChromStart: 5, ChromEnd: 15}
var two bed.Bed = bed.Bed{Chrom: "chr1", ChromStart: 11, ChromEnd: 14}
overlapSize := MatchOverlapLen(one.GetChromStart(), one.GetChromEnd(), two.GetChromStart(), two.GetChromEnd())
expected := 3
if overlapSize != expected {
t.Errorf("Error: MatchOverlapLen(%d, %d, %d, %d) %d != %d\n", one.GetChromStart(), one.GetChromEnd(), two.GetChromStart(), two.GetChromEnd(), overlapSize, expected)
}
}