from pathlib import Path


def replace_extension(infile):
    """Replace extensions of file."""
    extensions = "".join(Path(str(infile)).suffixes[-2:])
    new_ext = ".fastq.gz"
    outfile = str(infile).replace(extensions, new_ext)
    return outfile