Commit 091a18bb authored by Hervé Ménager's avatar Hervé Ménager
Browse files

retrieve list of phenotypes from HDF when accessing a project by ID

parent 34f524e1
......@@ -95,6 +95,31 @@ class Phenotype(Model):
"""
return deserialize_model(dikt, cls)
@classmethod
def from_phenolist(cls, row) -> "Phenotype":
"""
Returns the PhenoList row as a Phenotype object
:param row: A "PhenoList" dataframe row, as a dict.
:type: dict
:return: The generated PhenoList.
:rtype: PhenoList
"""
p = Phenotype()
import logging
logging.error(row)
p.id = row['ID']
p.consortium = row['Consortium']
p.outcome = row['Outcome']
p.full_name = row['FullName']
p.type = row['Type']
p.ref = row['Reference']
p.ref_link = row['ReferenceLink']
p.data_link = ''
p.data_path = ''
return p
@property
def id(self) -> str:
"""
......
......@@ -15,6 +15,7 @@ from jass.models.worktable import (
get_worktable_genomedata,
get_worktable_local_manhattan_data,
get_worktable_local_heatmap_data,
get_worktable_phenolist,
)
from jass.config import config
......@@ -68,9 +69,13 @@ class Project(Model):
self._phenotypes = phenotypes
self._id = id
if self._id is None:
self._id = self.get_id(chromosome, start, end)
else:
self._phenotypes = [
Phenotype.from_phenolist(row)
for row in get_worktable_phenolist(self.get_worktable_path()).values()
]
@classmethod
def from_dict(cls, dikt) -> "Project":
......
......@@ -823,6 +823,19 @@ def stringize_dataframe_region_chr(dataframe: DataFrame):
return dataframe
def get_worktable_phenolist(project_hdf_path: str):
"""
Read and return the PhenoList dataframe from a worktable file
:param project_hdf_path: path to the worktable file
:type project_hdf_path: str
:return: The dataframe as a dictionary with one entry per line number
:rtype: dict
"""
phenolist_dataframe = read_hdf(project_hdf_path, "PhenoList")
return phenolist_dataframe.to_dict(orient='index')
def get_worktable_summary(project_hdf_path: str):
"""
Read and return the summaryTable dataframe from a worktable file
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment