Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/biosim_schema_project-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches: [main]
pull_request:
schedule:
- cron: '0 8 * * 1-5'
workflow_dispatch:

jobs:
Expand Down
9 changes: 8 additions & 1 deletion biosim_schema/fieldextraction/extract_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import yaml

METADATA_KEYS = ("label", "hint", "typehint", "placeholder", "units")
METADATA_KEYS = ("label", "hint", "typehint", "placeholder", "units", "example")
"""tuple[str, ...]: Field metadata keys copied from each webform node into the summary."""


Expand Down Expand Up @@ -125,6 +125,7 @@ def _flatten_rows(node, path):
"placeholder_text": node.get("placeholder", ""),
"default_unit": node.get("default_unit", ""),
"data_type": node.get("typehint", ""),
"example": node.get("example", ""),
}
return [row]

Expand Down Expand Up @@ -153,6 +154,7 @@ def write_summary_csv(summary, output_path):
"placeholder_text",
"default_unit",
"data_type",
"example",
]

with open(output_path, "w", newline="", encoding="utf-8") as f:
Expand Down Expand Up @@ -203,6 +205,11 @@ def main():
summary, f, default_flow_style=False, allow_unicode=True, sort_keys=True
)

# output as json
json_path = yaml_path.with_suffix(".json")
with open(json_path, "w") as fp:
json.dump(summary, fp)

# flatten and output as csv
csv_path = yaml_path.with_suffix(".csv")
write_summary_csv(summary, str(csv_path))
Expand Down
19 changes: 14 additions & 5 deletions biosim_schema/fieldextraction/extract_webform_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ def _render_primitive(self, slot):
if self._get_annotation(slot, "textarea"):
result["type"] = "textarea"

example = self._get_annotation(slot, "example")
if example:
result["example"] = example[0]

if "unit" in slot:
symbol = slot["unit"]["symbol"]
result["units"] = [symbol]
result["label"] += f" ({symbol})"

if "pattern" in slot:
result["placeholder"] = (
slot["examples"][0]["value"] if "examples" in slot else None
)
if "pattern" in slot:
result["pattern"] = slot["pattern"]
if "examples" in slot:
Expand Down Expand Up @@ -208,6 +208,9 @@ def _render_enum(self, slot, enum):
],
"multiple": slot.get("multivalued", False),
}
example = self._get_annotation(slot, "example")
if example:
result["example"] = example[0]
return self._apply_ui_annotations(slot, result)

def _render_class_node(self, slot, context):
Expand Down Expand Up @@ -266,13 +269,19 @@ def _render_quantity(self, slot, context):
"placeholder": vector_placeholder,
}

return {
result = {
"type": "quantity",
"label": self._get_label(slot),
"hint": slot.get("description"),
"fields": fields,
}

example = self._get_annotation(slot, "example")
if example:
result["example"] = example[0]

return result

# =========================================================
# TYPE CHECKS
# =========================================================
Expand Down
56 changes: 55 additions & 1 deletion biosim_schema/schema/components/biosim_composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ slots:
Concentration of salt in the solution.
range: ConcentrationQuantity # class
examples:
- value: 1
- value: 0.1
annotations:
example:
- value: 0.1
value_unit: M

total_atom_count:
description:
Expand All @@ -72,6 +76,8 @@ slots:
engine_mapping:
- engine: toptrajparser
key: total_atom_count
example:
- value: 1

total_molecule_count:
description:
Expand All @@ -84,6 +90,8 @@ slots:
engine_mapping:
- engine: toptrajparser
key: total_molecule_count
example:
- value: 1

atom_count:
description:
Expand All @@ -96,6 +104,8 @@ slots:
engine_mapping:
- engine: toptrajparser
key: atom_count
example:
- value: 1

molecule_count:
description:
Expand All @@ -108,6 +118,8 @@ slots:
engine_mapping:
- engine: toptrajparser
key: molecule_count
example:
- value: 1

monomer_count:
description:
Expand All @@ -120,6 +132,8 @@ slots:
engine_mapping:
- engine: toptrajparser
key: monomer_count
example:
- value: 1

molecular_weight:
description:
Expand All @@ -132,6 +146,9 @@ slots:
- engine: toptrajparser
key: molecular_weight
unit: g/mol
example:
- value: 18.0
value_unit: g/mol

molecule_charge:
description:
Expand All @@ -145,6 +162,9 @@ slots:
- engine: toptrajparser
key: molecule_charge
unit: e
example:
- value: -1.0
value_unit: e

unique_molecule_count:
description:
Expand All @@ -157,6 +177,8 @@ slots:
engine_mapping:
- engine: toptrajparser
key: unique_molecule_count
example:
- value: 1

system_counts:
description:
Expand Down Expand Up @@ -194,6 +216,8 @@ slots:
database: "PDB"
prefix: "pdb"
base_uri: "https://identifiers.org/pdb:"
example:
- value: "2VB1"

UNIPROT_ID:
is_a: identifier
Expand All @@ -208,6 +232,8 @@ slots:
database: "UNIPROT"
prefix: "uniprot"
base_uri: "https://identifiers.org/uniprot:"
example:
- value: "P0DP23"

EMDB_ID:
is_a: identifier
Expand All @@ -222,6 +248,8 @@ slots:
database: "EMDB"
prefix: "emdb"
base_uri: "https://identifiers.org/emdb:"
example:
- value: "EMD-1001"

alphafold_ID:
is_a: identifier
Expand All @@ -235,6 +263,8 @@ slots:
annotations:
database: "AlphaFoldDB"
base_uri: "https://alphafold.ebi.ac.uk/entry/"
example:
- value: "AF-P12345-F1"

PubChem_CID:
is_a: identifier
Expand All @@ -250,6 +280,8 @@ slots:
database: "PubChem"
prefix: "pubchem.compound"
base_uri: "https://identifiers.org/pubchem.compound:"
example:
- value: "100101"

InChIKey:
is_a: identifier
Expand All @@ -268,6 +300,8 @@ slots:
engine_mapping:
- engine: toptrajparser
key: InChIKey
example:
- value: "RYYVLZVUVIJVGH-UHFFFAOYSA-N"

SMILES:
description:
Expand All @@ -282,6 +316,8 @@ slots:
engine_mapping:
- engine: toptrajparser
key: SMILES
example:
- value: "CN1C=NC2=C1C(=O)N(C(=O)N2C)C"

InChI:
description:
Expand All @@ -296,6 +332,8 @@ slots:
engine_mapping:
- engine: toptrajparser
key: InChI
example:
- value: "InChI=1S/C8H10N4O2/c1-10-4-9-6-5(10)7(13)12(3)8(14)11(6)2/h4H,1-3H3"

molecular_formula:
description:
Expand All @@ -308,16 +346,28 @@ slots:
engine_mapping:
- engine: toptrajparser
key: molecular_formula
example:
- value: "C8H10N4O2"

predicted_structure:
description:
Are the molecule positions derived from a prediction?
examples:
- value: "True"
range: boolean
annotations:
example:
- value: "True"

modified:
description:
Has the initial model been modified from the original?
examples:
- value: "True"
range: boolean
annotations:
example:
- value: "True"

protein_sequence:
description:
Expand All @@ -331,6 +381,8 @@ slots:
engine_mapping:
- engine: toptrajparser
key: protein_sequence
example:
- value: "DRVYIHPF"

nucleic_sequence:
description:
Expand All @@ -344,3 +396,5 @@ slots:
engine_mapping:
- engine: toptrajparser
key: nucleic_sequence
example:
- value: "ATGCATCGATCGATCGATCG"
Loading
Loading