Commit af0391aa authored by Mathieu Giraud's avatar Mathieu Giraud

tools/analysis.py: loads analysis

parent b3665a70
import json
from utils import *
from defs import *
class Analysis(VidjilJson):
def __init__(self):
self.clones = {}
def load(self, file_path):
with open(file_path, "r") as f:
tmp = json.load(f) # , object_hook=self.toPython)
self.d = tmp
self.check_version(file_path)
for clone in self.d['clones']:
self.clones[clone['id']] = clone
VIDJIL_JSON_VERSION = "2014.10"
......@@ -40,8 +40,8 @@ import subprocess
import tempfile
from operator import itemgetter
from utils import *
from defs import *
VIDJIL_JSON_VERSION = "2014.10"
FUSE_VERSION = "vidjil fuse"
TOOL_SIMILARITY = "../algo/tools/similarity"
......@@ -213,7 +213,7 @@ class OtherWindows:
print(' --[others]-->', w)
yield w
class ListWindows:
class ListWindows(VidjilJson):
'''storage class for sequences informations
>>> lw1.info()
......@@ -278,13 +278,6 @@ class ListWindows:
print(self)
for clone in self:
print(clone)
### check vidjil_json_version
def check_version(self, filepath):
if "vidjil_json_version" in self.d:
if self.d["vidjil_json_version"] <= VIDJIL_JSON_VERSION:
return
raise IOError ("File '%s' is too old -- please regenerate it with a newer version of Vidjil" % filepath)
### compute statistics about clones
def build_stat(self):
......
import collections
import defs
#### Utilities on dictionaries
......@@ -193,3 +193,17 @@ def interesting_substrings(l, target_length=6, substring_replacement='-'):
# return substrings
#########
class VidjilJson():
def check_version(self, filepath):
'''Check vidjil_json_version'''
if "vidjil_json_version" in self.d:
if self.d["vidjil_json_version"] <= defs.VIDJIL_JSON_VERSION:
return
raise IOError ("File '%s' is too old -- please regenerate it with a newer version of Vidjil" % filepath)
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