code: def filter_record(self, record):
          
          quality_scores = record.letter_annotations['phred_quality']
  
          # Simple case - window covers whole sequence
          if len(record) <= self.window_size:
              mean_score = mean(quality_scores)
              if mean_score >= self.min_mean_score:
                  return record
              else:
                  raise FailedFilter(mean_score)
  
          # Find the right clipping point. Start clipping at the beginning of the
          # sequence, then extend the window to include regions with acceptable
          # mean quality scores.
          clip_right = 0
          for i, a in enumerate(
                  moving_average(quality_scores, self.window_size)):
  
              if a >= self.min_mean_score:
                  clip_right = i + self.window_size
              else:
                  break
  
          if clip_right:
              return record[:clip_right]
          else:
              # First window failed - record fails
              raise FailedFilter()
docs: Filter a single record