<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def picard_formatconverter(picard, align_sam):
 """Convert aligned SAM file to BAM format. """

    out_bam = "%s.bam" % os.path.splitext(align_sam)[0]
    if not file_exists(out_bam):
        with tx_tmpdir(picard._config) as tmp_dir:
            with file_transaction(picard._config, out_bam) as tx_out_bam:
                opts = [("INPUT", align_sam),
                        ("OUTPUT", tx_out_bam),
                        ("TMP_DIR", tmp_dir)]
                picard.run("SamFormatConverter", opts)
    return out_bam