<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _filter_vcf(out_file):
 """Fix sample names, FILTER and FORMAT fields. Remove lines with ambiguous reference. """

    in_file = out_file.replace(".vcf", "-ori.vcf")
    FILTER_line = ('##FILTER=<ID=SBIAS,Description="Due to bias">\n'
                   '##FILTER=<ID=5BP,Description="Due to 5BP">\n'
                   '##FILTER=<ID=REJECT,Description="Not somatic due to qSNP filters">\n')
    SOMATIC_line = '##INFO=<ID=SOMATIC,Number=0,Type=Flag,Description="somatic event">\n'
    if not utils.file_exists(in_file):
        shutil.move(out_file, in_file)
    with file_transaction(out_file) as tx_out_file:
        with open(in_file) as in_handle, open(tx_out_file, "w") as out_handle:
            for line in in_handle:
                if line.startswith("##normalSample="):
                    normal_name = line.strip().split("=")[1]
                if line.startswith("##patient_id="):
                    tumor_name = line.strip().split("=")[1]
                if line.startswith("#CHROM"):
                    line = line.replace("Normal", normal_name)
                    line = line.replace("Tumour", tumor_name)
                if line.startswith("##INFO=<ID=FS"):
                    line = line.replace("ID=FS", "ID=RNT")
                if line.find("FS=") > -1:
                    line = line.replace("FS=", "RNT=")
                if "5BP" in line:
                    line = sub("5BP[0-9]+", "5BP", line)
                if line.find("PASS") == -1:
                    line = _set_reject(line)
                if line.find("PASS") > - 1 and line.find("SOMATIC") == -1:
                    line = _set_reject(line)
                if not _has_ambiguous_ref_allele(line):
                    out_handle.write(line)
                if line.startswith("##FILTER") and FILTER_line:
                    out_handle.write("%s" % FILTER_line)
                    FILTER_line = ""
                if line.startswith("##INFO") and SOMATIC_line:
                    out_handle.write("%s" % SOMATIC_line)
                    SOMATIC_line = ""
    return out_file