Skip to content

Commit

Permalink
Updates on membrane mech and comp
Browse files Browse the repository at this point in the history
Additionally cleans up comments and descriptions.
  • Loading branch information
zjuradoq committed Jan 16, 2025
1 parent 03ae95e commit b0d1ffd
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 600 deletions.
50 changes: 42 additions & 8 deletions Tests/Unit/test_component_membrane.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# Copyright (c) 2020, Build-A-Cell. All rights reserved.
# See LICENSE file in the project root directory for details.

from biocrnpyler import IntegralMembraneProtein, MembraneChannel, MembranePump
from biocrnpyler import DiffusibleMolecule, IntegralMembraneProtein, MembraneChannel, MembranePump, MembraneSensor
import pytest

def test_DiffusibleMolecule():
diffusion_molecule = 'DP'

dm = DiffusibleMolecule(substrate=diffusion_molecule)
assert diffusion_molecule == dm.substrate.name
assert diffusion_molecule== dm.product.name

assert dm.get_species().name == 'DP'

with pytest.raises(KeyError, match='Unable to find mechanism of type diffusion in Component'):
mp.update_species()

with pytest.raises(KeyError, match='Unable to find mechanism of type diffusion in Component'):
mp.update_reactions()

def test_IntegralMembraneProtein():
membrane_protein = 'MP1'
Expand All @@ -15,10 +29,10 @@ def test_IntegralMembraneProtein():

assert mp.get_species().name == 'MP1'

with pytest.raises(KeyError, match='Unable to find mechanism of type catalysis in Component'):
with pytest.raises(KeyError, match='Unable to find mechanism of type membrane_insertion in Component'):
mp.update_species()

with pytest.raises(KeyError, match='Unable to find mechanism of type catalysis in Component'):
with pytest.raises(KeyError, match='Unable to find mechanism of type membrane_insertion in Component'):
mp.update_reactions()

def test_MembraneChannel():
Expand All @@ -32,10 +46,10 @@ def test_MembraneChannel():

assert imp.get_species().name == 'IMP1'

with pytest.raises(KeyError, match='Unable to find mechanism of type catalysis in Component'):
with pytest.raises(KeyError, match='Unable to find mechanism of type transport in Component'):
imp.update_species()

with pytest.raises(KeyError, match='Unable to find mechanism of type catalysis in Component'):
with pytest.raises(KeyError, match='Unable to find mechanism of type transport in Component'):
imp.update_reactions()

def test_MembranePump():
Expand All @@ -49,8 +63,28 @@ def test_MembranePump():

assert imp.get_species().name == 'MPump1'

with pytest.raises(KeyError, match='Unable to find mechanism of type catalysis in Component'):
with pytest.raises(KeyError, match='Unable to find mechanism of type transport in Component'):
imp.update_species()

with pytest.raises(KeyError, match='Unable to find mechanism of type catalysis in Component'):
imp.update_reactions()
with pytest.raises(KeyError, match='Unable to find mechanism of type transport in Component'):
imp.update_reactions()

def test_MembraneSensor():
membrane_sensor = 'MSensor1'
response_protein = 'RP1'
assigned_substrate = 'Sub_A1'
signal_substrate = 'Sub_S1'

ms = MembraneSensor(membrane_sensor, response_protein=response_protein,
assigned_substrate=assigned_substrate, signal_substrate=signal_substrate)
assert response_protein == ms.response_protein.name
assert assigned_substrate == ms.assigned_substrate.name
assert signal_substrate == ms.signal_substrate.name

assert ms.get_species().name == 'MSensor1'

with pytest.raises(KeyError, match='Unable to find mechanism of type membrane_sensor in Component'):
ms.update_species()

with pytest.raises(KeyError, match='Unable to find mechanism of type membrane_sensor in Component'):
ms.update_reactions()
48 changes: 48 additions & 0 deletions Tests/Unit/test_membrane_signaling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

# Copyright (c) 2020, Build-A-Cell. All rights reserved.
# See LICENSE file in the project root directory for details.

from biocrnpyler import Species, Complex

