Skip to content

Commit 351cd41

Browse files
committed
More pep8 changes.
1 parent 404c126 commit 351cd41

File tree

5 files changed

+303
-303
lines changed

5 files changed

+303
-303
lines changed

compartment_tree.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import treelib3
22

33

4-
def getCompartmentHierarchy(compartmentList):
4+
def get_compartment_hierarchy(compartmentList):
55
'''
66
constructs a tree structure containing the
77
compartment hierarchy excluding 2D compartments
88
@param:compartmentList
99
'''
10-
def removeMembranes(tree, nodeID):
10+
def remove_membranes(tree, nodeID):
1111
node = tree.get_node(nodeID)
1212
if node.data == 2:
1313
parent = tree.get_node(nodeID).bpointer
@@ -53,7 +53,7 @@ def removeMembranes(tree, nodeID):
5353
return tree
5454

5555

56-
def getOutsideInsideCompartment(compartmentList, compartment):
56+
def get_outside_inside_compartment(compartmentList, compartment):
5757
outside = compartmentList[compartment][2]
5858
for comp in compartmentList:
5959
if compartmentList[comp][2] == compartment:

mdlr2mdl.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import sys
1313

1414

15-
def defineConsole():
15+
def define_console():
1616
parser = argparse.ArgumentParser(description='SBML to BNGL translator')
1717
parser.add_argument(
1818
'-i', '--input', type=str, help='input MDLr file', required=True)
@@ -25,7 +25,7 @@ def defineConsole():
2525
return parser
2626

2727

28-
def getScriptPath():
28+
def get_script_path():
2929
return os.path.dirname(os.path.realpath(sys.argv[0]))
3030

3131

@@ -45,13 +45,13 @@ def __init__(self, configpath):
4545
"mcellr.yaml")
4646
sys.exit(0)
4747

48-
def processMDLR(self, mdlrPath):
48+
def process_mdlr(self, mdlrPath):
4949
'''
5050
main method. extracts species definition, creates bng-xml, creates mdl
5151
definitions
5252
'''
5353
try:
54-
nautyDict = self.xml2HNautySpeciesDefinitions(mdlrPath)
54+
nauty_dict = self.xml2hnauty_species_definitions(mdlrPath)
5555
except OSError:
5656
print("Cannot open BNG2.pl. Please check bionetgen in mcellr.yaml")
5757
sys.exit(0)
@@ -65,11 +65,11 @@ def processMDLR(self, mdlrPath):
6565

6666
xmlspec = read_bngxml.parseFullXML(namespace.input + '.xml')
6767
# write out the equivalent plain mdl stuffs
68-
mdlDict = write_mdl.constructMCell(
69-
xmlspec, namespace.input, finalName.split(os.sep)[-1], nautyDict)
70-
write_mdl.writeMDL(mdlDict, finalName)
68+
mdlDict = write_mdl.construct_mcell(
69+
xmlspec, namespace.input, finalName.split(os.sep)[-1], nauty_dict)
70+
write_mdl.write_mdl(mdlDict, finalName)
7171

72-
def tokenizeSeedElements(self, seed):
72+
def tokenize_seed_elements(self, seed):
7373
# extract species names
7474
seedKeys = re.findall(
7575
'concentration="[0-9a-zA-Z_]+" name="[_0-9a-zA-Z@:(~!),.]+"', seed)
@@ -88,11 +88,11 @@ def tokenizeSeedElements(self, seed):
8888
# print '---', seedDict.keys()
8989
return seedDict
9090

91-
def getNamesFromDefinitionString(self, defStr):
91+
def get_names_from_definition_string(self, defStr):
9292
speciesNames = re.findall('[0-9a-zA-Z_]+\(', defStr)
9393
return [x[:-1] for x in speciesNames]
9494

