<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_input_files(prefix, the_type, required_type):
 """Check that the file is of a certain file type. :param prefix: the prefix of the input files. :param the_type: the type of the input files (bfile, tfile or file). :param required_type: the required type of the input files (bfile, tfile or file). :type prefix: str :type the_type: str :type required_type: str :returns: ``True`` if everything is OK. Checks if the files are of the required type, according to their current type. The available types are ``bfile`` (binary), ``tfile`` (transposed) and ``file`` (normal). """

    # The files required for each type
    bfile_type = {".bed", ".bim", ".fam"}
    tfile_type = {".tped", ".tfam"}
    file_type = {".ped", ".map"}

    # Check if of bfile, tfile and file
    plink_command = ["plink", "--noweb", "--out", prefix]
    if required_type == "bfile":
        # We need bfile
        plink_command += ["--make-bed"]
        if the_type == "bfile":
            return True
        elif the_type == "tfile":
            # We have tfile, we need to create bfile from tfile
            plink_command += ["--tfile", prefix]
        elif the_type == "file":
            # We have file, we need to create bfile from file
            plink_command += ["--file", prefix]
        else:
            msg = "{}: no suitable input format...".format(prefix)
            raise ProgramError(msg)

        # We create the required files
        if os.path.isfile(prefix + ".log"):
            # There is a log file... we need to copy it
            shutil.copyfile(prefix + ".log", prefix + ".olog")
        logger.info("Converting {} from {} to {}".format(
            prefix,
            the_type,
            required_type,
        ))
        run_command(plink_command)

        # Everything is now fine
        return True

    elif required_type == "tfile":
        # We need a tfile
        plink_command += ["--recode", "--transpose", "--tab"]
        if the_type == "tfile":
            return True
        elif the_type == "bfile":
            # We have bfile, we need to create tfile from bfile
            plink_command += ["--bfile", prefix]
        elif the_type == "file":
            # We have file, we need to create tfile from file
            plink_command += ["--file", prefix]
        else:
            msg = "{}: no suitable input format...".format(prefix)
            raise ProgramError(msg)

        # We create the required files
        if os.path.isfile(prefix + ".log"):
            # There is a log file... we need to copy it
            shutil.copyfile(prefix + ".log", prefix + ".olog")
        logger.info("Converting {} from {} to {}".format(
            prefix,
            the_type,
            required_type,
        ))
        run_command(plink_command)

        # Everything is now fine
        return True

    elif required_type == "file":
        # We need a file
        plink_command += ["--recode", "--tab"]
        if the_type == "file":
            return True
        elif the_type == "bfile":
            # We have bfile, we need to create file from bfile
            plink_command += ["--bfile", prefix]
        elif the_type == "tfile":
            # We have tfile, we need to create file from tfile
            plink_command += ["--tfile", prefix]
        else:
            msg = "{}: no suitable input format...".format(prefix)
            raise ProgramError(msg)

        # We create the required files
        if os.path.isfile(prefix + ".log"):
            # There is a log file... we need to copy it
            shutil.copyfile(prefix + ".log", prefix + ".olog")
        logger.info("Converting {} from {} to {}".format(
            prefix,
            the_type,
            required_type,
        ))
        run_command(plink_command)

        # Everything is now fine
        return True

    else:
        msg = "{}: unknown file format".format(required_type)
        raise ProgramError(msg)