def create_hashed_features_wdk(param, data):
    """
    creates hashed dot features for the wdk
    """

    # fix parameters
    start_degree = 0
    hash_bits = 12
    degree = param["degree"]
    order = 1
    gap = 0
    reverse = True

    #print "test", data[0]

    # create raw features
    feats_char = StringCharFeatures(data, DNA)
    feats_raw = StringByteFeatures(DNA)
    feats_raw.obtain_from_char(feats_char, order - 1, order, gap, reverse)

    # finish up
    feats = HashedWDFeaturesTransposed(feats_raw, start_degree, degree, degree,
                                       hash_bits)
    #feats = HashedWDFeatures(feats_raw, start_degree, degree, degree, hash_bits)
    #feats = WDFeatures(feats_raw, 1, 8)#, degree, hash_bits)

    return feats
def features_snp_modular(fname):
	from shogun.Features import StringByteFeatures, SNPFeatures, SNP

	sf=StringByteFeatures(SNP)
	sf.load_ascii_file(fname, False, SNP, SNP)
	#print sf.get_features()
	snps=SNPFeatures(sf)
def features_snp_modular(fname):
    from shogun.Features import StringByteFeatures, SNPFeatures, SNP

    sf = StringByteFeatures(SNP)
    sf.load_ascii_file(fname, False, SNP, SNP)
    #print sf.get_features()
    snps = SNPFeatures(sf)
def create_hashed_features_wdk(data, degree):
    """
    creates hashed dot features for the wdk
    """

    # fix parameters
    start_degree = 0
    hash_bits = 12
    order = 1
    gap = 0
    reverse = True

    dat = [str(xt) for xt in data]

    # create raw features
    feats_char = StringCharFeatures(dat, DNA)
    feats_raw = StringByteFeatures(DNA)
    feats_raw.obtain_from_char(feats_char, order - 1, order, gap, reverse)

    # finish up
    feats = HashedWDFeaturesTransposed(feats_raw, start_degree, degree, degree,
                                       hash_bits)
    #feats = HashedWDFeatures(feats_raw, start_degree, degree, degree, hash_bits)
    #feats = WDFeatures(feats_raw, 1, 8)#, degree, hash_bits)

    return feats
示例#5
0
def create_hashed_features_wdk(param, data):
    """
    creates hashed dot features for the wdk
    """

    # fix parameters
    start_degree = 0
    hash_bits = 12
    degree = param["degree"]
    order = 1
    gap = 0
    reverse = True

    #print "test", data[0]

    # create raw features
    feats_char = StringCharFeatures(data, DNA)
    feats_raw = StringByteFeatures(DNA)
    feats_raw.obtain_from_char(feats_char, order-1, order, gap, reverse)

    # finish up
    feats = HashedWDFeaturesTransposed(feats_raw, start_degree, degree, degree, hash_bits)
    #feats = HashedWDFeatures(feats_raw, start_degree, degree, degree, hash_bits)
    #feats = WDFeatures(feats_raw, 1, 8)#, degree, hash_bits)

    return feats
示例#6
0
def distribution_ppwm_modular (fm_dna=traindna, order=3):
	from shogun.Features import StringByteFeatures, StringCharFeatures, DNA
	from shogun.Distribution import PositionalPWM

	from numpy import array,e,log,exp

	charfeat=StringCharFeatures(DNA)
	charfeat.set_features(fm_dna)
	feats=StringByteFeatures(charfeat.get_alphabet())
	feats.obtain_from_char(charfeat, order-1, order, 0, False)

	L=20
	k=3
	sigma = 1;
	mu = 4

	ppwm=PositionalPWM()
	ppwm.set_sigma(sigma)
	ppwm.set_mean(mu)
	pwm=array([[0.0, 0.5, 0.1, 1.0],
               [0.0, 0.5, 0.5, 0.0],
               [1.0, 0.0, 0.4, 0.0],
               [0.0, 0.0, 0.0, 0.0]]);
	pwm=array([[0.01,0.09,0.1],[0.09,0.01,0.1],[0.85,0.4,0.1],[0.05,0.5,0.7]])



	ppwm.set_pwm(log(pwm))
	#print(ppwm.get_pwm())
	ppwm.compute_w(L)
	w=ppwm.get_w()
	#print(w)
	#from pylab import *
	#figure(1)
	#pcolor(exp(w))
	#pcolor(w)
	#colorbar()

	#figure(2)
	ppwm.compute_scoring(1)
	u=ppwm.get_scoring(0)
	#pcolor(exp(u))
	#show()

	#ppwm=PositionalPWM(feats)
	#ppwm.train()

	#out_likelihood = histo.get_log_likelihood()
	#out_sample = histo.get_log_likelihood_sample()
	return w,u
def features_string_hashed_wd_modular(A=matrix,order=3,start_order=1,hash_bits=2):
    a=LongIntFeatures(A)
    
    from numpy import array, uint8
    from shogun.Features import HashedWDFeatures, StringByteFeatures, RAWDNA
    from shogun.IO import MSG_DEBUG

    x=[array([0,1,2,3,0,1,2,3,3,2,2,1,1],dtype=uint8)]
    from_order=order
    f=StringByteFeatures(RAWDNA)
    #f.io.set_loglevel(MSG_DEBUG)
    f.set_features(x)

    y=HashedWDFeatures(f,start_order,order,from_order,hash_bits)
    fm=y.get_computed_dot_feature_matrix()

    return fm
示例#8
0
def distribution_ppwm_modular(fm_dna=traindna, order=3):
    from shogun.Features import StringByteFeatures, StringCharFeatures, DNA
    from shogun.Distribution import PositionalPWM

    from numpy import array, e, log, exp

    charfeat = StringCharFeatures(DNA)
    charfeat.set_features(fm_dna)
    feats = StringByteFeatures(charfeat.get_alphabet())
    feats.obtain_from_char(charfeat, order - 1, order, 0, False)

    ppwm = PositionalPWM()
    ppwm.set_sigma(5.0)
    ppwm.set_mean(10.0)
    pwm = array([[0.0, 0.5, 0.1, 1.0], [0.0, 0.5, 0.5, 0.0], [1.0, 0.0, 0.4, 0.0], [0.0, 0.0, 0.0, 0.0]])
    ppwm.set_pwm(log(pwm))
    print ppwm.get_pwm()
    ppwm.compute_w(20)
    w = ppwm.get_w()
def distribution_ppwm_modular (fm_dna=traindna, order=3):
	from shogun.Features import StringByteFeatures, StringCharFeatures, DNA
	from shogun.Distribution import PositionalPWM

	from numpy import array,e,log,exp

	charfeat=StringCharFeatures(DNA)
	charfeat.set_features(fm_dna)
	feats=StringByteFeatures(charfeat.get_alphabet())
	feats.obtain_from_char(charfeat, order-1, order, 0, False)

	ppwm=PositionalPWM()
	ppwm.set_sigma(5.0)
	ppwm.set_mean(10.0)
	pwm=array([[0.0, 0.5, 0.1, 1.0],
               [0.0, 0.5, 0.5, 0.0],
               [1.0, 0.0, 0.4, 0.0],
               [0.0, 0.0, 0.0, 0.0]]);
	ppwm.set_pwm(log(pwm))
	print ppwm.get_pwm()
	ppwm.compute_w(20)
	w= ppwm.get_w()