github.com/biogo/biogo@v1.0.4/align/pals/pile_test.go (about) 1 // Copyright ©2011-2012 The bíogo Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package pals 6 7 import ( 8 "gopkg.in/check.v1" 9 ) 10 11 var ( 12 testChr = Contig("testchr") 13 testPairs = []*Pair{ 14 { 15 A: &Feature{ID: "a", Loc: testChr, From: 2, To: 4}, 16 B: &Feature{ID: "g", Loc: testChr, From: 7, To: 9}, 17 Score: 1, 18 }, 19 { 20 A: &Feature{ID: "b", Loc: testChr, From: 3, To: 4}, 21 B: &Feature{ID: "i", Loc: testChr, From: 7, To: 8}, 22 Score: 1, 23 }, 24 { 25 A: &Feature{ID: "c", Loc: testChr, From: 1, To: 3}, 26 B: &Feature{ID: "j", Loc: testChr, From: 8, To: 9}, 27 Score: 1, 28 }, 29 { 30 A: &Feature{ID: "d", Loc: testChr, From: 1, To: 4}, 31 B: &Feature{ID: "f", Loc: testChr, From: 6, To: 9}, 32 Score: 1, 33 }, 34 { 35 A: &Feature{ID: "k", Loc: testChr, From: 10, To: 11}, 36 B: &Feature{ID: "e", Loc: testChr, From: 4, To: 5}, 37 Score: 1, 38 }, 39 } 40 ) 41 42 func (s *S) TestPiler(c *check.C) { 43 epsilon := 0.95 44 for _, f := range []PairFilter{ 45 nil, 46 func(p *Pair) bool { 47 return float64(p.A.Len()) >= float64(p.A.Loc.Len())*epsilon || 48 float64(p.B.Len()) >= float64(p.B.Loc.Len())*epsilon 49 }, 50 } { 51 p := NewPiler(0) 52 for _, fp := range testPairs { 53 fp.A.Pair = fp 54 fp.B.Pair = fp 55 err := p.Add(fp) 56 if err != nil { 57 c.Fatal(err) 58 } 59 } 60 61 for i, pi := range p.Piles(f) { 62 c.Logf("%d %v", i, pi) 63 for _, f := range pi.Images { 64 c.Logf("\t%v", f.Pair) 65 c.Check(f.Location(), check.DeepEquals, pi) 66 } 67 } 68 } 69 }