Exemplo n.º 1
0
def load_image(fn, colorkey=None):
    try:
        path = os.path.join(utils.get_library_path(), 'images', fn)
        image = pygame.image.load(path)
    except pygame.error, message:
        print 'Cannot load image:', path
        raise SystemExit, message
Exemplo n.º 2
0
 def evaluate_organism(self, organism):
     fd, fn = tempfile.mkstemp()
     outfn = "%s.out" % fn
     txt = Script % (utils.get_library_path(), organism.genome, outfn)
     os.close(fd)
     f = open(fn, 'w')
     f.write(txt)
     f.close()
     cmd = "/usr/bin/python %s" % fn
     os.system(cmd)
     f = open(outfn, 'r')
     results = f.read()
     results.strip()
     results = eval(results)
     if results != None:
         organism.results = results
         organism.value = results['value']
     os.unlink(fn)
     os.unlink(outfn)
Exemplo n.º 3
0
 def evaluate_organism(self, organism):
     fd, fn = tempfile.mkstemp()
     outfn = "%s.out" % fn
     txt = Script % (utils.get_library_path(), organism.genome, outfn)
     os.close(fd)
     f = open(fn, 'w')
     f.write(txt)
     f.close()
     cmd = "/usr/bin/python %s" % fn
     os.system(cmd)
     f = open(outfn, 'r')
     results = f.read()
     results.strip()
     results = eval(results)
     if results != None:
         organism.results = results
         organism.value = results['value']
     os.unlink(fn)
     os.unlink(outfn)
import itertools
import os

import numpy as np
import pandas as pd
from scipy.sparse import triu
import pickle
from collections import defaultdict
from tqdm.autonotebook import tqdm
import sys

from data_preparer import S_to_A, S_to_B, incidence_to_hyperedges, prepare_node_hyperneighbors_map
from utils import get_library_path, get_base_path

library_path = get_library_path()
sys.path.append(library_path)
sys.path.append(os.path.join(library_path, "hynetworkx"))
base_path = get_base_path()


def get_avg(_list):
    return sum(_list) * 1.0 / len(_list) if len(_list) > 0 else 0


def get_sum(_list):
    return sum(_list) * 1.0 if len(_list) > 0 else 0


def get_l11(_list):
    return sum(np.abs(_list)) * 1.0 if len(_list) > 0 else 0