Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
groundwork clade enrichment
  • Loading branch information
proost committed Nov 23, 2017
1 parent fc2f053 commit 45befec
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 100 deletions.
24 changes: 22 additions & 2 deletions conekt/controllers/admin/controls/clades.py
@@ -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')
Expand Down Expand Up @@ -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'))
2 changes: 1 addition & 1 deletion conekt/controllers/admin/views/expression_clusters.py
Expand Up @@ -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):
Expand Down
23 changes: 23 additions & 0 deletions conekt/models/expression/coexpression_clusters.py
Expand Up @@ -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

Expand Down Expand Up @@ -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():
"""
Expand Down
4 changes: 3 additions & 1 deletion conekt/models/relationships/__init__.py
Expand Up @@ -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)
)
2 changes: 2 additions & 0 deletions conekt/models/relationships/cluster_clade.py
Expand Up @@ -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),
Expand Down
4 changes: 0 additions & 4 deletions docs/building_conekt.md
Expand Up @@ -171,8 +171,4 @@ data and add everything to the database.

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

*UNDER CONSTRUCTION*

## Using the build script

*UNDER CONSTRUCTION*
92 changes: 0 additions & 92 deletions migrations/versions/cdcd89b3d017_.py

This file was deleted.

0 comments on commit 45befec

Please sign in to comment.