<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _prepare_file(fn, out_dir):
 """Cut the beginning of the reads to avoid detection of miRNAs"""

    atropos = _get_atropos()
    cmd = "{atropos} trim --max-reads 500000 -u 22 -se {fn} -o {tx_file}"
    out_file = os.path.join(out_dir, append_stem(os.path.basename(fn), "end"))
    if file_exists(out_file):
        return out_file
    with file_transaction(out_file) as tx_file:
        do.run(cmd.format(**locals()))
    return out_file