From 8c1ad14448a6754eb273f5e2b145dc76c5f0c776 Mon Sep 17 00:00:00 2001 From: Sebastian Proost Date: Thu, 25 Jan 2018 05:08:34 +0100 Subject: [PATCH] warning in custom profiles for missing genes --- conekt/controllers/profile_comparison.py | 15 ++++++++++----- conekt/models/expression/profiles.py | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/conekt/controllers/profile_comparison.py b/conekt/controllers/profile_comparison.py index cd11f63..1bb4ae0 100644 --- a/conekt/controllers/profile_comparison.py +++ b/conekt/controllers/profile_comparison.py @@ -1,5 +1,6 @@ import json import base64 +import contextlib from flask import Blueprint, request, render_template, flash, Markup, url_for from sqlalchemy.orm import noload @@ -85,12 +86,16 @@ def profile_comparison_main(): # get max 51 profiles, only show the first 50 (the extra one is fetched to throw the warning) profiles = ExpressionProfile.get_profiles(species_id, probes, limit=51) - missing = [] - for p in probes: - pass + not_found = [p.lower() for p in probes] + for p in profiles: + with contextlib.suppress(ValueError): + not_found.remove(p.probe.lower()) - if len(missing) > 0: - flash("Warning! %s were not found in the database" % ', '.join(missing)) + with contextlib.suppress(ValueError): + not_found.remove(p.sequence.name.lower()) + + if len(not_found) > 0: + flash("Couldn't find profile for: %s" % ", ".join(not_found), "warning") if len(profiles) > 50: flash(Markup(("To many profiles in this cluster only showing the first 50.
" + diff --git a/conekt/models/expression/profiles.py b/conekt/models/expression/profiles.py index e970a4a..47abaaf 100644 --- a/conekt/models/expression/profiles.py +++ b/conekt/models/expression/profiles.py @@ -199,7 +199,7 @@ def get_heatmap(species_id, probes, zlog=True, raw=False): "shortest_alias":profile.sequence.shortest_alias}) if len(not_found) > 0: - flash("Couldn't find profile for: %s" % ",".join(not_found), "warning") + flash("Couldn't find profile for: %s" % ", ".join(not_found), "warning") return {'order': order, 'heatmap_data': output}