技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
core-api-data【数据与研究】Use core PaddleHelix pahelix APIs for datasets, NPZ caches, splitters, protein tokenization, compound feature utilities, featurizer/model-zoo orientation, and import diagnostics.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when a task asks how to use the reusable pahelix package layer rather than a full application workflow. It covers small in-memory data objects, NPZ caches, splitters, protein token IDs, compound feature utility orientation, featurizer/model-zoo routing, and dependency diagnostics.
InMemoryDataset, slice a pahelix dataset, or cache/reload a data_list as .npz files.CompoundKit, Compound3DKit, mol_to_graph_data, or GEM featurizers expect and return.pahelix imports fail, especially around optional pgl, paddle, rdkit, or deprecated sklearn packaging.../compound-drug-discovery/SKILL.md.../protein-sequence-function/SKILL.md.../structure-prediction/SKILL.md.../linear-rna/SKILL.md.pahelix.utils.data_utils and pahelix.utils.protein_tools are dependency-light; dataset loaders, splitters, compound tools, featurizers, and model-zoo modules add optional dependencies.save_data_list_to_npz, load_npz_to_data_list, or InMemoryDataset.save_data rather than app-specific preprocessing.1.0; scaffold splitters also require rdkit and every record must contain a valid smiles string.Mol objects with mol_to_graph_data or mol_to_geognn_graph_data*; do not pass raw SMILES directly except to featurizer transform functions that explicitly accept raw SMILES/records.InMemoryDataset(data_list=records) stores a list-like data_list; dataset[i], dataset[start:stop], and dataset[[i, j]] return records or new datasets. It accepts Python int/np.int32/np.int64, slice, or list keys, not arbitrary NumPy index arrays.InMemoryDataset(npz_data_path=cache_dir) loads all sorted *.npz files from a directory; InMemoryDataset(npz_data_files=[...]) loads explicit part files.dataset.save_data(cache_dir) writes part-000000.npz, part-000001.npz, and so on, with up to 10,000 records per part.get_data_loader(...) depends on pgl.utils.data.Dataloader; if pgl is missing, use the lower-level NPZ utilities or install pgl before importing pahelix.datasets.inmemory_dataset.See references/data-formats.md for record and cache contracts.
RandomSplitter().split(dataset, frac_train, frac_valid, frac_test, seed=None) shuffles indices with NumPy and preserves total length.IndexSplitter().split(dataset, frac_train, frac_valid, frac_test) takes contiguous index ranges without shuffling.ScaffoldSplitter().split(dataset, frac_train, frac_valid, frac_test) groups records by Bemis-Murcko scaffold from record['smiles'] and assigns large scaffold groups first.RandomScaffoldSplitter().split(dataset, frac_train, frac_valid, frac_test, seed=None) randomizes scaffold groups before assigning valid/test/train groups.1.0; explain assertion errors as split-configuration problems, not model failures.ProteinTokenizer().tokenize(sequence) for character tokens.ProteinTokenizer().convert_tokens_to_ids(tokens) for explicit tokens.ProteinTokenizer().gen_token_ids(sequence) for <cls> + residues + <sep> IDs.<pad>=0, <mask>=1, <cls>=2, <sep>=3, <unk>=4; unknown residue characters map to <unk>.CompoundKit owns atom/bond vocabularies, fingerprint helpers, daylight functional group counts, and atom/bond feature ID helpers.Compound3DKit owns atom positions, MMFF/2D pose helpers, bond lengths, and superedge angle helpers.mol_to_graph_data(mol) returns a molecular graph dictionary with atom features, directed edges plus self-loops, bond features, fingerprints, and functional group counts.mol_to_geognn_graph_data(mol, atom_poses, dir_type), mol_to_geognn_graph_data_MMFF3d(mol), and mol_to_geognn_graph_data_raw3d(mol) add atom_pos, bond_length, and BondAngleGraph_* fields for GEM-style geometry.rdkit; collate/model code usually also requires pgl and paddle.AttrmaskTransformFn, AttrmaskCollateFn, SupervisedTransformFn, SupervisedCollateFn; route full compound training to ../compound-drug-discovery/SKILL.md.GeoPredTransformFn(pretrain_tasks, mask_ratio) and GeoPredCollateFn(...) build atom-bond and bond-angle graph feeds for GEM pretraining.LiteGEMTransformFn(config) and LiteGEMCollateFn() orient lightweight GEM graph batching.PretrainGNNModel, AttrmaskModel, SupervisedModel, GeoGNNModel, GeoPredModel, and LiteGEM are Paddle/PGL-backed classes.ProteinEncoderModel, ProteinModel, ProteinCriterion, and encoder/task classes depend on Paddle; route training or prediction to ../protein-sequence-function/SKILL.md.seq_vae_model.VAE and sd_vae_model.MolVAE are model classes; route molecular generation workflows to ../compound-drug-discovery/SKILL.md.Run the bundled checker from this sub-skill directory:
python scripts/check_core_api.py --help
python scripts/check_core_api.py --repo-root <PaddleHelix checkout> --check imports --check protein-tokenizer
python scripts/check_core_api.py --repo-root <PaddleHelix checkout> --check dataset
python scripts/check_core_api.py --repo-root <PaddleHelix checkout> --check splitters
The script never downloads data or starts training. Use --repo-root when pahelix is not already installed or importable; the script adds that source tree to sys.path only for the selected check and reports optional dependency failures as actionable diagnostics.
ModuleNotFoundError: pgl: expected when importing InMemoryDataset, splitters via dataset tests, featurizers, or many model-zoo paths without PGL; install compatible PGL or use dependency-light utilities.ModuleNotFoundError: rdkit: expected for scaffold splitters and compound graph utilities; install RDKit or avoid scaffold/compound feature checks.ModuleNotFoundError: paddle: expected for model-zoo execution; install a compatible PaddlePaddle backend before model construction/training.sklearn package installation failure: install scikit-learn directly, or use the documented compatibility environment variable only for legacy install workflows.smiles during scaffold split: add a string smiles key to every record or use RandomSplitter/IndexSplitter..seq_len and .singular metadata and confirm every record has the same keys.See references/troubleshooting.md for detailed diagnosis.
This sub-skill is distilled from pahelix/datasets/inmemory_dataset.py, pahelix/utils/data_utils.py, pahelix/utils/protein_tools.py, pahelix/utils/splitters.py, pahelix/utils/compound_tools.py, pahelix/featurizers/*.py, pahelix/model_zoo/*.py, docs/api_doc/*.rst, pahelix/tests/import_test.py, and pahelix/utils/tests/*.py.