kortschak/BioGo — pull request #1 by jaredwilkening (2012-03-28 00:03:44+00:00)
Title: seqio fixes and comments

I really like the what you have done with BioGo. I'm hoping to make heavy use of it in Shock and work with you to commit back changes.

**seqio** 7b6cf24ab907afb3ae290d5dfc750836babd23da

Added Close(), Rewind() to interface to enable building a multiformat sequence reader in Shock. I would be willing to port this into BioGo if you are interested.

**fasta** eecf062a7aef309c9805c92ffc2cd9e8e7470f17
Format(): new function in the style of BioPython seq.Format

Rewind(): wasn't resetting self.r (bufio reader) causing duplication of parts of the file.

Read(): I initially added an error message to

case bytes.HasPrefix(line, self.SeqPrefix):
if self.last == nil && label == nil { return nil, errors.New("invalid fasta format") }
line = bytes.Join(bytes.Fields(line[len(self.SeqPrefix):]), nil)
body = append(body, line...)

in order to error out on invalid fasta files. This caused read failures on valid fasta files. I found by printing line, body, label, self.last that on occasion label & self.last were nil when the body was being read causing it to be prepended to the next sequence.

I don't have time at the moment to track down the exact cause so I quickly ported a parsing strategy that has worked well for us in the past.

**fastq**

No commits. A few suggestions:

- +line ids are optional in fastq format
- move encode & decode quality to seq/qscore

Having encode tied to the writer type complicates creating a format func.

- lazy quality encode / decode.

For both speed and format compatibility reasons it would be nice only encode/decode qual scores when they are needed. BioPython takes a huge performance hit parsing fastq. I suspect it won't be as noticeable in Go but at least for most of my use cases I don't need the qual score in anything but a string.

- auto detect quality encoding: would make using this package much easier