Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e9cf81d
xml parsing
v-rocheleau Sep 13, 2023
2f765da
xsd ontologies utils
v-rocheleau Sep 14, 2023
e479e4c
lint
v-rocheleau Sep 14, 2023
26becc3
experiment library strategy data migration
v-rocheleau Sep 14, 2023
762d23a
xsd dir name change
v-rocheleau Sep 14, 2023
a32bd01
fix poetry.lock
v-rocheleau Sep 14, 2023
1390066
code clean
v-rocheleau Sep 14, 2023
d8d9a85
lint
v-rocheleau Sep 14, 2023
d030cb6
read library selection, add doc
v-rocheleau Sep 14, 2023
48ff585
fix test data
v-rocheleau Sep 14, 2023
2a93fe4
fix migration type
v-rocheleau Sep 14, 2023
eb93de0
migration fix, lint
v-rocheleau Sep 15, 2023
fae4540
add validation error descriptions to IngestError
v-rocheleau Sep 18, 2023
0c1cb1b
ingest response format
v-rocheleau Sep 18, 2023
9f8ff0c
ingestion error responds with warnings on schema changes
v-rocheleau Sep 19, 2023
2194a08
update api ingestion tests
v-rocheleau Sep 20, 2023
948f6bc
lint
v-rocheleau Sep 20, 2023
db378d2
add ingestion tests, exp workflow payload schema
v-rocheleau Sep 20, 2023
881f792
infer success from status code
v-rocheleau Sep 20, 2023
b359973
remove line call
v-rocheleau Sep 20, 2023
9b58dc4
get ingestion warnings from derived experiment results ingestion
v-rocheleau Sep 20, 2023
dd0f66c
save ingest report to file and output
v-rocheleau Sep 20, 2023
74e55fa
Merge branch 'develop' into features/library-strategies
v-rocheleau Jan 18, 2024
f9fa0f9
fix migrations, lint
v-rocheleau Jan 18, 2024
4148d36
schema changes version update
v-rocheleau Jan 18, 2024
bbef730
fix api ingest tests
v-rocheleau Jan 19, 2024
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
17 changes: 17 additions & 0 deletions chord_metadata_service/experiments/migrations/0009_v4_1_0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.db import migrations


def set_experiment_library_strategy(apps, _schema_editor):
Experiment = apps.get_model("experiments", "Experiment")
for exp in Experiment.objects.filter(library_strategy="WES"):
exp.library_strategy = "WXS"
exp.save()
Comment thread
v-rocheleau marked this conversation as resolved.
Outdated

Comment thread
v-rocheleau marked this conversation as resolved.
class Migration(migrations.Migration):
dependencies = [
('experiments', '0007_v4_0_0'),
]

operations = [
migrations.RunPython(set_experiment_library_strategy)
]
7 changes: 6 additions & 1 deletion chord_metadata_service/experiments/schemas.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
from .descriptions import EXPERIMENT, EXPERIMENT_RESULT, INSTRUMENT
from chord_metadata_service.restapi.schemas import ONTOLOGY_CLASS_LIST, KEY_VALUE_OBJECT
from chord_metadata_service.restapi.schema_utils import tag_ids_and_describe
from chord_metadata_service.ontologies import readXsdSimpleTypeValues


__all__ = ["EXPERIMENT_SCHEMA", "EXPERIMENT_RESULT_SCHEMA", "INSTRUMENT_SCHEMA"]

LIBRARY_STRATEGIES = readXsdSimpleTypeValues(
'chord_metadata_service/ontologies/xsd/SRA.experiment.xsd.xml',
Comment thread
v-rocheleau marked this conversation as resolved.
Outdated
'typeLibraryStrategy',
)

EXPERIMENT_RESULT_SCHEMA = tag_ids_and_describe({
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down Expand Up @@ -104,7 +109,7 @@
"molecule_ontology": ONTOLOGY_CLASS_LIST,
"library_strategy": {
"type": "string",
"enum": ["Bisulfite-Seq", "RNA-Seq", "ChIP-Seq", "WES", "Other"]
"enum": LIBRARY_STRATEGIES
},
"library_source": {
"type": "string",
Expand Down
5 changes: 5 additions & 0 deletions chord_metadata_service/ontologies/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .utils import readXsdSimpleTypeValues

__all__ = [
"readXsdSimpleTypeValues",
]
14 changes: 14 additions & 0 deletions chord_metadata_service/ontologies/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import xmltodict


def readXsdSimpleTypeValues(xsd_file_path: str, type_name: str):
Comment thread
v-rocheleau marked this conversation as resolved.
Outdated
"""Reads an XML Schema Definition (XSD) file and returns a type's values.
The XSD file is parsed using xmltodict following this spec:
https://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html
"""
sra_file = open(xsd_file_path).read()
Comment thread
v-rocheleau marked this conversation as resolved.
Outdated
sra_experiment_data = xmltodict.parse(sra_file, namespaces={'xs': None})
simple_types = {sp["@name"]: sp for sp in sra_experiment_data["schema"]["simpleType"]}
target_type = simple_types[type_name]
values = [val['@value'] for val in target_type['restriction']['enumeration']]
return values
Loading