Skip to content

Commit

Permalink
protein interaction queries
Browse files Browse the repository at this point in the history
  • Loading branch information
saapooch committed Nov 13, 2017
1 parent 83884d6 commit 69b5a09
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 13 deletions.
18 changes: 18 additions & 0 deletions kinetic_datanator/core/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,24 @@ class ProteinSpecie(PolymerSpecie):
length = obj_model.core.IntegerAttribute()
mass = obj_model.core.IntegerAttribute()

class KnownProteinComplex(ProteinSpecie):
""" Represents a protein interaction
Attributes:
"""
go_id = obj_model.core.StringAttribute()
go_dsc = obj_model.core.StringAttribute()
funcat_id = obj_model.core.StringAttribute()
funcat_dsc = obj_model.core.StringAttribute()
su_cmt = obj_model.core.StringAttribute()
complex_cmt = obj_model.core.StringAttribute()
disease_cmt = obj_model.core.StringAttribute()
class_name = obj_model.core.StringAttribute()
family_name = obj_model.core.StringAttribute()
molecular_weight = obj_model.core.FloatAttribute()



class Interaction(EntityInteractionOrProperty):
""" Represents an interaction
Expand Down
55 changes: 44 additions & 11 deletions kinetic_datanator/data_query/protein_protein_interactions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from kinetic_datanator.core import data_model
from kinetic_datanator.core import data_query
from kinetic_datanator.core import common_schema

from sqlalchemy import or_
class ProteintoProteinInteractionQueryGenerator(data_query.CachedDataSourceQueryGenerator):
""" Queries Proteins to find Interactions with other Proteins """

Expand Down Expand Up @@ -30,22 +30,55 @@ def __init__(self,
def get_observed_values(self):
pass

def get_observed_interactions_and_complex(self,protein):
pass
# outputs datamodel interaction and complex
def get_observable_interactions_and_complex(self,protein):

interact = self.get_interaction_by_subunit(protein.uniprot_id).all()

interaction = []
index = 1
for item in interact:
resource = data_model.Resource(namespace = item._metadata.resource[0].namespace,
id = item._metadata.resource[0]._id)
interaction.append(data_model.ProteinInteraction(participant_a = item.participant_a,
participant_b = item.participant_b, interaction_id = item.interaction,
stoichiometry_a = item.stoich_a, stoichiometry_b = item.stoich_b,
site_a=item.site_a, site_b=item.site_b, cross_references = [resource],
name = 'Interaction '+ str(index)))
index += 1

complex_ = self.get_known_complex_by_subunit(protein.uniprot_id)

plex = []
for item in complex_:
resource = data_model.Resource(namespace = item._metadata.resource[0].namespace,
id = item._metadata.resource[0]._id)
plex.append(data_model.KnownProteinComplex(name = item.complex_name,
go_id = item.go_id, go_dsc = item. go_dsc, funcat_id = item.funcat_id,
funcat_dsc = item.funcat_dsc, su_cmt = item.su_cmt, complex_cmt = item.complex_cmt,
disease_cmt = item.disease_cmt, class_name = item.class_name,
family_name = item.family_name, molecular_weight= item.molecular_weight,
cross_references = [resource]))


##FIXME: Put into encompassing structure

return interaction, plex



def get_interaction_by_subunit(self, uniprot, select = common_schema.ProteinInteractions):
# q = self.data_source.session.query(select).join(common_schema.ProteinInteractions, common_schema.AbundanceData.subunit)
# condition = common_schema.ProteinSubunit.gene_name == gene_name
# return q.filter(condition)
pass
q = self.data_source.session.query(select).filter(or_(select.participant_a == 'uniprotkb:'+uniprot,
select.participant_b == 'uniprotkb:'+uniprot))
return q


def get_known_complex_by_subunit(self, uniprot, select = common_schema.ProteinComplex):
q = self.data_source.session.query(select).join(common_schema.ProteinSubunit, select.protein_subunit)
condition = common_schema.ProteinSubunit.uniprot_id == uniprot
return q.filter(condition)


def get_subunits_by_known_complex(self, complex, select = common_schema.ProteinSubunit):
q = self.data_source.session.query(select).join(common_schema.ProteinSubunit, select.protein_subunit)
condition = common_schema.ProteinSubunit.uniprot_id == uniprot
def get_subunits_by_known_complex(self, complex_name, select = common_schema.ProteinSubunit):
q = self.data_source.session.query(select).join(common_schema.ProteinComplex, select.proteincomplex)
condition = common_schema.ProteinComplex.complex_name == complex_name
return q.filter(condition)
43 changes: 41 additions & 2 deletions tests/data_query/test_protein_protein_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,42 @@ class TestProteinProteinInteractionGenerator(unittest.TestCase):
@classmethod
def setUpClass(self):
self.protein_Q9CWF2 = data_model.ProteinSpecie(uniprot_id = 'Q9CWF2')
self.protein = data_model.ProteinSpecie(uniprot_id = 'P53622')

def test_get_interaction_by_subunit(self):
def get_observed_values(self):
pass

def test_get_observable_interactions_and_complex(self):
q= ppi.ProteintoProteinInteractionQueryGenerator()

interaction, complex = q.get_observable_interactions_and_complex(self.protein)

self.assertEqual(set([i.participant_a for i in interaction]),
set([u'uniprotkb:P41810', u'uniprotkb:P41811', u'uniprotkb:P53622',
u'uniprotkb:P33767', u'uniprotkb:P40509']))
self.assertEqual(complex, [])


def test_get_interaction_by_subunit(self):
q= ppi.ProteintoProteinInteractionQueryGenerator()

ans = q.get_interaction_by_subunit('P49418').all()

self.assertEqual(set([c.site_a for c in ans]),set([u'binding-associated region:545-695(MINT-1523780)',
u'binding-associated region:846-854(MINT-8096500)', u'binding-associated region:626-695(MINT-8094602)',
u'binding-associated region:626-695(MINT-8094834)',
u'glutathione s tranferase tag:?-?(MINT-8096286)|binding-associated region:620-695(MINT-8096289)',
u'glutathione s tranferase tag:?-?(MINT-8096392)|binding-associated region:620-695(MINT-8096394)',
u'binding-associated region:626-695(MINT-8094740)', u'-',
u'binding-associated region:620-695(MINT-8095970)|glutathione s tranferase tag:?-?(MINT-8095968)',
u'binding-associated region:626-695(MINT-376295)', u'binding-associated region:626-695(MINT-8094630)',
u'binding-associated region:620-695(MINT-8096476)|glutathione s tranferase tag:?-?(MINT-8096479)',
u'binding-associated region:545-695(MINT-1523797)',
u'binding-associated region:620-695(MINT-8095931)|glutathione s tranferase tag:?-?(MINT-8095934)',
u'glutathione s tranferase tag:?-?(MINT-8095915)|binding-associated region:620-695(MINT-8095918)',
u'glutathione s tranferase tag:?-?(MINT-8096369)|binding-associated region:620-695(MINT-8096366)',
u'binding-associated region:626-695(MINT-8094654)', u'binding-associated region:626-695(MINT-8094709)']))

def test_get_known_complex_by_subunit(self):
q= ppi.ProteintoProteinInteractionQueryGenerator()

Expand All @@ -24,4 +56,11 @@ def test_get_known_complex_by_subunit(self):
self.assertEqual(ans[0].go_id, 'GO:0006461;GO:0006897;GO:0030036')

def test_get_subunits_by_known_complex(self):
pass
q= ppi.ProteintoProteinInteractionQueryGenerator()

name = 'Succinyl-CoA synthetase, GDP-forming'

ans = q.get_subunits_by_known_complex(name).all()

self.assertEqual([c.uniprot_id for c in ans],
[u'O19069', u'P53590', u'P53597', u'Q96I99', u'Q9WUM5', u'Q9Z2I8'])

0 comments on commit 69b5a09

Please sign in to comment.