def filter(self, minMatchingReads=None, minMedianScore=None,
               withScoreBetterThan=None, minNewReads=None, minCoverage=None,
               maxTitles=None, sortOn='maxScore'):
        if minNewReads is None:
            readSetFilter = None
        else:
            if self.readSetFilter is None:
                self.readSetFilter = ReadSetFilter(minNewReads)
            readSetFilter = self.readSetFilter
        result = TitlesAlignments(
            self.readsAlignments, self.scoreClass, self.readSetFilter,
            importReadsAlignmentsTitles=False)
        if maxTitles is not None and len(self) > maxTitles:
            if maxTitles < 0:
                raise ValueError('maxTitles (%r) cannot be negative.' %
                                 maxTitles)
            else:
                titles = self.sortTitles(sortOn)
        else:
            titles = self.keys()
        for title in titles:
            if maxTitles is not None and len(result) == maxTitles:
                break
            titleAlignments = self[title]
            if (minMatchingReads is not None and
                    titleAlignments.readCount() < minMatchingReads):
                continue
            if (minMedianScore is not None and
                    self.scoreClass(titleAlignments.medianScore()) <
                    self.scoreClass(minMedianScore)):
                continue
            if (withScoreBetterThan is not None and not
                    titleAlignments.hasScoreBetterThan(withScoreBetterThan)):
                continue
            if (minCoverage is not None and
                    titleAlignments.coverage() < minCoverage):
                continue
            if (readSetFilter and not
                    readSetFilter.accept(title, titleAlignments)):
                continue
            result.addTitle(title, titleAlignments)
        return result