def filter(self, candidate_sequences_fasta_path, filtered_output_fasta_path):
<EOL>seq_ids_and_bitscores = {}<EOL>logging.debug("<STR_LIT>")<EOL>pd = self._proper_hits_diamond.run(<EOL>candidate_sequences_fasta_path,<EOL>UnpackRawReads.PROTEIN_SEQUENCE_TYPE)<EOL>for res in pd.each([SequenceSearchResult.QUERY_ID_FIELD,<EOL>SequenceSearchResult.ALIGNMENT_BIT_SCORE]):<EOL><INDENT>seq = res[<NUM_LIT:0>]<EOL>score = float(res[<NUM_LIT:1>])<EOL>if seq not in seq_ids_and_bitscores or seq_ids_and_bitscores[seq] < score:<EOL><INDENT>seq_ids_and_bitscores[seq] = score<EOL><DEDENT><DEDENT>num_before_decoy_removal = len(seq_ids_and_bitscores)<EOL>logging.info("<STR_LIT>" %num_before_decoy_removal)<EOL>if self._decoy_diamond is None:<EOL><INDENT>logging.debug("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>logging.debug("<STR_LIT>")<EOL>pd = self._decoy_diamond.run(<EOL>candidate_sequences_fasta_path,<EOL>UnpackRawReads.PROTEIN_SEQUENCE_TYPE)<EOL>for res in pd.each([SequenceSearchResult.QUERY_ID_FIELD,<EOL>SequenceSearchResult.ALIGNMENT_BIT_SCORE]):<EOL><INDENT>seq = res[<NUM_LIT:0>]<EOL>score = float(res[<NUM_LIT:1>])<EOL>if seq in seq_ids_and_bitscores and seq_ids_and_bitscores[seq] < score:<EOL><INDENT>logging.debug("<STR_LIT>" % seq)<EOL>del seq_ids_and_bitscores[seq]<EOL><DEDENT><DEDENT>logging.info("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" %(num_before_decoy_removal-len(seq_ids_and_bitscores)))<EOL>if len(seq_ids_and_bitscores) == <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>logging.debug("<STR_LIT>")<EOL>SequenceExtractor().extract(seq_ids_and_bitscores.keys(),<EOL>candidate_sequences_fasta_path,<EOL>filtered_output_fasta_path)<EOL>return True<EOL>
Filter the fasta file by only keeping sequences that hit a proper sequence
        better than the decoy database.

        Parameters
        ----------
        candidate_sequences_fasta_path: str
            path to candidate sequences fasta file i.e. sequences to be filtered.
        filtered_output_fasta_path: str
            path to file which, after this method is run, will contain only
            those sequences which pass the filter.

        Returns
        -------
        False if no sequences remain after filtering, else True.