95-
def xml2HNautySpeciesDefinitions(self, inputMDLRFile):
95+
def xml2hnauty_species_definitions(self, inputMDLRFile):
9696
"""
9797
Temporary function for translating xml bng definitions to nautty
9898
species definition strings
@@ -117,36 +117,36 @@ def xml2HNautySpeciesDefinitions(self, inputMDLRFile):
117117
with open(namespace.input + '_total.xml', 'w') as f:
118118
f.write(rest)
119119
# load up nfsim library
120-
self.nfsim.initNFsim(namespace.input + '_total.xml', 0)
120+
self.nfsim.init_nfsim(namespace.input + '_total.xml', 0)
121121

122122
# remove encapsulating tags
123123
seed = seed[30:-30]
124124
# get the seed species definitions as a list
125-
seedDict = self.tokenizeSeedElements(seed)
125+
seedDict = self.tokenize_seed_elements(seed)
126126

127-
nautyDict = {}
127+
nauty_dict = {}
128128
for seed in seedDict:
129129
# initialize nfsim with each species definition and get back a
130130
# dirty list where one of the entries is the one we want
131131
#
132132
# XXX: i think i've solved it on the nfsim side, double check
133-
tmpList = self.getNautyString(seedDict[seed])
133+
tmpList = self.get_nauty_string(seedDict[seed])
134134
# and now filter it out...
135135
# get species names from species definition string
136-
speciesNames = self.getNamesFromDefinitionString(seed)
137-
nautyDict[seed] = [x for x in tmpList if all(y in x for y in speciesNames)][0]
136+
speciesNames = self.get_names_from_definition_string(seed)
137+
nauty_dict[seed] = [x for x in tmpList if all(y in x for y in speciesNames)][0]
138138

139-
return nautyDict
139+
return nauty_dict
140140

141-
def getNautyString(self, xmlSpeciesDefinition):
142-
self.nfsim.resetSystem()
143-
self.nfsim.initSystemXML(xmlSpeciesDefinition)
141+
def get_nauty_string(self, xmlSpeciesDefinition):
142+
self.nfsim.reset_system()
143+
self.nfsim.init_system_xml(xmlSpeciesDefinition)
144144
result = self.nfsim.querySystemStatus("complex")
145145
return result
146146

147147

148148
if __name__ == "__main__":
149-
parser = defineConsole()
149+
parser = define_console()
150150
namespace = parser.parse_args()
151151
bnglPath = namespace.input + '.bngl'
152152
finalName = namespace.output if namespace.output else namespace.input
@@ -172,11 +172,11 @@ def getNautyString(self, xmlSpeciesDefinition):
172172
mdlDict = write_mdl.constructMDL(
173173
namespace.input + '_sbml.xml.json', namespace.input, finalName)
174174
# create an mdl with nfsim-species and nfsim-reactions
175-
write_mdl.writeMDL(mdlDict, finalName)
175+
write_mdl.write_mdl(mdlDict, finalName)
176176
else:
177177
try:
178-
mdlr2mdl = MDLR2MDL(os.path.join(getScriptPath(), 'mcellr.yaml'))
179-
mdlr2mdl.processMDLR(namespace.input)
178+
mdlr2mdl = MDLR2MDL(os.path.join(get_script_path(), 'mcellr.yaml'))
179+
mdlr2mdl.process_mdlr(namespace.input)
180180
except IOError:
181181
print("Please create mcellr.yaml in the mcellRules directory. Use "
182182
"mcellr.yaml.template as a reference.")

nfsim_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import split_bngxml
33

44

5-
def getCannonicalLabels(seeds):
5+
def get_cannonical_labels(seeds):
66
pass
77

88
seed, _ = split_bngxml.extractSeedBNG('example.mdlr.xml')

nfsim_python.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from ctypes import *
22

33

4-
class queryResultsStruct(Structure):
4+
class QueryResultsStruct(Structure):
55
_fields_ = [("numOfResults", c_int),
66
("results", POINTER(c_char_p))]
77

@@ -10,20 +10,20 @@ class NFSim:
1010
def __init__(self, libPath):
1111
self.lib = cdll.LoadLibrary(libPath)
1212

13-
def initNFsim(self, fileName, verbose):
13+
def init_nfsim(self, fileName, verbose):
1414
"""
1515
inits an nfsim object with a given xml file and a verbosity setting
1616
"""
1717
self.lib.setupNFSim_c(fileName, verbose)
1818

19-
def resetSystem(self):
19+
def reset_system(self):
2020
"""
2121
Resets an nfsim system to having no seeds species
2222
"""
2323
return self.lib.resetSystem_c()
2424

2525

26-
def initSystemNauty(self, initDict):
26+
def init_system_nauty(self, initDict):
2727
"""
2828
Initializes an nfsim simulation with a given nfsim dictionary with the species in nauty format
2929
"""
@@ -36,7 +36,7 @@ def initSystemNauty(self, initDict):
3636
return self.lib.initSystemNauty_c(speciesCArray, seedCArray, len(initDict))
3737

3838

39-
def initSystemXML(self, initXML):
39+
def init_system_xml(self, initXML):
4040
"""
4141
Initializes an nfsim simulation with a given seed species XML string
4242
"""
@@ -47,7 +47,7 @@ def querySystemStatus(self, option):
4747
"""
4848
returns all species that participate in active reactions with numReactants reactants
4949
"""
50-
#self.lib.querySystemStatus_c.restype = queryResultsStruct
50+
#self.lib.querySystemStatus_c.restype = QueryResultsStruct
5151

5252
mem = self.lib.mapvector_create()
5353
#queryResults = self.lib.querySystemStatus_c(option, mem)
@@ -71,12 +71,12 @@ def querySystemStatus(self, option):
7171
if __name__ == "__main__":
7272
nfsim = NFSim('./debug/libnfsim_c.so')
7373

74-
nfsim.initNFsim("cbngl_test_empty.xml", 0)
75-
nfsim.resetSystem()
76-
#nfsim.initSystemNauty({"c:a~NO_STATE!4!2,c:l~NO_STATE!3,c:l~NO_STATE!3!0,m:Lig!2!1,m:Rec!0":1})
77-
#nfsim.initSystemNauty({"c:a~NO_STATE!4!2,c:l~NO_STATE!3,c:l~NO_STATE!3!0,m:Lig!1!2,m:Rec!0,":1})
74+
nfsim.init_nfsim("cbngl_test_empty.xml", 0)
75+
nfsim.reset_system()
76+
#nfsim.init_system_nauty({"c:a~NO_STATE!4!2,c:l~NO_STATE!3,c:l~NO_STATE!3!0,m:Lig!2!1,m:Rec!0":1})
77+
#nfsim.init_system_nauty({"c:a~NO_STATE!4!2,c:l~NO_STATE!3,c:l~NO_STATE!3!0,m:Lig!1!2,m:Rec!0,":1})
7878
#print '---', nfsim.querySystemStatus("observables")
79-
nfsim.initSystemNauty({"c:l~NO_STATE!3!1,c:r~NO_STATE!2!0,m:L@EC!1,m:R@PM!0,":1})
79+
nfsim.init_system_nauty({"c:l~NO_STATE!3!1,c:r~NO_STATE!2!0,m:L@EC!1,m:R@PM!0,":1})
8080
print('----', nfsim.querySystemStatus("complex"))
8181

8282

0 commit comments

Comments
 (0)