Create a CSV file of CNV calls with log2 and number of marks.

def _prep_cnv_file(cns_file, svcaller, work_dir, data):
    """Create a CSV file of CNV calls with log2 and number of marks.
    """
    in_file = cns_file
    out_file = os.path.join(work_dir, "%s-%s-prep.csv" % (utils.splitext_plus(os.path.basename(in_file))[0],
                                                          svcaller))
    if not utils.file_uptodate(out_file, in_file):
        with file_transaction(data, out_file) as tx_out_file:
            with open(in_file) as in_handle:
                with open(tx_out_file, "w") as out_handle:
                    reader = csv.reader(in_handle, dialect="excel-tab")
                    writer = csv.writer(out_handle)
                    writer.writerow(["chrom", "start", "end", "num.mark", "seg.mean"])
                    header = next(reader)
                    for line in reader:
                        cur = dict(zip(header, line))
                        if chromhacks.is_autosomal(cur["chromosome"]):
                            writer.writerow([_to_ucsc_style(cur["chromosome"]), cur["start"],
                                             cur["end"], cur["probes"], cur["log2"]])
    return out_file