diff --git a/python-src/fastpdb/__init__.py b/python-src/fastpdb/__init__.py index 68bc1d9..4204f19 100644 --- a/python-src/fastpdb/__init__.py +++ b/python-src/fastpdb/__init__.py @@ -30,7 +30,7 @@ def read(file): else: if not is_text(file): raise TypeError("A file opened in 'text' mode is required") - pdb_file._pdb_file = RustPDBFile(file.read().splitlines()) + pdb_file._pdb_file = RustPDBFile([s.ljust(80) for s in file.read().splitlines()]) # Synchronize with PDB file representation in Rust pdb_file.lines = pdb_file._pdb_file.lines diff --git a/tests/test_fastpdb.py b/tests/test_fastpdb.py index bd709c6..2a94fd1 100644 --- a/tests/test_fastpdb.py +++ b/tests/test_fastpdb.py @@ -194,4 +194,14 @@ def test_inferred_elements(tmp_path): guessed_pdb_file = fastpdb.PDBFile.read(temp) atoms_guessed_elements = guessed_pdb_file.get_structure() - assert atoms_guessed_elements.element.tolist() == atoms.element.tolist() \ No newline at end of file + assert atoms_guessed_elements.element.tolist() == atoms.element.tolist() + + +def test_non_80_char_columns(): + with open(DATA_PATH / "1l2y.pdb") as f: + lines = list(map(lambda s: s.rstrip(), f.readlines())) + + pdb_file = fastpdb.PDBFile.read(StringIO(str.join("\n", lines))) + atoms = pdb_file.get_structure() + + assert atoms is not None