diff --git a/colabfold/input.py b/colabfold/input.py index 387f2f99..bd16ad36 100644 --- a/colabfold/input.py +++ b/colabfold/input.py @@ -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()) @@ -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: diff --git a/tests/test_input.py b/tests/test_input.py new file mode 100644 index 00000000..48497d87 --- /dev/null +++ b/tests/test_input.py @@ -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