from typing import Collection
from pathlib import Path


def group_profiles(profiles: Collection[str]) -> tuple:
    """Group input query profile HMMs by Pfam, custom or invalid.

    If the profile is found on disk, it will be loaded directly.
    If not found locally, but starts with PF, will try to extract from Pfam.
    Otherwise, marked as invalid.
    """
    local = []
    other = []
    for profile in profiles:
        if Path(profile).exists():
            local.append(profile)
        else:
            other.append(profile)
    return local, other