From aa458d1039c217e0df9b0b3e940601041294013d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20=20MENAGER?= <herve.menager@pasteur.fr> Date: Tue, 28 Mar 2017 11:57:37 +0200 Subject: [PATCH] modify phenotypes in Swagger and add the corresponding flask code TODO: read data from hdf5 with pandas --- .../controllers/default_controller.py | 5 +- .../swagger_server/models/phenotype.py | 85 +++++++++++++++---- .../swagger_server/swagger/swagger.yaml | 6 +- 3 files changed, 77 insertions(+), 19 deletions(-) diff --git a/python-flask-server/swagger_server/controllers/default_controller.py b/python-flask-server/swagger_server/controllers/default_controller.py index 9939484a..974f2c98 100644 --- a/python-flask-server/swagger_server/controllers/default_controller.py +++ b/python-flask-server/swagger_server/controllers/default_controller.py @@ -13,7 +13,10 @@ def phenotypes_get(): :rtype: List[Phenotype] """ - return 'do some magic!' + phenotypes = [] + phenotypes.append(Phenotype(id="z_GIANT_BMI", cohort="GIANT", phenotype="BMI", ref="10.1038/ng.686")) + phenotypes.append(Phenotype(id="z_GIANT_HEIGHT", cohort="GIANT", phenotype="BMI", ref="10.1038/ng.3097")) + return phenotypes def projects_get(): diff --git a/python-flask-server/swagger_server/models/phenotype.py b/python-flask-server/swagger_server/models/phenotype.py index ab8b1811..c059bc43 100644 --- a/python-flask-server/swagger_server/models/phenotype.py +++ b/python-flask-server/swagger_server/models/phenotype.py @@ -12,27 +12,37 @@ class Phenotype(Model): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ - def __init__(self, id: str=None, label: str=None): + def __init__(self, id: str=None, cohort: str=None, phenotype: str=None, ref: str=None): """ Phenotype - a model defined in Swagger - :param id: The id of this Phenotype. + :param id: dataset ID. :type id: str - :param label: The label of this Phenotype. - :type label: str + :param cohort: dataset cohort. + :type cohort: str + :param phenotype: dataset phenotype + :type phenotype: str + :param ref: dataset bibliographic reference + :type ref: str """ self.swagger_types = { 'id': str, - 'label': str + 'cohort': str, + 'phenotype': str, + 'ref': str } self.attribute_map = { 'id': 'id', - 'label': 'label' + 'cohort': 'cohort', + 'phenotype': 'phenotype', + 'ref': 'ref' } self._id = id - self._label = label + self._cohort = cohort + self._phenotype = phenotype + self._ref = ref @classmethod def from_dict(cls, dikt) -> 'Phenotype': @@ -68,23 +78,64 @@ class Phenotype(Model): self._id = id @property - def label(self) -> str: + def cohort(self) -> str: + """ + Gets the cohort of this Phenotype dataset. + + :return: The cohort of this Phenotype dataset. + :rtype: str + """ + return self._cohort + + @cohort.setter + def cohort(self, cohort: str): + """ + Sets the cohort of this Phenotype dataset. + + :param cohort: The cohort of this Phenotype dataset. + :type cohort: str + """ + + self._cohort = cohort + + @property + def phenotype(self) -> str: """ - Gets the label of this Phenotype. + Gets the phenotype of this Phenotype dataset. - :return: The label of this Phenotype. + :return: The phenotype of this Phenotype dataset. :rtype: str """ - return self._label + return self._phenotype + + @phenotype.setter + def phenotype(self, phenotype: str): + """ + Sets the phenotype of this Phenotype dataset. - @label.setter - def label(self, label: str): + :param phenotype: The phenotype of this Phenotype dataset. + :type phenotype: str """ - Sets the label of this Phenotype. - :param label: The label of this Phenotype. - :type label: str + self._phenotype = phenotype + + @property + def ref(self) -> str: """ + Gets the bibliographic reference for this Phenotype dataset. - self._label = label + :return: The bibliographic reference of this Phenotype dataset. + :rtype: str + """ + return self._ref + + @ref.setter + def ref(self, ref: str): + """ + Sets the bibliographic reference of this Phenotype dataset. + + :param ref: The bibliographic reference of this Phenotype dataset. + :type ref: str + """ + self._ref = ref diff --git a/python-flask-server/swagger_server/swagger/swagger.yaml b/python-flask-server/swagger_server/swagger/swagger.yaml index 91eb9a04..abcc213b 100644 --- a/python-flask-server/swagger_server/swagger/swagger.yaml +++ b/python-flask-server/swagger_server/swagger/swagger.yaml @@ -134,5 +134,9 @@ definitions: properties: id: type: "string" - label: + cohort: + type: "string" + phenotype: + type: "string" + ref: type: "string" -- GitLab