Skip to content

Instantly share code, notes, and snippets.

@bsipos
Last active October 21, 2017 17:50
Show Gist options
  • Save bsipos/49418cdf48ce9b87f042f993aea4e755 to your computer and use it in GitHub Desktop.
Save bsipos/49418cdf48ce9b87f042f993aea4e755 to your computer and use it in GitHub Desktop.
package main
// Import the standard formatting library:
import "fmt"
// Import the os library - needed for opening files:
import "os"
// Import the io library - needed for checking for EOF:
import "io"
//Import the necessary biogo fastq input/output library:
import (
"github.com/biogo/biogo/alphabet"
"github.com/biogo/biogo/io/seqio/fastq"
"github.com/biogo/biogo/seq/linear"
)
func main() {
// Open the fastq file specified on the command line
// for reading:
fh, err := os.Open(os.Args[1])
// Check for open errors and abort:
if err != nil {
panic(err)
}
// Create a template seuence for the reader:
template := linear.NewQSeq("", alphabet.QLetters{}, alphabet.DNA, alphabet.Sanger)
// Create a fastq reader:
reader := fastq.NewReader(fh, template)
for {
// Read the next record:
seq, err := reader.Read()
// Break loop if we reached the end of the file:
if err == io.EOF {
break
}
fmt.Println(seq.CloneAnnotation().ID)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment