Skip to content

Improve testability of pdb_deposition.py - #84

Merged
tdudgeon merged 1 commit into
masterfrom
feature/improve-pdb-deposition-testability
Jun 10, 2026
Merged

Improve testability of pdb_deposition.py#84
tdudgeon merged 1 commit into
masterfrom
feature/improve-pdb-deposition-testability

Conversation

@tdudgeon

Copy link
Copy Markdown
Collaborator

Summary

  • Extracts substitute_tokens() — a pure function handling all $CompoundCode, $CrystalName, $PoseID, and $ExternalCodeN replacement, replacing the inline block previously buried inside process_input()
  • Extracts merge_mmcifgen_into_structure() — pulls the loop that applied the mmcif-gen template block onto a per-crystal CIF block into its own testable function
  • Adds mmcifgen_runner=run_mmcifgen parameter to run() so tests can inject a stub without invoking the real external tool
  • Adds 31 new tests covering token substitution, CSV readers, CIF-level merging, and validation edge cases

Closes #83

Test plan

  • pytest tests/test_pdb_deposition.py -v — 20 new tests (unit + CIF-level)
  • pytest tests/test_validate_structure_cif_doc.py -v — 11 tests (3 existing + 8 new)
  • pytest — full suite stays green

🤖 Generated with Claude Code

Refactoring:
- substitute_tokens(): pure function for all $Token replacement, pulled out
  of the inline block in process_input()
- merge_mmcifgen_into_structure(): extracts the for-item loop that applied
  the mmcif-gen template block onto a per-crystal CIF block
- run() gains mmcifgen_runner= parameter (default run_mmcifgen) so tests
  can substitute a stub without running the full external tool

Tests (31 total, all passing):
- tests/test_pdb_deposition.py: unit tests for substitute_tokens,
  read_fragalysis_csv, read_cmpd_codes; CIF-level tests for
  merge_mmcifgen_into_structure using in-memory gemmi objects
- tests/test_validate_structure_cif_doc.py: extended with in-memory CIF
  fixtures covering missing categories, R-factor range checks, unsubstituted
  placeholders, and software ordinal validation

Closes #83

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tdudgeon
tdudgeon merged commit 6c4bba6 into master Jun 10, 2026
6 checks passed
@tdudgeon
tdudgeon deleted the feature/improve-pdb-deposition-testability branch June 10, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve testability of pdb_deposition.py

1 participant