def load_simmat(path): """(str) => lmatrix load the lmatrix from file """ def load_cids(): """() => set of str return a set of the complex ids >>> len(load_cids("fp_370_atg.txt")) 236 """ return set([c for l in open(path).readlines() for c in l.split()[:2]]) from lmatrix import lmatrix #init matrixc m = lmatrix(load_cids()) #set values for l in open(path).readlines(): c1,c2,value = l.split() value = float(value) m[c1,c2] = value m[c2,c1] = value return m
def load_simmat(path): """(str) => lmatrix load the lmatrix from file """ #init matrixc m = lmatrix(load_cids(path)) #set values for l in open(path).readlines(): c1, c2, value = l.split() value = float(value) m[c1, c2] = value m[c2, c1] = value return m
def load_simmat(path): """(str) => lmatrix load the lmatrix from file """ #init matrixc m = lmatrix(load_cids(path)) #set values for l in open(path).readlines(): c1,c2,value = l.split() value = float(value) m[c1,c2] = value m[c2,c1] = value return m
f = open("data/energy.values", "r") tpls = map(lambda l: l.split(), f.readlines()) tpls = map(lambda tpl: (tpl[0], float(tpl[1])), tpls) d = dict(tpls) cids = map(lambda s: s[0], tpls) from lmatrix import lmatrix m = lmatrix(cids) for c1 in cids: for c2 in cids: m[c1,c2] = abs(d[c1] - d[c2]) print m.to_csv_str()