Created
October 21, 2017 16:40
-
-
Save bsipos/5a6db6dfe6f865ce86b01103e5c99119 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment