Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- // Import libraries:
- import (
- "github.com/biogo/biogo/alphabet"
- "github.com/biogo/biogo/io/seqio/fasta"
- "github.com/biogo/biogo/io/seqio/fastq"
- "github.com/biogo/biogo/seq/linear"
- "io"
- "os"
- )
- 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)
- // Open the output file for writing:
- fho, err := os.Create(os.Args[2])
- // Close the file after we finished writing:
- defer fho.Close()
- if err != nil {
- panic(err)
- }
- // Create a fasta writer with width 80:
- writer := fasta.NewWriter(fho, 80)
- for {
- // Read the next fastq record:
- seq, err := reader.Read()
- // Break loop if we reached the end of the file:
- if err == io.EOF {
- break
- }
- // Write out the fasta record:
- writer.Write(seq)
- }
- }
Add Comment
Please, Sign In to add comment