def prep_ploidy(work_dir, sample, bam_file, cromwell_dir, sv_glob):
    """Create LOHHLA compatible input ploidy file from PureCN output.
    """
    purecn_file = _get_cromwell_file(cromwell_dir, sv_glob, dict(sample=sample, method="purecn", ext="purecn.csv"))
    work_dir = utils.safe_makedir(os.path.join(work_dir, sample, "inputs"))
    out_file = os.path.join(work_dir, "%s-solutions.txt" % sample)
    with open(purecn_file) as in_handle:
        reader = csv.reader(in_handle)
        purecn_stats = dict(zip(next(reader), next(reader)))
    with open(out_file, "w") as out_handle:
        out_handle.write("Ploidy\ttumorPurity\ttumorPloidy\n")
        lohhla_name = utils.splitext_plus(os.path.basename(bam_file))[0]
        out_handle.write("%s\t%s\t%s\t%s\n" % (lohhla_name, purecn_stats["Ploidy"],
                                               purecn_stats["Purity"], purecn_stats["Ploidy"]))
    return out_file
Create LOHHLA compatible input ploidy file from PureCN output.