biocore/bipy — pull request #106 by wasade (2014-02-26 15:49:54+00:00)
Title: Sequence iterators

Initial request for comment. The intent of these objects is to provide standardized generators for whatever type of sequence data you have. The basic fasta/fastq iterators are in place, the paired ones and a general factory object (e.g., just pass files, it sorts out types, iterators, etc) are stubbed out at the moment as I was hoping to get comments on the main iterators before implementing them fully.

As an example:

```python
# for fasta
for item in FastaIterator(seq=[open_fasta_fp1, open_fasta_fp2]):
become_rich(item['Sequence'])

# for fastq
for item in FastqIterator(seq=[open_fastq_fp1, open_fastq_fp2]):
sanity_check_qual(item['Qual'])
become_rich(item['Sequence'])
```

These objects support passing in qual and barcodes as well. The returned item, regardless of the sequence types being iterated over is always a ``dict`` with the exact same keys (``None`` when the value is missing). Qual is always a numpy ``array``.

By default, IDs and lengths are verified for sanity checking between sequence and quality, and sequence and barcode.

In addition, you can perform arbitrary independent manipulations on the data (e.g., reverse complement sequences, trim barcodes, whatever).

Finally, as in the examples above, these objects standardize dealing with N-files.

At the moment, "failed" sequences are currently ignored and I'd be interested in comments on this. Raising automatically, or just incrementing stats on reasons for failure are both very easy to do. These objects also do not currently support mixing and matching file types, as in, you cannot specify sequence in fasta and barcodes in fastq. It would not be prohibitive to allow this, but seemed excessive up front and was not aware of a specific usecase for the added complexity.