def replace(origbamfile, mutbamfile, outbamfile, excludefile, keepsecondary=False, seed=None):
    origbam = pysam.Samfile(origbamfile, 'rb')
    mutbam  = pysam.Samfile(mutbamfile, 'rb')
    outbam  = pysam.Samfile(outbamfile, 'wb', template=origbam)

    rr.replaceReads(origbam, mutbam, outbam, excludefile=excludefile, allreads=True, keepsecondary=keepsecondary, seed=seed)

    origbam.close()
    mutbam.close()
    outbam.close()
open .bam file and call replacereads
dataset/ETHPy150Open adamewing/bamsurgeon/bin/addsv.py/replace