Skip to content
Permalink
Browse files

groundwork clade enrichment

  • Loading branch information
proost committed Nov 23, 2017
1 parent fc2f053 commit 45befecb5119da8dc97b956bd992e2f6daf0b6ea
@@ -1,13 +1,14 @@
import json

from flask import flash, url_for, request
from flask import flash, url_for, request, Markup
from conekt.extensions import admin_required
from werkzeug.exceptions import abort
from werkzeug.utils import redirect

from conekt.controllers.admin.controls import admin_controls
from conekt.forms.admin.add_clades import AddCladesForm
from conekt.models.clades import Clade
from conekt.models.expression.coexpression_clusters import CoexpressionCluster


@admin_controls.route('/update/clades')
@@ -52,4 +53,23 @@ def add_clades():
flash('Unable to validate data, potentially missing fields', 'danger')
return redirect(url_for('admin.index'))
else:
abort(405)
abort(405)


@admin_controls.route('/calculate_clade_enrichment/<int:gf_method_id')
@admin_required
def calculate_clade_enrichment(gf_method_id):
"""
Controller to start GO enrichment calculations
:return: Redirect to admin main screen
"""
try:
CoexpressionCluster.calculate_clade_enrichment(gf_method_id)
except Exception as e:
flash(Markup('An error occurred! Please ensure the file is <strong>correctly formatted</strong>' +
' and <strong>update the counts</strong> if necessary'), 'warning')
finally:
flash('Successfully calculated clade enrichment for co-expression clusters', 'success')

return redirect(url_for('admin.controls.index'))
@@ -22,7 +22,7 @@ class CoexpressionClusteringMethodAdminView(MyModelView):

class ClusterSimilaritiesView(AdminBaseView):
"""
Control panel for administrators. Contains links to
Control panel for administrators. Contains links to start computing cluster similarities
"""
@expose('/')
def index(self):
@@ -16,6 +16,7 @@
from conekt.models.relationships.sequence_family import SequenceFamilyAssociation
from conekt.models.relationships.sequence_go import SequenceGOAssociation
from conekt.models.relationships.cluster_go import ClusterGOEnrichment
from conekt.models.relationships.cluster_clade import ClusterCladeEnrichment
from conekt.models.sequences import Sequence
from conekt.models.expression.profiles import ExpressionProfile

@@ -472,6 +473,28 @@ def calculate_enrichment(empty=True):
# print(i, "\t cluster: ", cluster.method_id, cluster.name)
cluster.__calculate_enrichment()

@staticmethod
def calculate_clade_enrichment(gene_family_method_id, empty=True):
"""
Calculates clade enrichment for co-expression clusters
:param gene_family_method_id:
:param empty:
:return:
"""
if empty:
try:
pass
except Exception as e:
db.session.rollback()
print(e)

# get background distribution

# calculate enrichment



@staticmethod
def delete_enrichment():
"""
@@ -78,5 +78,7 @@
cluster_clade_enrichment = db.Table('cluster_clade_enrichment',
db.Column('id', db.Integer, primary_key=True),
db.Column('cluster_id', db.Integer, db.ForeignKey('coexpression_clusters.id'), index=True),
db.Column('clade_id', db.Integer, db.ForeignKey('clades.id'), index=True)
db.Column('clade_id', db.Integer, db.ForeignKey('clades.id'), index=True),
db.Column('gene_family_methods_id', db.Integer,
db.ForeignKey('gene_family_methods.id'), index=True)
)
@@ -9,6 +9,8 @@ class ClusterCladeEnrichment(db.Model):
cluster_id = db.Column(db.Integer, db.ForeignKey('coexpression_clusters.id', ondelete='CASCADE'))
clade_id = db.Column(db.Integer, db.ForeignKey('clade.id', ondelete='CASCADE'))

gene_family_methods_id = db.Column(db.Integer, db.ForeignKey('gene_family_methods.id', ondelete='CASCADE'))

cluster = db.relationship('CoexpressionCluster', backref=db.backref('clade_enrichment',
lazy='dynamic',
passive_deletes=True),
@@ -171,8 +171,4 @@ data and add everything to the database.

### Computing enrichments, similarities, and counts ...

*UNDER CONSTRUCTION*

## Using the build script

*UNDER CONSTRUCTION*

This file was deleted.

0 comments on commit 45befec

Please sign in to comment.
You can’t perform that action at this time.