docs: def check_trim(self, trimmed_fastq, paired_end, trimmed_fastq_R2=None, fastqc_folder=None):
          """
          Build function to evaluate read trimming, and optionally run fastqc.
  
          This is useful to construct an argument for the 'follow' parameter of
          a PipelineManager's 'run' method.
  
          :param str trimmed_fastq: Path to trimmed reads file.
          :param bool paired_end: Whether the processing is being done with
              paired-end sequencing data.
          :param str trimmed_fastq_R2: Path to read 2 file for the paired-end case.
          :param str fastqc_folder: Path to folder within which to place fastqc
              output files; if unspecified, fastqc will not be run.
          :return callable: Function to evaluate read trimming and possibly run
              fastqc.
          """
  
          def temp_func():
  
              print("Evaluating read trimming")
  
              if paired_end and not trimmed_fastq_R2:
                  print("WARNING: specified paired-end but no R2 file")
  
              n_trim = float(self.count_reads(trimmed_fastq, paired_end))
              self.pm.report_result("Trimmed_reads", int(n_trim))
              try:
                  rr = float(self.pm.get_stat("Raw_reads"))
              except:
                  print("Can't calculate trim loss rate without raw read result.")
              else:
                  self.pm.report_result(
                      "Trim_loss_rate", round((rr - n_trim) * 100 / rr, 2))
  
              # Also run a fastqc (if installed/requested)
              if fastqc_folder:
                  if fastqc_folder and os.path.isabs(fastqc_folder):
                      self.make_sure_path_exists(fastqc_folder)
                  cmd = self.fastqc(trimmed_fastq, fastqc_folder)
                  self.pm.run(cmd, lock_name="trimmed_fastqc", nofail=True)
                  fname, ext = os.path.splitext(os.path.basename(trimmed_fastq))
                  fastqc_html = os.path.join(fastqc_folder, fname + "_fastqc.html")
                  self.pm.report_object("FastQC report r1", fastqc_html)
  
                  if paired_end and trimmed_fastq_R2:
                      cmd = self.fastqc(trimmed_fastq_R2, fastqc_folder)
                      self.pm.run(cmd, lock_name="trimmed_fastqc_R2", nofail=True)
                      fname, ext = os.path.splitext(os.path.basename(trimmed_fastq_R2))
                      fastqc_html = os.path.join(fastqc_folder, fname + "_fastqc.html")
                      self.pm.report_object("FastQC report r2", fastqc_html)
  
          return temp_func