#Test Membrane Transport Mechanisms
from biocrnpyler import Membrane_Signaling_Pathway_MM

class test_membrane_signaling_MM():
tcs = Membrane_Signaling_Pathway_MM()
MSP = Species("MSP1")
MSP.ATP=2
RP = Species("RP1")
sub_assign = Species("S1")
sub_signal = Species("S2")
energy = Species("E1")
waste = Species("W1")
c1 = Complex([sub_signal, MSP])
c2 = Complex([MP.ATP*[energy], c1])
c3 = Complex([c1, MP.ATP*[waste], sub_assign])
c4 = Complex([c1, sub_assign])
c5 = Complex([c4, RP])
c6 = Complex([c1, RP, sub_assign])
c7 = Complex([RP, sub_assign])

c_fake = Species("C")

#Test Update Species
assert len(tcs.update_species(MSP, RP, sub_assign, sub_signal, energy, waste)) == 13
assert c1 in tcs.update_species(MSP, RP, sub_assign, sub_signal, energy, waste)
assert c2 in tcs.update_species(MSP, RP, sub_assign, sub_signal, energy, waste)
assert c3 in tcs.update_species(MSP, RP, sub_assign, sub_signal, energy, waste)
assert c4 in tcs.update_species(MSP, RP, sub_assign, sub_signal, energy, waste)
assert c5 in tcs.update_species(MSP, RP, sub_assign, sub_signal, energy, waste)
assert c6 in tcs.update_species(MSP, RP, sub_assign, sub_signal, energy, waste)
assert c7 in tcs.update_species(MSP, RP, sub_assign, sub_signal, energy, waste)

assert c_fake in tcs.update_species(MSP, RP, sub_assign, sub_signal, energy, waste, complex = c_fake)

#Test Update Reactions
assert len(tcs.update_reactions(MSP, RP, sub_assign, sub_signal, energy, waste, kb1 = 2e-3, ku1 = 2e-10,
kb2 = 2e-3, ku2 = 2e-10, k_hydro = 1e-1, ku3 = 2e-1, kb4 = 2e-3, ku4 = 2e-10,
k_phosph = 1e-1, ku5 = 2e-1,ku6 = 2e-10)) == 8

assert len(tcs.update_reactions(MSP, RP, sub_assign, sub_signal, energy, waste, kb1 = 2e-3, ku1 = 2e-10,
kb2 = 2e-3, ku2 = 2e-10, k_hydro = 1e-1, ku3 = 2e-1, kb4 = 2e-3, ku4 = 2e-10,
k_phosph = 1e-1, ku5 = 2e-1,ku6 = 2e-10, complex_species = c_fake,)) == 8
19 changes: 16 additions & 3 deletions Tests/Unit/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@
from biocrnpyler import Species, Complex

#Test Membrane Transport Mechanisms
from biocrnpyler import Membrane_Protein_Integration, Simple_Transport, Facilitated_Transport_MM, Primary_Active_Transport_MM
from biocrnpyler import Simple_Diffusion, Membrane_Protein_Integration, Simple_Transport, Facilitated_Transport_MM, Primary_Active_Transport_MM

class test_simple_diffusion():
sd = Simple_Diffusion()
substrate = Species("DMi")
product = Species("DMo")
c_fake = Species("C")

#Test Update Species
assert len(sd.update_species(substrate, product))==2
assert c1 in sd.update_species(substrate, product)

#Test Update Reactions
assert len(sd.update_reactions(substrate, product, k_diff = 1.0,)) == 1
assert len(sd.update_reactions(substrate, product, k_diff = 1.0, complex_species = c_fake,)) == 1

class test_membrane_integration():
mpi = Membrane_Protein_Integration()
Expand Down Expand Up @@ -84,5 +98,4 @@ class test_active_transport_MM():

#Test Update Reactions
assert len(pat.update_reactions(MP, substrate, product, energy, waste, k1 = 1.0, ku1 = 1.0, k2 = 1.0, ku2 = 1.0, k_trnsp = 1.0, ku3= 1.0, ku4= 1.0)) == 7
assert len(pat.update_reactions(MP, substrate, product, energy, waste, k1 = 1.0, ku1 = 1.0, k2 = 1.0, ku2 = 1.0, k_trnsp = 1.0, ku3= 1.0, ku4= 1.0, complex_species = c_fake,)) == 7

