
import os

def check_subfolders():
    # List of file names to check
    file_names = ['alignmentdir.tar.gz', 'blastdir.tar.gz']
    file_extensions = ['.fna.tar.gz', '.gff.tar.gz']

    # Get all subfolders in the current directory
    subfolders = [folder for folder in os.listdir() if os.path.isdir(folder)]

    # Iterate over each subfolder
    for folder in subfolders:
        # Record the files existing in the subfolder
        files_exist = {file_name: False for file_name in file_names + file_extensions}

        # Iterate over the files in the subfolder
        for file_name in os.listdir(folder):
            # Check if the file exists in the list of files to check
            for check_file_name in file_names + file_extensions:
                if file_name.endswith(check_file_name):
                    files_exist[check_file_name] = True

        # Count the total number of files in the subfolder
        num_total_files = len(os.listdir(folder))

        # Check if all files exist and output the result
        all_files_exist = all(files_exist.values())
        if not all_files_exist or num_total_files < 4:
            print(f"The following files do not exist in the subfolder '{folder}':")
            for file_name, exists in files_exist.items():
                if not exists:
                    print(file_name)
            print(f"Total number of files in '{folder}': {num_total_files}")
            print()

# Call the function to check subfolders
check_subfolders()

