Commit c21f9418 authored by Thonier Florian's avatar Thonier Florian

fuse.py;: add call to categories/metadata aggregation

link to #3902
parent 7af0b7b3
......@@ -480,8 +480,10 @@ class ListWindows(VidjilJson):
def __init__(self):
'''init ListWindows with the minimum data required'''
self.d={}
self.d["samples"] = Samples()
self.d["reads"] = Reads()
self.d["samples"] = Samples()
self.d["reads"] = Reads()
self.d["categories"] = Categories()
self.d["clones"] = []
self.d["clusters"] = []
self.d["germlines"] = {}
......@@ -563,6 +565,12 @@ class ListWindows(VidjilJson):
self.id_lengths = defaultdict(int)
try:
data.d["categories"]
except:
data.d["categories"] = [{}]
self.d["categories"] = Categories(data.d["categories"], data.d["samples"].d["original_names"])
print("%%")
for clone in self:
self.id_lengths[len(clone.d['id'])] += 1
......@@ -579,7 +587,7 @@ class ListWindows(VidjilJson):
extension = file_path.split('.')[-1]
if verbose:
print("<==", file_path, "\t", end=' ')
print("<==", file_path, "\t")
with open(file_path, "r") as f:
self.init_data(json.load(f, object_hook=self.toPython))
......@@ -643,6 +651,7 @@ class ListWindows(VidjilJson):
obj.d["samples"] = self.d["samples"] + other.d["samples"]
obj.d["reads"] = self.d["reads"] + other.d["reads"]
obj.d["diversity"] = self.d["diversity"] + other.d["diversity"]
obj.d["categories"] = self.d["categories"] + other.d["categories"]
try:
# verify that same file is not present twice
......@@ -830,6 +839,9 @@ class ListWindows(VidjilJson):
return result
raise TypeError(repr(obj) + " fail !")
elif isinstance(obj, Categories):
return obj.d
else:
result = {}
for key in obj :
......@@ -924,8 +936,9 @@ class ListWindows(VidjilJson):
obj[values[0]][1] += nb_reads
return obj
def save_distributions(self, foname):
# Compute aggreg just before export
self.d["distributions"]["categories"] = self.d["categories"].get_aggreg()
fo = open(foname, "w")
json.dump(self.d["distributions"], fo, indent=2)
fo.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment