Skip to content

Instantly share code, notes, and snippets.

@bsipos
Created October 21, 2017 16:07
Show Gist options
  • Save bsipos/66a7d75c617cd4bd06d1e4472948ccd0 to your computer and use it in GitHub Desktop.
Save bsipos/66a7d75c617cd4bd06d1e4472948ccd0 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/biogo/biogo/alphabet"
"github.com/biogo/biogo/io/seqio/fastq"
"github.com/biogo/biogo/seq/linear"
"io"
"os"
)
func main() {
fh, err := os.Open(os.Args[1])
if err != nil {
panic(err)
}
template := linear.NewQSeq("", alphabet.QLetters{}, alphabet.DNA, alphabet.Sanger)
reader := fastq.NewReader(fh, template)
for {
seq, err := reader.Read()
if err == io.EOF {
break
}
// Print the sequence ID and a tab:
fmt.Print(seq.CloneAnnotation().ID, "\t")
// For positions 0...9:
for i := 0; i < 10; i++ {
// Get the QLetter at position i:
ql := seq.At(i)
// Print the base at position i:
fmt.Print(string(ql.L))
}
fmt.Println()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment