#NEWLINE# @ stable ( as_of = '0.4.0' ) #NEWLINE# def iter_contiguous( self , included , min_length = 1 , invert = False ) : #NEWLINE# #INDENT# "Yield contiguous subsequences based on `included`.\n\n        Parameters\n        ----------\n        included : 1D array_like (bool) or iterable (slices or ints)\n            `included` is transformed into a flat boolean vector where each\n            position will either be included or skipped. All contiguous\n            included positions will be yielded as a single region.\n        min_length : int, optional\n            The minimum length of a subsequence for it to be yielded.\n            Default is 1.\n        invert : bool, optional\n            Whether to invert `included` such that it describes what should be\n            skipped instead of included. Default is False.\n\n        Yields\n        ------\n        Sequence\n            Contiguous subsequence as indicated by `included`.\n\n        Notes\n        -----\n        If slices provide adjacent ranges, then they will be considered the\n        same contiguous subsequence.\n\n        Examples\n        --------\n        Here we use `iter_contiguous` to find all of the contiguous ungapped\n        sequences using a boolean vector derived from our DNA sequence.\n\n        >>> from skbio import DNA\n        >>> s = DNA('AAA--TT-CCCC-G-')\n        >>> no_gaps = ~s.gaps()\n        >>> for ungapped_subsequence in s.iter_contiguous(no_gaps,\n        ...                                               min_length=2):\n        ...     print(ungapped_subsequence)\n        AAA\n        TT\n        CCCC\n\n        Note how the last potential subsequence was skipped because it would\n        have been smaller than our `min_length` which was set to 2.\n\n        We can also use `iter_contiguous` on a generator of slices as is\n        produced by `find_motifs` (and `find_with_regex`).\n\n        >>> from skbio import Protein\n        >>> s = Protein('ACDFNASANFTACGNPNRTESL')\n        >>> for subseq in s.iter_contiguous(s.find_motifs('N-glycosylation')):\n        ...     print(subseq)\n        NASANFTA\n        NRTE\n\n        Note how the first subsequence contains two N-glycosylation sites. This\n        happened because they were contiguous.\n\n        " #NEWLINE# idx = self . _munge_to_index_array ( included ) #NEWLINE# if invert : #NEWLINE# #INDENT# idx = np . delete ( np . arange ( len ( idx ) ) , idx ) #NEWLINE# #UNINDENT# for contig in np . split ( idx , ( np . where ( ( np . diff ( idx ) != 1 ) ) [ 0 ] + 1 ) ) : #NEWLINE# #INDENT# r = self [ contig ] #NEWLINE# if ( len ( r ) >= min_length ) : #NEWLINE# #INDENT# ( yield r )