compara-deep-learning/save_data.py

24 lines
743 B
Python
Raw Permalink 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)
with open("temp_" + name + "/thread_" + str(i + 1) + "_smg.temp", "wb") as file:
pickle.dump(smg, file)
with open("temp_" + name + "/thread_" + str(i + 1) + "_sml.temp", "wb") as file:
pickle.dump(sml, file)
with open("temp_" + name + "/thread_" + str(i + 1) + "_indexes.temp", "wb") as file:
pickle.dump(indexes, file)