code: def parse_star_genecount_report(self, f):
          
          # Three numeric columns: unstranded, stranded/first-strand, stranded/second-strand
          keys = [ 'N_unmapped', 'N_multimapping', 'N_noFeature', 'N_ambiguous' ]
          unstranded = { 'N_genes': 0 }
          first_strand = { 'N_genes': 0 }
          second_strand = { 'N_genes': 0 }
          num_errors = 0
          num_genes = 0
          for l in f['f']:
              s = l.split("\t")
              try:
                  for i in [1,2,3]:
                      s[i] = float(s[i])
                  if s[0] in keys:
                      unstranded[s[0]] = s[1]
                      first_strand[s[0]] = s[2]
                      second_strand[s[0]] = s[3]
                  else:
                      unstranded['N_genes'] += s[1]
                      first_strand['N_genes'] += s[2]
                      second_strand['N_genes'] += s[3]
                      num_genes += 1
              except IndexError:
                  # Tolerate a few errors in case there is something random added at the top of the file
                  num_errors += 1
                  if num_errors > 10 and num_genes == 0:
                      log.warning("Error parsing {}".format(f['fn']))
                      return None
          if num_genes > 0:
              return { 'unstranded': unstranded, 'first_strand': first_strand, 'second_strand': second_strand }
          else:
              return None
docs: Parse a STAR gene counts output file