-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53ecb78
commit 3ef0d5a
Showing
72 changed files
with
493,912 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Node 1,Node 2,Node 3,Node 4,Node 5 | ||
0,0,0,0,0 | ||
1,1,1,1,0 | ||
1,1,1,-1,0 | ||
1,0,0,-1,0 | ||
0,0,1,-1,0 | ||
1,1,1,-1,0 | ||
1,1,0,-1,0 | ||
1,1,1,-1,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Node 1,Node 2,Node 3,Node 4,Node 5,Node 6 | ||
0,0,0,0,0,0 | ||
1,1,1,1,1,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
|
||
# memoryLength should be even so that the majority function is always defined; | ||
# the input to the majority function includes the current timestep and the | ||
# previous memoryLength timesteps | ||
def generateMajorityFunctionData(memoryLength, | ||
timeseries_filepath, | ||
function_output_filepath): | ||
time_series_file = open(timeseries_filepath) | ||
contents = time_series_file.read() | ||
time_series = [] | ||
for char in contents: | ||
if char == '1': | ||
time_series.append(1) | ||
elif char == '0': | ||
time_series.append(0) | ||
time_series_file.close() | ||
|
||
majority_data = [-1 for _ in range(memoryLength)] | ||
for i in range(memoryLength, len(time_series)): | ||
numberOfOnes = sum(time_series[i - memoryLength: i + 1]) | ||
if 2 * numberOfOnes > memoryLength: | ||
majority_data.append(1) | ||
else: | ||
majority_data.append(0) | ||
|
||
# Note that right now this only works with 1 input | ||
strToWrite = 'Majority\n' | ||
for datum in majority_data: | ||
strToWrite += str(datum) | ||
strToWrite += '\n' | ||
output_file = open(function_output_filepath, 'w') | ||
output_file.write(strToWrite) | ||
|
||
|
||
folder = '/Users/maxnotarangelo/Documents/ISB/BN_realization/' | ||
ts_filepath = folder + 'time_series_data.csv' | ||
output_filepath = folder + 'function_data.csv' | ||
|
||
generateMajorityFunctionData(2, ts_filepath, output_filepath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import sys | ||
|
||
def create_timeseries_csv(input_filepath, output_filepath, numberOfInputs): | ||
input_file = open(input_filepath) | ||
raw_input = input_file.readlines() | ||
input_file.close() | ||
|
||
one_line_input = '' | ||
for line in raw_input: | ||
one_line_input += line | ||
|
||
list_input = [] | ||
for char in one_line_input: | ||
if char == '1': | ||
list_input.append(1) | ||
elif char == '0': | ||
list_input.append(0) | ||
|
||
strToWrite = '' | ||
for i in range(numberOfInputs): | ||
strToWrite += 'Input_%d,' % (i + 1) | ||
strToWrite = strToWrite[:-1] + '\n' | ||
|
||
for i in range(len(list_input) // numberOfInputs): | ||
for j in range(numberOfInputs): | ||
strToWrite += str(list_input[numberOfInputs * i + j]) | ||
strToWrite += ',' | ||
strToWrite = strToWrite[:-1] + '\n' | ||
|
||
output_file = open(output_filepath, 'w') | ||
output_file.write(strToWrite) | ||
|
||
|
||
inputFile = '/Users/maxnotarangelo/Documents/ISB/code/BN_realization/' + \ | ||
sys.argv[1] # 'time_series_raw_2.txt' | ||
outputFile = '/Users/maxnotarangelo/Documents/ISB/code/BN_realization/' + \ | ||
sys.argv[2] # 'time_series_data_3.csv' | ||
|
||
create_timeseries_csv(inputFile, outputFile, int(sys.argv[3])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Node 1,Node 2,Node 3,Node 4,Node 5 | ||
0,1,1,0,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Node 1,Node 2,Node 3,Node 4,Node 5,Node 6 | ||
0,0,0,0,0,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Node 1,Node 2,Node 3,Node 4,Node 5 | ||
5,3,3,4,5 | ||
2,5,1,-1,4 | ||
4,4,5,-1,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Node 1,Node 2,Node 3,Node 4,Node 5,Node 6 | ||
1,2,3,4,5,6 |
Oops, something went wrong.