Return a new PileupCollection that includes only pileup elements
        satisfying the specified criteria.

        Parameters
        ----------
        drop_duplicates (optional, default False) : boolean
            Remove alignments with the is_duplicate flag.

        drop_improper_mate_pairs (optional, default False) : boolean
            Retain only alignments that have mapped mate pairs, where one
            alignment in the pair is on the forward strand and the other
            is on the reverse.

        min_mapping_quality (optional) : int
            If specified, retain only alignments with mapping quality >= the
            specified threshold.

        min_base_quality (optional) : int
            If specified, retain only pileup elements where the base quality
            for the bases aligning to the pileup's locus are >= the specified
            threshold.

        filters (optional) : list of PileupElement -> bool functions
            User-specified filter functions to apply. This will be called on 
            each PileupElement, and should return True if the element should
            be retained.

        Returns
        ----------
        A new PileupCollection that includes the subset of the pileup elements
        matching all the specified filters.

def filter(self,
            drop_duplicates=False,
            drop_improper_mate_pairs=False,
            min_mapping_quality=None,
            min_base_quality=None,
            filters=None):
        '''
        Return a new PileupCollection that includes only pileup elements
        satisfying the specified criteria.

        Parameters
        ----------
        drop_duplicates (optional, default False) : boolean
            Remove alignments with the is_duplicate flag.

        drop_improper_mate_pairs (optional, default False) : boolean
            Retain only alignments that have mapped mate pairs, where one
            alignment in the pair is on the forward strand and the other
            is on the reverse.

        min_mapping_quality (optional) : int
            If specified, retain only alignments with mapping quality >= the
            specified threshold.

        min_base_quality (optional) : int
            If specified, retain only pileup elements where the base quality
            for the bases aligning to the pileup's locus are >= the specified
            threshold.

        filters (optional) : list of PileupElement -> bool functions
            User-specified filter functions to apply. This will be called on 
            each PileupElement, and should return True if the element should
            be retained.

        Returns
        ----------
        A new PileupCollection that includes the subset of the pileup elements
        matching all the specified filters.
        '''

        if filters is None:
            filters = []
        if drop_duplicates:
            filters.append(lambda e: not e.alignment.is_duplicate)
        if drop_improper_mate_pairs:
            filters.append(lambda e: e.alignment.is_proper_pair)
        if min_mapping_quality is not None:
            filters.append(
                lambda e: e.alignment.mapping_quality >= min_mapping_quality)
        if min_base_quality is not None:
            filters.append(
                lambda e: e.min_base_quality >= min_base_quality)
        pileups = OrderedDict(
            (locus, pileup.filter(filters))
            for (locus, pileup)
            in self.pileups.items())
        return PileupCollection(pileups=pileups, parent=self)