Skip to content

Commit

Permalink
Fixes for applications
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Mar 20, 2012
1 parent 6b510fc commit ebe175c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 26 deletions.
3 changes: 2 additions & 1 deletion applications/asp/asp
Expand Up @@ -32,7 +32,8 @@ try:
print
sys.exit(1)
from signal_detectors import signal_detectors
except ImportError:
except ImportError,e :
print e
print
print "ERROR IMPORTING MODULES, MAKE SURE YOU HAVE SHOGUN INSTALLED"
print
Expand Down
4 changes: 2 additions & 2 deletions applications/asp/signal_detectors.py
Expand Up @@ -13,7 +13,7 @@
import numpy
import seqdict

from shogun.Classifier import SVM
from shogun.Classifier import KernelMachine
from shogun.Features import StringCharFeatures,DNA
from shogun.Kernel import WeightedDegreeStringKernel

Expand All @@ -24,7 +24,7 @@ def __init__(self, order, traindat, alphas, b, (window_left,offset,window_right)
wd_kernel = WeightedDegreeStringKernel(f,f, int(order))
wd_kernel.io.set_target_to_stderr()

self.svm=SVM(wd_kernel, alphas, numpy.arange(len(alphas), dtype=numpy.int32), b)
self.svm=KernelMachine(wd_kernel, alphas, numpy.arange(len(alphas), dtype=numpy.int32), b)
self.svm.io.set_target_to_stderr()
self.svm.parallel.set_num_threads(self.svm.parallel.get_num_cpus())
self.svm.set_linadd_enabled(False)
Expand Down
12 changes: 6 additions & 6 deletions applications/easysvm/esvm/experiment.py
Expand Up @@ -49,7 +49,7 @@
LinAddSVM = GPBTSVM
LinearSVM = LibSVM

from shogun.PreProc import SortWordString, SortUlongString
from shogun.Preprocessor import SortWordString, SortUlongString

from utils import calcprc, calcroc, accuracy
from utils import getPartitionedSet, getCurrentSplit
Expand Down Expand Up @@ -160,8 +160,8 @@ def create_features(kname, examples, kparam, train_mode, preproc, seq_source, nu
if train_mode:
preproc = SortUlongString()
preproc.init(wf)
wf.add_preproc(preproc)
ret = wf.apply_preproc()
wf.add_preprocessor(preproc)
ret = wf.apply_preprocessor()
#assert(ret)

feats = wf
Expand All @@ -183,7 +183,7 @@ def create_features(kname, examples, kparam, train_mode, preproc, seq_source, nu
preproc = SortWordString()
preproc.init(wf)
wf.add_preprocessor(preproc)
ret = wf.apply_preprocessors()
ret = wf.apply_preprocessor()
assert(ret)
feats['combined'].append_feature_obj(wf)
feats['f0'] = wf
Expand All @@ -196,8 +196,8 @@ def create_features(kname, examples, kparam, train_mode, preproc, seq_source, nu
if train_mode:
preproc = SortWordString()
preproc.init(wf)
wf.add_preproc(preproc)
ret = wf.apply_preproc()
wf.add_preprocessor(preproc)
ret = wf.apply_preprocessor()
assert(ret)
feats['combined'].append_feature_obj(wf)
feats['f1'] = wf
Expand Down
3 changes: 2 additions & 1 deletion applications/msplicer/msplicer
Expand Up @@ -33,7 +33,8 @@ try:
from content_sensors import content_sensors
from signal_detectors import signal_detectors
from plif import plif
except ImportError:
except ImportError, e:
print e
print
print "ERROR IMPORTING MODULES, MAKE SURE YOU HAVE SHOGUN INSTALLED"
print
Expand Down
30 changes: 15 additions & 15 deletions applications/msplicer/plif.py
Expand Up @@ -27,7 +27,7 @@ def __init__(self, model):
self.acceptor.set_plif_penalty(p)
self.acceptor.set_min_value(-1e+20)
self.acceptor.set_max_value(1e+20)
self.acceptor.set_name("acceptor")
self.acceptor.set_plif_name("acceptor")

l=array(model.penalty_donor_boundaries).flatten()
p=array(model.penalty_donor_penalty).flatten()
Expand All @@ -36,7 +36,7 @@ def __init__(self, model):
self.donor.set_plif_penalty(p)
self.donor.set_min_value(-1e+20)
self.donor.set_max_value(1e+20)
self.donor.set_name("donor")
self.donor.set_plif_name("donor")

l=array(model.penalty_coding_len_boundaries).flatten()
p=array(model.penalty_coding_len_penalty).flatten()
Expand All @@ -45,7 +45,7 @@ def __init__(self, model):
self.coding_len.set_plif_penalty(p)
self.coding_len.set_min_value(min_exon_len)
self.coding_len.set_max_value(max_len)
self.coding_len.set_name('coding_len')
self.coding_len.set_plif_name('coding_len')
self.coding_len.set_transform_type("log(+1)")

l=array(model.penalty_first_coding_len_boundaries).flatten()
Expand All @@ -55,7 +55,7 @@ def __init__(self, model):
self.first_coding_len.set_plif_penalty(p)
self.first_coding_len.set_min_value(min_exon_len)
self.first_coding_len.set_max_value(max_len)
self.first_coding_len.set_name("first_coding_len")
self.first_coding_len.set_plif_name("first_coding_len")
self.first_coding_len.set_transform_type("log(+1)")

l=array(model.penalty_last_coding_len_boundaries).flatten()
Expand All @@ -65,7 +65,7 @@ def __init__(self, model):
self.last_coding_len.set_plif_penalty(p)
self.last_coding_len.set_min_value(min_exon_len)
self.last_coding_len.set_max_value(max_len)
self.last_coding_len.set_name('last_coding_len')
self.last_coding_len.set_plif_name('last_coding_len')
self.last_coding_len.set_transform_type("log(+1)")

l=array(model.penalty_single_coding_len_boundaries).flatten()
Expand All @@ -75,7 +75,7 @@ def __init__(self, model):
self.single_coding_len.set_plif_penalty(p)
self.single_coding_len.set_min_value(min_exon_len)
self.single_coding_len.set_max_value(max_len)
self.single_coding_len.set_name('single_coding_len')
self.single_coding_len.set_plif_name('single_coding_len')
self.single_coding_len.set_transform_type("log(+1)")

l=array(model.penalty_intron_len_boundaries).flatten()
Expand All @@ -85,7 +85,7 @@ def __init__(self, model):
self.intron_len.set_plif_penalty(p)
self.intron_len.set_min_value(min_intron_len)
self.intron_len.set_max_value(max_len)
self.intron_len.set_name('intron_len')
self.intron_len.set_plif_name('intron_len')
self.intron_len.set_transform_type("log(+1)")

l=array(model.penalty_coding_boundaries).flatten()
Expand All @@ -96,7 +96,7 @@ def __init__(self, model):
self.coding.set_plif_penalty(p)
self.coding.set_min_value(-1e+20)
self.coding.set_max_value(1e+20)
self.coding.set_name('coding')
self.coding.set_plif_name('coding')

l=array(model.penalty_coding2_boundaries).flatten()
p=array(model.penalty_coding2_penalty).flatten()
Expand All @@ -106,7 +106,7 @@ def __init__(self, model):
self.coding2.set_plif_penalty(p)
self.coding2.set_min_value(-1e+20)
self.coding2.set_max_value(1e+20)
self.coding2.set_name('coding2')
self.coding2.set_plif_name('coding2')

l=array(model.penalty_coding3_boundaries).flatten()
p=array(model.penalty_coding3_penalty).flatten()
Expand All @@ -116,7 +116,7 @@ def __init__(self, model):
self.coding3.set_plif_penalty(p)
self.coding3.set_min_value(-1e+20)
self.coding3.set_max_value(1e+20)
self.coding3.set_name('coding3')
self.coding3.set_plif_name('coding3')

l=array(model.penalty_coding4_boundaries).flatten()
p=array(model.penalty_coding4_penalty).flatten()
Expand All @@ -126,7 +126,7 @@ def __init__(self, model):
self.coding4.set_plif_penalty(p)
self.coding4.set_min_value(-1e+20)
self.coding4.set_max_value(1e+20)
self.coding4.set_name('coding4')
self.coding4.set_plif_name('coding4')

l=array(model.penalty_intron_boundaries).flatten()
p=array(model.penalty_intron_penalty).flatten()
Expand All @@ -136,7 +136,7 @@ def __init__(self, model):
self.intron.set_plif_penalty(p)
self.intron.set_min_value(-1e+20)
self.intron.set_max_value(1e+20)
self.intron.set_name('intron')
self.intron.set_plif_name('intron')

l=array(model.penalty_intron2_boundaries).flatten()
p=array(model.penalty_intron2_penalty).flatten()
Expand All @@ -146,7 +146,7 @@ def __init__(self, model):
self.intron2.set_plif_penalty(p)
self.intron2.set_min_value(-1e+20)
self.intron2.set_max_value(1e+20)
self.intron2.set_name('intron2')
self.intron2.set_plif_name('intron2')

l=array(model.penalty_intron3_boundaries).flatten()
p=array(model.penalty_intron3_penalty).flatten()
Expand All @@ -156,7 +156,7 @@ def __init__(self, model):
self.intron3.set_plif_penalty(p)
self.intron3.set_min_value(-1e+20)
self.intron3.set_max_value(1e+20)
self.intron3.set_name('intron3')
self.intron3.set_plif_name('intron3')

l=array(model.penalty_intron4_boundaries).flatten()
p=array(model.penalty_intron4_penalty).flatten()
Expand All @@ -166,7 +166,7 @@ def __init__(self, model):
self.intron4.set_plif_penalty(p)
self.intron4.set_min_value(-1e+20)
self.intron4.set_max_value(1e+20)
self.intron4.set_name('intron4')
self.intron4.set_plif_name('intron4')

p=array(model.penalty_transitions_penalty).flatten()
self.transitions=Plif(len(p))
Expand Down
2 changes: 1 addition & 1 deletion applications/msplicer/signal_detectors.py
Expand Up @@ -19,7 +19,7 @@ class svm_splice_model(object):
def __init__(self, order, traindat, alphas, b, (window_left,offset,window_right), consensus):

f=StringCharFeatures(DNA)
f.set_string_features(traindat)
f.set_features(traindat)
wd_kernel = WeightedDegreeStringKernel(f,f, int(order))
wd_kernel.io.set_target_to_stderr()

Expand Down

0 comments on commit ebe175c

Please sign in to comment.