ENH: Add iter_regex and find_features

Fixes #612. Adds iter_regex to skbio._sequence.BiologicalSequence and
find_features to skbio._sequence.NucleotideSequence. Supported features are
currently purine_run and pyrimidine run, but more can be added by specifying
additional regular expressions.
I don't disagree with the intended use, I just don't understand the motive
for having this in the subclass vs. baseclass.

I'll be issuing a PR against QIIME for something unrelated in the next day
or so that includes a take on the numpy version of
http://stackoverflow.com/questions/1066758/find-length-of-sequences-of-identical-values-in-a-numpy-array
that provides start/stop/run length. The logic for the modified runs code
has substantial overlap with finding features (and I believe @gregcaporaso
used something similar in his cookbook example) as long as the feature can
be described to map to True/False, which I believe works for
purine/pyrimidine, aromatic AAs, introns/exons, gene copies, etc. I'm
pretty sure it should be possible to define a find_features method in the
BiologicalSequence baseclass using the idea of runs in a boolean vector
that accepts an arbitrary function to define the runs. The function would
only need to take a vector of char and returns a vector of bool. AFAIK,
common functions could also be definable as ufuncs for uber speed

@adamrp, you're much more familiar with regex than I am so I apologize if
I'm looking at incorrectly. Do you know if there particular benefits to
regex in this context over runs in a boolean vector?




On Tue, Aug 12, 2014 at 6:04 PM, adamrp <notifications@github.com> wrote:

> In skbio/sequence/_sequence.py:
>
> > @@ -1324,6 +1350,34 @@ def reverse_complement(self):
> >          return self._complement(reversed(self))
> >      rc = reverse_complement
> >
> > +    def find_features(self, feature_type, min_length=1):
> > +        """Search the sequence for features
> > +
> > +        Parameters
> > +        ----------
> > +        feature_type : {'purine_run', 'pyrimidine_run'}
>
> Thanks! I missed that one. Just the same though, the possible introduction
> of the PurinePyrimidineSequence subclass notwithstanding, I think there
> is still a use case for interrogating a NucleotideSequence with something
> like the find_features method posed here (e.g., if you wanted to find the
> purine/pyrimidine runs but wanted not only the length of the run, but also
> the start/stop positions of the run and the actual nucleotides -- in the
> original alphabet -- that compose the run).
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/biocore/scikit-bio/pull/613/files#r16151197>.
>