import csv


def calculate_number_of_synthetic_data_to_mix(original_data_file,
                                              target_ratio):
  """Calculate the number of negative samples that need to be added to 
    achieve the target ratio of negative samples.
    
    Args:
      original_data_file: path to the original data file
      target_ratio: the target ratio of negative samples
    
    Returns:
      The number of negative samples needed to achieve the target ratio.
    """
  total_number_of_samples = 0
  original_negative_sample_count = 0
  with open(original_data_file) as tsv_file:
    read_tsv = csv.reader(tsv_file, delimiter="\t")
    for line in read_tsv:
      if int(line[-1]) == 0:
        original_negative_sample_count += 1
      total_number_of_samples += 1

  return int(
      (original_negative_sample_count - total_number_of_samples * target_ratio)
      / (target_ratio - 1))