13
13
** copyright (C) 2003-2017 Upinder S. Bhalla. and NCBS
14
14
Created : Thu May 13 10:19:00 2016(+0530)
15
15
Version
16
- Last-Updated: Mon Jun 16 10 :30:00 2019 (+0530)
16
+ Last-Updated: Fri Mar 20 1 :30:00 2020 (+0530)
17
17
By:HarshaRani
18
18
**********************************************************************/
19
+ 2010:
20
+ Mar 04: - Enzyme-cplx reactant/product's based on stoichiometry number of connection are made.
21
+ Jan 09: - reading channel back from MMenz
19
22
2019:
20
23
Jun 06: - both compartment name and Id is mapped to the values in comptSbmlidMooseIdMap
21
24
May 23: - checking for integer in Assignment expr
78
81
import moose
79
82
from moose .chemUtil .chemConnectUtil import *
80
83
from moose .SBML .validation import validateModel
81
- import moose .print_utils as pu
82
84
import re
83
85
import os
84
86
@@ -101,7 +103,7 @@ def mooseReadSBML(filepath, loadpath, solver="ee",validate="on"):
101
103
return moose .element ('/' )
102
104
103
105
if not os .path .isfile (filepath ):
104
- pu . warn ('%s is not found ' % filepath )
106
+ print ('%s is not found ' % filepath )
105
107
return moose .element ('/' )
106
108
107
109
with open (filepath , "r" ) as filep :
@@ -119,11 +121,11 @@ def mooseReadSBML(filepath, loadpath, solver="ee",validate="on"):
119
121
if tobecontinue :
120
122
level = document .getLevel ()
121
123
version = document .getVersion ()
122
- pu . info ( "File : " + filepath + " (Level " +
124
+ print ( " \n File : " + filepath + " (Level " +
123
125
str (level ) + ", version " + str (version ) + ")" )
124
126
model = document .getModel ()
125
127
if model is None :
126
- pu . error ("No model present." )
128
+ print ("No model present." )
127
129
return moose .element ('/' )
128
130
else :
129
131
@@ -289,8 +291,7 @@ def checkGroup(basePath,model,comptSbmlidMooseIdMap):
289
291
groupInfo [p .getId ()] = {"mpath" :moosegrp , "splist" :memlists }
290
292
return groupInfo
291
293
292
- def setupEnzymaticReaction (enz , groupName , enzName ,
293
- specInfoMap , modelAnnotaInfo ,deletcplxMol ):
294
+ def setupEnzymaticReaction (enz , groupName , enzName , specInfoMap , modelAnnotaInfo ,deletcplxMol ):
294
295
enzPool = (modelAnnotaInfo [groupName ]["enzyme" ])
295
296
enzPool = str (idBeginWith (enzPool ))
296
297
enzParent = specInfoMap [enzPool ]["Mpath" ]
@@ -306,17 +307,42 @@ def setupEnzymaticReaction(enz, groupName, enzName,
306
307
prdlist = (modelAnnotaInfo [groupName ]["product" ])
307
308
deletcplxMol .append (complx .path )
308
309
complx = complx1
310
+
311
+ enz_sublist = {}
312
+ enz_prdlist = {}
313
+ #getting the reference of enz_complex_formation to get substrate and its stoichiometry
314
+ enz_cplx_form = (modelAnnotaInfo [groupName ]["enz_id_s1" ])
315
+ for tr in range (0 ,enz_cplx_form .getNumReactants ()):
316
+ sp = enz_cplx_form .getReactant (tr )
317
+ spspieces = sp .getSpecies ()
318
+ enz_sublist [spspieces ] = int (sp .getStoichiometry ())
319
+
320
+ for tr in range (0 ,enz .getNumProducts ()):
321
+ sp = enz .getProduct (tr )
322
+ spspieces = sp .getSpecies ()
323
+ enz_prdlist [spspieces ] = int (sp .getStoichiometry ())
324
+
309
325
for si in range (0 , len (sublist )):
310
326
sl = sublist [si ]
311
327
sl = str (idBeginWith (sl ))
312
328
mSId = specInfoMap [sl ]["Mpath" ]
313
- moose .connect (enzyme_ , "sub" , mSId , "reac" )
329
+ substoic = 1
330
+ if sl in enz_sublist :
331
+ substoic = enz_sublist [sl ]
332
+
333
+ for sls in range (0 ,substoic ):
334
+ moose .connect (enzyme_ , "sub" , mSId , "reac" )
335
+
314
336
315
337
for pi in range (0 , len (prdlist )):
316
338
pl = prdlist [pi ]
317
339
pl = str (idBeginWith (pl ))
318
340
mPId = specInfoMap [pl ]["Mpath" ]
319
- moose .connect (enzyme_ , "prd" , mPId , "reac" )
341
+ prdstoic = 1
342
+ if pl in enz_prdlist :
343
+ prdstoic = enz_prdlist [pl ]
344
+ for pls in range (0 ,prdstoic ):
345
+ moose .connect (enzyme_ , "prd" , mPId , "reac" )
320
346
321
347
if (enz .isSetNotes ):
322
348
pullnotes (enz , enzyme_ )
@@ -335,16 +361,16 @@ def addSubPrd(reac, reName, type, reactSBMLIdMooseId, specInfoMap):
335
361
rctMapIter [sp ] = rct .getStoichiometry ()
336
362
else :
337
363
rctMapIter [sp ] = 1
338
- if rct .getStoichiometry () > 1 :
339
- pass
340
- # print " stoich ",reac.name,rct.getStoichiometry()
341
364
noplusStoichsub = noplusStoichsub + rct .getStoichiometry ()
342
365
for key , value in list (rctMapIter .items ()):
343
366
key = str (idBeginWith (key ))
344
367
src = specInfoMap [key ]["Mpath" ]
345
368
des = reactSBMLIdMooseId [reName ]["MooseId" ]
346
369
for s in range (0 , int (value )):
347
- moose .connect (des , 'sub' , src , 'reac' , 'OneToOne' )
370
+ if (reactSBMLIdMooseId [reName ]["MooseId" ]).className == "ConcChan" :
371
+ moose .connect (des , 'in' , src , 'reac' , 'OneToOne' )
372
+ else :
373
+ moose .connect (des , 'sub' , src , 'reac' , 'OneToOne' )
348
374
addSubinfo = {"nSub" : noplusStoichsub }
349
375
reactSBMLIdMooseId [reName ].update (addSubinfo )
350
376
@@ -359,9 +385,6 @@ def addSubPrd(reac, reName, type, reactSBMLIdMooseId, specInfoMap):
359
385
else :
360
386
rctMapIter [sp ] = 1
361
387
362
- if rct .getStoichiometry () > 1 :
363
- pass
364
- # print " stoich prd",reac.name,rct.getStoichiometry()
365
388
noplusStoichprd = noplusStoichprd + rct .getStoichiometry ()
366
389
367
390
for key , values in list (rctMapIter .items ()):
@@ -370,7 +393,10 @@ def addSubPrd(reac, reName, type, reactSBMLIdMooseId, specInfoMap):
370
393
key = parentSp = str (idBeginWith (key ))
371
394
des = specInfoMap [key ]["Mpath" ]
372
395
for i in range (0 , int (values )):
373
- moose .connect (src , 'prd' , des , 'reac' , 'OneToOne' )
396
+ if (reactSBMLIdMooseId [reName ]["MooseId" ]).className == "ConcChan" :
397
+ moose .connect (src , 'out' , des , 'reac' , 'OneToOne' )
398
+ else :
399
+ moose .connect (src , 'prd' , des , 'reac' , 'OneToOne' )
374
400
addPrdinfo = {"nPrd" : noplusStoichprd }
375
401
reactSBMLIdMooseId [reName ].update (addPrdinfo )
376
402
@@ -504,6 +530,10 @@ def getObjAnnotation(obj, modelAnnotationInfo):
504
530
annotateMap [nodeName ] = nodeValue
505
531
if nodeName == "motorConstant" :
506
532
annotateMap [nodeName ] = nodeValue
533
+ if nodeName == "Channel" :
534
+ annotateMap [nodeName ] = nodeValue
535
+ if nodeName == "Permeability" :
536
+ annotateMap [nodeName ] = nodeValue
507
537
return annotateMap
508
538
509
539
@@ -575,7 +605,8 @@ def getEnzAnnotation(obj, modelAnnotaInfo, rev,
575
605
"stage" : list (annotateMap ["stage" ])[0 ],
576
606
"substrate" : sublist ,
577
607
"k1" : k1 ,
578
- "k2" : k2
608
+ "k2" : k2 ,
609
+ "enz_id_s1" :obj
579
610
}
580
611
)
581
612
else :
@@ -584,7 +615,8 @@ def getEnzAnnotation(obj, modelAnnotaInfo, rev,
584
615
"stage" : list (annotateMap ["stage" ])[0 ],
585
616
"substrate" : sublist ,
586
617
"k1" : k1 ,
587
- "k2" : k2
618
+ "k2" : k2 ,
619
+ "enz_id_s1" :obj
588
620
#"group" : list(annotateMap["Group"])[0],
589
621
#"xCord" : list(annotateMap["xCord"])[0],
590
622
#"yCord" : list(annotateMap["yCord"]) [0]
@@ -628,6 +660,7 @@ def createReaction(model, specInfoMap, modelAnnotaInfo, globparameterIdValue,fun
628
660
629
661
for ritem in range (0 , model .getNumReactions ()):
630
662
reactionCreated = False
663
+ channelCreated = False
631
664
groupName = ""
632
665
rName = ""
633
666
rId = ""
@@ -637,7 +670,6 @@ def createReaction(model, specInfoMap, modelAnnotaInfo, globparameterIdValue,fun
637
670
reacAnnoInfo = getObjAnnotation (reac , modelAnnotaInfo )
638
671
# if "Group" in reacAnnoInfo:
639
672
# group = reacAnnoInfo["Group"]
640
-
641
673
if (reac .isSetId ()):
642
674
rId = reac .getId ()
643
675
#groups = [k for k, v in groupInfo.items() if rId in v]
@@ -662,7 +694,6 @@ def createReaction(model, specInfoMap, modelAnnotaInfo, globparameterIdValue,fun
662
694
if (reac .getAnnotation () is not None ):
663
695
groupName = getEnzAnnotation (
664
696
reac , modelAnnotaInfo , rev , globparameterIdValue , specInfoMap ,funcDef )
665
-
666
697
if (groupName != "" and list (
667
698
modelAnnotaInfo [groupName ]["stage" ])[0 ] == 3 ):
668
699
reaction_ , reactionCreated = setupEnzymaticReaction (
@@ -693,7 +724,10 @@ def createReaction(model, specInfoMap, modelAnnotaInfo, globparameterIdValue,fun
693
724
reacInfo .textColor = v
694
725
695
726
elif (groupName == "" ):
696
-
727
+ channelfound = False
728
+ for k , v in list (reacAnnoInfo .items ()):
729
+ if k == "Channel" :
730
+ channelfound = True
697
731
numRcts = reac .getNumReactants ()
698
732
numPdts = reac .getNumProducts ()
699
733
nummodifiers = reac .getNumModifiers ()
@@ -702,11 +736,17 @@ def createReaction(model, specInfoMap, modelAnnotaInfo, globparameterIdValue,fun
702
736
# reactionCreated = False
703
737
704
738
if not (numRcts and numPdts ):
705
- print ("Warning: %s" % (rName )," : Substrate or Product is missing, we will be skiping creating this reaction in MOOSE" )
739
+ #print("Warning: %s" %(rName)," : Substrate or Product is missing, we will be skiping creating this reaction in MOOSE")
740
+ print ("Warning: %s" % (rName )," : Substrate or Product is missing, we will be skiping creating this %s" % ("reaction" if not channelfound else "Channel" ) + " in MOOSE" )
706
741
reactionCreated = False
707
742
elif (reac .getNumModifiers () > 0 ):
708
- reactionCreated , reaction_ = setupMMEnzymeReaction (
709
- reac , rName , specInfoMap , reactSBMLIdMooseId , modelAnnotaInfo , model , globparameterIdValue )
743
+ if not channelfound :
744
+ reactionCreated , reaction_ = setupMMEnzymeReaction (
745
+ reac , rName , specInfoMap , reactSBMLIdMooseId , modelAnnotaInfo , model , globparameterIdValue )
746
+ else :
747
+ channelCreated , channel_ = setupConcChannel (reac ,rName ,specInfoMap ,reactSBMLIdMooseId , modelAnnotaInfo , model , globparameterIdValue )
748
+ reactSBMLIdMooseId [rName ] = {
749
+ "MooseId" : channel_ }
710
750
# elif (reac.getNumModifiers() > 0):
711
751
# reactionCreated = setupMMEnzymeReaction(reac,rName,specInfoMap,reactSBMLIdMooseId,modelAnnotaInfo,model,globparameterIdValue)
712
752
# reaction_ = reactSBMLIdMooseId['classical']['MooseId']
@@ -731,7 +771,7 @@ def createReaction(model, specInfoMap, modelAnnotaInfo, globparameterIdValue,fun
731
771
reaction_ = moose .Reac (speCompt + '/' + rName )
732
772
reactionCreated = True
733
773
reactSBMLIdMooseId [rName ] = {
734
- "MooseId" : reaction_ , "className " : "reaction" }
774
+ "MooseId" : reaction_ }
735
775
elif (numPdts ):
736
776
# In moose, reactions compartment are decided from first Substrate compartment info
737
777
# substrate is missing then check for product
@@ -743,8 +783,11 @@ def createReaction(model, specInfoMap, modelAnnotaInfo, globparameterIdValue,fun
743
783
reaction_ = moose .Reac (speCompt + '/' + rName )
744
784
reactionCreated = True
745
785
reactSBMLIdMooseId [rId ] = {
746
- "MooseId" : reaction_ , "className" : "reaction" }
747
- if reactionCreated :
786
+ "MooseId" : reaction_ }
787
+ if reactionCreated or channelCreated :
788
+ if channelCreated :
789
+ reaction_ = channel_
790
+
748
791
if (reac .isSetNotes ):
749
792
pullnotes (reac , reaction_ )
750
793
reacAnnoInfo = {}
@@ -787,6 +830,8 @@ def createReaction(model, specInfoMap, modelAnnotaInfo, globparameterIdValue,fun
787
830
elif reaction_ .className == "MMenz" :
788
831
reaction_ .kcat = kfvalue
789
832
reaction_ .Km = kbvalue
833
+ elif reaction_ .className == "ConcChan" :
834
+ reaction_ .permeability = kfvalue
790
835
for l in deletecplxMol :
791
836
if moose .exists (l ):
792
837
moose .delete (moose .element (l ))
@@ -1449,6 +1494,23 @@ def createCompartment(basePath, model, comptSbmlidMooseIdMap):
1449
1494
return False ," EndoMesh's surrounding compartment missing or wrong deleting the compartment check the file"
1450
1495
return True ,""
1451
1496
1497
+ def setupConcChannel (reac , rName , specInfoMap , reactSBMLIdMooseId ,
1498
+ modelAnnotaInfo , model , globparameterIdValue ):
1499
+ msg = ""
1500
+ errorFlag = ""
1501
+ numRcts = reac .getNumReactants ()
1502
+ numPdts = reac .getNumProducts ()
1503
+ nummodifiers = reac .getNumModifiers ()
1504
+ if (nummodifiers ):
1505
+ parent = reac .getModifier (0 )
1506
+ parentSp = parent .getSpecies ()
1507
+ parentSp = str (idBeginWith (parentSp ))
1508
+ enzParent = specInfoMap [parentSp ]["Mpath" ]
1509
+ ConcChan = moose .ConcChan (enzParent .path + '/' + rName )
1510
+ moose .connect (enzParent , "nOut" , ConcChan , "setNumChan" )
1511
+ channelCreated = True
1512
+ if channelCreated :
1513
+ return (channelCreated ,ConcChan )
1452
1514
1453
1515
def setupMMEnzymeReaction (reac , rName , specInfoMap , reactSBMLIdMooseId ,
1454
1516
modelAnnotaInfo , model , globparameterIdValue ):
@@ -1465,7 +1527,7 @@ def setupMMEnzymeReaction(reac, rName, specInfoMap, reactSBMLIdMooseId,
1465
1527
MMEnz = moose .MMenz (enzParent .path + '/' + rName )
1466
1528
moose .connect (enzParent , "nOut" , MMEnz , "enzDest" )
1467
1529
reactionCreated = True
1468
- reactSBMLIdMooseId [rName ] = {"MooseId" : MMEnz , "className" : "MMEnz" }
1530
+ reactSBMLIdMooseId [rName ] = {"MooseId" : MMEnz }
1469
1531
if reactionCreated :
1470
1532
if (reac .isSetNotes ):
1471
1533
pullnotes (reac , MMEnz )
0 commit comments