<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_merged_bioassembly(inpath, outdir, outname, force_rerun=False):
 """Utility to take as input a bioassembly file and merge all its models into multiple chains in a single model. Args: infile (str):
 Path to input PDB file with multiple models that represent an oligomeric form of a structure. outdir (str):
 Path to output directory outname (str):
 New filename of structure file force_rerun (bool):
 If a new PDB should be written if the file exists Returns: str: Path to newly written PDB file. """

    outpath = outfile=op.join(outdir, outname + '.pdb')

    if ssbio.utils.force_rerun(flag=force_rerun, outfile=op.join(outdir, outname + '.pdb')):
        s = StructProp('Model merging', structure_path=inpath, file_type='pdb')
        ss = s.parse_structure()
        merge_all_models_into_first_model(ss.structure)
        outpath = ss.write_pdb(custom_name=outname, out_dir=outdir, force_rerun=force_rerun)
    else:
        return outpath