mtbls-mhd-integration 0.0.13__py3-none-any.whl → 0.0.15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mtbls2mhd/__init__.py +1 -1
- mtbls2mhd/convertor_factory.py +5 -1
- mtbls2mhd/v0_1/legacy/builder.py +67 -21
- mtbls2mhd/v0_1/ms/convertor.py +59 -3
- {mtbls_mhd_integration-0.0.13.dist-info → mtbls_mhd_integration-0.0.15.dist-info}/METADATA +3 -3
- {mtbls_mhd_integration-0.0.13.dist-info → mtbls_mhd_integration-0.0.15.dist-info}/RECORD +10 -10
- {mtbls_mhd_integration-0.0.13.dist-info → mtbls_mhd_integration-0.0.15.dist-info}/WHEEL +0 -0
- {mtbls_mhd_integration-0.0.13.dist-info → mtbls_mhd_integration-0.0.15.dist-info}/entry_points.txt +0 -0
- {mtbls_mhd_integration-0.0.13.dist-info → mtbls_mhd_integration-0.0.15.dist-info}/licenses/LICENSE +0 -0
- {mtbls_mhd_integration-0.0.13.dist-info → mtbls_mhd_integration-0.0.15.dist-info}/top_level.txt +0 -0
mtbls2mhd/__init__.py
CHANGED
mtbls2mhd/convertor_factory.py
CHANGED
|
@@ -6,6 +6,7 @@ from mhd_model.model.definitions import (
|
|
|
6
6
|
)
|
|
7
7
|
|
|
8
8
|
from mtbls2mhd.v0_1.legacy.convertor import LegacyProfileV01Convertor
|
|
9
|
+
from mtbls2mhd.v0_1.ms.convertor import MsProfileConvertor
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class Mtbls2MhdConvertorFactory(BaseMhdConvertorFactory):
|
|
@@ -21,7 +22,10 @@ class Mtbls2MhdConvertorFactory(BaseMhdConvertorFactory):
|
|
|
21
22
|
target_mhd_model_profile_uri=target_mhd_model_profile_uri,
|
|
22
23
|
)
|
|
23
24
|
elif target_mhd_model_profile_uri == MHD_MODEL_V0_1_MS_PROFILE_NAME:
|
|
24
|
-
|
|
25
|
+
return MsProfileConvertor(
|
|
26
|
+
target_mhd_model_schema_uri=target_mhd_model_schema_uri,
|
|
27
|
+
target_mhd_model_profile_uri=target_mhd_model_profile_uri,
|
|
28
|
+
)
|
|
25
29
|
raise NotImplementedError()
|
|
26
30
|
else:
|
|
27
31
|
raise NotImplementedError()
|
mtbls2mhd/v0_1/legacy/builder.py
CHANGED
|
@@ -361,14 +361,14 @@ class MhdLegacyDatasetBuilder:
|
|
|
361
361
|
reverse_relationship_name="affiliates",
|
|
362
362
|
)
|
|
363
363
|
for role in contact.roles:
|
|
364
|
-
if role.term == "principal investigator":
|
|
364
|
+
if role.term.lower() == "principal investigator":
|
|
365
365
|
mhd_builder.link(
|
|
366
366
|
mhd_contact,
|
|
367
367
|
"principal-investigator-of",
|
|
368
368
|
mhd_study,
|
|
369
369
|
reverse_relationship_name="has-principal-investigator",
|
|
370
370
|
)
|
|
371
|
-
elif role.term == "submitter":
|
|
371
|
+
elif role.term.lower() == "submitter":
|
|
372
372
|
mhd_builder.link(
|
|
373
373
|
mhd_contact,
|
|
374
374
|
"submits",
|
|
@@ -449,6 +449,46 @@ class MhdLegacyDatasetBuilder:
|
|
|
449
449
|
|
|
450
450
|
return organizations
|
|
451
451
|
|
|
452
|
+
def add_funders(
|
|
453
|
+
self,
|
|
454
|
+
data: MetabolightsStudyModel,
|
|
455
|
+
mhd_builder: MhDatasetBuilder,
|
|
456
|
+
mhd_study: mhd_domain.Study,
|
|
457
|
+
organizations: dict[str, mhd_domain.Organization],
|
|
458
|
+
build_type: BuildType = BuildType.FULL,
|
|
459
|
+
):
|
|
460
|
+
if build_type == build_type.MINIMUM:
|
|
461
|
+
return
|
|
462
|
+
study: Study = data.investigation.studies[0]
|
|
463
|
+
comments = {x.name: x for x in study.comments if x and x.name}
|
|
464
|
+
grant_ids = []
|
|
465
|
+
if comments.get("Funder") and comments["Funder"].value:
|
|
466
|
+
if isinstance(comments["Funder"].value, str):
|
|
467
|
+
funders = comments["Funder"].value.split(";") or []
|
|
468
|
+
else:
|
|
469
|
+
funders = comments["Funder"].value[0].split(";") or []
|
|
470
|
+
for funder in funders:
|
|
471
|
+
organization = organizations.get(funder)
|
|
472
|
+
if not organization:
|
|
473
|
+
organization = mhd_domain.Organization(name=funder)
|
|
474
|
+
mhd_builder.add(organization)
|
|
475
|
+
organizations[funder] = organization
|
|
476
|
+
mhd_builder.link(
|
|
477
|
+
mhd_study,
|
|
478
|
+
"funded-by",
|
|
479
|
+
organization,
|
|
480
|
+
reverse_relationship_name="funds",
|
|
481
|
+
)
|
|
482
|
+
grants = comments.get("Grant Identifier")
|
|
483
|
+
if grants and grants.value:
|
|
484
|
+
if isinstance(grants.value, str):
|
|
485
|
+
identifiers = grants.value.split(";")
|
|
486
|
+
else:
|
|
487
|
+
identifiers = grants.value[0].split(";")
|
|
488
|
+
if identifiers:
|
|
489
|
+
grant_ids.extend(identifiers)
|
|
490
|
+
mhd_study.grant_identifier_list = grant_ids
|
|
491
|
+
|
|
452
492
|
def add_publications(
|
|
453
493
|
self,
|
|
454
494
|
data: MetabolightsStudyModel,
|
|
@@ -1808,7 +1848,7 @@ class MhdLegacyDatasetBuilder:
|
|
|
1808
1848
|
files_map,
|
|
1809
1849
|
) -> dict[str, mhd_domain.Assay]:
|
|
1810
1850
|
protocol_summaries: OrderedDict[str, ProtocolRunSummary] = OrderedDict()
|
|
1811
|
-
assays
|
|
1851
|
+
assays: OrderedDict[str, mhd_domain.Assay] = OrderedDict()
|
|
1812
1852
|
for assay in selected_assays:
|
|
1813
1853
|
if assay.file_name not in data.assays:
|
|
1814
1854
|
continue
|
|
@@ -1864,28 +1904,32 @@ class MhdLegacyDatasetBuilder:
|
|
|
1864
1904
|
)
|
|
1865
1905
|
mhd_builder.add(assay_type)
|
|
1866
1906
|
mhd_assay.assay_type_ref = assay_type.id_
|
|
1907
|
+
omics_types: list[mhd_domain.CvTermObject] = []
|
|
1908
|
+
measurement_types: list[mhd_domain.CvTermObject] = []
|
|
1909
|
+
measurement = None
|
|
1910
|
+
if "untargeted" in assay.measurement_type.term.lower():
|
|
1911
|
+
measurement = MTBLS_MEASUREMENT_TYPES["untargeted"]
|
|
1912
|
+
elif "targeted" in assay.measurement_type.term.lower():
|
|
1913
|
+
measurement = MTBLS_MEASUREMENT_TYPES["targeted"]
|
|
1867
1914
|
|
|
1868
1915
|
inv_study = data.investigation.studies[0]
|
|
1869
1916
|
design_types = inv_study.study_design_descriptors.design_types
|
|
1870
1917
|
|
|
1871
|
-
omics_types: list[mhd_domain.CvTermObject] = []
|
|
1872
|
-
measurement_types: list[mhd_domain.CvTermObject] = []
|
|
1873
1918
|
for descriptor in design_types:
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1919
|
+
if not measurement:
|
|
1920
|
+
if "untargeted" in descriptor.term.lower():
|
|
1921
|
+
measurement = MTBLS_MEASUREMENT_TYPES["untargeted"]
|
|
1922
|
+
elif "targeted" in descriptor.term.lower():
|
|
1923
|
+
measurement = MTBLS_MEASUREMENT_TYPES["targeted"]
|
|
1924
|
+
|
|
1925
|
+
if measurement:
|
|
1926
|
+
measurement_type = create_cv_term_object(
|
|
1927
|
+
type_="descriptor",
|
|
1928
|
+
source=measurement.source,
|
|
1929
|
+
accession=measurement.accession,
|
|
1930
|
+
name=measurement.name,
|
|
1931
|
+
)
|
|
1932
|
+
measurement_types.append(measurement_type)
|
|
1889
1933
|
for v in COMMON_OMICS_TYPES.values():
|
|
1890
1934
|
if descriptor.term.lower() == v.name.lower():
|
|
1891
1935
|
omics_type = create_cv_term_object(
|
|
@@ -2110,7 +2154,9 @@ class MhdLegacyDatasetBuilder:
|
|
|
2110
2154
|
reverse_relationship_name="provided-by",
|
|
2111
2155
|
)
|
|
2112
2156
|
|
|
2113
|
-
self.add_contacts(data, mhd_builder, mhd_study, build_type)
|
|
2157
|
+
organizations = self.add_contacts(data, mhd_builder, mhd_study, build_type)
|
|
2158
|
+
self.add_funders(data, mhd_builder, mhd_study, organizations, build_type)
|
|
2159
|
+
|
|
2114
2160
|
metadata_files = self.add_metadata_files(
|
|
2115
2161
|
mhd_builder,
|
|
2116
2162
|
mhd_study,
|
mtbls2mhd/v0_1/ms/convertor.py
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from mhd_model.convertors.mhd.convertor import BaseMhdConvertor
|
|
4
|
+
from mhd_model.shared.model import Revision
|
|
5
|
+
|
|
6
|
+
from mtbls2mhd.config import Mtbls2MhdConfiguration, get_default_config
|
|
7
|
+
from mtbls2mhd.v0_1.legacy.builder import BuildType, MhdLegacyDatasetBuilder
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MsProfileConvertor(BaseMhdConvertor):
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
target_mhd_model_schema_uri: str,
|
|
14
|
+
target_mhd_model_profile_uri: str,
|
|
15
|
+
):
|
|
16
|
+
self.target_mhd_model_schema_uri = target_mhd_model_schema_uri
|
|
17
|
+
self.target_mhd_model_profile_uri = target_mhd_model_profile_uri
|
|
18
|
+
|
|
19
|
+
def convert(
|
|
20
|
+
self,
|
|
21
|
+
repository_name: str,
|
|
22
|
+
repository_identifier: str,
|
|
23
|
+
mhd_identifier: None | str,
|
|
24
|
+
repository_revision: None | Revision = None,
|
|
25
|
+
config: None | Mtbls2MhdConfiguration = None, # noqa: F821
|
|
26
|
+
cached_mtbls_model_file_path: None | str = None,
|
|
27
|
+
**kwargs,
|
|
28
|
+
):
|
|
29
|
+
if not config:
|
|
30
|
+
config = get_default_config()
|
|
31
|
+
mhd_dataset_builder = MhdLegacyDatasetBuilder()
|
|
32
|
+
mtbls_study_repository_url = (
|
|
33
|
+
f"{config.study_http_base_url}/{repository_identifier}"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
mtbls_study_path = Path(config.mtbls_studies_root_path) / Path(
|
|
37
|
+
repository_identifier
|
|
38
|
+
)
|
|
39
|
+
try:
|
|
40
|
+
success, message = mhd_dataset_builder.build(
|
|
41
|
+
mhd_id=mhd_identifier,
|
|
42
|
+
mtbls_study_id=repository_identifier,
|
|
43
|
+
mtbls_study_path=mtbls_study_path,
|
|
44
|
+
mtbls_study_repository_url=mtbls_study_repository_url,
|
|
45
|
+
target_mhd_model_schema_uri=self.target_mhd_model_schema_uri,
|
|
46
|
+
target_mhd_model_profile_uri=self.target_mhd_model_profile_uri,
|
|
47
|
+
config=config,
|
|
48
|
+
cached_mtbls_model_file_path=cached_mtbls_model_file_path,
|
|
49
|
+
revision=repository_revision,
|
|
50
|
+
repository_name=repository_name,
|
|
51
|
+
build_type=BuildType.FULL_AND_CUSTOM_NODES,
|
|
52
|
+
**kwargs,
|
|
53
|
+
)
|
|
54
|
+
return success, message
|
|
55
|
+
except Exception as ex:
|
|
56
|
+
import traceback
|
|
57
|
+
|
|
58
|
+
traceback.print_exc()
|
|
59
|
+
return False, str(ex)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mtbls-mhd-integration
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.15
|
|
4
4
|
Summary: MetaboLights - MetabolomicsHub Integration
|
|
5
5
|
Author-email: MetaboLights Team <metabolights-help@ebi.ac.uk>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -8,8 +8,8 @@ Requires-Python: <4.0,>=3.12
|
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
10
|
Requires-Dist: asyncpg>=0.30.0
|
|
11
|
-
Requires-Dist: metabolights-utils>=1.4.
|
|
12
|
-
Requires-Dist: mhd-model>=0.1.
|
|
11
|
+
Requires-Dist: metabolights-utils>=1.4.18
|
|
12
|
+
Requires-Dist: mhd-model>=0.1.44
|
|
13
13
|
Requires-Dist: psycopg[binary,pool]>=3.3.2
|
|
14
14
|
Requires-Dist: pydantic>=2.12.4
|
|
15
15
|
Requires-Dist: pydantic-settings>=2.10.1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
mtbls2mhd/__init__.py,sha256=
|
|
1
|
+
mtbls2mhd/__init__.py,sha256=sP6P2r3ohpNSNphplpratyl2bhnzH2tDhPYOOAPAmDg,158
|
|
2
2
|
mtbls2mhd/config.py,sha256=BjOqAyfDhp9byoFjJz70xh4HRR8pu1yrm_5jweqygSI,2310
|
|
3
|
-
mtbls2mhd/convertor_factory.py,sha256=
|
|
3
|
+
mtbls2mhd/convertor_factory.py,sha256=WNXgzLFq84whwv0phrB1B2L1YRabO2tD0nPDT9QJ6gQ,1365
|
|
4
4
|
mtbls2mhd/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
mtbls2mhd/commands/cli.py,sha256=XhLcqBxmBNX_nSEc4aU9q2D9VoYvqZKeRuYLbt-JwZ8,662
|
|
6
6
|
mtbls2mhd/commands/create.py,sha256=fcZO5Ez5yams95Zpx1vQjjagBiJzfnZrIKfk5Z6qoRw,452
|
|
@@ -8,16 +8,16 @@ mtbls2mhd/commands/create_mhd_file.py,sha256=0sDr-Cm0JhhEB5V1g66uoag3rlcaAnGP8Md
|
|
|
8
8
|
mtbls2mhd/commands/validate.py,sha256=iwIKegviRxdH0r8scRXbDISlwQUzAq5uVoCHinU7x6Q,473
|
|
9
9
|
mtbls2mhd/v0_1/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
mtbls2mhd/v0_1/legacy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
mtbls2mhd/v0_1/legacy/builder.py,sha256=
|
|
11
|
+
mtbls2mhd/v0_1/legacy/builder.py,sha256=xYPy_qoWIV_c6GGD_2AE-pCVAwxe_7BPq5Cn6tQqRbc,92682
|
|
12
12
|
mtbls2mhd/v0_1/legacy/convertor.py,sha256=Nu6xJvEk8WsRQJQFoxM5eo-y46tVfWV8EkedVoqI9rI,2198
|
|
13
13
|
mtbls2mhd/v0_1/legacy/db_metadata_collector.py,sha256=UGk1AeST1NQ9lWwy_sYZxaaWs0ajgaKELDJtXJ4-Uco,13071
|
|
14
14
|
mtbls2mhd/v0_1/legacy/folder_metadata_collector.py,sha256=QwtXI9rBvdh6pxILQDHymIwYDqzGuMxqdOcqtdAObME,7538
|
|
15
15
|
mtbls2mhd/v0_1/legacy/mtbls_study_schema.py,sha256=gUTbRmI8GfHI5leLiw8dxsmWnV3NnWw5RPX_LQWRFRQ,3162
|
|
16
16
|
mtbls2mhd/v0_1/ms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
mtbls2mhd/v0_1/ms/convertor.py,sha256=
|
|
18
|
-
mtbls_mhd_integration-0.0.
|
|
19
|
-
mtbls_mhd_integration-0.0.
|
|
20
|
-
mtbls_mhd_integration-0.0.
|
|
21
|
-
mtbls_mhd_integration-0.0.
|
|
22
|
-
mtbls_mhd_integration-0.0.
|
|
23
|
-
mtbls_mhd_integration-0.0.
|
|
17
|
+
mtbls2mhd/v0_1/ms/convertor.py,sha256=axkKDRx00ix6ceqJe9-KruEYEZOgaVtsAgCHiixPo5k,2201
|
|
18
|
+
mtbls_mhd_integration-0.0.15.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
19
|
+
mtbls_mhd_integration-0.0.15.dist-info/METADATA,sha256=zBXoZ7dOlmyE9AvtJxz2VyXflWLwqM-xe0JOampcOF0,688
|
|
20
|
+
mtbls_mhd_integration-0.0.15.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
21
|
+
mtbls_mhd_integration-0.0.15.dist-info/entry_points.txt,sha256=WQjM4flaYMyvHyv9zGKjCVk1i1_FGdNlhTmFVGgLgxs,61
|
|
22
|
+
mtbls_mhd_integration-0.0.15.dist-info/top_level.txt,sha256=b7pI95n6HIQMFXDD0yL1NwldiDc-XdeWql4Iw-uYygQ,10
|
|
23
|
+
mtbls_mhd_integration-0.0.15.dist-info/RECORD,,
|
|
File without changes
|
{mtbls_mhd_integration-0.0.13.dist-info → mtbls_mhd_integration-0.0.15.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{mtbls_mhd_integration-0.0.13.dist-info → mtbls_mhd_integration-0.0.15.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{mtbls_mhd_integration-0.0.13.dist-info → mtbls_mhd_integration-0.0.15.dist-info}/top_level.txt
RENAMED
|
File without changes
|