Mercurial > repos > bgruening > eden_cluster_motif_finder
view eden_wrapper.py @ 0:95a776023fbc draft
Uploaded
author | bgruening |
---|---|
date | Thu, 12 Jun 2014 11:35:21 -0400 |
parents | |
children |
line wrap: on
line source
#!/usr/bin/env python import argparse import sys import os import subprocess import random import tempfile import shlex import shutil from eden_utilities import log class EDeNWrapper: def __init__(self, args): self._param={} #default values self._param['path_to_EDeN']="EDeN" self._param['model_file_path']="model" self._param['radius']=2 self._param['distance']=5 self._param['output_dir']=tempfile.mkdtemp() self._param['kernel_type']="STRING" self._param['file_type']="STRINGSEQ" self._param['cluster_type']="DENSE_CONNECTED_CENTERS" self._param['sample_size']=1000 self._param['num_nearest_neighbors']=10 self._param['neighborhood_intersection_size']=int(self._param['num_nearest_neighbors']/2) self._param['fraction_center_scan']=1.0 #update self._param.update(args) @property def param(self): return self._param def Train(self): assert self._param.has_key('dat_file_path') assert self._param.has_key('target_file_path') assert self._param.has_key('model_file_path') cmd = "%(path_to_EDeN)s -a TRAIN -i %(dat_file_path)s -t %(target_file_path)s --kernel_type %(kernel_type)s --file_type %(file_type)s --radius %(radius)s --distance %(distance)s -y %(output_dir)s -m %(model_file_path)s" cmd = cmd % self._param log.info( "Executing call: %s" % cmd ) subprocess.call( shlex.split(cmd) ) def TestPart(self): assert self._param.has_key('dat_file_path') assert self._param.has_key('model_file_path') cmd = "%(path_to_EDeN)s -a TEST_PART -i %(dat_file_path)s --kernel_type %(kernel_type)s --file_type %(file_type)s --radius %(radius)s --distance %(distance)s -y %(output_dir)s -m %(output_dir)s/%(model_file_path)s" cmd = cmd % self._param log.info( "Executing call: %s" % cmd ) subprocess.call( shlex.split(cmd) ) def Test(self): assert self._param.has_key('dat_file_path') assert self._param.has_key('model_file_path') cmd = "%(path_to_EDeN)s -a TEST -i %(dat_file_path)s --kernel_type %(kernel_type)s --file_type %(file_type)s --radius %(radius)s --distance %(distance)s -y %(output_dir)s -m %(output_dir)s/%(model_file_path)s" cmd = cmd % self._param log.info( "Executing call: %s" % cmd ) subprocess.call( shlex.split(cmd) ) def Cluster(self): assert self._param.has_key('dat_file_path') cmd = "%(path_to_EDeN)s -a CLUSTER -i %(dat_file_path)s --kernel_type %(kernel_type)s --file_type %(file_type)s --radius %(radius)s --distance %(distance)s -y %(output_dir)s " cmd = cmd + "--cluster_type %(cluster_type)s --sample_size %(sample_size)s --num_nearest_neighbors %(num_nearest_neighbors)s --neighborhood_intersection_size %(neighborhood_intersection_size)s --fraction_center_scan %(fraction_center_scan)s" cmd = cmd % self._param log.info( "Executing call: %s" % cmd ) subprocess.call( shlex.split(cmd) )