aboutsummaryrefslogtreecommitdiff
path: root/gn3/db
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-02-12 23:04:14 +0300
committerBonfaceKilz2024-02-13 17:56:32 +0300
commit602514e0ab5118590ae052fbd801f7fb596436a8 (patch)
tree349809841e3c5a36941d6afd2810d894447034b4 /gn3/db
parent52a1ecf271531200514c772b46101ef25a794b57 (diff)
downloadgenenetwork3-602514e0ab5118590ae052fbd801f7fb596436a8.tar.gz
Retrieve metadata from text files given a path.
* gn3/db/datasets.py (retrieve_trait_dataset): New file. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/db')
-rw-r--r--gn3/db/datasets.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/gn3/db/datasets.py b/gn3/db/datasets.py
index 6e3977f..5501d92 100644
--- a/gn3/db/datasets.py
+++ b/gn3/db/datasets.py
@@ -3,6 +3,7 @@ This module contains functions relating to specific trait dataset manipulation
"""
import os
from typing import Any
+from pathlib import Path
from flask import current_app as app
@@ -330,3 +331,23 @@ def retrieve_trait_dataset(trait_type, trait, threshold, conn):
**dataset_fns[trait_type](),
**group
}
+
+
+def retrieve_dataset_metadata(name: str) -> dict:
+ """Return the full data given a path, NAME"""
+ result = {}
+ __subject = {
+ "summary": "dct:description",
+ "tissue": "gnt:hasTissueInfo",
+ "specifics": "gnt:hasTissueInfo",
+ "cases": "gnt:hasCaseInfo",
+ "platform": "gnt:hasPlatformInfo",
+ "processing": "gnt:hasDataProcessingInfo",
+ "notes": "gnt:hasNotes",
+ "experiment-design": "gnt:hasExperimentDesignInfo",
+ "acknowledgment": "gnt:hasAcknowledgement",
+ }
+ for __file in Path(name).glob("*rtf"):
+ with __file.open() as _f:
+ result[__subject.get(__file.stem, f"gn:{__file.stem}")] = _f.read()
+ return result