code: def parse_insert_size(self, f):
      
      # Get the sample name from the parent parent directory
      # Typical path: <sample name>/raw_data_qualimapReport/insert_size_histogram.txt
      s_name = self.get_s_name(f)
  
      d = dict()
      zero_insertsize = 0
      for l in f['f']:
          if l.startswith('#'):
              continue
          insertsize, count = l.split(None, 1)
          insertsize = int(round(float(insertsize)))
          count = float(count) / 1000000
          if(insertsize == 0):
              zero_insertsize = count
          else:
              d[insertsize] = count
  
      # Find median without importing anything to do it for us
      num_counts = sum(d.values())
      cum_counts = 0
      median_insert_size = None
      for thisins, thiscount in d.items():
          cum_counts += thiscount
          if cum_counts >= num_counts/2:
              median_insert_size = thisins
              break
      # Add the median insert size to the general stats table
      self.general_stats_data[s_name]['median_insert_size'] = median_insert_size
  
      # Save results
      if s_name in self.qualimap_bamqc_insert_size_hist:
          log.debug("Duplicate insert size histogram sample name found! Overwriting: {}".format(s_name))
      self.qualimap_bamqc_insert_size_hist[s_name] = d
      self.add_data_source(f, s_name=s_name, section='insert_size_histogram')
docs: Parse the contents of the Qualimap BamQC Insert Size Histogram file