How hekstra-lab/sfcalculator_torch works
Project type and purpose
• This is an open‑source Python library (packaged on PyPI) that provides a PyTorch implementation of crystallographic structure‐factor calculations (SFcalculator).
• Its goal is to read crystallographic data files (CIF, MTZ, PDB), process them (voxelization, masking, symmetry operations, packing score), compute structure factors, and derive Patterson maps—all using PyTorch tensors for GPU acceleration.
File structure
• Top‐level packaging/configuration:
• setup.py, setup.cfg, MANIFEST.in → Python package metadata & installation
• .github/workflows → CI/CD for build, test, and publish
• Source code directory: SFC_Torch/
• io.py → parsers for CIF/MTZ/PDB files and data loaders
• mask.py → mask‐generation routines
• voxel.py → voxelization of electron density
• symmetry.py → symmetry‐operation generators
• packingscore.py → molecular packing‐score computations
• Fmodel.py → computation of structure factors (core SFcalculator logic)
• patterson.py → Patterson‐map calculation
• utils.py → shared utilities (e.g., tensor conversions, constants)
• Test suite in tests/ exercising each module and sample data files
Extract insights from the README
• Confirms PyTorch dependency
• Installation steps: environment → install PyTorch → pip install SFcalculator‑torch
• Citations & badges show active CI, code coverage, and PyPI publication
a. Main components
1. External Inputs (CIF, MTZ, PDB files)
2. io.Parser Module
3. Preprocessing Modules
– mask
– voxel
– symmetry
– utils (shared helpers)
4. Core Computational Modules
– packingscore
– Fmodel (structure‐factor engine)
– patterson (Patterson map engine)
5. Outputs
– Structure‐factor arrays
– Patterson maps
6. Non‑functional/Infrastructure
– Python Environment & Dependencies (PyTorch)
– CI/CD Pipeline (GitHub Actions → test & publish)
– Packaging (setup.py → PyPI)
b. Relationships & data flow
• utils is connected bidirectionally to all modules that need shared code
c. Architectural patterns & principles
• Layered (Input → Preprocessing → Core → Output)
• Modular design (each scientific operation in its own module)
• Pipeline pattern (sequential transformations on tensor data)
• Dependency inversion for utilities
d. Key technologies/frameworks
• Python 3.x
• PyTorch (tensor operations, GPU acceleration)
• pytest (tests)
• GitHub Actions (CI/CD)
• packaging: setuptools (setup.py, setup.cfg)