code: def read_base_distrib_data(line_iter):
      
      try:
          line = next(line_iter)
          while 'BaseDistributionByCycle' not in line and '## METRICS CLASS' not in line:
              line = next(line_iter)
          line = next(line_iter)
          headers = line.strip().split("\t")
          assert headers == ['READ_END', 'CYCLE', 'PCT_A', 'PCT_C', 'PCT_G', 'PCT_T', 'PCT_N']
  
          # read base distribution by cycle
          data = {}
  
          row = next(line_iter).strip()
          max_cycle_r1 = None
          while row:
              row_data = list(map(float, row.strip().split("\t")))
              read_end, cycle, pct_a, pct_c, pct_g, pct_t, pct_n = row_data
              cycle = int(cycle)
              if read_end == 1.0:
                  if max_cycle_r1 is None or cycle > max_cycle_r1:
                      max_cycle_r1 = cycle
              elif max_cycle_r1 is not None:
                  cycle = cycle - max_cycle_r1
              data_by_cycle = data.setdefault(read_end, dict())
              data_by_cycle[cycle] = (
                  pct_a, pct_c, pct_g, pct_t, pct_n
              )
              row = next(line_iter).strip()
          return data
      except (StopIteration, AssertionError):
          return None
docs: Consumes lines from the provided line_iter and parses those lines
      for base distribution data.  Data should be tab separated and
      immediately preceded by a line of headers:
  
      READ_END  CYCLE  PCT_A  PCT_C  PCT_G  PCT_T  PCT_N
  
      Returns either None or a dict mapping cycles to tuples
        (read_end pct_a pct_c pct_g pct_t pct_n)
      where all values are numbers.
  
      A None indicates that no lines matching the expected format
      were found.