<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _make_ignore_file(work_dir, ref_file, ignore_file, impute_file):
 """Create input files with chromosomes to ignore and gender loci. """

    gl_file = os.path.join(work_dir, "gender_loci.txt")
    chroms = set([])
    with open(impute_file) as in_handle:
        for line in in_handle:
            chrom = line.split()[0]
            chroms.add(chrom)
            if not chrom.startswith("chr"):
                chroms.add("chr%s" % chrom)
    with open(ignore_file, "w") as out_handle:
        for contig in ref.file_contigs(ref_file):
            if contig.name not in chroms:
                out_handle.write("%s\n" % contig.name)
    with open(gl_file, "w") as out_handle:
        for contig in ref.file_contigs(ref_file):
            if contig.name in ["Y", "chrY"]:
                # From https://github.com/cancerit/cgpBattenberg/blob/dev/perl/share/gender/GRCh37d5_Y.loci
                positions = [2934912, 4546684, 4549638, 4550107]
                for pos in positions:
                    out_handle.write("%s\t%s\n" % (contig.name, pos))
    return ignore_file, gl_file