assert len(pat.update_reactions(MP, substrate, product, energy, waste, k1 = 1.0, ku1 = 1.0, k2 = 1.0, ku2 = 1.0, k_trnsp = 1.0, ku3= 1.0, ku4= 1.0, complex_species = c_fake,)) == 7
4 changes: 2 additions & 2 deletions biocrnpyler/components_membrane.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
from .reaction import Reaction
from .species import Complex, Species

class Diffusible_Molecule(Component):
class DiffusibleMolecule(Component):
"""A class to represent transmembrane proteins or integral membrane proteins.
This membrane class is to classify a membrane channel that will intergrate into the membrane.
Uses a mechanism called "diffusion".
"""
def __init__(self, substrate: Union[Species,str, Component],
internal_compartment='Internal', external_compartment='External',
cell=None, attributes=None, **keywords):
"""Initialize a Diffusible_Molecule object to store molecule/substance related information.
"""Initialize a DiffusibleMolecule object to store molecule/substance related information.
:param substrate: name of the diffusible substrate, reference to an Species or Component
:param internal_compartment: name of internal compartment
:param external_compartment: name of external compartment
Expand Down
6 changes: 4 additions & 2 deletions biocrnpyler/mechanism_signaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ def update_reactions(self, membrane_sensor_protein, response_protein, assigned_s
if part_id is None and component is not None:
part_id = component.name

if component is None and (kb1 is None or ku1 is None or kb2 is None or kex is None or kcat is None):
raise ValueError("Must pass in a Component or values for kb1, ku1, kb2, kex, and kcat.")
if component is None and (kb1 is None or ku1 is None or kb2 is None or ku2 is None or k_hydro is None
or ku3 is None or kb4 is None or ku4 is None or k_phosph is None
or ku5 is None or ku6 is None):
raise ValueError("Must pass in a Component or values for kb1, ku1, kb2, ku2, k_hydro, ku3, kb4, ku4, k_phosph, ku5 and ku6.")

if kb1 is None:
kb1 = component.get_parameter("kb1", part_id = part_id, mechanism = self)
Expand Down
10 changes: 5 additions & 5 deletions biocrnpyler/mechanisms_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def update_reactions(self, integral_membrane_protein, product, component=None, p
if part_id is None and component is not None:
part_id = component.name

if component is None and (kb is None or ku is None or kcat is None):
raise ValueError("Must pass in a Component or values for kb, ku, and kcat.")
if component is None and (kb1 is None or ku1 is None or kb2 is None or ku2 is None or kcat is None or kex is None):
raise ValueError("Must pass in a Component or values for kb1, ku1, kb2, ku2, kcat, and kex.")

if kb1 is None:
kb1 = component.get_parameter("kb1", part_id = part_id, mechanism = self)
Expand Down Expand Up @@ -150,7 +150,7 @@ def update_reactions(self, membrane_channel, substrate, product, component=None,
part_id = component.name

if component is None and (k_trnsp is None):
raise ValueError("Must pass in a Component or values for kb, ku, and kcat.")
raise ValueError("Must pass in a Component or values for k_trnsp.")
if k_trnsp is None:
k_trnsp = component.get_parameter("k_trnsp", part_id = part_id, mechanism = self)
else:
Expand Down Expand Up @@ -190,8 +190,8 @@ def update_reactions(self, membrane_carrier, substrate, product, component = Non
if part_id is None and component is not None:
part_id = component.name

if component is None and (kb is None or ku is None or k1 is None):
raise ValueError("Must pass in a Component or values for kb, ku, and kcat.")
if component is None and (k1 is None or ku1 is None or ku2 is None or k_trnsp is None):
raise ValueError("Must pass in a Component or values for k1, ku1, ku2, and k_trnsp.")

if k1 is None:
k1 = component.get_parameter("k1", part_id = part_id, mechanism = self)
Expand Down
Loading

0 comments on commit b0d1ffd

Please sign in to comment.