import gzip filename = "UP000003597.swiss.gz" helix_count = 0 transmem_count = 0 has_helix = False has_transmem = False with gzip.open(filename, "rt") as f: for line in f: if line.startswith("FT HELIX"): has_helix = True if line.startswith("FT TRANSMEM"): has_transmem = True if line.startswith("//"): if has_helix: helix_count += 1 if has_transmem: transmem_count += 1 has_helix = False has_transmem = False print(f"С альфа-спиралями: {helix_count}") print(f"С трансмембранными участками: {transmem_count}")