Guest User

Untitled

a guest
Oct 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. package main
  2.  
  3. // Import libraries:
  4. import (
  5. "github.com/biogo/biogo/alphabet"
  6. "github.com/biogo/biogo/io/seqio/fasta"
  7. "github.com/biogo/biogo/io/seqio/fastq"
  8. "github.com/biogo/biogo/seq/linear"
  9. "io"
  10. "os"
  11. )
  12.  
  13. func main() {
  14. // Open the fastq file specified on the command line
  15. // for reading:
  16. fh, err := os.Open(os.Args[1])
  17. // Check for open errors and abort:
  18. if err != nil {
  19. panic(err)
  20. }
  21.  
  22. // Create a template seuence for the reader:
  23. template := linear.NewQSeq("", alphabet.QLetters{}, alphabet.DNA, alphabet.Sanger)
  24. // Create a fastq reader:
  25. reader := fastq.NewReader(fh, template)
  26.  
  27. // Open the output file for writing:
  28. fho, err := os.Create(os.Args[2])
  29. // Close the file after we finished writing:
  30. defer fho.Close()
  31. if err != nil {
  32. panic(err)
  33. }
  34. // Create a fasta writer with width 80:
  35. writer := fasta.NewWriter(fho, 80)
  36.  
  37. for {
  38. // Read the next fastq record:
  39. seq, err := reader.Read()
  40. // Break loop if we reached the end of the file:
  41. if err == io.EOF {
  42. break
  43. }
  44. // Write out the fasta record:
  45. writer.Write(seq)
  46. }
  47. }
Add Comment
Please, Sign In to add comment