Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions colabfold/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ def get_queries(
logger.warning(f"non-fasta/a3m/pdb/cif file in input directory: {file}")
continue
if file.suffix.lower() in [".pdb", ".cif"]:
from alphafold.common import protein

header = file.stem
if file.suffix.lower() == ".pdb":
pdb_string = pdb_to_string(file.read_text())
Expand All @@ -351,6 +353,7 @@ def get_queries(
continue

queries.append((header, sequences, None, None))
continue
else: # file.suffix.lower() in [".a3m", ".fasta", ".faa"]
(seqs, header) = parse_fasta(file.read_text())
if len(seqs) == 0:
Expand Down
43 changes: 43 additions & 0 deletions tests/test_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import shutil

import pytest

from colabfold.input import get_queries


STRUCTURE_SEQUENCE = (
"CPSGWVGFSDNCYQWNSQKLTWSDAREFCNNHEADLVSIHSDLENNFISYQLSPKKQRFWIGTQRKAT"
"GSTEWLWTDGSSFDYENFCQGKLDNWLGNQDCLDIGYTWGSQCSRDTWDDQPCDHQLPFVCK"
)


@pytest.mark.parametrize("suffix", [".pdb", ".cif", ".PDB", ".CIF"])
def test_get_queries_structure_dir(pytestconfig, tmp_path, suffix):
source = pytestconfig.rootpath.joinpath(
f"test-data/ERR550519_2213899_unrelaxed_model_1{suffix.lower()}"
)
shutil.copyfile(source, tmp_path.joinpath(f"structure{suffix}"))

queries, is_complex = get_queries(tmp_path)

assert queries == [("structure", [STRUCTURE_SEQUENCE], None, None)]
assert is_complex


@pytest.mark.parametrize("suffix", [".pdb", ".cif"])
@pytest.mark.parametrize("fasta_first", [True, False])
def test_get_queries_mixed_structure_dir(pytestconfig, tmp_path, suffix, fasta_first):
source = pytestconfig.rootpath.joinpath(
f"test-data/ERR550519_2213899_unrelaxed_model_1{suffix}"
)
shutil.copyfile(source, tmp_path.joinpath(f"1_structure{suffix}"))
fasta_name = "0_fasta" if fasta_first else "2_fasta"
tmp_path.joinpath(f"{fasta_name}.fasta").write_text(">query\nACDEFG\n")

queries, is_complex = get_queries(tmp_path)

assert queries == [
(fasta_name, "ACDEFG", None, None),
("1_structure", [STRUCTURE_SEQUENCE], None, None),
]
assert is_complex