How gc-os-ai/pyaptamer works
Project type and purpose
• pyaptamer is an open-source Python library for AI-driven aptamer design.
• It provides algorithms, data loaders, feature extractors, and pipelines to build, train, and evaluate aptamer discovery models.
File structure
• Top-level modules under pyaptamer/:
• aptanet — neural-network–based aptamer design (NN models, feature classifiers, end-to-end pipeline).
• aptatrans — transformer-based model layers, model and pipeline.
• datasets — data-loader interfaces for PDB/online sources, sample data.
• experiments — orchestrators for running end-to-end aptamer design experiments.
• mcts — Monte Carlo Tree Search algorithm implementations for sequence search.
• pseaac — feature extraction utilities (physicochemical features).
• utils — low-level helpers (PDB parsing, sequence conversions, shared utilities).
• Tests accompany each module in parallel tests sub-folders.
• Build-and-CI scripts reside under .github, build_tools, and pyproject.toml.
Key insights from the README
• Emphasizes “scikit-learn–like API” and “easily extendable with plugins.”
• Mentions dependencies: Biopython, scikit-learn, minimal other packages.
Main components
a. User Application / API Layer
• Entry point for users: import classes/functions from pyaptamer.
b. Data Ingestion & Loaders (pyaptamer.datasets)
• Loads PDB files or online databank entries into structured objects.
c. Feature Extraction
• pseaac module computes sequence/protein features.
• aptanet utils + pseaac utils.
d. Model Components
• aptanet NN modules (_aptanet_nn.py, _feature_classifier.py).
• aptatrans transformer layers and full model (model.py).
e. Pipelines
• aptanet.pipeline and aptatrans.pipeline orchestrate data → features → model → predictions.
f. Search & Optimization
• MCTS algorithm module (mcts/_algorithm.py) for sequence optimization loops.
• Experiments module orchestrates end-to-end runs combining pipelines and search.
g. Utilities
• Low-level helpers in utils (file I/O, conversion, shared code).
h. External Dependencies
• Biopython, scikit-learn, PyTorch/NumPy, PDB source or web API.
Relationships & data flow
• Experiments module coordinates batches of these loops and records results.
• Utilities support every stage (parsing, conversion).
Architectural patterns & design principles
• Layered design: data layer, feature layer, model layer, orchestration layer.
• Pluggable pipelines: interchangeable pipeline modules for NN vs transformer.
• Test-first structure: each module has its own test suite.
• Minimal external dependencies and standardized API (scikit-learn style).
Diagramming recommendations
• Clear labels for each module/component.
• Data → Loaders → Feature Extractors → Pipelines → Models → Results
• Results → MCTS → Pipelines (optimization loop)
• Blue for data and I/O,
• Green for feature extraction,
• Orange for models,
• Purple for orchestration/search,
• Gray for utilities.
Final advice
• Document external dependencies and configuration entry points (e.g., pyproject.toml, CLI scripts).