Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace np float and int #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
Binary file modified SERGIO/.DS_Store
Binary file not shown.
54 changes: 27 additions & 27 deletions SERGIO/sergio.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def build_graph (self, input_file_taregts, input_file_regs, shared_coop_state =
reader = csv.reader(f, delimiter=',')
if (shared_coop_state <= 0):
for row in reader:
nRegs = np.int(row[1])
nRegs = int(float(row[1]))
##################### Raise Error ##########################
if nRegs == 0:
print ("Error: a master regulator (#Regs = 0) appeared in input")
Expand All @@ -165,22 +165,22 @@ def build_graph (self, input_file_taregts, input_file_regs, shared_coop_state =
currInteraction = []
currParents = []
for regId, K, C_state in zip(row[2: 2 + nRegs], row[2+nRegs : 2+2*nRegs], row[2+2*nRegs : 2+3*nRegs]):
currInteraction.append((np.int(regId), np.float(K), np.float(C_state), 0)) # last zero shows half-response, it is modified in another method
allRegs.append(np.int(regId))
currParents.append(np.int(regId))
self.graph_[np.int(regId)]['targets'].append(np.int(row[0]))
currInteraction.append((int(float(regId)), float(K), float(C_state), 0)) # last zero shows half-response, it is modified in another method
allRegs.append(int(float(regId)))
currParents.append(int(float(regId)))
self.graph_[int(float(regId))]['targets'].append(int(float(row[0])))

self.graph_[np.int(row[0])]['params'] = currInteraction
self.graph_[np.int(row[0])]['regs'] = currParents
self.graph_[np.int(row[0])]['level'] = -1 # will be modified later
allTargets.append(np.int(row[0]))
self.graph_[int(float(row[0]))]['params'] = currInteraction
self.graph_[int(float(row[0]))]['regs'] = currParents
self.graph_[int(float(row[0]))]['level'] = -1 # will be modified later
allTargets.append(int(float(row[0])))

#if self.dyn_:
# for b in range(self.nBins_):
# binDict[b].append(gene(np.int(row[0]),'T', b))
# binDict[b].append(gene(int(float(row[0]),'T', b))
else:
for indRow, row in enumerate(reader):
nRegs = np.int(np.float(row[1]))
nRegs = int(float((row[1])))
##################### Raise Error ##########################
if nRegs == 0:
print ("Error: a master regulator (#Regs = 0) appeared in input")
Expand All @@ -190,19 +190,19 @@ def build_graph (self, input_file_taregts, input_file_regs, shared_coop_state =
currInteraction = []
currParents = []
for regId, K, in zip(row[2: 2 + nRegs], row[2+nRegs : 2+2*nRegs]):
currInteraction.append((np.int(np.float(regId)), np.float(K), shared_coop_state, 0)) # last zero shows half-response, it is modified in another method
allRegs.append(np.int(np.float(regId)))
currParents.append(np.int(np.float(regId)))
self.graph_[np.int(np.float(regId))]['targets'].append(np.int(np.float(row[0])))
currInteraction.append((int(float((regId))), float(K), shared_coop_state, 0)) # last zero shows half-response, it is modified in another method
allRegs.append(int(float((regId))))
currParents.append(int(float((regId))))
self.graph_[int(float((regId)))]['targets'].append(int(float((row[0]))))

self.graph_[np.int(np.float(row[0]))]['params'] = currInteraction
self.graph_[np.int(np.float(row[0]))]['regs'] = currParents
self.graph_[np.int(np.float(row[0]))]['level'] = -1 # will be modified later
allTargets.append(np.int(np.float(row[0])))
self.graph_[int(float((row[0])))]['params'] = currInteraction
self.graph_[int(float((row[0])))]['regs'] = currParents
self.graph_[int(float((row[0])))]['level'] = -1 # will be modified later
allTargets.append(int(float((row[0]))))

#if self.dyn_:
# for b in range(self.nBins_):
# binDict[b].append(gene(np.int(row[0]),'T', b))
# binDict[b].append(gene(int(float(row[0]),'T', b))

#self.master_regulators_idx_ = set(np.setdiff1d(allRegs, allTargets))

Expand All @@ -214,14 +214,14 @@ def build_graph (self, input_file_taregts, input_file_regs, shared_coop_state =
print ("Error: Inconsistent number of bins")
sys.exit()

masterRegs.append(int(float(row[0])))
self.graph_[int(float(row[0]))]['rates'] = [np.float(i) for i in row[1:]]
self.graph_[int(float(row[0]))]['regs'] = []
self.graph_[int(float(row[0]))]['level'] = -1
masterRegs.append(int(float(float(row[0]))))
self.graph_[int(float(float(row[0])))]['rates'] = [float(i) for i in row[1:]]
self.graph_[int(float(float(row[0])))]['regs'] = []
self.graph_[int(float(float(row[0])))]['level'] = -1

#if self.dyn_:
# for b in range(self.nBins_):
# binDict[b].append(gene(np.int(row[0]),'MR', b))
# binDict[b].append(gene(int(float(row[0]),'MR', b))

self.master_regulators_idx_ = set(masterRegs)

Expand Down Expand Up @@ -614,15 +614,15 @@ def populate_with_parentCells_(self, binID):

elif np.count_nonzero(parentBins) == 1:
parentBinID = np.nonzero(parentBins)[0][0]
nPopulation = int(round(self.bifurcationMat_[parentBinID, binID] * self.nSC_))
nPopulation = int(float(round(self.bifurcationMat_[parentBinID, binID] * self.nSC_)))
#self.nInitCells_[binID] = nPopulation

#Bifurcation rates of <1/nSC are set to 1/nSC
if nPopulation < 1:
nPopulation = 1
else:
parentBinID = binID
nPopulation = int(max(1, np.random.normal(20,5)))
nPopulation = int(float(max(1, np.random.normal(20,5))))
#self.nInitCells_[binID] = nPopulation

for g in self.binDict[binID]:
Expand Down