-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparallel_simulate.py
144 lines (120 loc) · 5.45 KB
/
parallel_simulate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
from compute_sup_jux_segment import compute_segment
from driver import compute
from values import *
from defs import *
import os
import argparse
import multiprocessing
import output
import re
solute = ['Na','K','Cl','HCO3','H2CO3','CO2','HPO4','H2PO4','urea','NH3','NH4','H','HCO2','H2CO2','glu']
compart = ['Lumen','Cell','ICA','ICB','LIS','Bath']
cw=Vref*60e6
parser = argparse.ArgumentParser()
# required input
parser.add_argument('--sex',choices=['Male','Female'],required = True,type = str,help = 'Sex')
parser.add_argument('--species',choices=['human','rat','mouse'],required = True,type = str, help = 'Human, Rat, or Mouse model')
parser.add_argument('--type',choices = ['superficial','multiple'],required = True,type=str,help='superficial nephron or multiple nephrons?')
# diabetic options
parser.add_argument('--diabetes',choices = ['Severe','Moderate'],default='Non',type=str,help='diabete status (Severe/Moderate)')
parser.add_argument('--inhibition',choices=['ACE','SGLT2','NHE3-50','NHE3-80','NKCC2-70','NKCC2-100','NCC-70','NCC-100','ENaC-70','ENaC-100','SNB-70','SNB-100', 'empa'],default = None,type = str,help = 'any transporter inhibition?')
parser.add_argument('--unx',choices=['N','Y'],default = 'N',type = str,help = 'uninephrectomy status')
# pregnancy option
parser.add_argument('--pregnant', choices=['mid','late'], default='non', type=str, help='pregnant female? (mid/late)')
parser.add_argument('--HT',choices=['N','Y'],default = 'N',type = str,help = 'hypertension?')
args = parser.parse_args()
sex = args.sex
species = args.species
sup_or_multi = args.type
diabete = args.diabetes
inhib = args.inhibition
unx = args.unx
preg = args.pregnant
HT = args.HT
if diabete != 'Non':
if preg != 'non':
raise Exception('pregnant diabetic not done')
if inhib != None:
file_to_save = inhib+'_'+sex+'_'+species[0:3]+'_'+diabete+'_diab'+'_'+unx+'_unx'
else:
file_to_save = sex+'_'+species[0:3]+'_'+diabete+'_diab'+'_'+unx+'_unx'
elif preg != 'non':
if sex == 'Male':
raise Exception('pregnant only for female')
if species[0:3] == 'hum' or species[0:3] == 'mou':
raise Exception('pregnant model not set up for human or mouse yet')
if HT == 'Y':
file_to_save = preg+'pregnant_'+species[0:3]+'_HT'
else:
file_to_save = preg+'pregnant_'+species[0:3]
elif inhib != None:
file_to_save = inhib+'_'+sex+'_'+species[0:3]
elif HT != 'N':
file_to_save = sex + '_' + species[0:3]+'_HT'
else:
file_to_save = sex + '_' + species[0:3] +'_normal'
if os.path.isdir(file_to_save) == False:
os.makedirs(file_to_save)
if sup_or_multi == 'superficial':
parts = ['sup']
else:
parts = ['sup','jux1','jux2','jux3','jux4','jux5']
if os.path.isdir('outlets') == False:
os.makedirs('outlets')
def multiprocessing_func(sup_or_jux):
compute_segment(sup_or_jux, sex, species, sup_or_multi, diabete, inhib, unx, preg, HT, file_to_save)
if __name__ == '__main__':
pool = multiprocessing.Pool()
pool.map(multiprocessing_func,parts)
pool.close()
#========================================================
# Cortical collecting duct
#========================================================
print('Collecting duct begin')
print('CCD start')
NCCD = 200
if sex == 'Male':
filename = './datafiles/CCDparams_M_'+species[0:3]+'.dat'
elif sex == 'Female':
filename = './datafiles/CCDparams_F_'+species[0:3]+'.dat'
else:
filename ='./datafiles/CCDparams_F_'+species[0:3]+'.dat'
ccd=compute(NCCD,filename,'Newton',diabete=diabete,species=species,sup_or_multi=sup_or_multi,inhibition = inhib,unx = unx, preg=preg, HT=HT)
Scaletorq = np.ones(NCCD)
output.output_segment_results(ccd,"",Scaletorq,file_to_save,NCCD)
print('CCD finished.')
print('\n')
#========================================================
# Outer medullary collecting duct
#========================================================
print('OMCD start')
NOMCD = 200
if sex == 'Male':
filename = './datafiles/OMCDparams_M_'+species[0:3]+'.dat'
elif sex == 'Female':
filename = './datafiles/OMCDparams_F_'+species[0:3]+'.dat'
else:
filename ='./datafiles/OMCDparams_F_'+species[0:3]+'.dat'
if ccd[0].sex == 'male':
omcd=compute(NOMCD,filename,'Newton',diabete=diabete,species=species,sup_or_multi=sup_or_multi,inhibition=inhib,unx=unx, preg=preg, HT=HT)
elif ccd[0].sex == 'female':
omcd=compute(NOMCD,filename,'Newton',diabete=diabete,species=species,sup_or_multi=sup_or_multi,inhibition=inhib,unx=unx, preg=preg, HT=HT)
Scaletorq = np.ones(NOMCD)
output.output_segment_results(omcd,"",Scaletorq,file_to_save,NOMCD)
print('OMCD finished.')
print('\n')
#========================================================
# Inner medullary collecting duct
#========================================================
print('IMCD start')
NIMCD = 200
if sex == 'Male':
filename = './datafiles/IMCDparams_M_'+species[0:3]+'.dat'
elif sex == 'Female':
filename = './datafiles/IMCDparams_F_'+species[0:3]+'.dat'
else:
filename ='./datafiles/IMCDparams_F_'+species[0:3]+'.dat'
imcd=compute(NIMCD,filename,'Newton',diabete=diabete,species=species,sup_or_multi=sup_or_multi,inhibition=inhib,unx=unx, preg=preg, HT=HT)
Scaletorq = np.ones(NIMCD)
jvol = output.output_segment_results(imcd,"",Scaletorq,file_to_save,NIMCD)
print('IMCD finished.')