compara-deep-learning/save_data.py

27 lines
788 B
Python
Raw Normal View History

2019-07-24 03:27:54 -07:00
import os
import pickle
import json
2019-07-24 04:54:02 -07:00
def write_dict_json(name, dir, d):
2019-07-24 03:27:54 -07:00
if not os.path.exists(dir):
os.mkdir(dir)
2019-07-24 04:54:02 -07:00
path = os.path.join(dir, name + ".json")
with open(path, 'w') as file:
json.dump(d, file)
def write_data_synteny(smg, sml, indexes, i, name):
if not os.path.exists("temp_" + name):
os.mkdir("temp_" + name)
2021-04-08 08:41:16 -07:00
with open("temp_" + name + "/thread_" + str(i + 1) +
"_smg.temp", "wb") as file:
2019-07-24 04:54:02 -07:00
pickle.dump(smg, file)
2021-04-08 08:41:16 -07:00
with open("temp_" + name + "/thread_" + str(i + 1) +
"_sml.temp", "wb") as file:
2019-07-24 04:54:02 -07:00
pickle.dump(sml, file)
2021-04-08 08:41:16 -07:00
with open("temp_" + name + "/thread_" + str(i + 1) +
"_indexes.temp", "wb") as file:
2019-07-24 04:54:02 -07:00
pickle.dump(indexes, file)