diff --git a/catalog/migrations/0003_release_efotrait_count.py b/catalog/migrations/0003_release_efotrait_count.py
new file mode 100644
index 00000000..c0e275f4
--- /dev/null
+++ b/catalog/migrations/0003_release_efotrait_count.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.2.10 on 2024-03-25 15:57
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('catalog', '0002_alter_metric_name'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='release',
+ name='efotrait_count',
+ field=models.IntegerField(default=0, verbose_name='Number of new EFO traits released'),
+ ),
+ ]
diff --git a/catalog/models.py b/catalog/models.py
index d712796d..32bc47f7 100644
--- a/catalog/models.py
+++ b/catalog/models.py
@@ -1138,6 +1138,7 @@ class Release(models.Model):
score_count = models.IntegerField('Number of new PGS scores released', default=0)
performance_count = models.IntegerField('Number of new PGS Performance metrics released', default=0)
publication_count = models.IntegerField('Number of new PGS Publication released', default=0)
+ efotrait_count = models.IntegerField('Number of new EFO traits released', default=0)
notes = models.TextField(verbose_name='Release notes', max_length=600, blank=True)
updated_score_count = models.IntegerField('Number of PGS scores updated', default=0)
updated_performance_count = models.IntegerField('Number of PGS Performance metrics updated', default=0)
@@ -1160,3 +1161,9 @@ def released_publication_ids(self):
def released_performance_ids(self):
performances = Performance.objects.values_list('id', flat=True).filter(date_released__exact=self.date).order_by('id')
return list(performances)
+
+ @property
+ def released_new_trait_ids(self):
+ previous_traits = Score.objects.values_list('trait_efo__id', flat=True).filter(date_released__lt=self.date).distinct()
+ new_traits = Score.objects.values_list('trait_efo__id', flat=True).filter(date_released__exact=self.date).distinct()
+ return list(new_traits.difference(previous_traits))
diff --git a/catalog/static/catalog/pgs_bar_charts.js b/catalog/static/catalog/pgs_bar_charts.js
index 9ab4378a..a07c0bdd 100644
--- a/catalog/static/catalog/pgs_bar_charts.js
+++ b/catalog/static/catalog/pgs_bar_charts.js
@@ -1,15 +1,17 @@
-var rest_url = 'https://www.pgscatalog.org/rest/release/'
+var rest_url = '/rest/release/'
bg_colours = {
'score': '#007C82',
'publication': '#BE4A81',
'performance': 'DodgerBlue',
+ 'trait': '#c03b23',
'new_entry': '#FFC200'
};
bg_hover_colours = {
'score': '#00adb5',
'publication': '#e83e8c',
'performance': '#51a9ff',
+ 'trait': '#f67d51',
'new_entry': '#FFD700'
};
@@ -41,6 +43,15 @@ $('.get_pgs_ids').click(function() {
html_pub += '';
$(list_pub_id).html(html_pub);
$('#list_'+id).show();
+
+ list_trait_id = '#list_'+id.replace(type,'trait');
+ html_trait = "
";
+ $.each(result.released_new_trait_ids, function(index, trait_id) {
+ html_trait += '- '+trait_id+'
';
+ });
+ html_trait += '
';
+ $(list_trait_id).html(html_trait);
+ $('#list_'+id).show();
})
.fail(function (xhRequest, ErrorText, thrownError) {
console.log(xhRequest);
diff --git a/catalog/templates/catalog/releases.html b/catalog/templates/catalog/releases.html
index 5cc3858b..df34d598 100644
--- a/catalog/templates/catalog/releases.html
+++ b/catalog/templates/catalog/releases.html
@@ -20,6 +20,7 @@
Score(s) |
Publication(s) |
Performance(s) |
+ Trait(s) |
Notes |
@@ -32,7 +33,7 @@
{% if latest_release.score_count > 0 %}
{{ latest_release.score_count }}
-
+
{% else %}
-
{% endif %}
@@ -41,7 +42,7 @@
{% if latest_release.publication_count > 0 %}
{{ latest_release.publication_count }}
-
+
{% else %}
-
{% endif %}
@@ -53,6 +54,15 @@
-
{% endif %}
+
+ {% if latest_release.efotrait_count > 0 %}
+ {{ latest_release.efotrait_count }}
+
+
+ {% else %}
+ -
+ {% endif %}
+ |
{{ latest_release.notes }} |
@@ -70,6 +80,7 @@ {{ release.score_count }}
-
+
{% else %}
-
{% endif %}
@@ -97,7 +108,7 @@ {{ release.publication_count }}
-
+
{% else %}
-
{% endif %}
@@ -109,6 +120,15 @@ {{ release.efotrait_count }}
+
+
+ {% else %}
+ -
+ {% endif %}
+
{{ release.notes }} |
{% endfor %}
@@ -130,6 +150,7 @@
- Scores, Publications and Performance Metrics per release
+ Scores, Publications, Performance Metrics and Traits per release
@@ -159,6 +180,9 @@
+
+
+
Distribution of publications per year
diff --git a/catalog/views.py b/catalog/views.py
index 8b04d792..12c67a00 100644
--- a/catalog/views.py
+++ b/catalog/views.py
@@ -689,6 +689,7 @@ def releases(request):
total_score = 0
total_perf = 0
total_publi = 0
+ total_trait = 0
max_score = 0
max_publi = 0
max_perf = 0
@@ -756,6 +757,7 @@ def releases(request):
score = release.score_count
perf = release.performance_count
publi = release.publication_count
+ trait = release.efotrait_count
date = release.date
release_item = {
@@ -763,13 +765,16 @@ def releases(request):
'score_count': score,
'performance_count': perf,
'publication_count': publi,
+ 'trait_count': trait,
'total_score_count': total_score,
'total_performance_count': total_perf,
- 'total_publication_count': total_publi
+ 'total_publication_count': total_publi,
+ 'total_trait_count': total_trait
}
total_score += score
total_perf += perf
total_publi += publi
+ total_trait += trait
release_data.append(release_item)
diff --git a/release/scripts/CreateRelease.py b/release/scripts/CreateRelease.py
index 9b38be81..2f14eb04 100644
--- a/release/scripts/CreateRelease.py
+++ b/release/scripts/CreateRelease.py
@@ -11,6 +11,7 @@ class CreateRelease:
new_scores = {}
new_performances = {}
+ new_traits = set()
def __init__(self, release_tomorrow=None):
self.release_tomorrow = release_tomorrow
@@ -30,6 +31,7 @@ def update_data_to_release(self):
by adding a date in the 'date_released' columns
"""
self.get_release_date()
+ previous_traits = set(Score.objects.values_list('trait_efo__id', flat=True).exclude(date_released__isnull=True).distinct())
#### Add release date for each publications and dependent models ####
for publication in self.new_publications:
publication.date_released = self.new_release_date
@@ -42,6 +44,9 @@ def update_data_to_release(self):
# Update date_release
score.date_released = self.new_release_date
score.save()
+ # Get new traits
+ score_traits = {efotrait.id for efotrait in score.trait_efo.all()}
+ self.new_traits.update(score_traits.difference(previous_traits))
# Performances
performances_list = Performance.objects.filter(date_released__isnull=True, publication=publication)
@@ -55,12 +60,13 @@ def update_data_to_release(self):
def create_new_release(self):
""" Create new release instance and save it in the database """
#### Create new release instance ####
- release_notes = 'This release contains {} new Score(s), {} new Publication(s) and {} new Performance metric(s)'.format(len(self.new_scores.keys()), len(self.new_publications), len(self.new_performances.keys()))
+ release_notes = 'This release contains {} new Score(s), {} new Publication(s), {} new Performance metric(s) and {} new Trait(s)'.format(len(self.new_scores.keys()), len(self.new_publications), len(self.new_performances.keys()), len(self.new_traits))
release = Release.objects.create(
date=self.new_release_date,
performance_count=len(self.new_performances.keys()),
publication_count=len(self.new_publications),
score_count=len(self.new_scores.keys()),
+ efotrait_count=len(self.new_traits),
notes=release_notes
)
return release
@@ -123,6 +129,7 @@ def run():
print(', '.join(release.new_scores.keys()))
print("Number of new Publications: "+str(new_release.publication_count))
print("Number of new Performances: "+str(new_release.performance_count))
+ print("Number of new Traits: " + str(new_release.efotrait_count))
# Scores
scores_direct = Score.objects.filter(date_released__isnull=True)
diff --git a/release/scripts/run_release_script.py b/release/scripts/run_release_script.py
index 266c281f..338bb393 100644
--- a/release/scripts/run_release_script.py
+++ b/release/scripts/run_release_script.py
@@ -181,6 +181,7 @@ def call_create_release():
output_report(', '.join(release.new_scores.keys()))
output_report("Number of new Publications: "+str(new_release.publication_count))
output_report("Number of new Performances: "+str(new_release.performance_count))
+ output_report("Number of new Traits: " + str(new_release.efotrait_count))
if new_release.score_count == 0 or new_release.publication_count == 0 or new_release.performance_count == 0:
error_report("at least one of the main components (Score, Publication or Performance Metrics) hasn't a new entry this release")
diff --git a/rest_api/serializers.py b/rest_api/serializers.py
index efbef993..9d011131 100644
--- a/rest_api/serializers.py
+++ b/rest_api/serializers.py
@@ -196,8 +196,8 @@ class ReleaseSerializer(serializers.ModelSerializer):
class Meta:
model = Release
- meta_fields = ('date', 'score_count', 'performance_count', 'publication_count', 'notes',
- 'released_score_ids', 'released_publication_ids', 'released_performance_ids')
+ meta_fields = ('date', 'score_count', 'performance_count', 'publication_count', 'efotrait_count', 'notes',
+ 'released_score_ids', 'released_publication_ids', 'released_performance_ids', 'released_new_trait_ids')
fields = meta_fields
read_only_fields = meta_fields