Ejemplo n.º 1
0
#     def update_path_for_stempy():
#         dir = os.path.dirname(__file__)
#         append_to_path(os.path.normpath(os.path.join(dir, '..', '..'))) # stempy
#         append_to_path(os.path.normpath(os.path.join(dir, '..', '..', '..', '..', 'Infpy', 'python'))) # Infpy
#         append_to_path(os.path.normpath(os.path.join(dir, '..', '..', '..', '..', 'PyICL', 'Python'))) # PyICL
# 
#     update_path_for_stempy()



#
# Set up the logging
#
import logging, os, sys, time
from cookbook.script_basics import setup_logging
setup_logging(__file__, level=logging.INFO)
import stempy


def get_fasta_file(filename):
    return os.path.join(os.path.dirname(__file__), '..', 'fasta', filename)

seed = 'TTTAAAATACTTTAAA'
num_to_find = 10000

options = stempy.get_default_options()
options.max_num_sites = options.min_num_sites = 10
options.min_w = options.max_w = W = len(seed)

#
# read in data
Ejemplo n.º 2
0
import logging
from optparse import OptionParser
import pylab as pl, numpy as np
from cookbook.script_basics import log_options, setup_logging
import infpy.mixture.beta

reload(infpy.mixture.beta)
from infpy.mixture import beta


def sigmoid(x):
    return 1.0 / (1.0 + np.exp(-x))


setup_logging()
np.seterr(over="warn", invalid="raise")

parser = OptionParser()
beta.add_options(parser)
options, args = parser.parse_args()
log_options(parser, options)

logging.info("Seeding numpy.random")
np.random.seed(1)

exp_family = beta.DirichletExpFamily(k=2)

logging.info("Creating data")
block_size = 30
y = np.empty(3 * block_size)
Ejemplo n.º 3
0
    dest="model_file",
    help="Filename where model is stored and saved (will create new model if file does not exist or option not given).",
    default=None,
)
parser.add_option(
    "--num-starts", dest="num_starts", help="Number of different starting points to try.", type="int", default=1
)
parser.add_option("--plot-file", dest="plot_file", help="File to plot distribution in.", default=None)
parser.add_option("--log-plot", dest="log_plot", help="Use log-scale for plot.", action="store_true")
parser.add_option(
    "--predictions-file", dest="predictions_file", help="Filename predictions are written to.", default=None
)
parser.add_option("--seed", dest="seed", help="Seed for the RNG.", type="int", default=1)
parser.add_option("--log-file", dest="log_file", help="Log file.", type="str", default=None)
options, args = parser.parse_args()
setup_logging(file=options.log_file, level=logging.INFO)
log_options(parser, options)

exp_family = beta.DirichletExpFamily(k=2)
x, weights = load_data(options)
X = np.empty((len(x), 2))
X[:, 0] = x
X[:, 1] = 1.0 - X[:, 0]

# get sufficient statistics
T = exp_family.T(X)

# plot prior for pi bar
# plot_pi_bar_prior(options.alpha)

# make reproducible
Ejemplo n.º 4
0
    type='int',
    default=1,
)
parser.add_option(
    "--x-validate-groups",
    help="Number of cross-validation groups.",
    type='int',
    default=5,
)
parser.add_option(
    "--seed",
    dest="seed",
    help="Seed for the RNG.",
    type='int',
    default=1,
)
options, args = parser.parse_args()
if 1 != len(args):
    raise ValueError('Need to specify data file.')
filename = args[0]
setup_logging(level=logging.INFO)
log_options(parser, options)

exp_family = beta.DirichletExpFamily(k=2)
    
# create object for parallelism
tc = client.TaskClient()

results = main(filename)
plot_results(results)