code: def sample_alt_and_depth(rec, sample):
      
      if sample and "AD" in sample:
          all_counts = [int(x) for x in sample["AD"]]
          alt_counts = sum(all_counts[1:])
          depth = sum(all_counts)
      elif sample and "AO" in sample and sample.get("RO") is not None:
          alts = sample["AO"]
          if not isinstance(alts, (list, tuple)):
              alts = [alts]
          alt_counts = sum([int(x) for x in alts])
          depth = alt_counts + int(sample["RO"])
      elif "DP" in rec.info and "AF" in rec.info:
          af = rec.info["AF"][0] if isinstance(rec.info["AF"], (tuple, list)) else rec.info["AF"]
          return None, rec.info["DP"], af
      else:
          alt_counts = None
      if alt_counts is None or depth is None or depth == 0:
          return None, None, None
      else:
          freq = float(alt_counts) / float(depth)
          return alt_counts, depth, freq
docs: Flexibly get ALT allele and depth counts, handling FreeBayes, MuTect and other cases.