code: def _merge_theta_calls(bounds_file, result_file, cnv_file, data):
      
      out_file = "%s-merged.txt" % (result_file.replace(".BEST.results", ""))
      if not utils.file_uptodate(out_file, result_file):
          with file_transaction(data, out_file) as tx_out_file:
              updater = _update_with_calls(result_file, cnv_file)
              with open(bounds_file) as in_handle:
                  with open(tx_out_file, "w") as out_handle:
                      i = 0
                      for line in in_handle:
                          if line.startswith("#"):
                              parts = line.rstrip().split("\t")
                              parts += ["cnv", "pop_cnvs", "pop_pvals"]
                              out_handle.write("\t".join(parts) + "\n")
                          else:
                              out_handle.write(updater(i, line))
                              i += 1
      return out_file
docs: Create a final output file with merged CNVkit and THetA copy and population estimates.