# Path: mitty/lib/evcfparse.py
# def parse_line(v):
#   """Given a variant (line) from the VCF categorize it as a TP, FP, FN or GT
# 
#   :param v:
#   :return:   (category,
#               size)
#   """
#   t, q = v.samples['TRUTH'], v.samples['QUERY']
#   cat = cat_dict.get(t['BD'] + q['BD'], None)
#   if cat is not None and cat is not 'skip':
#     alt = alt_dict[cat](t, q)
#     sz = len(alt) - len(v.ref)
#   else:
#     alt, sz = None, None
# 
#   return cat, sz, alt


import time
import numpy as np
import pysam
import logging
from mitty.lib.evcfparse import parse_line
  """
  hdr = vcf_fp.header.copy()
  for k in hdr.info.keys():
    if k != 'Regions':
      hdr.info.remove_header(k)
  for k in hdr.formats.keys():
    if k != 'GT':
      hdr.formats.remove_header(k)

  hdr_lines = str(hdr).splitlines(keepends=True)
  column_line = '\t'.join(hdr_lines[-1].split('\t')[:-2] + partition_list())  # Add the 12 samples

  hdr_lines[-1] = '##INFO=<ID=Vtype,Number=1,Type=String,Description="High-level variant type (SNP|INDEL).">\n'
  hdr_lines += [column_line]

  out_fp.writelines(hdr_lines)


def partition_count_dict():
  return {
    k: {vtype: 0 for vtype in ['SNP', 'INDEL']}
    for k in partition_list()
  }


def variant_hash(v, alt):
  return '{}.{}.{}.{}'.format(v.chrom, v.pos, v.ref, alt)


def process_v(v):

# Path: mitty/lib/evcfparse.py
# def parse_line(v):
#   """Given a variant (line) from the VCF categorize it as a TP, FP, FN or GT
# 
#   :param v:
#   :return:   (category,
#               size)
#   """
#   t, q = v.samples['TRUTH'], v.samples['QUERY']
#   cat = cat_dict.get(t['BD'] + q['BD'], None)
#   if cat is not None and cat is not 'skip':
#     alt = alt_dict[cat](t, q)
#     sz = len(alt) - len(v.ref)
#   else:
#     alt, sz = None, None
# 
#   return cat, sz, alt


# Path: mitty/benchmarking/callfate.py
import time
import numpy as np
import pysam
import logging
from mitty.lib.evcfparse import parse_line

  """
  hdr = vcf_fp.header.copy()
  for k in hdr.info.keys():
    if k != 'Regions':
      hdr.info.remove_header(k)
  for k in hdr.formats.keys():
    if k != 'GT':
      hdr.formats.remove_header(k)

  hdr_lines = str(hdr).splitlines(keepends=True)
  column_line = '\t'.join(hdr_lines[-1].split('\t')[:-2] + partition_list())  # Add the 12 samples

  hdr_lines[-1] = '##INFO=<ID=Vtype,Number=1,Type=String,Description="High-level variant type (SNP|INDEL).">\n'
  hdr_lines += [column_line]

  out_fp.writelines(hdr_lines)


def partition_count_dict():
  return {
    k: {vtype: 0 for vtype in ['SNP', 'INDEL']}
    for k in partition_list()
  }


def variant_hash(v, alt):
  return '{}.{}.{}.{}'.format(v.chrom, v.pos, v.ref, alt)


def process_v(v):

  cat, sz, alt = parse_line(v) if v is not None else (None, None, None)