Add normalized Parquet train/test CycPepMPDB table
Browse files- README.md +72 -113
- data/test-00000-of-00001.parquet +3 -0
- data/train-00000-of-00001.parquet +3 -0
- dataset_summary.json +303 -0
- metadata/column_mapping.parquet +3 -0
- metadata/source_tables.parquet +3 -0
- scripts/prepare_wrapped_jsonl_dataset.py +416 -0
README.md
CHANGED
|
@@ -1,133 +1,92 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
license: other
|
| 3 |
-
pretty_name: CycPepMPDB
|
| 4 |
-
size_categories:
|
| 5 |
-
- 10K<n<100K
|
| 6 |
-
task_categories:
|
| 7 |
-
- other
|
| 8 |
-
language:
|
| 9 |
-
- en
|
| 10 |
tags:
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
---
|
| 17 |
|
| 18 |
-
# CycPepMPDB
|
| 19 |
-
|
| 20 |
-
CycPepMPDB cyclic peptide membrane-permeability dataset (monomers and analogs), normalized to newline-delimited JSON with row-level provenance.
|
| 21 |
-
|
| 22 |
-
Processed and uploaded by the [MegaData](https://github.com/) post-download pipeline
|
| 23 |
-
(internal repo). Original source: <http://cycpeptmpdb.com/>.
|
| 24 |
-
|
| 25 |
-
## Statistics
|
| 26 |
-
|
| 27 |
-
| | |
|
| 28 |
-
|---|---|
|
| 29 |
-
| Table files | 99 |
|
| 30 |
-
| Total rows | 43,514 |
|
| 31 |
-
| Total bytes | 259.87 MiB (272,498,665) |
|
| 32 |
-
|
| 33 |
-
## Tables
|
| 34 |
-
|
| 35 |
-
| Table | Rows | Bytes |
|
| 36 |
-
|---|---:|---:|
|
| 37 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_All.csv.jsonl` | 385 | 2.23 MiB |
|
| 38 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_A.csv.jsonl` | 34 | 216.30 KiB |
|
| 39 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_C.csv.jsonl` | 4 | 22.01 KiB |
|
| 40 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_D.csv.jsonl` | 6 | 39.63 KiB |
|
| 41 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_E.csv.jsonl` | 5 | 25.48 KiB |
|
| 42 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_F.csv.jsonl` | 63 | 364.35 KiB |
|
| 43 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_G.csv.jsonl` | 47 | 265.58 KiB |
|
| 44 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_H.csv.jsonl` | 3 | 15.38 KiB |
|
| 45 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_I.csv.jsonl` | 8 | 46.23 KiB |
|
| 46 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_K.csv.jsonl` | 13 | 66.15 KiB |
|
| 47 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_L.csv.jsonl` | 19 | 191.37 KiB |
|
| 48 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_M.csv.jsonl` | 3 | 15.24 KiB |
|
| 49 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_N.csv.jsonl` | 7 | 35.72 KiB |
|
| 50 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_P.csv.jsonl` | 12 | 110.07 KiB |
|
| 51 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_Q.csv.jsonl` | 10 | 51.57 KiB |
|
| 52 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_R.csv.jsonl` | 4 | 20.67 KiB |
|
| 53 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_S.csv.jsonl` | 29 | 151.32 KiB |
|
| 54 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_T.csv.jsonl` | 6 | 48.74 KiB |
|
| 55 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_V.csv.jsonl` | 15 | 84.60 KiB |
|
| 56 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_W.csv.jsonl` | 8 | 41.30 KiB |
|
| 57 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_X.csv.jsonl` | 78 | 417.57 KiB |
|
| 58 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Monomer_Analog_Y.csv.jsonl` | 11 | 58.28 KiB |
|
| 59 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_All.csv.jsonl` | 8,466 | 50.54 MiB |
|
| 60 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Assay_Caco2.csv.jsonl` | 1,332 | 8.23 MiB |
|
| 61 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Assay_MDCK.csv.jsonl` | 64 | 396.71 KiB |
|
| 62 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Assay_PAMPA.csv.jsonl` | 7,298 | 43.31 MiB |
|
| 63 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Assay_RRCK.csv.jsonl` | 186 | 1.09 MiB |
|
| 64 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_10.csv.jsonl` | 1,777 | 10.82 MiB |
|
| 65 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_11.csv.jsonl` | 675 | 4.23 MiB |
|
| 66 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_12.csv.jsonl` | 632 | 3.98 MiB |
|
| 67 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_13.csv.jsonl` | 234 | 1.49 MiB |
|
| 68 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_14.csv.jsonl` | 125 | 825.96 KiB |
|
| 69 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_15.csv.jsonl` | 26 | 174.11 KiB |
|
| 70 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_2.csv.jsonl` | 4 | 22.71 KiB |
|
| 71 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_3.csv.jsonl` | 69 | 387.80 KiB |
|
| 72 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_4.csv.jsonl` | 55 | 313.75 KiB |
|
| 73 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_5.csv.jsonl` | 88 | 512.88 KiB |
|
| 74 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_6.csv.jsonl` | 2,167 | 12.50 MiB |
|
| 75 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_7.csv.jsonl` | 2,071 | 12.09 MiB |
|
| 76 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_8.csv.jsonl` | 120 | 730.00 KiB |
|
| 77 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Length_9.csv.jsonl` | 423 | 2.57 MiB |
|
| 78 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Shape_Circle.csv.jsonl` | 5,530 | 32.46 MiB |
|
| 79 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Shape_Lariat.csv.jsonl` | 2,936 | 18.15 MiB |
|
| 80 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Source_2006_Rezai_1.csv.jsonl` | 10 | 60.53 KiB |
|
| 81 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Source_2006_Rezai_2.csv.jsonl` | 11 | 65.58 KiB |
|
| 82 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Source_2011_White.csv.jsonl` | 10 | 60.81 KiB |
|
| 83 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Source_2012_Rand.csv.jsonl` | 16 | 95.80 KiB |
|
| 84 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Source_2013_CHUGAI.csv.jsonl` | 878 | 5.51 MiB |
|
| 85 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Source_2013_Zaretsky.csv.jsonl` | 2 | 11.60 KiB |
|
| 86 |
-
| `peptide_cycpeptmpdb_CycPeptMPDB_Peptide_Source_2014_Nielsen.csv.jsonl` | 4 | 23.96 KiB |
|
| 87 |
-
| _… 49 more table file(s) …_ | | |
|
| 88 |
-
|
| 89 |
-
## Layout
|
| 90 |
|
| 91 |
-
```
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
-
|
| 98 |
-
`dataset_id`, `row` (the raw upstream row), `row_index`, and `source_file`
|
| 99 |
-
fields, so every row carries its upstream provenance.
|
| 100 |
|
| 101 |
-
##
|
| 102 |
|
| 103 |
-
```
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
```
|
| 106 |
|
| 107 |
-
|
| 108 |
|
| 109 |
```python
|
| 110 |
-
import
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
local = snapshot_download(repo_id="LiteFold/CycPepMPDB", repo_type="dataset")
|
| 115 |
-
for jsonl in sorted(Path(local, "tables").glob("*.jsonl")):
|
| 116 |
-
with jsonl.open() as f:
|
| 117 |
-
for line in f:
|
| 118 |
-
row = json.loads(line)
|
| 119 |
-
... # row["row"] is the upstream record
|
| 120 |
```
|
| 121 |
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
-
|
|
|
|
|
|
|
| 125 |
|
| 126 |
-
|
| 127 |
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
-
##
|
| 131 |
|
| 132 |
-
|
| 133 |
-
Pipeline source: `megadata-post normalize --dataset cycpeptmpdb --tables-only`.
|
|
|
|
| 1 |
---
|
| 2 |
+
pretty_name: CycPepMPDB Peptides And Monomers
|
| 3 |
license: other
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
+
- chemistry
|
| 6 |
+
- peptide
|
| 7 |
+
- cyclic-peptide
|
| 8 |
+
- permeability
|
| 9 |
+
- cycpeptmpdb
|
| 10 |
+
- parquet
|
| 11 |
+
configs:
|
| 12 |
+
- config_name: default
|
| 13 |
+
data_files:
|
| 14 |
+
- split: train
|
| 15 |
+
path: data/train-*.parquet
|
| 16 |
+
- split: test
|
| 17 |
+
path: data/test-*.parquet
|
| 18 |
---
|
| 19 |
|
| 20 |
+
# LiteFold/CycPepMPDB
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
This repository now includes a Dataset Viewer-friendly Parquet version of the LiteFold CycPepMPDB tables. The default `load_dataset()` configuration reads the normalized Parquet files in `data/`.
|
| 23 |
+
|
| 24 |
+
The normalized default table contains 8,851 rows from the `CycPeptMPDB_Peptide_All.csv` and `CycPeptMPDB_Monomer_All.csv` source tables. These all-record tables are used as the default view to avoid duplicating rows from overlapping subset tables. The original wrapped JSONL source tables remain available in the repository under `tables/`.
|
| 25 |
+
|
| 26 |
+
## Splits
|
| 27 |
+
|
| 28 |
+
- `train`: 7,983 rows
|
| 29 |
+
- `test`: 868 rows
|
| 30 |
+
|
| 31 |
+
Rows are assigned with a deterministic hash split: `sha256(record_id) % 10`, where bucket `0` is test and buckets `1-9` are train.
|
| 32 |
+
|
| 33 |
+
## Columns
|
| 34 |
+
|
| 35 |
+
The table includes common browsing and modeling columns:
|
| 36 |
+
|
| 37 |
+
- `record_id`: stable SHA-256 row identifier
|
| 38 |
+
- `dataset_id`, `source_file`, `source_table`, `source_row_index`: source provenance
|
| 39 |
+
- `entity_type`: `peptide` or `monomer`
|
| 40 |
+
- `assay_name`, `sequence`, `sequence_length`, `target`, `score_value`, `label`: normalized convenience fields when present
|
| 41 |
+
- `split_bucket`: deterministic split bucket
|
| 42 |
|
| 43 |
+
Original descriptor and assay fields are preserved as snake_case string columns, including fields such as `smiles`, `permeability`, `caco2`, `pampa`, `mdck`, `rrck`, and molecular descriptor columns. See `metadata/column_mapping.parquet` for the original field-name mapping and `metadata/source_tables.parquet` for per-table row counts.
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
## Usage
|
| 46 |
|
| 47 |
+
```python
|
| 48 |
+
from datasets import load_dataset
|
| 49 |
+
|
| 50 |
+
ds = load_dataset("LiteFold/CycPepMPDB")
|
| 51 |
+
print(ds)
|
| 52 |
+
print(ds["train"][0])
|
| 53 |
```
|
| 54 |
|
| 55 |
+
Load selected columns:
|
| 56 |
|
| 57 |
```python
|
| 58 |
+
from datasets import load_dataset
|
| 59 |
+
|
| 60 |
+
cols = ["record_id", "entity_type", "sequence", "smiles", "permeability", "score_value"]
|
| 61 |
+
train = load_dataset("LiteFold/CycPepMPDB", split="train", columns=cols)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
```
|
| 63 |
|
| 64 |
+
Filter to peptides:
|
| 65 |
+
|
| 66 |
+
```python
|
| 67 |
+
from datasets import load_dataset
|
| 68 |
|
| 69 |
+
train = load_dataset("LiteFold/CycPepMPDB", split="train")
|
| 70 |
+
peptides = train.filter(lambda row: row["entity_type"] == "peptide")
|
| 71 |
+
```
|
| 72 |
|
| 73 |
+
Metadata tables can be loaded directly:
|
| 74 |
|
| 75 |
+
```python
|
| 76 |
+
from datasets import load_dataset
|
| 77 |
+
|
| 78 |
+
source_tables = load_dataset(
|
| 79 |
+
"parquet",
|
| 80 |
+
data_files="hf://datasets/LiteFold/CycPepMPDB/metadata/source_tables.parquet",
|
| 81 |
+
split="train",
|
| 82 |
+
)
|
| 83 |
+
column_mapping = load_dataset(
|
| 84 |
+
"parquet",
|
| 85 |
+
data_files="hf://datasets/LiteFold/CycPepMPDB/metadata/column_mapping.parquet",
|
| 86 |
+
split="train",
|
| 87 |
+
)
|
| 88 |
+
```
|
| 89 |
|
| 90 |
+
## Rebuild
|
| 91 |
|
| 92 |
+
The normalization script used for this upload is included at `scripts/prepare_wrapped_jsonl_dataset.py`.
|
|
|
data/test-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5fb34b91e32e7a4e094b656ca605c63bf8925e9bb9808c5830d29e543b1e2ae8
|
| 3 |
+
size 481925
|
data/train-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b2b67a97cb745940e640240330aaa9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 8 |
+
"train": 7983,
|
| 9 |
+
"test": 868
|
| 10 |
+
},
|
| 11 |
+
"split_strategy": "deterministic sha256(record_id) % 10; bucket 0 is test, buckets 1-9 are train",
|
| 12 |
+
"table_group_counts": {
|
| 13 |
+
"cycpeptmpdb": 2
|
| 14 |
+
},
|
| 15 |
+
"columns": [
|
| 16 |
+
"record_id",
|
| 17 |
+
"dataset_id",
|
| 18 |
+
"source_file",
|
| 19 |
+
"source_table",
|
| 20 |
+
"source_row_index",
|
| 21 |
+
"table_group",
|
| 22 |
+
"task_name",
|
| 23 |
+
"subtask_name",
|
| 24 |
+
"entity_type",
|
| 25 |
+
"assay_name",
|
| 26 |
+
"sequence",
|
| 27 |
+
"sequence_length",
|
| 28 |
+
"mutation",
|
| 29 |
+
"target",
|
| 30 |
+
"score_value",
|
| 31 |
+
"label",
|
| 32 |
+
"split_bucket",
|
| 33 |
+
"bcut2d_chghi",
|
| 34 |
+
"bcut2d_chglo",
|
| 35 |
+
"bcut2d_logphi",
|
| 36 |
+
"bcut2d_logplow",
|
| 37 |
+
"bcut2d_mrhi",
|
| 38 |
+
"bcut2d_mrlow",
|
| 39 |
+
"bcut2d_mwhi",
|
| 40 |
+
"bcut2d_mwlow",
|
| 41 |
+
"balabanj",
|
| 42 |
+
"bertzct",
|
| 43 |
+
"chcl3_3dpsa",
|
| 44 |
+
"cxsmiles",
|
| 45 |
+
"caco2",
|
| 46 |
+
"chi0",
|
| 47 |
+
"chi0n",
|
| 48 |
+
"chi0v",
|
| 49 |
+
"chi1",
|
| 50 |
+
"chi1n",
|
| 51 |
+
"chi1v",
|
| 52 |
+
"chi2n",
|
| 53 |
+
"chi2v",
|
| 54 |
+
"chi3n",
|
| 55 |
+
"chi3v",
|
| 56 |
+
"chi4n",
|
| 57 |
+
"chi4v",
|
| 58 |
+
"compound_name",
|
| 59 |
+
"detection_limit_1",
|
| 60 |
+
"detection_limit_2",
|
| 61 |
+
"epsa",
|
| 62 |
+
"estate_vsa1",
|
| 63 |
+
"estate_vsa10",
|
| 64 |
+
"estate_vsa11",
|
| 65 |
+
"estate_vsa2",
|
| 66 |
+
"estate_vsa3",
|
| 67 |
+
"estate_vsa4",
|
| 68 |
+
"estate_vsa5",
|
| 69 |
+
"estate_vsa6",
|
| 70 |
+
"estate_vsa7",
|
| 71 |
+
"estate_vsa8",
|
| 72 |
+
"estate_vsa9",
|
| 73 |
+
"exactmolwt",
|
| 74 |
+
"fpdensitymorgan1",
|
| 75 |
+
"fpdensitymorgan2",
|
| 76 |
+
"fpdensitymorgan3",
|
| 77 |
+
"fractioncsp3",
|
| 78 |
+
"h2o_3dpsa",
|
| 79 |
+
"helm",
|
| 80 |
+
"helm_url",
|
| 81 |
+
"hallkieralpha",
|
| 82 |
+
"heavyatomcount",
|
| 83 |
+
"heavyatommolwt",
|
| 84 |
+
"id",
|
| 85 |
+
"iupac_condensed",
|
| 86 |
+
"iupac_name",
|
| 87 |
+
"ipc",
|
| 88 |
+
"kappa1",
|
| 89 |
+
"kappa2",
|
| 90 |
+
"kappa3",
|
| 91 |
+
"labuteasa",
|
| 92 |
+
"mdck",
|
| 93 |
+
"maxabsestateindex",
|
| 94 |
+
"maxabspartialcharge",
|
| 95 |
+
"maxestateindex",
|
| 96 |
+
"maxpartialcharge",
|
| 97 |
+
"minabsestateindex",
|
| 98 |
+
"minabspartialcharge",
|
| 99 |
+
"minestateindex",
|
| 100 |
+
"minpartialcharge",
|
| 101 |
+
"mollogp",
|
| 102 |
+
"molmr",
|
| 103 |
+
"molwt",
|
| 104 |
+
"molecule_shape",
|
| 105 |
+
"monomer_length",
|
| 106 |
+
"monomer_length_in_main_chain",
|
| 107 |
+
"monomer_type",
|
| 108 |
+
"nhohcount",
|
| 109 |
+
"nocount",
|
| 110 |
+
"null",
|
| 111 |
+
"natural_analog",
|
| 112 |
+
"numaliphaticcarbocycles",
|
| 113 |
+
"numaliphaticheterocycles",
|
| 114 |
+
"numaliphaticrings",
|
| 115 |
+
"numaromaticcarbocycles",
|
| 116 |
+
"numaromaticheterocycles",
|
| 117 |
+
"numaromaticrings",
|
| 118 |
+
"numhacceptors",
|
| 119 |
+
"numhdonors",
|
| 120 |
+
"numheteroatoms",
|
| 121 |
+
"numradicalelectrons",
|
| 122 |
+
"numrotatablebonds",
|
| 123 |
+
"numsaturatedcarbocycles",
|
| 124 |
+
"numsaturatedheterocycles",
|
| 125 |
+
"numsaturatedrings",
|
| 126 |
+
"numvalenceelectrons",
|
| 127 |
+
"original_name_in_source_literature",
|
| 128 |
+
"pampa",
|
| 129 |
+
"pc1",
|
| 130 |
+
"pc2",
|
| 131 |
+
"peoe_vsa1",
|
| 132 |
+
"peoe_vsa10",
|
| 133 |
+
"peoe_vsa11",
|
| 134 |
+
"peoe_vsa12",
|
| 135 |
+
"peoe_vsa13",
|
| 136 |
+
"peoe_vsa14",
|
| 137 |
+
"peoe_vsa2",
|
| 138 |
+
"peoe_vsa3",
|
| 139 |
+
"peoe_vsa4",
|
| 140 |
+
"peoe_vsa5",
|
| 141 |
+
"peoe_vsa6",
|
| 142 |
+
"peoe_vsa7",
|
| 143 |
+
"peoe_vsa8",
|
| 144 |
+
"peoe_vsa9",
|
| 145 |
+
"psa",
|
| 146 |
+
"permeability",
|
| 147 |
+
"polymer_type",
|
| 148 |
+
"pubchem_cid",
|
| 149 |
+
"r1",
|
| 150 |
+
"r2",
|
| 151 |
+
"r3",
|
| 152 |
+
"rrck",
|
| 153 |
+
"r_caco2",
|
| 154 |
+
"r_mdck",
|
| 155 |
+
"r_pamap",
|
| 156 |
+
"r_rrck",
|
| 157 |
+
"ringcount",
|
| 158 |
+
"smiles",
|
| 159 |
+
"smr_vsa1",
|
| 160 |
+
"smr_vsa10",
|
| 161 |
+
"smr_vsa2",
|
| 162 |
+
"smr_vsa3",
|
| 163 |
+
"smr_vsa4",
|
| 164 |
+
"smr_vsa5",
|
| 165 |
+
"smr_vsa6",
|
| 166 |
+
"smr_vsa7",
|
| 167 |
+
"smr_vsa8",
|
| 168 |
+
"smr_vsa9",
|
| 169 |
+
"same_peptides_assay",
|
| 170 |
+
"same_peptides_id",
|
| 171 |
+
"same_peptides_permeability",
|
| 172 |
+
"same_peptides_source",
|
| 173 |
+
"raw_sequence",
|
| 174 |
+
"sequence_logp",
|
| 175 |
+
"sequence_tpsa",
|
| 176 |
+
"slogp_vsa1",
|
| 177 |
+
"slogp_vsa10",
|
| 178 |
+
"slogp_vsa11",
|
| 179 |
+
"slogp_vsa12",
|
| 180 |
+
"slogp_vsa2",
|
| 181 |
+
"slogp_vsa3",
|
| 182 |
+
"slogp_vsa4",
|
| 183 |
+
"slogp_vsa5",
|
| 184 |
+
"slogp_vsa6",
|
| 185 |
+
"slogp_vsa7",
|
| 186 |
+
"slogp_vsa8",
|
| 187 |
+
"slogp_vsa9",
|
| 188 |
+
"source",
|
| 189 |
+
"structurally_unique_id",
|
| 190 |
+
"symbol",
|
| 191 |
+
"tpsa",
|
| 192 |
+
"t_pampa",
|
| 193 |
+
"vsa_estate1",
|
| 194 |
+
"vsa_estate10",
|
| 195 |
+
"vsa_estate2",
|
| 196 |
+
"vsa_estate3",
|
| 197 |
+
"vsa_estate4",
|
| 198 |
+
"vsa_estate5",
|
| 199 |
+
"vsa_estate6",
|
| 200 |
+
"vsa_estate7",
|
| 201 |
+
"vsa_estate8",
|
| 202 |
+
"vsa_estate9",
|
| 203 |
+
"version",
|
| 204 |
+
"year",
|
| 205 |
+
"x_3dpsa",
|
| 206 |
+
"capped_smiles",
|
| 207 |
+
"contain_id",
|
| 208 |
+
"contain_count",
|
| 209 |
+
"contain_pepnum",
|
| 210 |
+
"contain_perme",
|
| 211 |
+
"fr_al_coo",
|
| 212 |
+
"fr_al_oh",
|
| 213 |
+
"fr_al_oh_notert",
|
| 214 |
+
"fr_arn",
|
| 215 |
+
"fr_ar_coo",
|
| 216 |
+
"fr_ar_n",
|
| 217 |
+
"fr_ar_nh",
|
| 218 |
+
"fr_ar_oh",
|
| 219 |
+
"fr_coo",
|
| 220 |
+
"fr_coo2",
|
| 221 |
+
"fr_c_o",
|
| 222 |
+
"fr_c_o_nocoo",
|
| 223 |
+
"fr_c_s",
|
| 224 |
+
"fr_hoccn",
|
| 225 |
+
"fr_imine",
|
| 226 |
+
"fr_nh0",
|
| 227 |
+
"fr_nh1",
|
| 228 |
+
"fr_nh2",
|
| 229 |
+
"fr_n_o",
|
| 230 |
+
"fr_ndealkylation1",
|
| 231 |
+
"fr_ndealkylation2",
|
| 232 |
+
"fr_nhpyrrole",
|
| 233 |
+
"fr_sh",
|
| 234 |
+
"fr_aldehyde",
|
| 235 |
+
"fr_alkyl_carbamate",
|
| 236 |
+
"fr_alkyl_halide",
|
| 237 |
+
"fr_allylic_oxid",
|
| 238 |
+
"fr_amide",
|
| 239 |
+
"fr_amidine",
|
| 240 |
+
"fr_aniline",
|
| 241 |
+
"fr_aryl_methyl",
|
| 242 |
+
"fr_azide",
|
| 243 |
+
"fr_azo",
|
| 244 |
+
"fr_barbitur",
|
| 245 |
+
"fr_benzene",
|
| 246 |
+
"fr_benzodiazepine",
|
| 247 |
+
"fr_bicyclic",
|
| 248 |
+
"fr_diazo",
|
| 249 |
+
"fr_dihydropyridine",
|
| 250 |
+
"fr_epoxide",
|
| 251 |
+
"fr_ester",
|
| 252 |
+
"fr_ether",
|
| 253 |
+
"fr_furan",
|
| 254 |
+
"fr_guanido",
|
| 255 |
+
"fr_halogen",
|
| 256 |
+
"fr_hdrzine",
|
| 257 |
+
"fr_hdrzone",
|
| 258 |
+
"fr_imidazole",
|
| 259 |
+
"fr_imide",
|
| 260 |
+
"fr_isocyan",
|
| 261 |
+
"fr_isothiocyan",
|
| 262 |
+
"fr_ketone",
|
| 263 |
+
"fr_ketone_topliss",
|
| 264 |
+
"fr_lactam",
|
| 265 |
+
"fr_lactone",
|
| 266 |
+
"fr_methoxy",
|
| 267 |
+
"fr_morpholine",
|
| 268 |
+
"fr_nitrile",
|
| 269 |
+
"fr_nitro",
|
| 270 |
+
"fr_nitro_arom",
|
| 271 |
+
"fr_nitro_arom_nonortho",
|
| 272 |
+
"fr_nitroso",
|
| 273 |
+
"fr_oxazole",
|
| 274 |
+
"fr_oxime",
|
| 275 |
+
"fr_para_hydroxylation",
|
| 276 |
+
"fr_phenol",
|
| 277 |
+
"fr_phenol_noorthohbond",
|
| 278 |
+
"fr_phos_acid",
|
| 279 |
+
"fr_phos_ester",
|
| 280 |
+
"fr_piperdine",
|
| 281 |
+
"fr_piperzine",
|
| 282 |
+
"fr_priamide",
|
| 283 |
+
"fr_prisulfonamd",
|
| 284 |
+
"fr_pyridine",
|
| 285 |
+
"fr_quatn",
|
| 286 |
+
"fr_sulfide",
|
| 287 |
+
"fr_sulfonamd",
|
| 288 |
+
"fr_sulfone",
|
| 289 |
+
"fr_term_acetylene",
|
| 290 |
+
"fr_tetrazole",
|
| 291 |
+
"fr_thiazole",
|
| 292 |
+
"fr_thiocyan",
|
| 293 |
+
"fr_thiophene",
|
| 294 |
+
"fr_unbrch_alkane",
|
| 295 |
+
"fr_urea",
|
| 296 |
+
"qed",
|
| 297 |
+
"replaced_smiles"
|
| 298 |
+
],
|
| 299 |
+
"metadata_tables": [
|
| 300 |
+
"metadata/source_tables.parquet",
|
| 301 |
+
"metadata/column_mapping.parquet"
|
| 302 |
+
]
|
| 303 |
+
}
|
metadata/column_mapping.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6512818ae9d502dfe05a87bd3f142f05a23c2b66c857312697869e07bc3399c6
|
| 3 |
+
size 5394
|
metadata/source_tables.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:368b28f94700bc178d92aa15b27ee86a1af7b10e1fb91b409b310dfcf13ae5d0
|
| 3 |
+
size 4031
|
scripts/prepare_wrapped_jsonl_dataset.py
ADDED
|
@@ -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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Build viewer-friendly Parquet splits for LiteFold wrapped JSONL table repos."""
|
| 3 |
+
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import argparse
|
| 7 |
+
import hashlib
|
| 8 |
+
import json
|
| 9 |
+
import os
|
| 10 |
+
import re
|
| 11 |
+
import shutil
|
| 12 |
+
from collections import Counter
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
from typing import Any, Iterable
|
| 15 |
+
|
| 16 |
+
import pyarrow as pa
|
| 17 |
+
import pyarrow.parquet as pq
|
| 18 |
+
import pandas as pd
|
| 19 |
+
from huggingface_hub import HfApi, hf_hub_download
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
BASE_COLUMNS = [
|
| 23 |
+
"record_id",
|
| 24 |
+
"dataset_id",
|
| 25 |
+
"source_file",
|
| 26 |
+
"source_table",
|
| 27 |
+
"source_row_index",
|
| 28 |
+
"table_group",
|
| 29 |
+
"task_name",
|
| 30 |
+
"subtask_name",
|
| 31 |
+
"entity_type",
|
| 32 |
+
"assay_name",
|
| 33 |
+
"sequence",
|
| 34 |
+
"sequence_length",
|
| 35 |
+
"mutation",
|
| 36 |
+
"target",
|
| 37 |
+
"score_value",
|
| 38 |
+
"label",
|
| 39 |
+
"split_bucket",
|
| 40 |
+
]
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def load_token() -> str | None:
|
| 44 |
+
for key in ("HF_TOKEN", "HUGGINGFACE_HUB_TOKEN"):
|
| 45 |
+
value = os.environ.get(key)
|
| 46 |
+
if value:
|
| 47 |
+
return value
|
| 48 |
+
env_path = Path(".env")
|
| 49 |
+
if env_path.exists():
|
| 50 |
+
for line in env_path.read_text().splitlines():
|
| 51 |
+
stripped = line.strip()
|
| 52 |
+
if not stripped or stripped.startswith("#") or "=" not in stripped:
|
| 53 |
+
continue
|
| 54 |
+
key, value = stripped.split("=", 1)
|
| 55 |
+
if key.strip() in {"HF_TOKEN", "HUGGINGFACE_HUB_TOKEN"}:
|
| 56 |
+
value = value.strip().strip('"').strip("'")
|
| 57 |
+
if value:
|
| 58 |
+
return value
|
| 59 |
+
return None
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def stable_bucket(value: str, buckets: int = 10) -> int:
|
| 63 |
+
digest = hashlib.sha256(value.encode("utf-8")).hexdigest()[:16]
|
| 64 |
+
return int(digest, 16) % buckets
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def normalize_name(name: str) -> str:
|
| 68 |
+
normalized = re.sub(r"[^0-9A-Za-z]+", "_", name).strip("_").lower()
|
| 69 |
+
if not normalized:
|
| 70 |
+
normalized = "field"
|
| 71 |
+
if normalized[0].isdigit():
|
| 72 |
+
normalized = f"x_{normalized}"
|
| 73 |
+
return normalized
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def unique_names(keys: Iterable[str]) -> dict[str, str]:
|
| 77 |
+
mapping: dict[str, str] = {}
|
| 78 |
+
used: Counter[str] = Counter()
|
| 79 |
+
for key in sorted(keys):
|
| 80 |
+
base = normalize_name(key)
|
| 81 |
+
candidate = base
|
| 82 |
+
if candidate in BASE_COLUMNS:
|
| 83 |
+
candidate = f"raw_{candidate}"
|
| 84 |
+
used[candidate] += 1
|
| 85 |
+
if used[candidate] > 1:
|
| 86 |
+
candidate = f"{candidate}_{used[candidate]}"
|
| 87 |
+
mapping[key] = candidate
|
| 88 |
+
return mapping
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def scalar_string(value: Any) -> str | None:
|
| 92 |
+
if value is None or value == "":
|
| 93 |
+
return None
|
| 94 |
+
if isinstance(value, (dict, list)):
|
| 95 |
+
return json.dumps(value, sort_keys=True, ensure_ascii=False)
|
| 96 |
+
return str(value)
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def parse_float(value: Any) -> float | None:
|
| 100 |
+
if value is None or value == "":
|
| 101 |
+
return None
|
| 102 |
+
try:
|
| 103 |
+
return float(value)
|
| 104 |
+
except (TypeError, ValueError):
|
| 105 |
+
return None
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def first_present(row: dict[str, Any], keys: list[str]) -> Any:
|
| 109 |
+
for key in keys:
|
| 110 |
+
value = row.get(key)
|
| 111 |
+
if value is not None and value != "":
|
| 112 |
+
return value
|
| 113 |
+
return None
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def table_path_from_manifest(output_file: str) -> str:
|
| 117 |
+
prefix = "data/processed/"
|
| 118 |
+
if output_file.startswith(prefix):
|
| 119 |
+
parts = output_file.split("/tables/", 1)
|
| 120 |
+
if len(parts) == 2:
|
| 121 |
+
return "tables/" + parts[1]
|
| 122 |
+
return output_file
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def get_table_files(repo_id: str, mode: str, raw_dir: Path, token: str | None) -> tuple[list[str], list[dict[str, Any]]]:
|
| 126 |
+
manifest_path = Path(
|
| 127 |
+
hf_hub_download(repo_id=repo_id, repo_type="dataset", filename="_MANIFEST.json", local_dir=raw_dir, token=token)
|
| 128 |
+
)
|
| 129 |
+
manifest = json.loads(manifest_path.read_text())
|
| 130 |
+
manifest_tables = manifest.get("tables") or []
|
| 131 |
+
if manifest_tables:
|
| 132 |
+
table_paths = [table_path_from_manifest(item["output_file"]) for item in manifest_tables]
|
| 133 |
+
else:
|
| 134 |
+
api = HfApi(token=token)
|
| 135 |
+
info = api.dataset_info(repo_id, files_metadata=True)
|
| 136 |
+
table_paths = [s.rfilename for s in info.siblings or [] if s.rfilename.startswith("tables/")]
|
| 137 |
+
manifest_tables = []
|
| 138 |
+
|
| 139 |
+
if mode == "cycpeptmpdb":
|
| 140 |
+
table_paths = [
|
| 141 |
+
path for path in table_paths if path.endswith("_Peptide_All.csv.jsonl") or path.endswith("_Monomer_All.csv.jsonl")
|
| 142 |
+
]
|
| 143 |
+
if mode == "proteingym":
|
| 144 |
+
table_paths = [path for path in table_paths if ".ipynb_checkpoints" not in path]
|
| 145 |
+
return sorted(set(table_paths)), manifest_tables
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
def classify(mode: str, source_file: str, source_table: str) -> dict[str, Any]:
|
| 149 |
+
source_parts = Path(source_file).parts
|
| 150 |
+
basename = Path(source_file).name.removesuffix(".csv")
|
| 151 |
+
if mode == "proteingym":
|
| 152 |
+
lower = source_file.lower()
|
| 153 |
+
if "indels" in lower:
|
| 154 |
+
table_group = "indels"
|
| 155 |
+
elif "substitutions" in lower:
|
| 156 |
+
table_group = "substitutions"
|
| 157 |
+
elif "clinical" in lower:
|
| 158 |
+
table_group = "clinical"
|
| 159 |
+
else:
|
| 160 |
+
table_group = "other"
|
| 161 |
+
if "raw_dms" in lower:
|
| 162 |
+
task_name = "DMS"
|
| 163 |
+
elif "clinical" in lower:
|
| 164 |
+
task_name = "clinical"
|
| 165 |
+
else:
|
| 166 |
+
task_name = None
|
| 167 |
+
return {
|
| 168 |
+
"table_group": table_group,
|
| 169 |
+
"task_name": task_name,
|
| 170 |
+
"subtask_name": None,
|
| 171 |
+
"entity_type": "variant",
|
| 172 |
+
"assay_name": basename,
|
| 173 |
+
}
|
| 174 |
+
if mode == "flip2":
|
| 175 |
+
task_name = source_parts[-2] if len(source_parts) >= 2 else None
|
| 176 |
+
return {
|
| 177 |
+
"table_group": "benchmark",
|
| 178 |
+
"task_name": task_name,
|
| 179 |
+
"subtask_name": basename,
|
| 180 |
+
"entity_type": "sequence",
|
| 181 |
+
"assay_name": f"{task_name}/{basename}" if task_name else basename,
|
| 182 |
+
}
|
| 183 |
+
if mode == "cycpeptmpdb":
|
| 184 |
+
entity_type = "peptide" if "Peptide" in basename else "monomer" if "Monomer" in basename else None
|
| 185 |
+
return {
|
| 186 |
+
"table_group": "all",
|
| 187 |
+
"task_name": "CycPeptMPDB",
|
| 188 |
+
"subtask_name": basename,
|
| 189 |
+
"entity_type": entity_type,
|
| 190 |
+
"assay_name": basename,
|
| 191 |
+
}
|
| 192 |
+
return {"table_group": None, "task_name": None, "subtask_name": None, "entity_type": None, "assay_name": basename}
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def derived_values(mode: str, wrapper: dict[str, Any]) -> dict[str, Any]:
|
| 196 |
+
row = wrapper.get("row") or {}
|
| 197 |
+
source_file = wrapper.get("source_file") or ""
|
| 198 |
+
source_table = wrapper.get("_source_table") or ""
|
| 199 |
+
source_row_index = wrapper.get("row_index")
|
| 200 |
+
record_seed = f"{source_file}|{source_row_index}|{json.dumps(row, sort_keys=True, ensure_ascii=False)}"
|
| 201 |
+
record_id = hashlib.sha256(record_seed.encode("utf-8")).hexdigest()
|
| 202 |
+
derived = {
|
| 203 |
+
"record_id": record_id,
|
| 204 |
+
"dataset_id": wrapper.get("dataset_id"),
|
| 205 |
+
"source_file": source_file,
|
| 206 |
+
"source_table": source_table,
|
| 207 |
+
"source_row_index": int(source_row_index) if source_row_index is not None else None,
|
| 208 |
+
"split_bucket": stable_bucket(record_id),
|
| 209 |
+
}
|
| 210 |
+
derived.update(classify(mode, source_file, source_table))
|
| 211 |
+
|
| 212 |
+
sequence = first_present(
|
| 213 |
+
row,
|
| 214 |
+
[
|
| 215 |
+
"mutated_sequence",
|
| 216 |
+
"mutant_sequence",
|
| 217 |
+
"sequence",
|
| 218 |
+
"Sequence",
|
| 219 |
+
"aa_seq",
|
| 220 |
+
"aa_seq_full",
|
| 221 |
+
"wildtype_sequence",
|
| 222 |
+
"WT_sequence",
|
| 223 |
+
],
|
| 224 |
+
)
|
| 225 |
+
target = first_present(row, ["target", "DMS_score", "fitness", "score", "Permeability", "deltaG", "dG_ML"])
|
| 226 |
+
score_value = None
|
| 227 |
+
for key in ["target", "DMS_score", "fitness", "score", "Permeability", "deltaG", "dG_ML", "ddG_ML", "Caco2", "PAMPA", "MDCK", "RRCK"]:
|
| 228 |
+
score_value = parse_float(row.get(key))
|
| 229 |
+
if score_value is not None:
|
| 230 |
+
break
|
| 231 |
+
mutation = first_present(row, ["mutant", "mutation", "mutations", "name", "mut_class", "ID", "id"])
|
| 232 |
+
label = first_present(row, ["DMS_score_bin", "label", "set", "validation", "class", "mut_type", "Molecule_Shape"])
|
| 233 |
+
|
| 234 |
+
derived.update(
|
| 235 |
+
{
|
| 236 |
+
"sequence": scalar_string(sequence),
|
| 237 |
+
"sequence_length": len(str(sequence)) if sequence is not None else None,
|
| 238 |
+
"mutation": scalar_string(mutation),
|
| 239 |
+
"target": scalar_string(target),
|
| 240 |
+
"score_value": score_value,
|
| 241 |
+
"label": scalar_string(label),
|
| 242 |
+
}
|
| 243 |
+
)
|
| 244 |
+
return derived
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
def iter_wrappers(path: Path, source_table: str) -> Iterable[dict[str, Any]]:
|
| 248 |
+
with path.open("r", encoding="utf-8", errors="replace") as handle:
|
| 249 |
+
for line in handle:
|
| 250 |
+
if not line.strip():
|
| 251 |
+
continue
|
| 252 |
+
item = json.loads(line)
|
| 253 |
+
item["_source_table"] = source_table
|
| 254 |
+
yield item
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def download_tables(repo_id: str, table_paths: list[str], raw_dir: Path, token: str | None) -> list[Path]:
|
| 258 |
+
paths = []
|
| 259 |
+
for index, table_path in enumerate(table_paths, start=1):
|
| 260 |
+
local = Path(hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=table_path, local_dir=raw_dir, token=token))
|
| 261 |
+
paths.append(local)
|
| 262 |
+
if index == 1 or index % 25 == 0 or index == len(table_paths):
|
| 263 |
+
print(f"downloaded {index}/{len(table_paths)} {table_path}", flush=True)
|
| 264 |
+
return paths
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
def write_split_shards(
|
| 268 |
+
out_dir: Path,
|
| 269 |
+
rows_iter: Iterable[dict[str, Any]],
|
| 270 |
+
schema: pa.Schema,
|
| 271 |
+
chunk_rows: int,
|
| 272 |
+
) -> dict[str, int]:
|
| 273 |
+
data_dir = out_dir / "data"
|
| 274 |
+
data_dir.mkdir(parents=True, exist_ok=True)
|
| 275 |
+
buffers: dict[str, list[dict[str, Any]]] = {"train": [], "test": []}
|
| 276 |
+
counts = {"train": 0, "test": 0}
|
| 277 |
+
shard_counts = {"train": 0, "test": 0}
|
| 278 |
+
|
| 279 |
+
def flush(split: str) -> None:
|
| 280 |
+
if not buffers[split]:
|
| 281 |
+
return
|
| 282 |
+
shard = shard_counts[split]
|
| 283 |
+
path = data_dir / f"{split}-{shard:05d}-of-XXXXX.parquet"
|
| 284 |
+
table = pa.Table.from_pylist(buffers[split], schema=schema)
|
| 285 |
+
pq.write_table(table, path, compression="zstd")
|
| 286 |
+
counts[split] += len(buffers[split])
|
| 287 |
+
shard_counts[split] += 1
|
| 288 |
+
buffers[split].clear()
|
| 289 |
+
|
| 290 |
+
for row in rows_iter:
|
| 291 |
+
split = "test" if row["split_bucket"] == 0 else "train"
|
| 292 |
+
buffers[split].append(row)
|
| 293 |
+
if len(buffers[split]) >= chunk_rows:
|
| 294 |
+
flush(split)
|
| 295 |
+
flush("train")
|
| 296 |
+
flush("test")
|
| 297 |
+
|
| 298 |
+
for split in ["train", "test"]:
|
| 299 |
+
total = shard_counts[split]
|
| 300 |
+
for path in sorted(data_dir.glob(f"{split}-*-of-XXXXX.parquet")):
|
| 301 |
+
new_name = path.name.replace("of-XXXXX", f"of-{total:05d}")
|
| 302 |
+
path.rename(path.with_name(new_name))
|
| 303 |
+
return counts
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
def build_dataset(repo_id: str, mode: str, raw_dir: Path, out_dir: Path, chunk_rows: int) -> dict[str, Any]:
|
| 307 |
+
token = load_token()
|
| 308 |
+
raw_dir.mkdir(parents=True, exist_ok=True)
|
| 309 |
+
table_paths, manifest_tables = get_table_files(repo_id, mode, raw_dir, token)
|
| 310 |
+
local_paths = download_tables(repo_id, table_paths, raw_dir, token)
|
| 311 |
+
|
| 312 |
+
raw_keys: set[str] = set()
|
| 313 |
+
table_stats: list[dict[str, Any]] = []
|
| 314 |
+
total_rows = 0
|
| 315 |
+
for source_table, local_path in zip(table_paths, local_paths):
|
| 316 |
+
rows = 0
|
| 317 |
+
dataset_id = None
|
| 318 |
+
source_file = None
|
| 319 |
+
for wrapper in iter_wrappers(local_path, source_table):
|
| 320 |
+
row = wrapper.get("row") or {}
|
| 321 |
+
raw_keys.update(row.keys())
|
| 322 |
+
rows += 1
|
| 323 |
+
dataset_id = wrapper.get("dataset_id")
|
| 324 |
+
source_file = wrapper.get("source_file")
|
| 325 |
+
total_rows += rows
|
| 326 |
+
table_stats.append(
|
| 327 |
+
{
|
| 328 |
+
"source_table": source_table,
|
| 329 |
+
"source_file": source_file,
|
| 330 |
+
"dataset_id": dataset_id,
|
| 331 |
+
"rows": rows,
|
| 332 |
+
"size_bytes": local_path.stat().st_size,
|
| 333 |
+
}
|
| 334 |
+
)
|
| 335 |
+
print(f"scanned {source_table}: {rows} rows", flush=True)
|
| 336 |
+
|
| 337 |
+
raw_mapping = unique_names(raw_keys)
|
| 338 |
+
raw_columns = [raw_mapping[key] for key in sorted(raw_mapping)]
|
| 339 |
+
schema_fields = [
|
| 340 |
+
pa.field("record_id", pa.string()),
|
| 341 |
+
pa.field("dataset_id", pa.string()),
|
| 342 |
+
pa.field("source_file", pa.string()),
|
| 343 |
+
pa.field("source_table", pa.string()),
|
| 344 |
+
pa.field("source_row_index", pa.int64()),
|
| 345 |
+
pa.field("table_group", pa.string()),
|
| 346 |
+
pa.field("task_name", pa.string()),
|
| 347 |
+
pa.field("subtask_name", pa.string()),
|
| 348 |
+
pa.field("entity_type", pa.string()),
|
| 349 |
+
pa.field("assay_name", pa.string()),
|
| 350 |
+
pa.field("sequence", pa.string()),
|
| 351 |
+
pa.field("sequence_length", pa.int64()),
|
| 352 |
+
pa.field("mutation", pa.string()),
|
| 353 |
+
pa.field("target", pa.string()),
|
| 354 |
+
pa.field("score_value", pa.float64()),
|
| 355 |
+
pa.field("label", pa.string()),
|
| 356 |
+
pa.field("split_bucket", pa.int64()),
|
| 357 |
+
] + [pa.field(column, pa.string()) for column in raw_columns]
|
| 358 |
+
schema = pa.schema(schema_fields)
|
| 359 |
+
|
| 360 |
+
if out_dir.exists():
|
| 361 |
+
shutil.rmtree(out_dir)
|
| 362 |
+
out_dir.mkdir(parents=True, exist_ok=True)
|
| 363 |
+
|
| 364 |
+
def row_iter() -> Iterable[dict[str, Any]]:
|
| 365 |
+
emitted = 0
|
| 366 |
+
for source_table, local_path in zip(table_paths, local_paths):
|
| 367 |
+
for wrapper in iter_wrappers(local_path, source_table):
|
| 368 |
+
raw = wrapper.get("row") or {}
|
| 369 |
+
row = {column: None for column in BASE_COLUMNS + raw_columns}
|
| 370 |
+
row.update(derived_values(mode, wrapper))
|
| 371 |
+
for original_key, column in raw_mapping.items():
|
| 372 |
+
row[column] = scalar_string(raw.get(original_key))
|
| 373 |
+
emitted += 1
|
| 374 |
+
if emitted % 250000 == 0:
|
| 375 |
+
print(f"prepared {emitted}/{total_rows} rows", flush=True)
|
| 376 |
+
yield row
|
| 377 |
+
|
| 378 |
+
split_counts = write_split_shards(out_dir, row_iter(), schema, chunk_rows)
|
| 379 |
+
|
| 380 |
+
metadata_dir = out_dir / "metadata"
|
| 381 |
+
metadata_dir.mkdir(parents=True, exist_ok=True)
|
| 382 |
+
pd.DataFrame.from_records(table_stats).to_parquet(metadata_dir / "source_tables.parquet", index=False, compression="zstd")
|
| 383 |
+
pd.DataFrame.from_records(
|
| 384 |
+
[{"raw_key": key, "column": raw_mapping[key]} for key in sorted(raw_mapping)]
|
| 385 |
+
).to_parquet(metadata_dir / "column_mapping.parquet", index=False, compression="zstd")
|
| 386 |
+
|
| 387 |
+
summary = {
|
| 388 |
+
"source": repo_id,
|
| 389 |
+
"mode": mode,
|
| 390 |
+
"source_table_rows": len(table_stats),
|
| 391 |
+
"entry_rows": int(total_rows),
|
| 392 |
+
"raw_field_count": len(raw_columns),
|
| 393 |
+
"splits": split_counts,
|
| 394 |
+
"split_strategy": "deterministic sha256(record_id) % 10; bucket 0 is test, buckets 1-9 are train",
|
| 395 |
+
"table_group_counts": dict(Counter(item["source_file"].split("/")[-2] if item["source_file"] and "/" in item["source_file"] else "unknown" for item in table_stats).most_common()),
|
| 396 |
+
"columns": BASE_COLUMNS + raw_columns,
|
| 397 |
+
"metadata_tables": ["metadata/source_tables.parquet", "metadata/column_mapping.parquet"],
|
| 398 |
+
}
|
| 399 |
+
(out_dir / "dataset_summary.json").write_text(json.dumps(summary, indent=2) + "\n", encoding="utf-8")
|
| 400 |
+
return summary
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
def main() -> None:
|
| 404 |
+
parser = argparse.ArgumentParser()
|
| 405 |
+
parser.add_argument("--repo-id", required=True)
|
| 406 |
+
parser.add_argument("--mode", required=True, choices=["proteingym", "flip2", "cycpeptmpdb"])
|
| 407 |
+
parser.add_argument("--raw-dir", type=Path, required=True)
|
| 408 |
+
parser.add_argument("--out-dir", type=Path, required=True)
|
| 409 |
+
parser.add_argument("--chunk-rows", type=int, default=200000)
|
| 410 |
+
args = parser.parse_args()
|
| 411 |
+
summary = build_dataset(args.repo_id, args.mode, args.raw_dir, args.out_dir, args.chunk_rows)
|
| 412 |
+
print(json.dumps(summary, indent=2))
|
| 413 |
+
|
| 414 |
+
|
| 415 |
+
if __name__ == "__main__":
|
| 416 |
+
main()
|