Date: Thu, 3 Sep 2020 17:01:31 +0200
Subject: [PATCH 040/207] better design
---
frontend/src/components/Overview.vue | 2 +-
frontend/src/components/lib/chips/FileChip.vue | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/frontend/src/components/Overview.vue b/frontend/src/components/Overview.vue
index ccbd8e92..c909c418 100644
--- a/frontend/src/components/Overview.vue
+++ b/frontend/src/components/Overview.vue
@@ -26,7 +26,7 @@
- Any pharmacokinetics study consist of subjects under investigation. These subjects are characterised by properties
+ Any pharmacokinetics study contains subjects under investigation. These subjects are characterised by properties
like their sex, age, body weight, health status, and further accessible pharmacokinetics influencing characteristica.
In PK-DB this data is saved as groups and individuals.
Next, some kind of interventions are performed on the subjects, which is mostly a dosing of a substance to the body
diff --git a/frontend/src/components/lib/chips/FileChip.vue b/frontend/src/components/lib/chips/FileChip.vue
index 96a73a88..dc3f9ebf 100644
--- a/frontend/src/components/lib/chips/FileChip.vue
+++ b/frontend/src/components/lib/chips/FileChip.vue
@@ -2,14 +2,14 @@
-
- {{ faIcon('file_image') }}
- {{ faIcon('file') }}
+
+ {{ faIcon('file_image') }}
+ {{ faIcon('file') }}
- {{ faIcon('file_excel') }}
+ {{ faIcon('file_excel') }}
- {{ faIcon('file_pdf') }}
- {{ faIcon('file') }}
+ {{ faIcon('file_pdf') }}
+ {{ faIcon('file') }}
{{ name(file) }}
From 393ddb4c063be6aaafaac4d8c7dda8cd42c23263 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Thu, 3 Sep 2020 17:20:43 +0200
Subject: [PATCH 041/207] rest api details for timecourse and scatter
---
backend/pkdb_app/data/serializers.py | 2 +-
frontend/src/components/tables/ScatterTable.vue | 2 ++
frontend/src/components/tables/TimecoursesTable.vue | 2 ++
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/backend/pkdb_app/data/serializers.py b/backend/pkdb_app/data/serializers.py
index 70d46a14..0ef0978c 100644
--- a/backend/pkdb_app/data/serializers.py
+++ b/backend/pkdb_app/data/serializers.py
@@ -381,7 +381,7 @@ class Meta:
def get_array(self,object):
#return [[SmallOutputSerializer(point.point,many=True, read_only=True).data] for point in object["array"]]
- return [[p.to_dict() for p in point.point] for point in object["array"]]
+ return [point["point"] for point in object.to_dict()["array"]]
class DataSetElasticSmallSerializer(serializers.ModelSerializer):
descriptions = DescriptionElasticSerializer(many=True, read_only=True)
comments = CommentElasticSerializer(many=True, read_only=True)
diff --git a/frontend/src/components/tables/ScatterTable.vue b/frontend/src/components/tables/ScatterTable.vue
index 5dc8afbf..a933c0ff 100644
--- a/frontend/src/components/tables/ScatterTable.vue
+++ b/frontend/src/components/tables/ScatterTable.vue
@@ -20,6 +20,8 @@
:title="'Study: '+item.study.name"
icon="study"
/>
+
+
diff --git a/frontend/src/components/tables/TimecoursesTable.vue b/frontend/src/components/tables/TimecoursesTable.vue
index d824dcfc..5242a1fa 100644
--- a/frontend/src/components/tables/TimecoursesTable.vue
+++ b/frontend/src/components/tables/TimecoursesTable.vue
@@ -20,6 +20,8 @@
:title="'Study: '+item.study.name"
icon="study"
/>
+
+
From 1d3b64f005dc710e449f255f11ab982ac976655f Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Thu, 3 Sep 2020 18:07:31 +0200
Subject: [PATCH 042/207] better design characteristica cards
---
.../components/detail/CharacteristicaCard.vue | 99 ++++++++++---------
.../components/tables/InterventionsTable.vue | 9 +-
.../src/components/tables/OutputsTable.vue | 19 +---
3 files changed, 58 insertions(+), 69 deletions(-)
diff --git a/frontend/src/components/detail/CharacteristicaCard.vue b/frontend/src/components/detail/CharacteristicaCard.vue
index b5a69cd8..d298fb6c 100644
--- a/frontend/src/components/detail/CharacteristicaCard.vue
+++ b/frontend/src/components/detail/CharacteristicaCard.vue
@@ -4,64 +4,62 @@
flat
tile
height="100%"
+ width="100%"
@click="update_details"
outlined
class="characteristica_card"
- align="start"
- justify="start">
+ align="start">
-
-
-
-
- {{ this.count }}/{{this.subject_count}}
-
-
-
- fa fa-female
- fa fa-male
- fa fa-femalefa fa-male
- fa fa-smoking
- fa fa-smoking-ban
- fa fa-tablets
- fa fa-tablets
-
- fa fa-check-circle
- fa fa-times-circle
-
-
-
-
-
-
-
-
+
+
+ {{ this.count }}/{{this.subject_count}}
+
+
+ fa fa-female
+ fa fa-male
+ fa fa-femalefa fa-male
+ fa fa-smoking
+ fa fa-smoking-ban
+ fa fa-tablets
+ fa fa-tablets
+
+ fa fa-check-circle
+ fa fa-times-circle
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
- {{ value }} {{ error }}
- {{ data.unit }}
-
-
-
- {{ faIcon("na") }}
-
-
+
+ {{ value }} {{ error }}
+ {{ data.unit }}
+
+
+
+ {{ faIcon("na") }}
+
+
@@ -70,6 +68,7 @@
+
+
\ No newline at end of file
diff --git a/frontend/src/components/Data.vue b/frontend/src/components/Data.vue
index d5c1af3a..cc50846c 100644
--- a/frontend/src/components/Data.vue
+++ b/frontend/src/components/Data.vue
@@ -1,175 +1,23 @@
-
-
-
-
- {{ faIcon('search') }}
- Search
-
-
-
-
-
-
-
-
-
-
-
- {{ item.tab }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ faIcon('download') }}
- Download
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
\ No newline at end of file
+
diff --git a/frontend/src/components/Home.vue b/frontend/src/components/Home.vue
index 32b16e1a..2e1d4b24 100644
--- a/frontend/src/components/Home.vue
+++ b/frontend/src/components/Home.vue
@@ -7,25 +7,18 @@
-
-
-
-
-
diff --git a/frontend/src/components/Overview.vue b/frontend/src/components/Overview.vue
index 0b433328..ec034963 100644
--- a/frontend/src/components/Overview.vue
+++ b/frontend/src/components/Overview.vue
@@ -1,16 +1,6 @@
-
PK-DB - pharmacokinetics database
-
-
+
PK-DB - pharmacokinetics database
An open issue in the field of pharmacokinetics is the reproducible and reusable storage of data from
@@ -22,8 +12,6 @@
Data
-
-
Any pharmacokinetics study contains subjects under investigation. These subjects are characterised by properties
@@ -36,137 +24,64 @@
These are often some kind of concentration profiles in some tissue of the subject.
Additionally, derived pharmacokinetics parameters e.g. AUC, clearance, or half-lives are commonly reported.
Correlations between theses outputs are often shown in form of scatter plots.
-
-
-
Curation Example
-
+
+ {{ faIcon('data') }}
+ data
+
-
-
- RV Patwardhan, P V Desmond, R F Johnson, S Schenker
-
-
- The Journal of Laboratory and clinical medicine, 1980-05-30
-
+
+
+
+
-
-
+
+
+
-
-
- Features
- Experimental errors and variation
-
- Normalisation of units
-
- Automatic calculation of PKs from timecourses
-
- Annotations to biological Ontologies
-
- REST API
-
- Simple curation workflow
-
- Strong validation rules during curation
-
-
-
-
-
-
+
-
+
+
\ No newline at end of file
+
\ No newline at end of file
diff --git a/frontend/src/components/Results.vue b/frontend/src/components/Results.vue
deleted file mode 100644
index 681f6704..00000000
--- a/frontend/src/components/Results.vue
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/frontend/src/components/navigation/Navigation.vue b/frontend/src/components/navigation/Navigation.vue
index b43b66f4..19860a9d 100644
--- a/frontend/src/components/navigation/Navigation.vue
+++ b/frontend/src/components/navigation/Navigation.vue
@@ -1,21 +1,17 @@
-
+ >
+
PK-DB
-
-
- {{ faIcon('data') }}
- {{ tables_label }}
-
+
+ {{ faIcon('data') }}Data
+
@@ -55,27 +51,11 @@
username(){
return this.$store.state.username
},
- tables_label(){
- if(this.$store.getters.isInitial){
- return "Data"
- }else{
- return "Results"
- }
- }
}
}
\ No newline at end of file
diff --git a/frontend/src/components/tables/CountTable.vue b/frontend/src/components/tables/CountTable.vue
index b3260364..68fe3e99 100644
--- a/frontend/src/components/tables/CountTable.vue
+++ b/frontend/src/components/tables/CountTable.vue
@@ -21,47 +21,26 @@
diff --git a/frontend/src/router.js b/frontend/src/router.js
index 4a5e6aa5..f62b8b6e 100644
--- a/frontend/src/router.js
+++ b/frontend/src/router.js
@@ -2,9 +2,7 @@ import Vue from 'vue';
import Router from 'vue-router';
import Home from './components/Home';
-import Data from './components/Data';
-import Results from './components/Results'
-import Search from './components/Search';
+import Data from './components/Data'
import Page404 from './components/Page404';
import Curation from './components/Curation';
import Account from './components/auth/Account';
@@ -24,21 +22,11 @@ export default new Router({
name: 'Home',
component: Home
},
- {
- path: '/search',
- name: 'Search',
- component: Search
- },
{
path: '/data',
name: 'Data',
component: Data
},
- {
- path: '/results',
- name: 'Results',
- component: Results
- },
{
path: '/curation',
name: 'Curation',
From 6e28c12edac5bf6c567b47d0200c6dfc6ca361ce Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Wed, 9 Sep 2020 00:32:28 +0200
Subject: [PATCH 053/207] Fixed details drawer
---
frontend/src/components/Home.vue | 77 ++++++++++++++--
frontend/src/components/Overview.vue | 87 -------------------
.../components/{ => deprecated}/FooterBar.vue | 0
.../components/{ => deprecated}/ListView.vue | 2 +-
.../src/components/deprecated/References.vue | 2 +-
.../ReferencesTable.vue | 6 +-
.../components/{ => deprecated}/Search.vue | 24 ++---
.../components/navigation/DetailDrawer.vue | 25 +++++-
.../components/search/OutputSearchForm.vue | 9 +-
frontend/src/components/search/SearchHelp.vue | 28 +++---
.../components/search/SearchNavigation.vue | 9 +-
.../src/components/search/StudySearchForm.vue | 6 +-
.../components/search/SubjectSearchForm.vue | 5 +-
13 files changed, 134 insertions(+), 146 deletions(-)
delete mode 100644 frontend/src/components/Overview.vue
rename frontend/src/components/{ => deprecated}/FooterBar.vue (100%)
rename frontend/src/components/{ => deprecated}/ListView.vue (92%)
rename frontend/src/components/{tables => deprecated}/ReferencesTable.vue (94%)
rename frontend/src/components/{ => deprecated}/Search.vue (91%)
diff --git a/frontend/src/components/Home.vue b/frontend/src/components/Home.vue
index 2e1d4b24..c698ee50 100644
--- a/frontend/src/components/Home.vue
+++ b/frontend/src/components/Home.vue
@@ -4,7 +4,66 @@
-
+
+ PK-DB - pharmacokinetics database
+
+
+ An open issue in the field of pharmacokinetics is the reproducible and reusable storage of data from
+ experimental and clinical studies, which is especially important for computational modeling. We present PK-DB
+ an open database for pharmacokinetics information from clinical trials as well as pre-clinical research.
+ The focus of PK-DB is to provide high-quality
+ pharmacokinetics data enriched with the required meta-information for computational modeling and data integration.
+
+
+ Data
+
+
+
+ Any pharmacokinetics study contains subjects under investigation. These subjects are characterised by properties
+ like their sex, age, body weight, health status, and further accessible pharmacokinetics influencing characteristica.
+ In PK-DB this data is saved as groups and individuals.
+ Next, some kind of interventions are performed on the subjects, which is mostly a dosing of a substance to the body
+ of the subject.
+
+ Finally, pharmacokinetics measurements are performed on the subject.
+ These are often some kind of concentration profiles in some tissue of the subject.
+ Additionally, derived pharmacokinetics parameters e.g. AUC, clearance, or half-lives are commonly reported.
+ Correlations between theses outputs are often shown in form of scatter plots.
+
+
+
+ {{ faIcon('data') }}
+ data
+
+
+
+
+
+
+
+
+
+
+
+
@@ -12,14 +71,20 @@
diff --git a/frontend/src/components/Overview.vue b/frontend/src/components/Overview.vue
deleted file mode 100644
index ec034963..00000000
--- a/frontend/src/components/Overview.vue
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
PK-DB - pharmacokinetics database
-
-
- An open issue in the field of pharmacokinetics is the reproducible and reusable storage of data from
- experimental and clinical studies, which is especially important for computational modeling. We present PK-DB
- an open database for pharmacokinetics information from clinical trials as well as pre-clinical research.
- The focus of PK-DB is to provide high-quality
- pharmacokinetics data enriched with the required meta-information for computational modeling and data integration.
-
-
-
Data
-
-
-
- Any pharmacokinetics study contains subjects under investigation. These subjects are characterised by properties
- like their sex, age, body weight, health status, and further accessible pharmacokinetics influencing characteristica.
- In PK-DB this data is saved as groups and individuals.
- Next, some kind of interventions are performed on the subjects, which is mostly a dosing of a substance to the body
- of the subject.
-
- Finally, pharmacokinetics measurements are performed on the subject.
- These are often some kind of concentration profiles in some tissue of the subject.
- Additionally, derived pharmacokinetics parameters e.g. AUC, clearance, or half-lives are commonly reported.
- Correlations between theses outputs are often shown in form of scatter plots.
-
-
-
- {{ faIcon('data') }}
- data
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/frontend/src/components/FooterBar.vue b/frontend/src/components/deprecated/FooterBar.vue
similarity index 100%
rename from frontend/src/components/FooterBar.vue
rename to frontend/src/components/deprecated/FooterBar.vue
diff --git a/frontend/src/components/ListView.vue b/frontend/src/components/deprecated/ListView.vue
similarity index 92%
rename from frontend/src/components/ListView.vue
rename to frontend/src/components/deprecated/ListView.vue
index 85b918ed..a966bcb1 100644
--- a/frontend/src/components/ListView.vue
+++ b/frontend/src/components/deprecated/ListView.vue
@@ -15,7 +15,7 @@
\ No newline at end of file
diff --git a/frontend/src/components/search/StudySearchForm.vue b/frontend/src/components/search/StudySearchForm.vue
index d473973e..3559599f 100644
--- a/frontend/src/components/search/StudySearchForm.vue
+++ b/frontend/src/components/search/StudySearchForm.vue
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/frontend/src/components/search/SubjectSearchForm.vue b/frontend/src/components/search/SubjectSearchForm.vue
index 98b92048..6c11151a 100644
--- a/frontend/src/components/search/SubjectSearchForm.vue
+++ b/frontend/src/components/search/SubjectSearchForm.vue
@@ -3,12 +3,10 @@
-
-
-
+
+
+
-
-
diff --git a/frontend/src/components/tables/TableTabs.vue b/frontend/src/components/tables/TableTabs.vue
index f7802030..0adaaed3 100644
--- a/frontend/src/components/tables/TableTabs.vue
+++ b/frontend/src/components/tables/TableTabs.vue
@@ -13,6 +13,7 @@
:key="item.tab"
:href="'#'+ item.tab"
>
+
{{ item.tab }} ({{results[item.tab].count}})
{{ faIcon(item.tab) }}
@@ -26,19 +27,20 @@
:key="item.tab"
:value="item.tab"
>
-
+
-
-
-
-
From 2d2c9194d90ac06f392ce1ea7cbc268b6d495371 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 9 Sep 2020 19:58:52 +0200
Subject: [PATCH 074/207] info nodes contain name now
---
backend/pkdb_app/documents.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/backend/pkdb_app/documents.py b/backend/pkdb_app/documents.py
index 0a1f6afe..d8ccd648 100644
--- a/backend/pkdb_app/documents.py
+++ b/backend/pkdb_app/documents.py
@@ -72,6 +72,7 @@ def info_node(attr, **kwargs):
attr=attr,
properties={
'sid': string_field('sid'),
+ 'name': string_field('name'),
'label': string_field('label'),
},
**kwargs
From 38a4639b580694c6abaedd61c0f5e124d0c57d4f Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Wed, 9 Sep 2020 22:42:41 +0200
Subject: [PATCH 075/207] fix units display
---
frontend/src/components/detail/CharacteristicaCard.vue | 7 +++++--
frontend/src/components/tables/TableTabs.vue | 4 ++--
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/frontend/src/components/detail/CharacteristicaCard.vue b/frontend/src/components/detail/CharacteristicaCard.vue
index f45aea95..0eb9fc62 100644
--- a/frontend/src/components/detail/CharacteristicaCard.vue
+++ b/frontend/src/components/detail/CharacteristicaCard.vue
@@ -1,12 +1,14 @@
@@ -55,7 +57,7 @@
/>
{{ value }} {{ error }}
- {{ data.unit }}
+ [{{ data.unit }}]
@@ -216,5 +218,6 @@
\ No newline at end of file
diff --git a/frontend/src/components/tables/TableTabs.vue b/frontend/src/components/tables/TableTabs.vue
index 0adaaed3..95b53a0f 100644
--- a/frontend/src/components/tables/TableTabs.vue
+++ b/frontend/src/components/tables/TableTabs.vue
@@ -30,13 +30,13 @@
-
-
From 8ab64309f100097d679c9f56f274bef93aef68ba Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 9 Sep 2020 23:36:11 +0200
Subject: [PATCH 076/207] fixes #632
---
frontend/src/components/tables/mixins.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/frontend/src/components/tables/mixins.js b/frontend/src/components/tables/mixins.js
index 75daa083..bff34994 100644
--- a/frontend/src/components/tables/mixins.js
+++ b/frontend/src/components/tables/mixins.js
@@ -14,7 +14,7 @@ let searchTableMixin = {
itemsPerPageOptions: [5, 10, 20, 50, 100]
},
table_class: "elevation-0",
- windowHeight: window.innerHeight-240,
+ windowHeight: window.innerHeight-260,
}
},
@@ -137,7 +137,7 @@ let searchTableMixin = {
},
methods: {
onResize() {
- this.windowHeight = window.innerHeight-240
+ this.windowHeight = window.innerHeight-260
},
faIcon(key) {
return lookupIcon(key)
From 11c23b757c54a75fd9f4936a4059a21ed0c420ba Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Wed, 9 Sep 2020 23:39:48 +0200
Subject: [PATCH 077/207] cleanup of components and bugfixes search
---
.../components/search/SearchNavigation.vue | 86 +++++++++----------
1 file changed, 40 insertions(+), 46 deletions(-)
diff --git a/frontend/src/components/search/SearchNavigation.vue b/frontend/src/components/search/SearchNavigation.vue
index 3e79ddb2..1b733c51 100644
--- a/frontend/src/components/search/SearchNavigation.vue
+++ b/frontend/src/components/search/SearchNavigation.vue
@@ -9,7 +9,7 @@
mini-variant-width="40"
width="420"
>
-
+
{{ faIcon('search') }}
@@ -64,66 +64,60 @@
-
-
+
-
- {{faIcon("studies")}}Studies ({{results.studies.count}})
+
+ {{faIcon("studies")}}
+
+ Studies
+
-
-
-
-
-
-
-
-
- {{faIcon("groups")}}Groups ({{ results.groups.count }})|
- {{faIcon("individuals")}}Individuals ({{results.individuals.count}})
+
-
+
+ {{faIcon("groups")}}
+
+ Groups
+
+ |
+ {{faIcon("individuals")}}
+
+ Individuals
+
+
-
-
-
-
-
-
- {{faIcon("interventions")}}Interventions ({{results.interventions.count}})
-
+
+ {{faIcon("interventions")}}
+
+ Interventions
+
+
-
-
-
-
-
-
- {{faIcon("outputs")}}Outputs ({{results.outputs.count}})|
- {{faIcon("timecourses")}}Timecourses ({{results.timecourses.count}})|
- Scatter ({{results.scatter.count}})
-
+
+ {{faIcon("outputs")}}
+
+ Outputs
+
+ |
+ {{faIcon("timecourses")}}
+
+ Timecourses
+
+ |
+
+ Scatter
+
+
From ed85d37d1726da951f0a211f94a5339bd69418ee Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Thu, 10 Sep 2020 18:36:07 +0200
Subject: [PATCH 078/207] minor cleanup
---
backend/pkdb_app/info_nodes/models.py | 15 +++++------
backend/pkdb_app/interventions/serializers.py | 20 +++++++-------
backend/pkdb_app/outputs/serializers.py | 14 +++++-----
backend/pkdb_app/studies/serializers.py | 4 +--
backend/pkdb_app/subjects/serializers.py | 4 +--
backend/pkdb_app/utils.py | 27 ++++++++-----------
backend/requirements.txt | 2 +-
7 files changed, 39 insertions(+), 47 deletions(-)
diff --git a/backend/pkdb_app/info_nodes/models.py b/backend/pkdb_app/info_nodes/models.py
index 5b645a5e..22c8d54c 100644
--- a/backend/pkdb_app/info_nodes/models.py
+++ b/backend/pkdb_app/info_nodes/models.py
@@ -1,6 +1,5 @@
"""
Model for the InfoNodes.
-
"""
from numbers import Number
import pint
@@ -11,8 +10,7 @@
from pkdb_app.behaviours import Sidable
from pkdb_app.info_nodes.units import ureg
-from pkdb_app.users.models import User
-from pkdb_app.utils import CHAR_MAX_LENGTH, CHAR_MAX_LENGTH_LONG, _validate_requried_key
+from pkdb_app.utils import CHAR_MAX_LENGTH, CHAR_MAX_LENGTH_LONG, _validate_required_key
class Annotation(models.Model):
@@ -24,7 +22,7 @@ class Annotation(models.Model):
label = models.CharField(max_length=CHAR_MAX_LENGTH, null=True)
url = models.URLField(max_length=CHAR_MAX_LENGTH_LONG, null=False)
-# TODO: add cross reference
+
class CrossReference(models.Model):
""" CrossReference. """
name = models.CharField(max_length=CHAR_MAX_LENGTH, null=False)
@@ -117,7 +115,6 @@ class Method(AbstractInfoNode):
class Route(AbstractInfoNode):
""" Route Model """
-
info_node = models.OneToOneField(
InfoNode, related_name="route", on_delete=models.CASCADE, null=True
)
@@ -200,11 +197,11 @@ def dimension_to_n_unit(self):
def p_unit(unit):
try:
p_unit = ureg(unit)
- p_unit.u
+ p_unit.u # check if pint unit can be accessed
return p_unit
except (UndefinedUnitError, AttributeError):
if unit == "%":
- raise ValueError(f"unit: [{unit}] has to written as 'percent'")
+ raise ValueError(f"unit: [{unit}] has to be encoded as 'percent'")
raise ValueError(f"unit [{unit}] is not defined in unit registry or not allowed.")
@@ -345,8 +342,8 @@ def validate_complete(self, data):
if self.time_required:
details = f"for measurement type `{self.info_node.name}`"
- _validate_requried_key(data, "time", details=details)
- _validate_requried_key(data, "time_unit", details=details)
+ _validate_required_key(data, "time", details=details)
+ _validate_required_key(data, "time_unit", details=details)
return {"choice":d_choice}
diff --git a/backend/pkdb_app/interventions/serializers.py b/backend/pkdb_app/interventions/serializers.py
index bd18f440..ffb7d5f8 100644
--- a/backend/pkdb_app/interventions/serializers.py
+++ b/backend/pkdb_app/interventions/serializers.py
@@ -25,7 +25,7 @@
# ----------------------------------
# Serializer FIELDS
# ----------------------------------
-from ..utils import list_of_pk, list_duplicates, _validate_requried_key, _create, create_multiple_bulk, \
+from ..utils import list_of_pk, list_duplicates, _validate_required_key, _create, create_multiple_bulk, \
create_multiple_bulk_normalized
MEDICATION = "medication"
@@ -81,20 +81,20 @@ def to_internal_value(self, data):
data = self.retransform_ex_fields(data)
self.validate_wrong_keys(data, additional_fields=InterventionExSerializer.Meta.fields)
- _validate_requried_key(data, "measurement_type")
+ _validate_required_key(data, "measurement_type")
measurement_type = data.get("measurement_type")
if any([measurement_type == MEDICATION, measurement_type == DOSING]):
- _validate_requried_key(data, "substance")
- _validate_requried_key(data, "route")
- _validate_requried_key(data, "value")
- _validate_requried_key(data, "unit")
+ _validate_required_key(data, "substance")
+ _validate_required_key(data, "route")
+ _validate_required_key(data, "value")
+ _validate_required_key(data, "unit")
if measurement_type == DOSING:
- _validate_requried_key(data, "form")
- _validate_requried_key(data, "application")
- _validate_requried_key(data, "time")
- _validate_requried_key(data, "time_unit")
+ _validate_required_key(data, "form")
+ _validate_required_key(data, "application")
+ _validate_required_key(data, "time")
+ _validate_required_key(data, "time_unit")
application = data["application"]
allowed_applications = ["constant infusion", "single dose"]
if not application in allowed_applications:
diff --git a/backend/pkdb_app/outputs/serializers.py b/backend/pkdb_app/outputs/serializers.py
index c2df4034..42c94830 100644
--- a/backend/pkdb_app/outputs/serializers.py
+++ b/backend/pkdb_app/outputs/serializers.py
@@ -28,7 +28,7 @@
# ----------------------------------
# Serializer FIELDS
# ----------------------------------
-from ..utils import list_of_pk, _validate_requried_key, create_multiple, _create, create_multiple_bulk_normalized, \
+from ..utils import list_of_pk, _validate_required_key, create_multiple, _create, create_multiple_bulk_normalized, \
create_multiple_bulk
EXTRA_FIELDS = ["tissue", "method", "label","output_type"]
@@ -104,12 +104,12 @@ def validate(self, attrs):
self._validate_group_output(attrs)
self.validate_group_individual_output(attrs)
- _validate_requried_key(attrs, "measurement_type")
+ _validate_required_key(attrs, "measurement_type")
- _validate_requried_key(attrs, "substance")
- _validate_requried_key(attrs, "tissue")
- _validate_requried_key(attrs, "interventions")
- _validate_requried_key(attrs, "output_type")
+ _validate_required_key(attrs, "substance")
+ _validate_required_key(attrs, "tissue")
+ _validate_required_key(attrs, "interventions")
+ _validate_required_key(attrs, "output_type")
self._validate_timecourse(attrs)
@@ -132,7 +132,7 @@ def validate(self, attrs):
def _validate_timecourse(self, attrs):
if attrs["output_type"] == Output.OutputTypes.Timecourse:
- _validate_requried_key(attrs,"label")
+ _validate_required_key(attrs, "label")
if not attrs.get("label",None):
msg = "Label is required on on output_type=timecourse"
raise serializers.ValidationError(msg)
diff --git a/backend/pkdb_app/studies/serializers.py b/backend/pkdb_app/studies/serializers.py
index 8fffc065..df05d828 100644
--- a/backend/pkdb_app/studies/serializers.py
+++ b/backend/pkdb_app/studies/serializers.py
@@ -24,7 +24,7 @@
GroupSetElasticSmallSerializer, IndividualSetElasticSmallSerializer
from ..users.models import User
from ..users.serializers import UserElasticSerializer
-from ..utils import update_or_create_multiple, create_multiple, list_duplicates, _validate_requried_key, \
+from ..utils import update_or_create_multiple, create_multiple, list_duplicates, _validate_required_key, \
_validate_not_allowed_key
@@ -384,7 +384,7 @@ def create_relations(self, study, related):
def validate(self, attrs):
if str(attrs.get("sid")).startswith("PKDB"):
- _validate_requried_key(attrs, "date", extra_message="For a study with a '^PKDB\d+$' identifier "
+ _validate_required_key(attrs, "date", extra_message="For a study with a '^PKDB\d+$' identifier "
"the date must be set in the study.json.")
else:
if attrs.get("date", None) is not None:
diff --git a/backend/pkdb_app/subjects/serializers.py b/backend/pkdb_app/subjects/serializers.py
index b7b90545..a31fe0b1 100644
--- a/backend/pkdb_app/subjects/serializers.py
+++ b/backend/pkdb_app/subjects/serializers.py
@@ -19,7 +19,7 @@
from ..comments.serializers import DescriptionSerializer, CommentSerializer, DescriptionElasticSerializer, \
CommentElasticSerializer
from ..serializers import WrongKeyValidationSerializer, ExSerializer, ReadSerializer
-from ..utils import list_of_pk, _validate_requried_key, create_multiple, _create
+from ..utils import list_of_pk, _validate_required_key, create_multiple, _create
CHARACTERISTICA_FIELDS = ['count']
CHARACTERISTICA_MAP_FIELDS = map_field(CHARACTERISTICA_FIELDS)
@@ -122,7 +122,7 @@ def to_internal_value(self, data):
data = self.retransform_ex_fields(data)
self.validate_wrong_keys(data, additional_fields=GroupExSerializer.Meta.fields)
- _validate_requried_key(data, 'count')
+ _validate_required_key(data, 'count')
for characteristica_single in data.get('characteristica', []):
disabled = ['value']
diff --git a/backend/pkdb_app/utils.py b/backend/pkdb_app/utils.py
index 7d49ad87..9009cf8e 100644
--- a/backend/pkdb_app/utils.py
+++ b/backend/pkdb_app/utils.py
@@ -4,8 +4,6 @@
import copy
import os
-from django.http import Http404
-from django.shortcuts import _get_queryset
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
@@ -21,6 +19,7 @@ class SlugRelatedField(serializers.SlugRelatedField):
def list_duplicates(seq):
+ # FIXME: use colletions.Counter
seen = set()
seen_add = seen.add
# adds all elements it doesn't know yet to seen and all other to seen_twice
@@ -82,7 +81,7 @@ def ensure_dir(file_path):
os.makedirs(directory)
-def update_or_create_multiple(parent, children, related_name, lookup_fields=[]):
+def update_or_create_multiple(parent, children, related_name, lookup_fields=None):
for child in children:
lookup_dict = {}
instance_child = getattr(parent, related_name)
@@ -93,8 +92,6 @@ def update_or_create_multiple(parent, children, related_name, lookup_fields=[]):
else:
lookup_dict = child
- # instance_child.update_or_create(**lookup_dict, defaults=child)
-
try:
if instance_child.model.__name__ in ["Choice", "Unit"]:
obj = instance_child.get(**lookup_dict)
@@ -110,17 +107,13 @@ def update_or_create_multiple(parent, children, related_name, lookup_fields=[]):
obj.save()
-
-
except instance_child.model.DoesNotExist:
instance_dict = {**lookup_dict, **child}
instance_child.create(**instance_dict)
-
def create_multiple(parent, children, related_name):
instance_child = getattr(parent, related_name)
-
return [instance_child.create(**child) for child in children]
@@ -134,8 +127,10 @@ def create_multiple_bulk_normalized(notnormalized_instances, model_class):
return model_class.objects.bulk_create(
[initialize_normed(notnorm_instance) for notnorm_instance in notnormalized_instances])
-def _create(validated_data, model_manager=None, model_serializer= None, create_multiple_keys=[], add_multiple_keys=[], pop=[]):
- poped_data = {related: validated_data.pop(related, []) for related in pop}
+
+def _create(validated_data, model_manager=None, model_serializer=None,
+ create_multiple_keys=[], add_multiple_keys=[], pop=[]):
+ popped_data = {related: validated_data.pop(related, []) for related in pop}
related_data_create = {related: validated_data.pop(related, []) for related in create_multiple_keys}
related_data_add = {related: validated_data.pop(related, []) for related in add_multiple_keys}
if model_manager is not None:
@@ -149,9 +144,10 @@ def _create(validated_data, model_manager=None, model_serializer= None, create_
create_multiple(instance, item, key)
for key, item in related_data_add.items():
- getattr(instance,key).add(*item)
+ getattr(instance, key).add(*item)
+
+ return instance, popped_data
- return instance, poped_data
def initialize_normed(notnorm_instance):
norm = copy.copy(notnorm_instance)
@@ -162,13 +158,11 @@ def initialize_normed(notnorm_instance):
try:
norm.individual_id = notnorm_instance.individual.pk
-
except AttributeError:
pass
try:
norm.group_id = notnorm_instance.group.pk
-
except AttributeError:
pass
@@ -203,13 +197,14 @@ def set_keys(d, value, *keys):
d[keys[-1]] = value
-def _validate_requried_key(attrs, key, details=None, extra_message=""):
+def _validate_required_key(attrs, key, details=None, extra_message: str = ""):
if key not in attrs:
error_json = {key: f"The key <{key}> is required. {extra_message}"}
if details:
error_json["details"] = details
raise serializers.ValidationError(error_json)
+
def _validate_not_allowed_key(attrs, key, details=None, extra_message=""):
if key in attrs:
error_json = {key: f"The key <{key}> is not allowed. {extra_message}"}
diff --git a/backend/requirements.txt b/backend/requirements.txt
index b8113437..d930af7c 100644
--- a/backend/requirements.txt
+++ b/backend/requirements.txt
@@ -25,7 +25,7 @@ pandas>=1.1.0
numpy>=1.19.1
scipy>=1.5.2
matplotlib>=3.3.0
-pint>=0.14
+pint>=0.15
pkdb-analysis>=0.1.5
From 8a2ccadce06dbafc506b565c8f6a393f8aba7712 Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Thu, 10 Sep 2020 23:56:31 +0200
Subject: [PATCH 079/207] minor fixes
---
backend/pkdb_app/data/models.py | 8 +-------
backend/pkdb_app/data/serializers.py | 17 ++++-------------
backend/pkdb_app/outputs/pk_calculation.py | 17 ++++++++---------
3 files changed, 13 insertions(+), 29 deletions(-)
diff --git a/backend/pkdb_app/data/models.py b/backend/pkdb_app/data/models.py
index ec8c9947..3f78597f 100644
--- a/backend/pkdb_app/data/models.py
+++ b/backend/pkdb_app/data/models.py
@@ -21,9 +21,8 @@ def subsets(self):
class Data(models.Model):
"""
- A Data These are mostly scatterplots or timecourses.
+ These are mostly scatter or timecourses.
"""
-
class DataTypes(models.TextChoices):
""" Data Types. """
Scatter = 'scatter', _('scatter')
@@ -36,16 +35,11 @@ class DataTypes(models.TextChoices):
dataset = models.ForeignKey(DataSet, related_name="data", on_delete=models.CASCADE, null=True)
-
class SubSet(Accessible):
- """
-
- """
name = models.CharField(max_length=CHAR_MAX_LENGTH)
data = models.ForeignKey(Data, related_name="subsets", on_delete=models.CASCADE)
study = models.ForeignKey('studies.Study', on_delete=models.CASCADE, related_name="subsets")
-
def get_single_dosing(self) -> Intervention:
"""Returns a single intervention of type dosing if existing.
If multiple dosing interventions exist, no dosing is returned!.
diff --git a/backend/pkdb_app/data/serializers.py b/backend/pkdb_app/data/serializers.py
index f10df389..0240f51a 100644
--- a/backend/pkdb_app/data/serializers.py
+++ b/backend/pkdb_app/data/serializers.py
@@ -1,4 +1,3 @@
-import collections
import traceback
from pkdb_app.comments.serializers import DescriptionSerializer, CommentSerializer, CommentElasticSerializer, \
@@ -13,7 +12,6 @@
from rest_framework import serializers
import pandas as pd
import numpy as np
-from django.apps import apps
class DimensionSerializer(WrongKeyValidationSerializer):
@@ -48,7 +46,6 @@ def to_internal_value(self, data):
self.validate_wrong_keys(data)
return data
-
def create(self, validated_data):
validated_data["study"] = self.context["study"]
@@ -66,15 +63,12 @@ def create(self, validated_data):
# subset_instance.save()
return subset_instance
-
def _validate_time(self, time):
if any(np.isnan(np.array(time))):
raise serializers.ValidationError({"time": "no time points are allowed to be nan", "detail": time})
-
def calculate_pks_from_timecourses(self, subset):
-
# calculate pharmacokinetics outputs
try:
outputs = pkoutputs_from_timecourse(subset)
@@ -159,13 +153,12 @@ def create_scatter(self, dimensions, shared, subset_instance):
x_data = shared_data[shared_data["dimension"] == 0]
y_data = shared_data[shared_data["dimension"] == 1]
-
if len(x_data) != 1 or len(y_data) != 1:
raise serializers.ValidationError(
- f"Dimensions <{dimensions}> do not match in respect to the shared fields."
- f"The shared field <{shared}> with values <{shared_values}>"
- f" do not uniquely assign 1 x output to 1 y output. "
- f"<{dimensions[0]}> has <{len(x_data)}> outputs. <{dimensions[1]}> has <{len(y_data)}> outputs."
+ f"Dimensions <{dimensions}> do not match in respect to the shared fields."
+ f"The shared field <{shared}> with values <{shared_values}>"
+ f" do not uniquely assign 1 x output to 1 y output. "
+ f"<{dimensions[0]}> has <{len(x_data)}> outputs. <{dimensions[1]}> has <{len(y_data)}> outputs."
)
data_point_instance = DataPoint.objects.create(subset=subset_instance)
x_output = study_outputs.get(pk=x_data["id"])
@@ -261,8 +254,6 @@ def create(self, validated_data):
create_multiple_keys=['comments', 'descriptions'])
return data_instance
-
-
class DataSetSerializer(ExSerializer):
data = DataSerializer(many=True, read_only=False, required=False, allow_null=True)
diff --git a/backend/pkdb_app/outputs/pk_calculation.py b/backend/pkdb_app/outputs/pk_calculation.py
index 0b0b31ea..ce4d9b45 100644
--- a/backend/pkdb_app/outputs/pk_calculation.py
+++ b/backend/pkdb_app/outputs/pk_calculation.py
@@ -2,13 +2,16 @@
Calculate pharmacokinetics
"""
from typing import List, Dict
+from rest_framework import serializers
+import logging
import warnings
import numpy as np
-import pandas as pd
from django.apps import apps
from pkdb_app.info_nodes.units import ureg
from pkdb_analysis.pk import pharmacokinetics
+logger = logging.getLogger(__name__)
+
MeasurementType = apps.get_model('info_nodes.MeasurementType')
Substance = apps.get_model('info_nodes.Substance')
Method = apps.get_model('info_nodes.Method')
@@ -28,28 +31,24 @@ def pkoutputs_from_timecourse(subset:Subset) -> List[Dict]:
"""
outputs = []
dosing = subset.get_single_dosing()
+ # dosing information must exist
if not dosing:
- # dosing information must exist
return outputs
+
# pharmacokinetics are only calculated on normalized concentrations
timecourse = subset.timecourse()
-
-
- if timecourse["measurement_type_name"] == "concentration":
-
+ if timecourse["measurement_type_name"] == "concentration":
variables = _timecourse_to_pkdict(timecourse, dosing)
ctype = variables.pop("ctype", None)
+
if dosing.application.info_node.name == "single dose" and timecourse["substance"] == dosing.substance.pk:
pkinf = pharmacokinetics.TimecoursePK(**variables)
-
else:
_ = variables.pop("dosing", None)
_ = variables.pop("intervention_time", None)
pkinf = pharmacokinetics.TimecoursePKNoDosing(**variables)
-
-
pk = pkinf.pk
key_mapping = {
From 64d4629162430fca997f3ae9e9fd918010c0ad9d Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Fri, 11 Sep 2020 11:28:40 +0200
Subject: [PATCH 080/207] fixes #582
---
backend/pkdb_app/info_nodes/models.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/backend/pkdb_app/info_nodes/models.py b/backend/pkdb_app/info_nodes/models.py
index 5b645a5e..fdcae814 100644
--- a/backend/pkdb_app/info_nodes/models.py
+++ b/backend/pkdb_app/info_nodes/models.py
@@ -2,6 +2,7 @@
Model for the InfoNodes.
"""
+import re
from numbers import Number
import pint
@@ -209,6 +210,11 @@ def p_unit(unit):
raise ValueError(f"unit [{unit}] is not defined in unit registry or not allowed.")
def is_valid_unit(self, unit):
+ if not re.match("^[\/^.[:space:]*a-zA-Z0-9]*$", unit):
+ msg = f"Characters used in unit field are not allowed. " \
+ f"Allowed special characters are '[\/^.[:space:]]' allowed normal characters are '[a-zA-Z0-9]'."
+ raise ValueError(
+ {"unit": msg})
try:
p_unit = self.p_unit(unit)
From 086f3c04fcaae24bbc8fa6ad96236b0d6cafdf29 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Fri, 11 Sep 2020 12:15:20 +0200
Subject: [PATCH 081/207] clsoes #586
---
backend/pkdb_app/studies/serializers.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/backend/pkdb_app/studies/serializers.py b/backend/pkdb_app/studies/serializers.py
index df05d828..f7559367 100644
--- a/backend/pkdb_app/studies/serializers.py
+++ b/backend/pkdb_app/studies/serializers.py
@@ -43,6 +43,10 @@ def to_internal_value(self, data):
self.validate_wrong_keys(data)
return super().to_internal_value(data)
+ def validate(self, attrs):
+ if ((attrs.get("first_name") =="Max") and (attrs.get("last_name") == "Musterman")):
+ raise serializers.ValidationError("Replace 'Max Musternamn' with th correct author in ")
+
class ReferenceSerializer(WrongKeyValidationSerializer):
authors = AuthorSerializer(many=True, read_only=False)
@@ -81,6 +85,13 @@ def to_internal_value(self, data):
self.validate_wrong_keys(data)
return super().to_internal_value(data)
+ def validate(self, attrs):
+ if ((attrs.get("journal") == "Add your title")):
+ raise serializers.ValidationError("Add a journal to .")
+ if ((attrs.get("title") == "Add your title ")):
+ raise serializers.ValidationError("Add a title to .")
+ if ((attrs.get("date") == "1000-10-10")):
+ raise serializers.ValidationError("Replace '1000-10-10' with the correct date in .")
class CuratorRatingSerializer(serializers.ModelSerializer):
rating = serializers.FloatField(min_value=0, max_value=5)
From 6ee768b98650c82535b72898d0a2c0f10611097f Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Fri, 11 Sep 2020 13:31:56 +0200
Subject: [PATCH 082/207] wokring on validation
---
backend/pkdb_app/info_nodes/models.py | 10 +++++-----
backend/pkdb_app/studies/serializers.py | 3 +++
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/backend/pkdb_app/info_nodes/models.py b/backend/pkdb_app/info_nodes/models.py
index e08e1d0d..c418c501 100644
--- a/backend/pkdb_app/info_nodes/models.py
+++ b/backend/pkdb_app/info_nodes/models.py
@@ -207,11 +207,11 @@ def p_unit(unit):
raise ValueError(f"unit [{unit}] is not defined in unit registry or not allowed.")
def is_valid_unit(self, unit):
- if not re.match("^[\/^.[:space:]*a-zA-Z0-9]*$", unit):
- msg = f"Characters used in unit field are not allowed. " \
- f"Allowed special characters are '[\/^.[:space:]]' allowed normal characters are '[a-zA-Z0-9]'."
- raise ValueError(
- {"unit": msg})
+ #if not re.match("[ \/\^\.[:space:]\*a-zA-Z0-9_$ ]", str(unit)):
+ #if not re.match("^[\/α-ωΑ-Ωa-zA-Z0-9]*$", unit.decode("utf-8", "strict")):
+ # msg = f"Unit value <{str(unit)}> contains not allowed characters. " \
+ # f"Allowed special characters are '[/^.[:space:]]' allowed normal characters are '[a-zA-Z0-9]'."
+ # raise ValueError({"unit": msg})
try:
p_unit = self.p_unit(unit)
diff --git a/backend/pkdb_app/studies/serializers.py b/backend/pkdb_app/studies/serializers.py
index f7559367..7ae93f14 100644
--- a/backend/pkdb_app/studies/serializers.py
+++ b/backend/pkdb_app/studies/serializers.py
@@ -46,6 +46,7 @@ def to_internal_value(self, data):
def validate(self, attrs):
if ((attrs.get("first_name") =="Max") and (attrs.get("last_name") == "Musterman")):
raise serializers.ValidationError("Replace 'Max Musternamn' with th correct author in ")
+ return super().validate(attrs)
class ReferenceSerializer(WrongKeyValidationSerializer):
@@ -92,6 +93,8 @@ def validate(self, attrs):
raise serializers.ValidationError("Add a title to .")
if ((attrs.get("date") == "1000-10-10")):
raise serializers.ValidationError("Replace '1000-10-10' with the correct date in .")
+ return super().validate(attrs)
+
class CuratorRatingSerializer(serializers.ModelSerializer):
rating = serializers.FloatField(min_value=0, max_value=5)
From f7f5a0fa87702024a2c9ff53a3912d443807b620 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Fri, 11 Sep 2020 14:54:05 +0200
Subject: [PATCH 083/207] , in units
---
backend/pkdb_app/info_nodes/models.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/backend/pkdb_app/info_nodes/models.py b/backend/pkdb_app/info_nodes/models.py
index c418c501..41827352 100644
--- a/backend/pkdb_app/info_nodes/models.py
+++ b/backend/pkdb_app/info_nodes/models.py
@@ -6,12 +6,14 @@
import pint
from django.db import models
+from django.utils.encoding import smart_str
from django.utils.translation import gettext_lazy as _
from pint import UndefinedUnitError
from pkdb_app.behaviours import Sidable
from pkdb_app.info_nodes.units import ureg
from pkdb_app.utils import CHAR_MAX_LENGTH, CHAR_MAX_LENGTH_LONG, _validate_required_key
+from rest_framework import serializers
class Annotation(models.Model):
@@ -208,16 +210,17 @@ def p_unit(unit):
def is_valid_unit(self, unit):
#if not re.match("[ \/\^\.[:space:]\*a-zA-Z0-9_$ ]", str(unit)):
- #if not re.match("^[\/α-ωΑ-Ωa-zA-Z0-9]*$", unit.decode("utf-8", "strict")):
- # msg = f"Unit value <{str(unit)}> contains not allowed characters. " \
- # f"Allowed special characters are '[/^.[:space:]]' allowed normal characters are '[a-zA-Z0-9]'."
- # raise ValueError({"unit": msg})
+
+ if not re.match("^[\/^. µα-ωΑ-Ωa-zA-Z0-9]*$", str(unit)):
+ msg = f"Unit value <{unit}> contains not allowed characters. " \
+ f"Allowed characters are '[\/^. µα-ωΑ-Ωa-zA-Z0-9]'."
+ raise serializers.ValidationError({"unit":msg})
try:
p_unit = self.p_unit(unit)
except pint.DefinitionSyntaxError:
msg = f"The unit [{unit}] has a wrong syntax."
- raise ValueError(
+ raise serializers.ValidationError(
{"unit": msg})
if len(self.n_units) != 0:
From 42083766aab19c6d10a433e46b2fee08710e7e77 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Fri, 11 Sep 2020 15:23:48 +0200
Subject: [PATCH 084/207] cleanup
---
backend/pkdb_app/info_nodes/models.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/backend/pkdb_app/info_nodes/models.py b/backend/pkdb_app/info_nodes/models.py
index 41827352..c662e686 100644
--- a/backend/pkdb_app/info_nodes/models.py
+++ b/backend/pkdb_app/info_nodes/models.py
@@ -6,7 +6,6 @@
import pint
from django.db import models
-from django.utils.encoding import smart_str
from django.utils.translation import gettext_lazy as _
from pint import UndefinedUnitError
From d2e2201ac75a3325813360978b5bf0849736232f Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Fri, 11 Sep 2020 16:05:12 +0200
Subject: [PATCH 085/207] closes 580
---
backend/pkdb_app/studies/models.py | 2 +-
backend/pkdb_app/studies/serializers.py | 14 ++++++++------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/backend/pkdb_app/studies/models.py b/backend/pkdb_app/studies/models.py
index 5e9c1fcb..cc8e9016 100644
--- a/backend/pkdb_app/studies/models.py
+++ b/backend/pkdb_app/studies/models.py
@@ -113,7 +113,7 @@ class Study(Sidable, models.Model):
)
licence = models.CharField(max_length=CHAR_MAX_LENGTH, null=True, choices=STUDY_LICENCE_CHOICES)
creator = models.ForeignKey(
- User, related_name="creator_of_studies", on_delete=models.CASCADE, null=True
+ User, related_name="creator_of_studies", on_delete=models.CASCADE
)
curators = models.ManyToManyField(
User, related_name="curator_of_studies", through=Rating
diff --git a/backend/pkdb_app/studies/serializers.py b/backend/pkdb_app/studies/serializers.py
index 7ae93f14..58174ad1 100644
--- a/backend/pkdb_app/studies/serializers.py
+++ b/backend/pkdb_app/studies/serializers.py
@@ -121,8 +121,7 @@ class StudySerializer(SidSerializer):
queryset=Reference.objects.all(), required=True, allow_null=False
)
groupset = GroupSetSerializer(read_only=False, required=False, allow_null=True)
- curators = CuratorRatingSerializer(many=True, required=False,
- allow_null=True)
+ curators = CuratorRatingSerializer(many=True)
collaborators = utils.SlugRelatedField(
queryset=User.objects.all(),
slug_field="username",
@@ -133,8 +132,6 @@ class StudySerializer(SidSerializer):
creator = utils.SlugRelatedField(
queryset=User.objects.all(),
slug_field="username",
- required=False,
- allow_null=True,
)
descriptions = DescriptionSerializer(
many=True, read_only=False, required=False, allow_null=True
@@ -188,7 +185,12 @@ def to_internal_value(self, data):
data["creator"] = self.get_or_val_error(User, username=creator)
# curators to internal
- if "curators" in data:
+ if hasattr(data,"curators"):
+ if len(data.get("curators",[])) == 0:
+ raise serializers.ValidationError(
+ {"curators": "At least One curator is required"}
+ )
+ else:
ratings = []
for curator_and_rating in data.get("curators", []):
rating_dict = {}
@@ -407,7 +409,7 @@ def validate(self, attrs):
if "curators" in attrs and "creator" in attrs:
if attrs["creator"] not in [curator["user"] for curator in attrs["curators"]]:
- error_json = {"creator": "Creator must be in curator."}
+ error_json = {"curators": "Creator must be in curators."}
raise serializers.ValidationError(error_json)
return super().validate(attrs)
From 1e8e3419464987791d9ea8ad82e9877f7edf92b4 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Fri, 11 Sep 2020 20:23:53 +0200
Subject: [PATCH 086/207] closes #579
---
backend/pkdb_app/info_nodes/models.py | 7 ++++---
backend/pkdb_app/utils.py | 9 ++++++++-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/backend/pkdb_app/info_nodes/models.py b/backend/pkdb_app/info_nodes/models.py
index c662e686..786721d9 100644
--- a/backend/pkdb_app/info_nodes/models.py
+++ b/backend/pkdb_app/info_nodes/models.py
@@ -11,7 +11,8 @@
from pkdb_app.behaviours import Sidable
from pkdb_app.info_nodes.units import ureg
-from pkdb_app.utils import CHAR_MAX_LENGTH, CHAR_MAX_LENGTH_LONG, _validate_required_key
+from pkdb_app.utils import CHAR_MAX_LENGTH, CHAR_MAX_LENGTH_LONG, _validate_required_key, \
+ _validate_required_key_and_value
from rest_framework import serializers
@@ -350,8 +351,8 @@ def validate_complete(self, data):
if self.time_required:
details = f"for measurement type `{self.info_node.name}`"
- _validate_required_key(data, "time", details=details)
- _validate_required_key(data, "time_unit", details=details)
+ _validate_required_key_and_value(data, "time", details=details)
+ _validate_required_key_and_value(data, "time_unit", details=details)
return {"choice":d_choice}
diff --git a/backend/pkdb_app/utils.py b/backend/pkdb_app/utils.py
index 9009cf8e..2ba498f3 100644
--- a/backend/pkdb_app/utils.py
+++ b/backend/pkdb_app/utils.py
@@ -3,7 +3,7 @@
"""
import copy
import os
-
+import pandas as pd
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
@@ -196,6 +196,13 @@ def set_keys(d, value, *keys):
d = d[key]
d[keys[-1]] = value
+def _validate_required_key_and_value(attrs, key, details=None, extra_message: str = ""):
+ print(attrs.get(key,None))
+ if pd.isnull(attrs.get(key,None)) or pd.isna(attrs.get(key,None)):
+ error_json = {key: f"The key <{key}> is required. {extra_message}"}
+ if details:
+ error_json["details"] = details
+ raise serializers.ValidationError(error_json)
def _validate_required_key(attrs, key, details=None, extra_message: str = ""):
if key not in attrs:
From bd2fb83d7f5de2055ab60c7f1399607f8faca415 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Fri, 11 Sep 2020 20:28:04 +0200
Subject: [PATCH 087/207] closes #560
---
backend/pkdb_app/interventions/serializers.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/backend/pkdb_app/interventions/serializers.py b/backend/pkdb_app/interventions/serializers.py
index ffb7d5f8..4f31c844 100644
--- a/backend/pkdb_app/interventions/serializers.py
+++ b/backend/pkdb_app/interventions/serializers.py
@@ -26,7 +26,7 @@
# Serializer FIELDS
# ----------------------------------
from ..utils import list_of_pk, list_duplicates, _validate_required_key, _create, create_multiple_bulk, \
- create_multiple_bulk_normalized
+ create_multiple_bulk_normalized, _validate_required_key_and_value
MEDICATION = "medication"
DOSING = "dosing"
@@ -85,16 +85,16 @@ def to_internal_value(self, data):
measurement_type = data.get("measurement_type")
if any([measurement_type == MEDICATION, measurement_type == DOSING]):
- _validate_required_key(data, "substance")
- _validate_required_key(data, "route")
- _validate_required_key(data, "value")
- _validate_required_key(data, "unit")
+ _validate_required_key_and_value(data, "substance")
+ _validate_required_key_and_value(data, "route")
+ _validate_required_key_and_value(data, "value")
+ _validate_required_key_and_value(data, "unit")
if measurement_type == DOSING:
- _validate_required_key(data, "form")
- _validate_required_key(data, "application")
- _validate_required_key(data, "time")
- _validate_required_key(data, "time_unit")
+ _validate_required_key_and_value(data, "form")
+ _validate_required_key_and_value(data, "application")
+ _validate_required_key_and_value(data, "time")
+ _validate_required_key_and_value(data, "time_unit")
application = data["application"]
allowed_applications = ["constant infusion", "single dose"]
if not application in allowed_applications:
From 32ef1d9d06a5a7955bf7ef9c84838a92861c79a2 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Mon, 14 Sep 2020 11:48:58 +0200
Subject: [PATCH 088/207] bad display of container
---
backend/pkdb_app/documents.py | 3 +-
.../src/components/detail/FileImageView.vue | 59 +++++++++----------
.../src/components/detail/StudyOverview.vue | 18 +-----
3 files changed, 33 insertions(+), 47 deletions(-)
diff --git a/backend/pkdb_app/documents.py b/backend/pkdb_app/documents.py
index d8ccd648..d66c34c9 100644
--- a/backend/pkdb_app/documents.py
+++ b/backend/pkdb_app/documents.py
@@ -13,7 +13,8 @@
elastic_settings = {
'number_of_shards': 1,
'number_of_replicas': 1,
- 'max_ngram_diff': 15
+ 'max_ngram_diff': 15,
+ 'max_terms_count':65536*4,
}
edge_ngram_filter = token_filter(
diff --git a/frontend/src/components/detail/FileImageView.vue b/frontend/src/components/detail/FileImageView.vue
index 8ae75d8e..88eead22 100644
--- a/frontend/src/components/detail/FileImageView.vue
+++ b/frontend/src/components/detail/FileImageView.vue
@@ -1,33 +1,36 @@
+
-
- {{ id_from_name(item.name) }}
-
-
-
-
-
-
-
-
-
-
+ v-model="active"
+ show-arrows
+ color="#999999"
+ dark
+ slider-size ="width"
+ >
+
+ {{ id_from_name(item.name) }}
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/frontend/src/components/detail/StudyOverview.vue b/frontend/src/components/detail/StudyOverview.vue
index 9f88e1d0..41c8e93d 100644
--- a/frontend/src/components/detail/StudyOverview.vue
+++ b/frontend/src/components/detail/StudyOverview.vue
@@ -1,6 +1,5 @@
-
-
+
@@ -91,20 +90,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/frontend/src/components/search/SearchNavigation.vue b/frontend/src/components/search/SearchNavigation.vue
index e94f1ab4..319db7e5 100644
--- a/frontend/src/components/search/SearchNavigation.vue
+++ b/frontend/src/components/search/SearchNavigation.vue
@@ -8,12 +8,17 @@
dark
mini-variant-width="40"
width="420"
+ height="100%"
>
{{ faIcon('search') }}
+
+
+
+
-
-
+
+
+
{{faIcon("studies")}}
@@ -120,7 +129,8 @@
-
+
+
@@ -140,12 +150,14 @@ import SearchHelp from "../search/SearchHelp";
import StudyOverview from "../detail/StudyOverview";
import {searchTableMixin} from "../tables/mixins";
import {SearchMixin} from "../../search";
+import ConciseCheckBox from "./ConciseCheckBox";
export default {
mixins: [searchTableMixin, SearchMixin],
name: "SearchNavigation",
components: {
+ ConciseCheckBox,
CountBadge,
StudyOverview,
SearchHelp,
@@ -264,4 +276,5 @@ export default {
\ No newline at end of file
diff --git a/frontend/src/search.js b/frontend/src/search.js
index 50168697..80c3ad39 100644
--- a/frontend/src/search.js
+++ b/frontend/src/search.js
@@ -105,6 +105,9 @@ let SearchMixin = {
url = url + "&" + "studies__licence__in=" + [...licence__in].join("__")
}
}
+ if(!this.$store.state.concise){
+ url = url + "&" + "concise=false"
+ }
return url
},
},
diff --git a/frontend/src/store.js b/frontend/src/store.js
index 0ff4fd51..8bd36114 100644
--- a/frontend/src/store.js
+++ b/frontend/src/store.js
@@ -36,7 +36,9 @@ const vuexLocalStorage = new VuexPersist({
});
// Initial search values
+const initial_concise = true
const initial_queries = {
+
//studies
studies__sid__in: [],
@@ -97,6 +99,7 @@ export default new Vuex.Store({
data_info_type: "study",
// search queries
+ concise: initial_concise,
queries: initial_queries,
licence_boolean:initial_licence_boolean,
subjects_boolean: initial_subjects_boolean,
@@ -156,6 +159,7 @@ export default new Vuex.Store({
},
mutations: {
resetQuery(state){
+ Object.assign(state.concise, initial_concise)
Object.assign(state.queries, initial_queries)
Object.assign(state.subjects_boolean, initial_subjects_boolean)
Object.assign(state.subjects_queries, initial_subjects_queries)
From 34b96767d5cfb94219b77b8e17bbc23fe9ab8d4b Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 16 Sep 2020 15:42:09 +0200
Subject: [PATCH 097/207] study links not concise data
---
frontend/src/components/Data.vue | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/frontend/src/components/Data.vue b/frontend/src/components/Data.vue
index 4cf4877b..3b09be4f 100644
--- a/frontend/src/components/Data.vue
+++ b/frontend/src/components/Data.vue
@@ -78,7 +78,11 @@ export default {
"key": "studies__sid__in",
"value": [study_info]}
this.update_store(study)
- },
+
+ this.$store.dispatch('updateAction', {
+ "key": "concise",
+ "value": false})
+ },
reset() {
this.$store.commit('resetQuery');
},
From 87d6c8d3186240b07dd41a197192bb4fe043ac32 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 16 Sep 2020 17:23:29 +0200
Subject: [PATCH 098/207] refactoring
---
.../lib/buttons/ClearSearchButton.vue | 25 +++++
.../components/lib/buttons/DownloadButton.vue | 41 +++++++
.../lib/buttons/SearchHelpButton.vue | 32 ++++++
.../components/search/SearchNavigation.vue | 101 ++++--------------
frontend/src/storeInteraction.js | 54 ++++++++++
5 files changed, 171 insertions(+), 82 deletions(-)
create mode 100644 frontend/src/components/lib/buttons/ClearSearchButton.vue
create mode 100644 frontend/src/components/lib/buttons/DownloadButton.vue
create mode 100644 frontend/src/components/lib/buttons/SearchHelpButton.vue
create mode 100644 frontend/src/storeInteraction.js
diff --git a/frontend/src/components/lib/buttons/ClearSearchButton.vue b/frontend/src/components/lib/buttons/ClearSearchButton.vue
new file mode 100644
index 00000000..e8be98c0
--- /dev/null
+++ b/frontend/src/components/lib/buttons/ClearSearchButton.vue
@@ -0,0 +1,25 @@
+
+
+ fas fa fa-trash-alt
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/components/lib/buttons/DownloadButton.vue b/frontend/src/components/lib/buttons/DownloadButton.vue
new file mode 100644
index 00000000..e3a0729d
--- /dev/null
+++ b/frontend/src/components/lib/buttons/DownloadButton.vue
@@ -0,0 +1,41 @@
+
+
+
+ {{ faIcon('download') }}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/components/lib/buttons/SearchHelpButton.vue b/frontend/src/components/lib/buttons/SearchHelpButton.vue
new file mode 100644
index 00000000..e97847fb
--- /dev/null
+++ b/frontend/src/components/lib/buttons/SearchHelpButton.vue
@@ -0,0 +1,32 @@
+
+
+ fas fa fa-question
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/components/search/SearchNavigation.vue b/frontend/src/components/search/SearchNavigation.vue
index 319db7e5..2274930e 100644
--- a/frontend/src/components/search/SearchNavigation.vue
+++ b/frontend/src/components/search/SearchNavigation.vue
@@ -14,46 +14,24 @@
{{ faIcon('search') }}
-
+
+
+
+
-
+
+
-
- {{ faIcon('download') }}
+
+
+
+
+
-
-
- fas fa fa-trash-alt
-
-
- fas fa fa-question
-
Date: Wed, 16 Sep 2020 17:30:45 +0200
Subject: [PATCH 099/207] refactoring
---
.../lib/buttons/HideSearchButton.vue | 27 +++++++++++
.../components/search/SearchNavigation.vue | 46 ++++++-------------
2 files changed, 41 insertions(+), 32 deletions(-)
create mode 100644 frontend/src/components/lib/buttons/HideSearchButton.vue
diff --git a/frontend/src/components/lib/buttons/HideSearchButton.vue b/frontend/src/components/lib/buttons/HideSearchButton.vue
new file mode 100644
index 00000000..6c3f27b8
--- /dev/null
+++ b/frontend/src/components/lib/buttons/HideSearchButton.vue
@@ -0,0 +1,27 @@
+
+
+ {{ faIcon("left_arrow") }}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/components/search/SearchNavigation.vue b/frontend/src/components/search/SearchNavigation.vue
index 2274930e..da1c821c 100644
--- a/frontend/src/components/search/SearchNavigation.vue
+++ b/frontend/src/components/search/SearchNavigation.vue
@@ -31,25 +31,11 @@
-
-
-
- {{ faIcon("left_arrow") }}
-
+
+
-
-
-
+
@@ -64,20 +50,17 @@
{{faIcon("groups")}}
-
- Groups
-
- |
- {{faIcon("individuals")}}
-
- Individuals
-
+
+ Groups
+
+ |
+ {{faIcon("individuals")}}
+
+ Individuals
+
-
+
{{faIcon("interventions")}}
@@ -133,11 +116,13 @@ import ClearSearchButton from "../lib/buttons/ClearSearchButton";
import DownloadButton from "../lib/buttons/DownloadButton";
import SearchHelpButton from "../lib/buttons/SearchHelpButton";
import {StoreInteractionMixin} from "../../storeInteraction";
+import HideSearchButton from "../lib/buttons/HideSearchButton";
export default {
mixins: [searchTableMixin, SearchMixin, StoreInteractionMixin],
name: "SearchNavigation",
components: {
+ HideSearchButton,
SearchHelpButton,
DownloadButton,
ClearSearchButton,
@@ -153,9 +138,6 @@ export default {
OutputForm,
},
methods: {
- reset() {
- this.$store.commit('resetQuery');
- },
update_subject_query(emitted_object) {
this.subject_queries = emitted_object;
},
From cb3d9e781214e6ff86443473aecab03383f3c9da Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 16 Sep 2020 21:23:30 +0200
Subject: [PATCH 100/207] refactoring
---
frontend/src/components/Data.vue | 34 ++-----------
.../src/components/search/ConciseCheckBox.vue | 16 ++----
.../components/search/SubjectSearchForm.vue | 39 ++-------------
frontend/src/storeInteraction.js | 49 +++++++++++++++++++
4 files changed, 58 insertions(+), 80 deletions(-)
diff --git a/frontend/src/components/Data.vue b/frontend/src/components/Data.vue
index 3b09be4f..21ff6d52 100644
--- a/frontend/src/components/Data.vue
+++ b/frontend/src/components/Data.vue
@@ -10,9 +10,11 @@
import TableTabs from './tables/TableTabs';
import SearchNavigation from './search/SearchNavigation'
import axios from 'axios'
+import {StoreInteractionMixin} from "../storeInteraction";
export default {
name: "Data",
+ mixins: [StoreInteractionMixin],
components: {
SearchNavigation,
TableTabs
@@ -25,17 +27,7 @@ export default {
sid(){
return this.$route.params.sid
},
- hide_search: {
- get() {
- return this.$store.state.hide_search
- },
- set(value) {
- this.$store.dispatch('updateAction', {
- key: "hide_search",
- value: value,
- })
- }
- },
+
},
created() {
if(this.sid){
@@ -72,27 +64,7 @@ export default {
})
.finally(() => this.loading = false);
},
- updateSearch(study_info) {
- let study = {
- "query_type": "queries",
- "key": "studies__sid__in",
- "value": [study_info]}
- this.update_store(study)
- this.$store.dispatch('updateAction', {
- "key": "concise",
- "value": false})
- },
- reset() {
- this.$store.commit('resetQuery');
- },
- update_store(q) {
- this.$store.dispatch('updateQueryAction', {
- query_type: q.query_type,
- key: q.key,
- value: q.value,
- })
- }
}}
diff --git a/frontend/src/components/search/ConciseCheckBox.vue b/frontend/src/components/search/ConciseCheckBox.vue
index cf7b290c..0a8b6340 100644
--- a/frontend/src/components/search/ConciseCheckBox.vue
+++ b/frontend/src/components/search/ConciseCheckBox.vue
@@ -10,21 +10,11 @@
>
diff --git a/frontend/src/components/search/SubjectSearchForm.vue b/frontend/src/components/search/SubjectSearchForm.vue
index 6c11151a..01ca50c9 100644
--- a/frontend/src/components/search/SubjectSearchForm.vue
+++ b/frontend/src/components/search/SubjectSearchForm.vue
@@ -13,49 +13,16 @@
\ No newline at end of file
diff --git a/frontend/src/storeInteraction.js b/frontend/src/storeInteraction.js
index f37aac10..564cbaa7 100644
--- a/frontend/src/storeInteraction.js
+++ b/frontend/src/storeInteraction.js
@@ -3,8 +3,57 @@ let StoreInteractionMixin = {
reset() {
this.$store.commit('resetQuery');
},
+ updateSearch(study_info) {
+ let study = {
+ "query_type": "queries",
+ "key": "studies__sid__in",
+ "value": [study_info]}
+ this.update_store(study)
+ this.concise = false
+ },
+
+ update_store(q) {
+ this.$store.dispatch('updateQueryAction', {
+ query_type: q.query_type,
+ key: q.key,
+ value: q.value,
+ })
+ }
},
computed: {
+ individuals_query: {
+ get(){
+ return this.$store.state.subjects_boolean.individuals_query
+ },
+ set (value) {
+ this.$store.dispatch('updateQueryAction', {
+ query_type: "subjects_boolean",
+ key: "individuals_query",
+ value: value, })
+ }
+ },
+ groups_query: {
+ get(){
+ return this.$store.state.subjects_boolean.groups_query
+ },
+ set (value) {
+ this.$store.dispatch('updateQueryAction', {
+ query_type: "subjects_boolean",
+ key: "groups_query",
+ value: value, })
+ },
+ },
+ concise: {
+ get(){
+ return this.$store.state.concise
+ },
+ set(value) {
+ this.$store.dispatch('updateAction', {
+ key: "concise",
+ value: value,
+ })
+ }
+ },
display_detail: {
get() {
return this.$store.state.display_detail
From d6771c34982b92e30daf035d521571f1934445a9 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 16 Sep 2020 21:44:04 +0200
Subject: [PATCH 101/207] further refactoring
---
frontend/src/components/Data.vue | 6 ++--
.../components/deprecated/ReferencesTable.vue | 2 +-
frontend/src/components/deprecated/Search.vue | 3 +-
.../components/detail/CharacteristicaCard.vue | 12 ++++----
.../src/components/detail/InfoNodeDetail.vue | 6 ++--
.../src/components/detail/StudyOverview.vue | 6 ++--
.../src/components/info_node/Annotation.vue | 9 +++---
frontend/src/components/info_node/Xref.vue | 9 ++----
frontend/src/components/lib/NodeElement.vue | 13 ++++-----
.../src/components/lib/buttons/LinkButton.vue | 28 +++++++++----------
.../src/components/tables/GroupsTable.vue | 4 +--
.../components/tables/IndividualsTable.vue | 4 +--
.../components/tables/InterventionsTable.vue | 4 +--
.../src/components/tables/OutputsTable.vue | 4 +--
.../src/components/tables/ScatterTable.vue | 4 +--
.../src/components/tables/StudiesTable.vue | 12 ++------
.../components/tables/TimecoursesTable.vue | 4 +--
frontend/src/storeInteraction.js | 11 ++++++++
18 files changed, 70 insertions(+), 71 deletions(-)
diff --git a/frontend/src/components/Data.vue b/frontend/src/components/Data.vue
index 21ff6d52..a1884f9f 100644
--- a/frontend/src/components/Data.vue
+++ b/frontend/src/components/Data.vue
@@ -50,9 +50,9 @@ export default {
.then(response => {
if(response.data.sid) {
this.updateSearch(response.data)
- this.$store.state.show_type = "study";
- this.$store.state.detail_info = response.data;
- this.$store.state.display_detail = true;
+ this.show_type = "study";
+ this.detail_info = response.data;
+ this.display_detail = true;
}else{
this.$route.push('/404')
}
diff --git a/frontend/src/components/deprecated/ReferencesTable.vue b/frontend/src/components/deprecated/ReferencesTable.vue
index 0e28c036..4b5747a0 100644
--- a/frontend/src/components/deprecated/ReferencesTable.vue
+++ b/frontend/src/components/deprecated/ReferencesTable.vue
@@ -14,7 +14,7 @@
:footer-props="footer_options"
>
-
import {lookupIcon} from "@/icons"
import axios from 'axios'
- import store from "../../store";
+ import {StoreInteractionMixin} from "../../storeInteraction";
+
export default {
name: "CharacteristicaCard",
+ mixins: [StoreInteractionMixin],
props: {
data: Object,
},
computed: {
search(){
- return store.state.highlight
+ return this.highlight
},
count() {
if (!this.data.count){
@@ -170,9 +172,9 @@
// get data (FIXME: caching of InfoNodes in store)
axios.get(url)
.then(response => {
- this.$store.state.show_type = "info_node";
- this.$store.state.detail_info = response.data;
- this.$store.state.display_detail = true;
+ this.show_type = "info_node";
+ this.detail_info = response.data;
+ this.display_detail = true;
})
.catch(err => {
this.exists = false;
diff --git a/frontend/src/components/detail/InfoNodeDetail.vue b/frontend/src/components/detail/InfoNodeDetail.vue
index dffdaf24..10e02536 100644
--- a/frontend/src/components/detail/InfoNodeDetail.vue
+++ b/frontend/src/components/detail/InfoNodeDetail.vue
@@ -75,9 +75,11 @@
import Annotation from "../info_node/Annotation";
import Xref from "../info_node/Xref";
+import {StoreInteractionMixin} from "../../storeInteraction";
export default {
name: 'InfoNodeDetail',
+ mixins: [StoreInteractionMixin],
components: {
Annotation,
Xref,
@@ -93,9 +95,7 @@ export default {
}
},
computed: {
- highlight(){
- return this.$store.state.highlight
- },
+
parents_labels: function () {
let labels = []
let parents = this.data.parents
diff --git a/frontend/src/components/detail/StudyOverview.vue b/frontend/src/components/detail/StudyOverview.vue
index 41c8e93d..905668c3 100644
--- a/frontend/src/components/detail/StudyOverview.vue
+++ b/frontend/src/components/detail/StudyOverview.vue
@@ -98,6 +98,7 @@
import ReferenceDetail from "./ReferenceDetail"
import FileImageView from "./FileImageView"
import {UrlMixin} from "../tables/mixins";
+ import {StoreInteractionMixin} from "../../storeInteraction";
export default {
name: "StudyOverview",
@@ -111,12 +112,9 @@
required: true,
}
},
- mixins: [UrlMixin],
+ mixins: [UrlMixin, StoreInteractionMixin],
computed: {
- highlight(){
- return this.$store.state.highlight
- },
images() {
let list = [];
for (let k = 0; k < this.study.files.length; k++) {
diff --git a/frontend/src/components/info_node/Annotation.vue b/frontend/src/components/info_node/Annotation.vue
index 361c100e..3ebe2448 100644
--- a/frontend/src/components/info_node/Annotation.vue
+++ b/frontend/src/components/info_node/Annotation.vue
@@ -22,20 +22,19 @@
diff --git a/frontend/src/components/info_node/Xref.vue b/frontend/src/components/info_node/Xref.vue
index ab066151..9e0719d9 100644
--- a/frontend/src/components/info_node/Xref.vue
+++ b/frontend/src/components/info_node/Xref.vue
@@ -14,8 +14,11 @@
diff --git a/frontend/src/components/lib/NodeElement.vue b/frontend/src/components/lib/NodeElement.vue
index ff5d5736..faab748d 100644
--- a/frontend/src/components/lib/NodeElement.vue
+++ b/frontend/src/components/lib/NodeElement.vue
@@ -9,9 +9,12 @@
diff --git a/frontend/src/components/lib/buttons/LinkButton.vue b/frontend/src/components/lib/buttons/LinkButton.vue
index c36f5e20..8b41e09c 100644
--- a/frontend/src/components/lib/buttons/LinkButton.vue
+++ b/frontend/src/components/lib/buttons/LinkButton.vue
@@ -15,13 +15,15 @@
diff --git a/frontend/src/components/tables/GroupsTable.vue b/frontend/src/components/tables/GroupsTable.vue
index cc5d96f9..24560421 100644
--- a/frontend/src/components/tables/GroupsTable.vue
+++ b/frontend/src/components/tables/GroupsTable.vue
@@ -16,9 +16,9 @@
:footer-props="footer_options"
>
-
diff --git a/frontend/src/components/tables/IndividualsTable.vue b/frontend/src/components/tables/IndividualsTable.vue
index 467021cd..9b98a440 100644
--- a/frontend/src/components/tables/IndividualsTable.vue
+++ b/frontend/src/components/tables/IndividualsTable.vue
@@ -15,9 +15,9 @@
>
-
diff --git a/frontend/src/components/tables/InterventionsTable.vue b/frontend/src/components/tables/InterventionsTable.vue
index f0f4115c..d0210283 100644
--- a/frontend/src/components/tables/InterventionsTable.vue
+++ b/frontend/src/components/tables/InterventionsTable.vue
@@ -14,9 +14,9 @@
:footer-props="footer_options"
>
-
diff --git a/frontend/src/components/tables/OutputsTable.vue b/frontend/src/components/tables/OutputsTable.vue
index 20ea4c06..2fd6c372 100644
--- a/frontend/src/components/tables/OutputsTable.vue
+++ b/frontend/src/components/tables/OutputsTable.vue
@@ -14,9 +14,9 @@
:footer-props="footer_options"
>
-
diff --git a/frontend/src/components/tables/ScatterTable.vue b/frontend/src/components/tables/ScatterTable.vue
index 1149bf87..cc205e0e 100644
--- a/frontend/src/components/tables/ScatterTable.vue
+++ b/frontend/src/components/tables/ScatterTable.vue
@@ -14,9 +14,9 @@
:footer-props="footer_options"
>
-
diff --git a/frontend/src/components/tables/StudiesTable.vue b/frontend/src/components/tables/StudiesTable.vue
index afd8a8c7..7e4fe8c4 100644
--- a/frontend/src/components/tables/StudiesTable.vue
+++ b/frontend/src/components/tables/StudiesTable.vue
@@ -16,8 +16,8 @@
:footer-props="footer_options"
>
-
@@ -39,13 +39,7 @@
-
+
{{ item.reference.title }}
diff --git a/frontend/src/components/tables/TimecoursesTable.vue b/frontend/src/components/tables/TimecoursesTable.vue
index b12cd7e9..8d400d2a 100644
--- a/frontend/src/components/tables/TimecoursesTable.vue
+++ b/frontend/src/components/tables/TimecoursesTable.vue
@@ -14,9 +14,9 @@
:footer-props="footer_options"
>
-
diff --git a/frontend/src/storeInteraction.js b/frontend/src/storeInteraction.js
index 564cbaa7..52a94391 100644
--- a/frontend/src/storeInteraction.js
+++ b/frontend/src/storeInteraction.js
@@ -76,6 +76,17 @@ let StoreInteractionMixin = {
})
}
},
+ highlight: {
+ get() {
+ return this.$store.state.highlight
+ },
+ set(value) {
+ this.$store.dispatch('updateAction', {
+ key: "highlight",
+ value: value,
+ })
+ }
+ },
detail_info: {
get() {
return this.$store.state.detail_info
From 20676af7ee49b706aea8e1abe72ffd6139223f34 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 16 Sep 2020 21:52:29 +0200
Subject: [PATCH 102/207] further refactoring
---
frontend/src/apiInteraction.js | 35 +++++++++++++++++++++++++++++++
frontend/src/components/Data.vue | 36 +++-----------------------------
2 files changed, 38 insertions(+), 33 deletions(-)
create mode 100644 frontend/src/apiInteraction.js
diff --git a/frontend/src/apiInteraction.js b/frontend/src/apiInteraction.js
new file mode 100644
index 00000000..190fc4bc
--- /dev/null
+++ b/frontend/src/apiInteraction.js
@@ -0,0 +1,35 @@
+import axios from 'axios'
+import {StoreInteractionMixin} from "./storeInteraction";
+
+let ApiInteractionMixin = {
+ mixins: [StoreInteractionMixin],
+ methods: {
+ getStudy(sid) {
+ // object is an InfoNode
+ let url = `${this.$store.state.endpoints.api}studies/${sid}/?format=json`;
+ let headers = {};
+ if (localStorage.getItem('token')) {
+ headers = {Authorization: 'Token ' + localStorage.getItem('token')}
+ }
+ // get data (FIXME: caching of InfoNodes in store)
+ axios.get(url, {headers: headers})
+ .then(response => {
+ if (response.data.sid) {
+ this.updateSearch(response.data)
+ this.show_type = "study";
+ this.detail_info = response.data;
+ this.display_detail = true;
+ } else {
+ this.$route.push('/404')
+ }
+ })
+ .catch(err => {
+ this.exists = false;
+ this.$router.push('/404')
+ console.log(err)
+ })
+ .finally(() => this.loading = false);
+ },
+ }
+}
+export {ApiInteractionMixin}
\ No newline at end of file
diff --git a/frontend/src/components/Data.vue b/frontend/src/components/Data.vue
index a1884f9f..27d954fa 100644
--- a/frontend/src/components/Data.vue
+++ b/frontend/src/components/Data.vue
@@ -9,12 +9,11 @@
\ No newline at end of file
From 18530c3cdf4cb4ea944549c69b3a3b839cb67f35 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 16 Sep 2020 22:13:51 +0200
Subject: [PATCH 105/207] further refeactoring
---
frontend/src/components/{ => home}/About.vue | 0
.../components/{ => home}/CurationExample.vue | 0
.../components/home/CurationExampleImage.vue | 13 ++++++++++
.../lib/buttons/SingleStudyButton.vue | 25 +++++++++++++++++++
4 files changed, 38 insertions(+)
rename frontend/src/components/{ => home}/About.vue (100%)
rename frontend/src/components/{ => home}/CurationExample.vue (100%)
create mode 100644 frontend/src/components/home/CurationExampleImage.vue
create mode 100644 frontend/src/components/lib/buttons/SingleStudyButton.vue
diff --git a/frontend/src/components/About.vue b/frontend/src/components/home/About.vue
similarity index 100%
rename from frontend/src/components/About.vue
rename to frontend/src/components/home/About.vue
diff --git a/frontend/src/components/CurationExample.vue b/frontend/src/components/home/CurationExample.vue
similarity index 100%
rename from frontend/src/components/CurationExample.vue
rename to frontend/src/components/home/CurationExample.vue
diff --git a/frontend/src/components/home/CurationExampleImage.vue b/frontend/src/components/home/CurationExampleImage.vue
new file mode 100644
index 00000000..e76e6710
--- /dev/null
+++ b/frontend/src/components/home/CurationExampleImage.vue
@@ -0,0 +1,13 @@
+
+$END$
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/components/lib/buttons/SingleStudyButton.vue b/frontend/src/components/lib/buttons/SingleStudyButton.vue
new file mode 100644
index 00000000..817d6c94
--- /dev/null
+++ b/frontend/src/components/lib/buttons/SingleStudyButton.vue
@@ -0,0 +1,25 @@
+
+
+ {{ faIcon('data') }}
+ data
+
+
+
+
+
+
\ No newline at end of file
From 90d8d69e7710d5f193f2c68c50f4e10e7f1d6a1a Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 16 Sep 2020 22:41:10 +0200
Subject: [PATCH 106/207] further refactoring
---
frontend/src/apiInteraction.js | 24 ++++++-
frontend/src/components/Home.vue | 4 +-
.../src/components/home/CurationExample.vue | 40 +++---------
.../components/home/CurationExampleImage.vue | 19 +++++-
.../lib/buttons/SingleStudyButton.vue | 16 +++--
.../src/components/lib/chips/InfoNodeChip.vue | 36 +++++++++++
frontend/src/components/tables/CountTable.vue | 27 ++------
.../src/components/tables/InfoNodeTable.vue | 63 ++++++-------------
8 files changed, 124 insertions(+), 105 deletions(-)
create mode 100644 frontend/src/components/lib/chips/InfoNodeChip.vue
diff --git a/frontend/src/apiInteraction.js b/frontend/src/apiInteraction.js
index 190fc4bc..f4979ae0 100644
--- a/frontend/src/apiInteraction.js
+++ b/frontend/src/apiInteraction.js
@@ -3,6 +3,11 @@ import {StoreInteractionMixin} from "./storeInteraction";
let ApiInteractionMixin = {
mixins: [StoreInteractionMixin],
+ computed: {
+ api() {
+ return this.$store.state.endpoints.api;
+ },
+ },
methods: {
getStudy(sid) {
// object is an InfoNode
@@ -28,8 +33,25 @@ let ApiInteractionMixin = {
this.$router.push('/404')
console.log(err)
})
- .finally(() => this.loading = false);
+
},
+ fetch_data(url) {
+ let headers = {};
+ if (localStorage.getItem('token')) {
+ headers = {Authorization: 'Token ' + localStorage.getItem('token')}
+ }
+ // get data (FIXME: caching of InfoNodes in store)
+ axios.get(url, {headers: headers})
+ .then(response => {
+ this.data = response.data;
+ })
+ .catch((error) => {
+ this.data = null;
+ console.error(this.resource_url);
+ console.error(error);
+ })
+ }
+
}
}
export {ApiInteractionMixin}
\ No newline at end of file
diff --git a/frontend/src/components/Home.vue b/frontend/src/components/Home.vue
index 28492729..334678ff 100644
--- a/frontend/src/components/Home.vue
+++ b/frontend/src/components/Home.vue
@@ -62,9 +62,9 @@
-
-
\ No newline at end of file
diff --git a/frontend/src/components/home/CurationExampleImage.vue b/frontend/src/components/home/CurationExampleImage.vue
index e76e6710..38a51b1c 100644
--- a/frontend/src/components/home/CurationExampleImage.vue
+++ b/frontend/src/components/home/CurationExampleImage.vue
@@ -1,5 +1,14 @@
-$END$
+
+
+
+ RV Patwardhan, P V Desmond, R F Johnson, S Schenker
+
+
+ The Journal of Laboratory and clinical medicine, 1980-05-30
+
+
+
\ No newline at end of file
diff --git a/frontend/src/components/lib/buttons/SingleStudyButton.vue b/frontend/src/components/lib/buttons/SingleStudyButton.vue
index 817d6c94..d2314564 100644
--- a/frontend/src/components/lib/buttons/SingleStudyButton.vue
+++ b/frontend/src/components/lib/buttons/SingleStudyButton.vue
@@ -2,11 +2,11 @@
{{ faIcon('data') }}
- data
+ {{text}}
@@ -14,8 +14,14 @@
import {IconsMixin} from "../../../icons";
export default {
- name: "DataButton",
- mixins: [IconsMixin]
+ name: "SingleStudyButton",
+ mixins: [IconsMixin],
+ props: {
+ text: {
+ type:String,
+ default:"Example study"
+ },
+ }
}
diff --git a/frontend/src/components/lib/chips/InfoNodeChip.vue b/frontend/src/components/lib/chips/InfoNodeChip.vue
new file mode 100644
index 00000000..416440df
--- /dev/null
+++ b/frontend/src/components/lib/chips/InfoNodeChip.vue
@@ -0,0 +1,36 @@
+
+
+
+
+ {{ item.label }}
+
+
+ {{ item.label }} |
+ {{ item.name }}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/components/tables/CountTable.vue b/frontend/src/components/tables/CountTable.vue
index e3f17a8f..0e89879f 100644
--- a/frontend/src/components/tables/CountTable.vue
+++ b/frontend/src/components/tables/CountTable.vue
@@ -21,12 +21,12 @@
diff --git a/frontend/src/components/tables/InfoNodeTable.vue b/frontend/src/components/tables/InfoNodeTable.vue
index 78c1d530..a65e45cf 100644
--- a/frontend/src/components/tables/InfoNodeTable.vue
+++ b/frontend/src/components/tables/InfoNodeTable.vue
@@ -1,19 +1,7 @@
-
-
-
-
-
-
-
- {{ item.label }}
-
-
- {{ item.label }} |
- {{ item.name }}
-
-
+
- {{ item.ntype }}
+ {{ item.ntype }}
-
+
{{ item.dtype }}
- {{ item.description }}
+ {{ item.description }}
- - {{ synonym }}
+ - {{ synonym }}
@@ -74,11 +47,11 @@
>
- {{ parent.label }}
+ {{ parent.label }}
- {{ parent.label }} |
- {{ parent.name }}
+ {{ parent.label }} |
+ {{ parent.name }}
@@ -101,17 +74,17 @@
Choices
-
- {{ choice.label }}
+ {{ choice.label }}
- {{ choice.label }} |
- {{ choice.name }}
+ {{ choice.label }} |
+ {{ choice.name }}
@@ -120,17 +93,17 @@
- Mass: {{
+ Mass: {{
item.substance.mass
}}
Charge: {{ item.substance.charge }}
+ :queries="highlight.split(/[ ,]+/)">{{ item.substance.charge }}
Formula: {{ item.substance.formula }}
+ :queries="highlight.split(/[ ,]+/)">{{ item.substance.formula }}
@@ -159,20 +132,22 @@ import TableToolbar from '../tables/TableToolbar';
import NoData from '../tables/NoData';
import Annotation from "../info_node/Annotation";
import Xref from "../info_node/Xref";
+import InfoNodeChip from "../lib/chips/InfoNodeChip";
+import {StoreInteractionMixin} from "../../storeInteraction";
export default {
name: "InfoNodeTable",
components: {
+ InfoNodeChip,
NoData,
TableToolbar,
Annotation,
Xref,
},
- mixins: [searchTableMixin, UrlMixin],
+ mixins: [searchTableMixin, UrlMixin, StoreInteractionMixin],
data() {
return {
otype: "info_nodes",
- ntypes: ["all", "info_node", "choice", "measurement_type", "application", "tissue", "method", "route", "form", "substance"],
otype_single: "info_nodes",
headers: [
{text: '', value: 'buttons', sortable: false},
From 109fad93db3a4a602831fb2ef9847264dcef0245 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 16 Sep 2020 22:48:19 +0200
Subject: [PATCH 107/207] debug data single
---
frontend/src/apiInteraction.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/frontend/src/apiInteraction.js b/frontend/src/apiInteraction.js
index f4979ae0..7e9711f1 100644
--- a/frontend/src/apiInteraction.js
+++ b/frontend/src/apiInteraction.js
@@ -33,6 +33,8 @@ let ApiInteractionMixin = {
this.$router.push('/404')
console.log(err)
})
+ .finally(() => this.loading = false);
+
},
fetch_data(url) {
@@ -50,6 +52,7 @@ let ApiInteractionMixin = {
console.error(this.resource_url);
console.error(error);
})
+
}
}
From 9f62bacd75a4a9226a781540aabbf7c94e0c6f1d Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Thu, 17 Sep 2020 12:02:27 +0200
Subject: [PATCH 108/207] added api to docs
---
backend/pkdb_app/urls.py | 6 ++---
frontend/src/apiInteraction.js | 6 +++++
.../components/navigation/DropDownMenu.vue | 24 ++++++++++++++-----
.../src/components/navigation/Navigation.vue | 3 ---
frontend/src/store.js | 3 +++
5 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/backend/pkdb_app/urls.py b/backend/pkdb_app/urls.py
index b97e18f0..296b4b7d 100755
--- a/backend/pkdb_app/urls.py
+++ b/backend/pkdb_app/urls.py
@@ -129,7 +129,7 @@
path('verify/?P[-\w]+)', obtain_auth_token),
path('reset/?P[-\w]+)', obtain_auth_token),
- url(r'^swagger(?P\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
- url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
- url(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
+ url(r'^api/v1/swagger(?P\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
+ url(r'^api/v1/swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
+ url(r'^api/v1/redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]
\ No newline at end of file
diff --git a/frontend/src/apiInteraction.js b/frontend/src/apiInteraction.js
index 7e9711f1..0eae1c5f 100644
--- a/frontend/src/apiInteraction.js
+++ b/frontend/src/apiInteraction.js
@@ -7,6 +7,12 @@ let ApiInteractionMixin = {
api() {
return this.$store.state.endpoints.api;
},
+ api_swagger() {
+ return this.$store.state.endpoints.api_swagger;
+ },
+ api_redoc() {
+ return this.$store.state.endpoints.api_redoc;
+ },
},
methods: {
getStudy(sid) {
diff --git a/frontend/src/components/navigation/DropDownMenu.vue b/frontend/src/components/navigation/DropDownMenu.vue
index 2bb48fe6..51a75114 100644
--- a/frontend/src/components/navigation/DropDownMenu.vue
+++ b/frontend/src/components/navigation/DropDownMenu.vue
@@ -22,14 +22,28 @@
-
+
{{ faIcon('api') }}
API
-
+
+
+ {{ faIcon('api') }}
+
+ Swagger API
+
+
+
+
+
+ {{ faIcon('api') }}
+
+ Redoc API
+
+
@@ -58,18 +72,16 @@
diff --git a/frontend/src/components/navigation/Navigation.vue b/frontend/src/components/navigation/Navigation.vue
index 0a88d29b..fd1e085e 100644
--- a/frontend/src/components/navigation/Navigation.vue
+++ b/frontend/src/components/navigation/Navigation.vue
@@ -12,18 +12,49 @@
{{ faIcon('data') }}Data
+
+ {{ faIcon('curation') }}Info Nodes
+
-
+
+
+
+
{{ username }}
+
+
+
+
+
+
+
+ {{faIcon('account')}}
+
+
+ {{ faIcon('api') }}
+
+
+
+
+
-
+
@@ -32,6 +63,7 @@
import DropDownMenu from "./DropDownMenu";
import Account from "./Account";
import UserLogin from "../auth/UserLogin"
+ import {ApiInteractionMixin} from "../../apiInteraction";
export default {
name: 'Navigation',
@@ -40,15 +72,10 @@
Account,
DropDownMenu,
},
- mixins: [IconsMixin],
+ mixins: [IconsMixin, ApiInteractionMixin],
data: () => ({
dialog: false,
}),
- computed: {
- username(){
- return this.$store.state.username
- },
- }
}
From 4f255c5cf3266b9af69115dde44d184aa19daed4 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Thu, 24 Sep 2020 13:36:10 +0200
Subject: [PATCH 141/207] no button wrap
---
.../src/components/navigation/Navigation.vue | 49 ++++++++++++-------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/frontend/src/components/navigation/Navigation.vue b/frontend/src/components/navigation/Navigation.vue
index fd1e085e..a32425b4 100644
--- a/frontend/src/components/navigation/Navigation.vue
+++ b/frontend/src/components/navigation/Navigation.vue
@@ -20,38 +20,44 @@
-
-
+
-
+
+
+
@@ -80,9 +86,14 @@
\ No newline at end of file
From cb98fc0738bfdce84f35b4265c0d0578561bd020 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Thu, 24 Sep 2020 15:03:43 +0200
Subject: [PATCH 142/207] closes #640
---
backend/pkdb_app/subjects/serializers.py | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/backend/pkdb_app/subjects/serializers.py b/backend/pkdb_app/subjects/serializers.py
index aa47fdef..358b832e 100644
--- a/backend/pkdb_app/subjects/serializers.py
+++ b/backend/pkdb_app/subjects/serializers.py
@@ -87,7 +87,15 @@ def to_internal_value(self, data):
self.validate_wrong_keys(data, additional_fields=CharacteristicaExSerializer.Meta.fields)
return super(serializers.ModelSerializer, self).to_internal_value(data)
+ @staticmethod
+ def validate_count(count):
+ if count < 1:
+ raise serializers.ValidationError(f"count <{count}> has to be greater or equal to 1. ")
+ return count
+
+
def validate(self, attrs):
+
try:
# perform via dedicated function on categorials
for info_node in ['substance', 'measurement_type']:
@@ -141,8 +149,7 @@ def _validate_required_measurement_type(measurement_type, characteristica):
'details': characteristica}
)
@staticmethod
- def _validate_characteristica_count(characteristica, group_count):
-
+ def _validate_group_characteristica_count(characteristica, group_count):
if int(characteristica.get("count",group_count)) > int(group_count):
raise serializers.ValidationError(
{
@@ -154,6 +161,8 @@ def _validate_characteristica_count(characteristica, group_count):
}
)
+
+
def validate(self, attrs):
''' validates species information on group with name all
:param attrs:
@@ -167,7 +176,7 @@ def validate(self, attrs):
for characteristica_single in attrs.get('characteristica', []):
disabled = ['value']
self._validate_disabled_data(characteristica_single, disabled)
- self._validate_characteristica_count(characteristica_single, attrs.get("count"))
+ self._validate_group_characteristica_count(characteristica_single, attrs.get("count"))
return super().validate(attrs)
From bb72724659db2f7a7762f2e00a1ac4a8cc8b7179 Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Thu, 24 Sep 2020 15:05:22 +0200
Subject: [PATCH 143/207] fix navigation bar and smaller issues api
documentation
---
backend/pkdb_app/urls.py | 8 +-
.../src/components/navigation/Navigation.vue | 155 +++++++++---------
2 files changed, 81 insertions(+), 82 deletions(-)
diff --git a/backend/pkdb_app/urls.py b/backend/pkdb_app/urls.py
index 6246ba39..0b1ab483 100755
--- a/backend/pkdb_app/urls.py
+++ b/backend/pkdb_app/urls.py
@@ -96,14 +96,13 @@
path('api/v1/filter/', PKDataView.as_view()),
]
#router.register("pkdata", PKDataView, basename="pkdata")
-# FIXME: urls will not work !!!
+
schema_view = get_schema_view(
openapi.Info(
- title="PKDB API",
+ title="PK-DB REST API",
default_version='v1',
description="""
- ## Overview
- This is the REST API of PK-DB. The API provides web services for querying data from PKDB.
+ PK-DB provides web services based on REST to search, filter, retrieve and download data.
The data in PK-DB is structured based on **studies**, with a single study corresponding to a single source of information. In most cases such a study corresponds to a single publication or a single clinical trial.
@@ -131,7 +130,6 @@
terms_of_service="https://github.com/matthiaskoenig/pkdb/blob/develop/TERMS_OF_USE.md",
contact=openapi.Contact(email="koenigmx@hu-berlin.de", name="Matthias König"),
license=openapi.License(name="GNU Lesser General Public License v3 (LGPLv3)"),
- logo={"url": 'http://0.0.0.0:8081/assets/images/logo-PKDB.png', "altText": 'PKDB Logo'}
),
generator_class=CustomOpenAPISchemaGenerator,
public=False,
diff --git a/frontend/src/components/navigation/Navigation.vue b/frontend/src/components/navigation/Navigation.vue
index a32425b4..9a54610c 100644
--- a/frontend/src/components/navigation/Navigation.vue
+++ b/frontend/src/components/navigation/Navigation.vue
@@ -1,99 +1,100 @@
-
-
- PK-DB
+
+
+ PK-DB
-
-
- {{ faIcon('data') }}Data
-
-
- {{ faIcon('curation') }}Info Nodes
-
-
-
+
+
+ {{ faIcon('data') }}
+ Data
+
-
+
-
- {{ data.label }}
+ {{ data.label }}
+
+ {{ substance_class.toUpperCase() }}
+
+
Parents:
+
+
+
+
@@ -29,7 +43,7 @@
-
+
@@ -41,7 +55,7 @@
{{ annotation.description ? annotation.description: "" }}
-
+
@@ -95,6 +109,17 @@ export default {
}
},
computed: {
+ substance_class: function (){
+ let label = "generic";
+ let annotations = this.data.annotations
+ for (const annotation of annotations){
+ if (annotation.collection == "inchikey"){
+ label = "specific";
+ break;
+ }
+ }
+ return label
+ },
parents_labels: function () {
let labels = []
From c25fa8386b2cd5d722ee899a2e6fff74beb00692 Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Fri, 25 Sep 2020 00:02:23 +0200
Subject: [PATCH 153/207] proxy pass parameters for server
---
backend/pkdb_app/urls.py | 2 +-
nginx/pk-db.com | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/backend/pkdb_app/urls.py b/backend/pkdb_app/urls.py
index 6dd9e498..275f9671 100755
--- a/backend/pkdb_app/urls.py
+++ b/backend/pkdb_app/urls.py
@@ -157,5 +157,5 @@
url(r'^api/v1/swagger(?P\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
url(r'^api/v1/swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
- # url(r'^api/v1/redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
+ url(r'^api/v1/redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]
diff --git a/nginx/pk-db.com b/nginx/pk-db.com
index 9889bb13..c0e1f5c6 100644
--- a/nginx/pk-db.com
+++ b/nginx/pk-db.com
@@ -42,10 +42,10 @@ server {
location / {
# return 200 "ssl on proxy";
proxy_pass http://127.0.0.1:8888;
- # proxy_set_header HOST $host;
- # proxy_set_header X-Real-IP $remote_addr;
- # proxy_set_header X-Forwarded-for $remote_addr;
- # proxy_set_header X-Forwarded-Proto https;
- # port_in_redirect off;
+ proxy_set_header HOST $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-for $remote_addr;
+ proxy_set_header X-Forwarded-Proto https;
+ port_in_redirect off;
}
}
From f76efa3cfbcfacd31445492b0282453ceb7e31fe Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Fri, 25 Sep 2020 00:14:48 +0200
Subject: [PATCH 154/207] explicit IP configuration
---
nginx/pk-db.com | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nginx/pk-db.com b/nginx/pk-db.com
index c0e1f5c6..01efea5b 100644
--- a/nginx/pk-db.com
+++ b/nginx/pk-db.com
@@ -41,7 +41,7 @@ server {
location / {
# return 200 "ssl on proxy";
- proxy_pass http://127.0.0.1:8888;
+ proxy_pass http://192.168.0.184:8888;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
From 072aa99306081f2f2fc8667e84dcc410e8fe8dd5 Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Fri, 25 Sep 2020 00:47:12 +0200
Subject: [PATCH 155/207] endpoint in example notebook updated
---
docs/pkdb_api.ipynb | 58 ++++++++++++++++++++++-----------------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/docs/pkdb_api.ipynb b/docs/pkdb_api.ipynb
index 8c227a3d..35806f9c 100644
--- a/docs/pkdb_api.ipynb
+++ b/docs/pkdb_api.ipynb
@@ -21,12 +21,12 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# API base url\n",
- "base_url = \"http://0.0.0.0:8000/api/v1\" # https://pk-db.com/api/v1"
+ "base_url = \"https://pk-db.com/api/v1\" "
]
},
{
@@ -83,16 +83,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "{'version': '0.9.2a3',\n",
- " 'study_count': 507,\n",
- " 'reference_count': 507,\n",
- " 'group_count': 1447,\n",
- " 'individual_count': 6212,\n",
- " 'intervention_count': 1391,\n",
- " 'output_count': 72068,\n",
- " 'output_calculated_count': 11651,\n",
- " 'timecourse_count': 3036,\n",
- " 'scatter_count': 37}\n"
+ "{'version': '0.9.2a4',\n",
+ " 'study_count': 19,\n",
+ " 'reference_count': 19,\n",
+ " 'group_count': 77,\n",
+ " 'individual_count': 237,\n",
+ " 'intervention_count': 41,\n",
+ " 'output_count': 2682,\n",
+ " 'output_calculated_count': 799,\n",
+ " 'timecourse_count': 154,\n",
+ " 'scatter_count': 0}\n"
]
}
],
@@ -140,6 +140,7 @@
" 'anti-inflammatory activities.',\n",
" 'synonyms': ['1,3,7-TMX',\n",
" '1,3,7-Trimethylxanthine',\n",
+ " '1,3,7-trimethyl-2,6-dioxopurine',\n",
" '1,3,7-trimethyl-3,7-dihydro-1H-purine-2,6-dione',\n",
" '1,3,7-trimethylpurine-2,6-dione',\n",
" '1,3,7-trimethylxanthine',\n",
@@ -156,6 +157,7 @@
" 'Methyltheobromine',\n",
" 'Thein',\n",
" 'Theine',\n",
+ " 'Trimethylxanthine',\n",
" 'anhydrous caffeine',\n",
" 'cafeina',\n",
" 'cafeine',\n",
@@ -164,9 +166,7 @@
" 'mateina',\n",
" 'methyltheobromine',\n",
" 'teina',\n",
- " 'theine',\n",
- " '1,3,7-trimethyl-2,6-dioxopurine',\n",
- " 'Trimethylxanthine'],\n",
+ " 'theine'],\n",
" 'parents': [],\n",
" 'annotations': [{'label': 'caffeine',\n",
" 'relation': 'BQB_IS',\n",
@@ -239,6 +239,9 @@
" {'name': 'emolecules',\n",
" 'accession': '493944',\n",
" 'url': 'https://www.emolecules.com/cgi-bin/more?vid=493944'},\n",
+ " {'name': 'ibm',\n",
+ " 'accession': 'F5DC77C5C625DA4D47FA47B7105235AE',\n",
+ " 'url': 'http://www-935.ibm.com/services/us/gbs/bao/siip/nih/?sid=F5DC77C5C625DA4D47FA47B7105235AE'},\n",
" {'name': 'atlas',\n",
" 'accession': 'caffeine',\n",
" 'url': 'http://www.ebi.ac.uk/gxa/query?conditionQuery=caffeine'},\n",
@@ -328,10 +331,7 @@
" 'url': 'http://www.chemspider.com/inchikey=RYYVLZVUVIJVGH-UHFFFAOYSA-N'},\n",
" {'name': 'InChiKey resolver at NCI',\n",
" 'accession': 'RYYVLZVUVIJVGH-UHFFFAOYSA-N',\n",
- " 'url': 'http://cactus.nci.nih.gov/chemical/structure/RYYVLZVUVIJVGH-UHFFFAOYSA-N/names'},\n",
- " {'name': 'ibm',\n",
- " 'accession': 'F5DC77C5C625DA4D47FA47B7105235AE',\n",
- " 'url': 'http://www-935.ibm.com/services/us/gbs/bao/siip/nih/?sid=F5DC77C5C625DA4D47FA47B7105235AE'}],\n",
+ " 'url': 'http://cactus.nci.nih.gov/chemical/structure/RYYVLZVUVIJVGH-UHFFFAOYSA-N/names'}],\n",
" 'measurement_type': None,\n",
" 'substance': {'mass': 194.19076, 'charge': 0.0, 'formula': 'C8H10N4O2'}}\n"
]
@@ -597,7 +597,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "{'uuid': '54dcdbb8-0105-43c4-a722-f353d4d66ee1',\n",
+ "{'uuid': '1d049323-7990-4080-9e04-91eaca309aeb',\n",
" 'studies': 1,\n",
" 'groups': 4,\n",
" 'individuals': 46,\n",
@@ -606,7 +606,7 @@
" 'timecourses': 4,\n",
" 'scatter': 0}\n",
"\n",
- "uuid: 54dcdbb8-0105-43c4-a722-f353d4d66ee1\n"
+ "uuid: 1d049323-7990-4080-9e04-91eaca309aeb\n"
]
}
],
@@ -634,17 +634,17 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "http://0.0.0.0:8000/api/v1/groups/?uuid=54dcdbb8-0105-43c4-a722-f353d4d66ee1&format=json\n",
+ "https://pk-db.com/api/v1/groups/?uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
"groups: 4\n",
- "http://0.0.0.0:8000/api/v1/individuals/?uuid=54dcdbb8-0105-43c4-a722-f353d4d66ee1&format=json\n",
+ "https://pk-db.com/api/v1/individuals/?uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
"individuals: 46\n",
- "http://0.0.0.0:8000/api/v1/interventions/?uuid=54dcdbb8-0105-43c4-a722-f353d4d66ee1&format=json\n",
+ "https://pk-db.com/api/v1/interventions/?uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
"interventions: 1\n",
- "http://0.0.0.0:8000/api/v1/outputs/?uuid=54dcdbb8-0105-43c4-a722-f353d4d66ee1&format=json\n",
+ "https://pk-db.com/api/v1/outputs/?uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
"outputs: 147\n",
- "http://0.0.0.0:8000/api/v1/subsets/?data_type=timecourse&uuid=54dcdbb8-0105-43c4-a722-f353d4d66ee1&format=json\n",
+ "https://pk-db.com/api/v1/subsets/?data_type=timecourse&uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
"timecourses: 4\n",
- "http://0.0.0.0:8000/api/v1/subsets/?data_type=scatter&uuid=54dcdbb8-0105-43c4-a722-f353d4d66ee1&format=json\n",
+ "https://pk-db.com/api/v1/subsets/?data_type=scatter&uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
"scatters: 0\n"
]
}
@@ -684,8 +684,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "http://0.0.0.0:8000/api/v1/filter/?studies__name=Abernethy1982&download=true\n",
- "created temporary directory /tmp/tmp9yzj5nnv\n",
+ "https://pk-db.com/api/v1/filter/?studies__name=Abernethy1982&download=true\n",
+ "created temporary directory /tmp/tmp1jrs4rpc\n",
"['studies.csv', 'scatter.csv', 'timecourses.csv', 'groups.csv', 'outputs.csv', 'interventions.csv', 'individuals.csv']\n",
" study_sid study_name output_pk intervention_pk group_pk \\\n",
"0 PKDB00198 Abernethy1982 29 2 6.0 \n",
From 920a726f07acb03bec841d4c30b9c58c8a8cdba9 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Fri, 25 Sep 2020 10:44:42 +0200
Subject: [PATCH 156/207] typo in notebook
---
docs/pkdb_api.ipynb | 63 ++++++++++++++++++++++++---------------------
1 file changed, 33 insertions(+), 30 deletions(-)
diff --git a/docs/pkdb_api.ipynb b/docs/pkdb_api.ipynb
index 35806f9c..e0c39f98 100644
--- a/docs/pkdb_api.ipynb
+++ b/docs/pkdb_api.ipynb
@@ -33,7 +33,6 @@
"cell_type": "code",
"execution_count": 2,
"metadata": {
- "collapsed": false,
"jupyter": {
"outputs_hidden": false
},
@@ -70,7 +69,6 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {
- "collapsed": false,
"jupyter": {
"outputs_hidden": false
},
@@ -84,15 +82,15 @@
"output_type": "stream",
"text": [
"{'version': '0.9.2a4',\n",
- " 'study_count': 19,\n",
- " 'reference_count': 19,\n",
- " 'group_count': 77,\n",
- " 'individual_count': 237,\n",
- " 'intervention_count': 41,\n",
- " 'output_count': 2682,\n",
- " 'output_calculated_count': 799,\n",
- " 'timecourse_count': 154,\n",
- " 'scatter_count': 0}\n"
+ " 'study_count': 489,\n",
+ " 'reference_count': 489,\n",
+ " 'group_count': 1346,\n",
+ " 'individual_count': 5505,\n",
+ " 'intervention_count': 1329,\n",
+ " 'output_count': 67695,\n",
+ " 'output_calculated_count': 11473,\n",
+ " 'timecourse_count': 2957,\n",
+ " 'scatter_count': 36}\n"
]
}
],
@@ -110,7 +108,7 @@
"Information in PK-DB is organized as info nodes. Meta-information is encoded in the form of the info nodes which for a given field encodes meta-data such as description, synonyms, annotations and database cross-references. The information in the info nodes can be used to map data to other databases.\n",
"\n",
"### Get info node information\n",
- "Information on info nodes can be retrieved using the `sid` with the `info_nodes` endpoint. An overview of the existing info nodes is available from the info nodes tab https://pk-db/curation. \n",
+ "Information on info nodes can be retrieved using the `sid` with the `info_nodes` endpoint. An overview of the existing info nodes is available from the info nodes tab https://pk-db.com/curation. \n",
"\n",
"In the following example we query the information for the substance `caffeine` with the`sid=caf`\n",
"\n",
@@ -359,7 +357,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 6,
"metadata": {},
"outputs": [
{
@@ -497,7 +495,7 @@
"9 Metabolite of caffeine. "
]
},
- "execution_count": 5,
+ "execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@@ -532,9 +530,8 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 7,
"metadata": {
- "collapsed": false,
"jupyter": {
"outputs_hidden": false
},
@@ -582,9 +579,8 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 8,
"metadata": {
- "collapsed": false,
"jupyter": {
"outputs_hidden": false
},
@@ -597,7 +593,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "{'uuid': '1d049323-7990-4080-9e04-91eaca309aeb',\n",
+ "{'uuid': '0c178b63-6a93-4d75-92b0-e2f42372b0ea',\n",
" 'studies': 1,\n",
" 'groups': 4,\n",
" 'individuals': 46,\n",
@@ -606,7 +602,7 @@
" 'timecourses': 4,\n",
" 'scatter': 0}\n",
"\n",
- "uuid: 1d049323-7990-4080-9e04-91eaca309aeb\n"
+ "uuid: 0c178b63-6a93-4d75-92b0-e2f42372b0ea\n"
]
}
],
@@ -627,24 +623,24 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "https://pk-db.com/api/v1/groups/?uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
+ "https://pk-db.com/api/v1/groups/?uuid=0c178b63-6a93-4d75-92b0-e2f42372b0ea&format=json\n",
"groups: 4\n",
- "https://pk-db.com/api/v1/individuals/?uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
+ "https://pk-db.com/api/v1/individuals/?uuid=0c178b63-6a93-4d75-92b0-e2f42372b0ea&format=json\n",
"individuals: 46\n",
- "https://pk-db.com/api/v1/interventions/?uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
+ "https://pk-db.com/api/v1/interventions/?uuid=0c178b63-6a93-4d75-92b0-e2f42372b0ea&format=json\n",
"interventions: 1\n",
- "https://pk-db.com/api/v1/outputs/?uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
+ "https://pk-db.com/api/v1/outputs/?uuid=0c178b63-6a93-4d75-92b0-e2f42372b0ea&format=json\n",
"outputs: 147\n",
- "https://pk-db.com/api/v1/subsets/?data_type=timecourse&uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
+ "https://pk-db.com/api/v1/subsets/?data_type=timecourse&uuid=0c178b63-6a93-4d75-92b0-e2f42372b0ea&format=json\n",
"timecourses: 4\n",
- "https://pk-db.com/api/v1/subsets/?data_type=scatter&uuid=1d049323-7990-4080-9e04-91eaca309aeb&format=json\n",
+ "https://pk-db.com/api/v1/subsets/?data_type=scatter&uuid=0c178b63-6a93-4d75-92b0-e2f42372b0ea&format=json\n",
"scatters: 0\n"
]
}
@@ -677,7 +673,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 10,
"metadata": {},
"outputs": [
{
@@ -685,8 +681,8 @@
"output_type": "stream",
"text": [
"https://pk-db.com/api/v1/filter/?studies__name=Abernethy1982&download=true\n",
- "created temporary directory /tmp/tmp1jrs4rpc\n",
- "['studies.csv', 'scatter.csv', 'timecourses.csv', 'groups.csv', 'outputs.csv', 'interventions.csv', 'individuals.csv']\n",
+ "created temporary directory /tmp/tmpipkyxwfy\n",
+ "['interventions.csv', 'studies.csv', 'timecourses.csv', 'scatter.csv', 'groups.csv', 'individuals.csv', 'outputs.csv']\n",
" study_sid study_name output_pk intervention_pk group_pk \\\n",
"0 PKDB00198 Abernethy1982 29 2 6.0 \n",
"1 PKDB00198 Abernethy1982 31 2 4.0 \n",
@@ -766,6 +762,13 @@
" print(df)\n",
" "
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
From d14427543b72cf9156db53590f3d1bcbcfe840c4 Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Fri, 25 Sep 2020 14:31:03 +0200
Subject: [PATCH 157/207] Fix #641, comments displayed on study detail
---
backend/pkdb_app/data/models.py | 27 ++-
.../src/components/detail/StudyOverview.vue | 191 +++++++++---------
frontend/src/components/lib/Annotations.vue | 27 ++-
.../components/navigation/DetailDrawer.vue | 10 +-
4 files changed, 136 insertions(+), 119 deletions(-)
diff --git a/backend/pkdb_app/data/models.py b/backend/pkdb_app/data/models.py
index 7cee95e6..d09aad3a 100644
--- a/backend/pkdb_app/data/models.py
+++ b/backend/pkdb_app/data/models.py
@@ -130,7 +130,6 @@ def keys_timecourse_representation(self):
'unit': 'outputs__unit',
}
-
def _timecourse_extra(self):
return {
**self.timecourse_extra_no_intervention(),
@@ -198,26 +197,28 @@ def validate_timecourse(self, timecourse):
name = self.get_name(timecourse[key], value)
else:
name = list(timecourse[key])
- raise Exception(f"Subset used for timecourse is not unique on '{key}'. Values are {name}. "
- f"Check uniqueness of labels for timecourses.")
+ raise ValueError(f"Subset used for timecourse is not unique on '{key}'. Values are '{name}'. "
+ f"Check uniqueness of labels for timecourses.")
def timecourse(self):
- timecourse = self.merge_values(
- self.data_points.prefetch_related('outputs').values(*self._timecourse_extra().values()))
-
- self.reformat_timecourse(timecourse, self._timecourse_extra())
- self.validate_timecourse(timecourse)
- return timecourse
+ """ FIXME: Documentation """
+ tc = self.merge_values(
+ self.data_points.prefetch_related('outputs').values(*self._timecourse_extra().values())
+ )
+ self.reformat_timecourse(tc, self._timecourse_extra())
+ self.validate_timecourse(tc)
+ return tc
def reformat_timecourse(self, timecourse, mapping):
+ """ FIXME: Documentation & type hinting """
for new_key, old_key in mapping.items():
timecourse[new_key] = timecourse.pop(old_key)
if new_key == "interventions":
if isinstance(timecourse[new_key], int):
timecourse[new_key] = (timecourse[new_key],)
-
def timecourse_representation(self):
+ """ FIXME: Documentation """
timecourse = self.merge_values(
self.data_points.prefetch_related('outputs').values(*self.keys_timecourse_representation().values()))
@@ -225,19 +226,17 @@ def timecourse_representation(self):
return timecourse
def keys_scatter_representation(self):
+ """ FIXME: Documentation """
return {**self.keys_timecourse_representation(),
"dimension": "dimensions__dimension",
"data_point": "pk"
-
}
def reformat_scatter(self):
-
+ """ FIXME: Documentation """
pass
-
def scatter_representation(self):
-
scatter_x = self.merge_values(self.data_points.filter(dimensions__dimension=0).prefetch_related('outputs').values(*self.keys_scatter_representation().values()))
self.reformat_timecourse(scatter_x, self.keys_scatter_representation())
diff --git a/frontend/src/components/detail/StudyOverview.vue b/frontend/src/components/detail/StudyOverview.vue
index 905668c3..fd9c8049 100644
--- a/frontend/src/components/detail/StudyOverview.vue
+++ b/frontend/src/components/detail/StudyOverview.vue
@@ -1,72 +1,71 @@
-
-
+
+
- {{ faIcon('study') }}
- {{ study.name }} ({{ study.sid }})
+ {{ faIcon('study') }}
+ {{ study.name }} ({{ study.sid }})
{{ faIcon(study.access) }}
+ >{{ faIcon(study.access) }}
+
{{ faIcon(study.licence) }}
+ >{{ faIcon(study.licence) }}
+
-
-
-
-
Substances
-
+
+
+
+ Substances
+
-
-
-
-
-
-
- Creator
-
-
-
- Curators
-
-
-
-
+
+
-
-
+
+
+
+ Creator
+
+
+
+ Curators
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
Files
-
-
+
+
+
+
+
+ Files
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
+
\ No newline at end of file
diff --git a/frontend/src/components/lib/buttons/DownloadButton.vue b/frontend/src/components/lib/buttons/DownloadButton.vue
index e3a0729d..16d1bb01 100644
--- a/frontend/src/components/lib/buttons/DownloadButton.vue
+++ b/frontend/src/components/lib/buttons/DownloadButton.vue
@@ -11,26 +11,26 @@
>
{{ faIcon('download') }}
+
+
+
\ No newline at end of file
diff --git a/frontend/src/components/navigation/Navigation.vue b/frontend/src/components/navigation/Navigation.vue
index 9a54610c..917056b3 100644
--- a/frontend/src/components/navigation/Navigation.vue
+++ b/frontend/src/components/navigation/Navigation.vue
@@ -13,7 +13,6 @@
{{ faIcon('data') }}
Data
-
@@ -30,7 +29,7 @@
-
+
diff --git a/frontend/src/components/lib/Annotations.vue b/frontend/src/components/lib/Annotations.vue
index 9cde9b27..0a6ca1fd 100644
--- a/frontend/src/components/lib/Annotations.vue
+++ b/frontend/src/components/lib/Annotations.vue
@@ -1,6 +1,6 @@
-
-
+
fas fa-align-left
{{ description.text }}
From 0cc3b9219c3ceac0834eb4fea026d6e8511ca6ab Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Wed, 30 Sep 2020 17:41:25 +0200
Subject: [PATCH 202/207] minor frontend fixes
---
frontend/src/components/info_node/Annotation.vue | 1 +
frontend/src/components/info_node/Xref.vue | 1 +
frontend/src/components/tables/StudiesTable.vue | 2 +-
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/frontend/src/components/info_node/Annotation.vue b/frontend/src/components/info_node/Annotation.vue
index bcb515f3..df14b7a4 100644
--- a/frontend/src/components/info_node/Annotation.vue
+++ b/frontend/src/components/info_node/Annotation.vue
@@ -7,6 +7,7 @@
small
:href="annotation.url"
target="_blank"
+ :title="'Open ' + annotation.collection + '|' + annotation.term"
>
{{ annotation.relation }}
diff --git a/frontend/src/components/info_node/Xref.vue b/frontend/src/components/info_node/Xref.vue
index ed81a369..f527ad02 100644
--- a/frontend/src/components/info_node/Xref.vue
+++ b/frontend/src/components/info_node/Xref.vue
@@ -6,6 +6,7 @@
small
:href="url"
target="_blank"
+ :title="'Open ' + name + '|' + accession"
>
{{ name }} | {{ accession}}
diff --git a/frontend/src/components/tables/StudiesTable.vue b/frontend/src/components/tables/StudiesTable.vue
index b17ee6a7..fc19ed5f 100644
--- a/frontend/src/components/tables/StudiesTable.vue
+++ b/frontend/src/components/tables/StudiesTable.vue
@@ -18,7 +18,7 @@
From 783d0580277aca148f1e5e91ed18c92b80567f58 Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Wed, 30 Sep 2020 17:50:49 +0200
Subject: [PATCH 203/207] opening json in new tab
---
frontend/src/components/lib/buttons/JsonButton.vue | 1 +
1 file changed, 1 insertion(+)
diff --git a/frontend/src/components/lib/buttons/JsonButton.vue b/frontend/src/components/lib/buttons/JsonButton.vue
index 8654fde1..581b5e97 100644
--- a/frontend/src/components/lib/buttons/JsonButton.vue
+++ b/frontend/src/components/lib/buttons/JsonButton.vue
@@ -10,6 +10,7 @@
:disabled="resource_url ? false : true"
title="JSON for query"
icon
+ target="_blank"
>
fas fa-code
From 514a9b504e85e2038a3f89cbcb273c87552325dc Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 30 Sep 2020 18:48:00 +0200
Subject: [PATCH 204/207] changed order in search navigation
---
backend/pkdb_app/statistics.py | 16 ++++++++++++
backend/pkdb_app/studies/views.py | 25 +------------------
backend/pkdb_app/urls.py | 3 ++-
.../search/InterventionSearchForm.vue | 2 +-
.../components/search/OutputSearchForm.vue | 2 +-
.../components/search/SubjectSearchForm.vue | 2 +-
6 files changed, 22 insertions(+), 28 deletions(-)
diff --git a/backend/pkdb_app/statistics.py b/backend/pkdb_app/statistics.py
index b4d5ed81..b0f5e149 100644
--- a/backend/pkdb_app/statistics.py
+++ b/backend/pkdb_app/statistics.py
@@ -1,7 +1,9 @@
"""
Basic information and statistics about data base content.
"""
+from django.db.models import Count, F, Q
from pkdb_app.data.models import SubSet, Data
+from pkdb_app.info_nodes.models import Substance
from rest_framework import serializers
from rest_framework import viewsets
from rest_framework.response import Response
@@ -42,8 +44,22 @@
'''
+class SubstanceStatisticsViewSet(viewsets.ViewSet):
+ def list(self,request):
+ substances_interventions = Substance.objects.annotate(label=F('info_node__label'),intervention_count=Count("intervention", filter=Q(intervention__normed=True)))
+ substances_outputs = Substance.objects.annotate(label=F('info_node__label'),output_count=Count("output", filter=Q(output__normed=True)))
+ return Response({"output":SubstanceStatisticsSerializer(substances_outputs, many=True).data,
+ "output": SubstanceStatisticsSerializer(substances_interventions, many=True).data,
+ })
+
+
+class SubstanceStatisticsSerializer(serializers.Serializer):
+ label = serializers.CharField()
+ intervention_count = serializers.IntegerField(allow_null=True)
+ output_count = serializers.IntegerField(allow_null=True)
+
class Statistics(object):
""" Basic database statistics. """
diff --git a/backend/pkdb_app/studies/views.py b/backend/pkdb_app/studies/views.py
index 664c5da7..d0e3391b 100644
--- a/backend/pkdb_app/studies/views.py
+++ b/backend/pkdb_app/studies/views.py
@@ -749,31 +749,8 @@ def sorted_tuple(v):
if key=="outputs":
timecourse_df = df[df["output_type"] == Output.OutputTypes.Timecourse]
-
timecourse_df = pd.pivot_table(data=timecourse_df,index=["output_pk"], aggfunc=sorted_tuple).apply(SubSet.to_list)
-
- timecourse_df = pd.pivot_table(data=timecourse_df,index=["label","study_name",],aggfunc=tuple).apply(SubSet.to_list)
- print("here I am")
- #print(set(timecourse_df.iloc[1]["intervention_pk"]))
- #from pprint import pprint
- #pprint(timecourse_df)
-
- #timecourse_df = SubSet.merge_values(df=timecourse_df,groupby=("output_pk",),sort_values=["time", "intervention_pk"])
-
- #df = timecourse_df.groupby(["label","study_name"],as_index=False).apply(lambda df_t: pd.Series(SubSet.merge_values(
- # df=df_t,
- # groupby=("output_pk",),
- # sort_values=["time","intervention_pk"])))
-
- #timecourse_data = []
- #for (n, df_t) in timecourse_df.groupby(["label","study_name"]):
- # timecourse = SubSet.merge_values(
- # df=df_t,
- # groupby=("output_pk",),
- # sort_values=["time","intervention_pk"])
- # timecourse_data.append(timecourse)
- #df = pd.DataFrame(timecourse_data)
-
+ timecourse_df = pd.pivot_table(data=timecourse_df,index=["label","study_name"], aggfunc=tuple).apply(SubSet.to_list)
timecourse_df.to_csv(string_buffer)
archive.writestr(f'timecourse.csv', string_buffer.getvalue())
diff --git a/backend/pkdb_app/urls.py b/backend/pkdb_app/urls.py
index 275f9671..824c14e9 100755
--- a/backend/pkdb_app/urls.py
+++ b/backend/pkdb_app/urls.py
@@ -12,7 +12,7 @@
from drf_yasg import openapi
from .statistics import (
- StatisticsViewSet,
+ StatisticsViewSet, SubstanceStatisticsViewSet,
)
from .info_nodes.views import (
@@ -55,6 +55,7 @@
# Misc URLs
# -----------------------------------------------------------------------------
router.register("statistics", StatisticsViewSet, basename="statistics")
+router.register("statistics/substances", SubstanceStatisticsViewSet, basename="statistics")
# -----------------------------------------------------------------------------
# Elastic URLs
diff --git a/frontend/src/components/search/InterventionSearchForm.vue b/frontend/src/components/search/InterventionSearchForm.vue
index d36efe39..1045b3a6 100644
--- a/frontend/src/components/search/InterventionSearchForm.vue
+++ b/frontend/src/components/search/InterventionSearchForm.vue
@@ -1,10 +1,10 @@
+
-
diff --git a/frontend/src/components/search/OutputSearchForm.vue b/frontend/src/components/search/OutputSearchForm.vue
index fe4d8b9f..b7387f7f 100644
--- a/frontend/src/components/search/OutputSearchForm.vue
+++ b/frontend/src/components/search/OutputSearchForm.vue
@@ -1,7 +1,7 @@
-
+
diff --git a/frontend/src/components/search/SubjectSearchForm.vue b/frontend/src/components/search/SubjectSearchForm.vue
index 01ca50c9..54b929ff 100644
--- a/frontend/src/components/search/SubjectSearchForm.vue
+++ b/frontend/src/components/search/SubjectSearchForm.vue
@@ -1,7 +1,7 @@
-
+
From d6f9315466771f059c15209ea21b5adef2703246 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 30 Sep 2020 19:23:20 +0200
Subject: [PATCH 205/207] added basic statistics
---
backend/pkdb_app/statistics.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/backend/pkdb_app/statistics.py b/backend/pkdb_app/statistics.py
index b0f5e149..3aeeff5b 100644
--- a/backend/pkdb_app/statistics.py
+++ b/backend/pkdb_app/statistics.py
@@ -46,13 +46,19 @@
'''
class SubstanceStatisticsViewSet(viewsets.ViewSet):
def list(self,request):
- substances_interventions = Substance.objects.annotate(label=F('info_node__label'),intervention_count=Count("intervention", filter=Q(intervention__normed=True)))
- substances_outputs = Substance.objects.annotate(label=F('info_node__label'),output_count=Count("output", filter=Q(output__normed=True)))
+ substances_interventions = Substance.objects.annotate(label=F('info_node__label'),intervention_count=Count("intervention", filter=Q(intervention__normed=True))).order_by('info_node__label')
+ substances_outputs = Substance.objects.annotate(label=F('info_node__label'),output_count=Count("output", filter=Q(output__normed=True))).order_by('info_node__label')
+ data = zip(substances_outputs.values("info_node__label"),substances_outputs.values("output_count"), substances_interventions.values("intervention_count"))
- return Response({"output":SubstanceStatisticsSerializer(substances_outputs, many=True).data,
- "output": SubstanceStatisticsSerializer(substances_interventions, many=True).data,
- })
+ result = []
+ for x in data:
+ res = {}
+ for v in x:
+ res = {**res, **v}
+ result.append(res)
+
+ return Response(result)
class SubstanceStatisticsSerializer(serializers.Serializer):
From b3c5cad432b61a228fa2691937046db7c22f3981 Mon Sep 17 00:00:00 2001
From: Jan Grzegorzewski
Date: Wed, 30 Sep 2020 19:35:55 +0200
Subject: [PATCH 206/207] typo with scatters
---
frontend/src/components/tables/StudiesTable.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frontend/src/components/tables/StudiesTable.vue b/frontend/src/components/tables/StudiesTable.vue
index fc19ed5f..07b607bc 100644
--- a/frontend/src/components/tables/StudiesTable.vue
+++ b/frontend/src/components/tables/StudiesTable.vue
@@ -34,7 +34,7 @@
-
+
From 0ce3f95eeee7133d119e89f8e1c34a6bfb66949f Mon Sep 17 00:00:00 2001
From: Matthias Koenig
Date: Wed, 30 Sep 2020 21:07:25 +0200
Subject: [PATCH 207/207] version bump for release
---
backend/pkdb_app/_version.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/backend/pkdb_app/_version.py b/backend/pkdb_app/_version.py
index c0fd7924..ec4dbea7 100644
--- a/backend/pkdb_app/_version.py
+++ b/backend/pkdb_app/_version.py
@@ -1,4 +1,4 @@
"""
Definition of version string.
"""
-__version__ = "0.9.2a5"
+__version__ = "0.9.3"
+