github.com/biogo/biogo@v1.0.4/seq/multi/set_example_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 multi 6 7 import ( 8 "fmt" 9 10 "github.com/biogo/biogo/alphabet" 11 "github.com/biogo/biogo/seq/linear" 12 ) 13 14 var set Set 15 16 func ExampleSet_AppendEach() { 17 ss := [][]alphabet.Letter{ 18 []alphabet.Letter("ACGCTGACTTGGTGCACGT"), 19 []alphabet.Letter("ACGACTGGGACGT"), 20 []alphabet.Letter("ACGCTGACTGGCCGT"), 21 []alphabet.Letter("GCCTTTGCACGT"), 22 } 23 set = make(Set, 4) 24 for i := range set { 25 set[i] = linear.NewSeq(fmt.Sprintf("example DNA %d", i), ss[i], alphabet.DNA) 26 } 27 as := [][]alphabet.QLetter{ 28 alphabet.QLetter{L: 'A'}.Repeat(2), 29 alphabet.QLetter{L: 'C'}.Repeat(2), 30 alphabet.QLetter{L: 'G'}.Repeat(2), 31 alphabet.QLetter{L: 'T'}.Repeat(2), 32 } 33 34 set.AppendEach(as) 35 36 for _, s := range set { 37 fmt.Printf("%-s\n", s) 38 } 39 // Output: 40 // ACGCTGACTTGGTGCACGTAA 41 // ACGACTGGGACGTCC 42 // ACGCTGACTGGCCGTGG 43 // GCCTTTGCACGTTT 44 } 45 46 func ExampleSet_Rows() { 47 fmt.Println(set.Rows()) 48 // Output: 49 // 4 50 } 51 52 func ExampleSet_Row() { 53 fmt.Printf("%-s\n", set.Row(2)) 54 // Output: 55 // ACGCTGACTGGCCGTGG 56 } 57 58 func ExampleSet_Len() { 59 fmt.Println(set.Len()) 60 // Output: 61 // 21 62 } 63 64 func ExampleSet_RevComp() { 65 set.RevComp() 66 for _, s := range set { 67 fmt.Println(s) 68 } 69 } 70 71 func ExampleSet_Reverse() { 72 set.RevComp() 73 for _, s := range set { 74 fmt.Println(s) 75 } 76 }