def METHOD_NAME(self, structure, transform=True):
    """Align the input structure onto the reference structure.
    Parameters
    ----------
    transform: bool, optional
        If True (default), apply the rotation/translation that minimizes
        the RMSD between the two structures to the input structure. If
        False, the structure is not modified but the optimal RMSD will
        still be calculated.
    """
    self.rms = None  # clear before aligning
    coord = self.get_guide_coord_from_structure(structure)
    if len(coord) < self.window_size * 2:
        n_atoms = len(coord)
        msg = (
            f"Too few atoms in the mobile structure ({n_atoms}). "
            "Try reducing the window_size parameter."
        )
        raise PDBException(msg)
    # Run CEAlign
    # CEAlign returns the best N paths, where each path is a pair of lists
    # with aligned atom indices. Paths are not guaranteed to be unique.
    paths = run_cealign(self.refcoord, coord, self.window_size, self.max_gap)
    unique_paths = {(tuple(pA), tuple(pB)) for pA, pB in paths}
    # Iterate over unique paths and find the one that gives the lowest
    # corresponding RMSD. Use QCP to align the molecules.
    best_rmsd, best_u = 1e6, None
    for u_path in unique_paths:
        idxA, idxB = u_path
        coordsA = np.array([self.refcoord[i] for i in idxA])
        coordsB = np.array([coord[i] for i in idxB])
        aln = QCPSuperimposer()
        aln.set(coordsA, coordsB)
        aln.run()
        if aln.rms < best_rmsd:
            best_rmsd = aln.rms
            best_u = (aln.rot, aln.tran)
    if best_u is None:
        raise RuntimeError("Failed to find a suitable alignment.")
    if transform:
        # Transform all atoms
        rotmtx, trvec = best_u
        for chain in structure.get_chains():
            for resid in chain.get_unpacked_list():
                for atom in resid.get_unpacked_list():
                    atom.transform(rotmtx, trvec)
    self.rms = best_rmsd