Beispiel #1
0
import OSU
import LucksLabUtils_config
from collections import defaultdict, Counter
import re
import SU
import VIU
from itertools import combinations, chain
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from seaborn import color_palette

LucksLabUtils_config.config("Quest_R2D2")

opts = OSU.getopts("", [
    "sample_sizes=", "outfile_pre=", "output_dir=", "reactivities_files=",
    "linker_seq=", "pol_fp=", "processors=", "MDS_processors="
])
print opts
infiles = opts["--reactivities_files"].split(",")
outfile = opts["--outfile_pre"]
output_dir = OSU.create_directory(opts["--output_dir"])
reactivities_files = opts["--reactivities_files"].split(",")
linker_seq = opts["--linker_seq"]
sample_sizes = [int(s) for s in opts["--sample_sizes"].split(",")]
pol_fp = int(opts["--pol_fp"]) if "--pol_fp" in opts else 0
p = int(opts["--processors"]) if "--processors" in opts else 1
MDS_p = int(opts["--MDS_processors"]) if "--MDS_processors" in opts else 1

# setup counters, scaling functions, and output file header
unique_struct_nums = defaultdict(list)
unique_struct_dists = defaultdict(list)
import re
from itertools import repeat
from multiprocessing import Pool, Lock
import numpy
from sys import maxsize
from sklearn.decomposition import PCA
from sklearn.manifold import MDS
from sklearn.preprocessing import scale
from sklearn.metrics import pairwise_distances
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt

# setup environment variables
LucksLabUtils_config.config("Quest_R2D2")
opts = OSU.getopts("o:c:r:p:", ["shape_intercept=", "shape_slope="])
print opts
numpy.set_printoptions(threshold=maxsize)
plt.style.use('seaborn-whitegrid')
fig = plt.figure(figsize=(8, 8))

reactivities_files = glob.glob(opts['-r'])
crystal_files = glob.glob(opts['-c'])
output_dir = OSU.create_directory(opts['-o'])
R2D2_output_dir = OSU.create_directory(output_dir + "/R2D2_intermediate/")
num_proc = int(opts['-p']) if '-p' in opts else 1
shape_intercept = float(opts["--shape_intercept"]) \
                    if "--shape_intercept" in opts else -0.3
shape_slope = float(opts["--shape_slope"]) if "--shape_slope" in opts else 1.1

reactivities = PAU.parse_input_panels(reactivities_files, output_dir)
Beispiel #3
0
All rights reserved.
Distributed under the terms of the GNU General Public License, see 'LICENSE'.
"""
import OSU
import LucksLabUtils_config
import VIU
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from seaborn import color_palette
import numpy as np

LucksLabUtils_config.config("Quest_R2D2")

opts = OSU.getopts("", [
    "Y_first_sampled=", "MDS_ct_coords=", "MDS_mat_coords=", "PCA_coords=",
    "outfile_pre=", "output_dir=", "first_color_dict="
])
print opts
filename_Y_first_sampled = opts["--Y_first_sampled"]
filename_MDS_ct_coords = opts["--MDS_ct_coords"]
filename_MDS_mat_coords = opts["--MDS_mat_coords"]
filename_PCA_coords = opts["--PCA_coords"]
outfile = opts["--outfile_pre"]
output_dir = OSU.create_directory(opts["--output_dir"])
filename_first_color_dict = opts["--first_color_dict"]

# plotting setup
plt.style.use('seaborn-whitegrid')
fig = plt.figure(figsize=(3, 3), dpi=300)

# load input
Copyright (C) 2016, 2017  Julius B. Lucks, Angela M Yu.
All rights reserved.
Distributed under the terms of the GNU General Public License, see 'LICENSE'.
"""

import LucksLabUtils_config
import VIU
import OSU
import SU
import re

LucksLabUtils_config.config("Quest_R2D2")  # set up environment

# parse command line arguments
opts = OSU.getopts("", [
    "seq=", "seq_start=", "seq_end=", "outdir=", "rhos_dir=", "SHAPE_direct=",
    "make_DG_dump="
])
print opts
seq = opts["--seq"]
outdir = opts["--outdir"]
seq_start = int(opts["--seq_start"]) if "--seq_start" in opts else -1
seq_end = int(opts["--seq_end"]) if "--seq_end" in opts else -1
rhos_dir = opts["--rhos_dir"] if "--rhos_dir" in opts else ""
SHAPE_direct = bool(
    opts["--SHAPE_direct"] == "True") if "--SHAPE_direct" in opts else False
make_DG_dump = bool(
    opts["--make_DG_dump"] == "True") if "--make_DG_dump" in opts else False

# generate MFE movie
VIU.generate_MFE_CoTrans_movie(seq, outdir, seq_start, seq_end, rhos_dir,
                               SHAPE_direct)
Copyright (C) 2017  Julius B. Lucks, Angela M Yu.
All rights reserved.
Distributed under the terms of the GNU General Public License, see 'LICENSE'.
"""

import LucksLabUtils_config
import OSU
import SU
import glob
import re

LucksLabUtils_config.config("Quest_R2D2")  # set up environment

# parse command line arguments
opts = OSU.getopts("", [
    "KineFold_dir=", "outdir=", "KineFold_times=", "seq_name=", "time=",
    "pseudoknots=", "entanglements=", "speed=", "sequence="
])
print opts
KineFold_dir = opts["--KineFold_dir"]
outdir = opts["--outdir"]
KF_times = int(opts["--KineFold_times"]) if "--KineFold_times" in opts else 0
seq_name = opts["--seq_name"] if "--seq_name" in opts else "test"
time = opts["--time"] if "--time" in opts else 160000
pseudoknots = bool(
    opts["--pseudoknots"] == "True") if "--pseudoknots" in opts else False
entanglements = bool(
    opts["--entanglements"] == "True") if "--entanglementss" in opts else False
speed = opts["--speed"] if "--speed" in opts else 20
sequence = opts["--sequence"] if "--sequence" in opts else ""

# create directories
Copyright (C) 2016  Julius B. Lucks and Angela M Yu.
All rights reserved.
Distributed under the terms of the GNU General Public License, see 'LICENSE'.
"""

import R2D2
import LucksLabUtils_config
import OSU

LucksLabUtils_config.config("Quest_R2D2")
OSU.system_command("echo $PATH")
OSU.system_command("echo $CLASSPATH")

opts = OSU.getopts("", [
    "in_dir=", "out_dir=", "adapter=", "p=", "e=", "endcut=", "constrained_c=",
    "scale_rho_max=", "draw_all=", "most_count_tie_break=", "scaling_func=",
    "weight_paired=", "cap_rhos=", "pol_fp="
])
print opts

# This specifically calls R2D2.R2D2() assuming the user has specified the arguments:
# in_dir, out_dir, adapter, e, endcut, constrained_c, scale_rho_max, draw_all, most_count_tie_break, scaling_func, weight_paired, cap_rhos, pol_fp
# Only in_dir, out_dir, and adapter are truly required to run R2D2.R2D2(). Default values for the other parameters are set within R2D2.py.

cotrans = R2D2.R2D2(
    opts['--in_dir'],
    opts['--out_dir'],
    opts['--adapter'],
    p=int(opts['--p']),
    e=int(opts['--e']),
    endcut=int(opts['--endcut']),
Version: 0.0.1
Author: Angela M Yu, 2014-2017

Copyright (C) 2017  Julius B. Lucks and Angela M Yu.
All rights reserved.
Distributed under the terms of the GNU General Public License, see 'LICENSE'.
"""

import SU
import OSU
import LucksLabUtils_config
import glob

# setup environment variables
LucksLabUtils_config.config("Quest_R2D2")
opts = OSU.getopts("o:", ["dbn_dir=", "out_prefix="])
print opts

output_dir = OSU.create_directory(opts['-o'])
dbn_dir = opts['--dbn_dir']
out_prefix = opts['--out_prefix']

dbns = {}
for dbnf in glob.glob(dbn_dir + "/*.dbn"):
    # read in each rho reactivitiy spectra
    with open(dbnf, "r") as f:
        dbn = f.readlines()[-1].strip()  # last line with dotbracket
        SU.run_dot2ct(dbnf, output_dir + "temp.ct")
        SU.runRNAstructure_efn2(output_dir + "temp.ct",
                                output_dir + "temp.efn2",
                                parallel=False)
Beispiel #8
0
"""

from __future__ import division  # allows division of ints to output decimals
import LucksLabUtils_config
import OSU
import SU
import glob
import re
import numpy
from collections import defaultdict

LucksLabUtils_config.config("Quest_R2D2")  # set up environment

# parse command line arguments
opts = OSU.getopts("", [
    "KineFold_dir=", "out_dir=", "time_weight", "simulation_time_ms=",
    "last_structure"
])
print opts
KineFold_dir = opts["--KineFold_dir"]
outdir = OSU.create_directory(opts["--out_dir"])
time_weight = True if "--time_weight" in opts else False
last_structure = True if "--last_structure" in opts else False
simulation_time_ms = int(
    opts["--simulation_time_ms"]) if "--simulation_time_ms" in opts else -1

assert int(time_weight) + int(last_structure) <= 1, (
    "Only can specify either time_weight OR last_structure")


# From Paul Gasper's pairs_from_dbn_2.py
def read_dbn(dbn_fn):
    all_dbns = defaultdict(list)
    for dbn_dir in dbn_dirs:
        dbns = glob.glob(dbn_dir + "*.dbn")
        for dbn_f in dbns:
            with open(dbn_f, "r") as f:
                lines = f.readlines()
            length = len(lines[-1].split()[0])
            image = re.sub('(_mult\d+)?.dbn', '_structure.png', dbn_f)
            if image not in all_dbns[length] and OSU.check_file_exists(image):
                all_dbns[length].append(image)
    return all_dbns


if __name__ == "__main__":
    # read in arguments
    opts = OSU.getopts("", ["dbn_dirs=", "output_dir="])
    dbn_dirs = opts["--dbn_dirs"].split(",")
    width = 1200 * len(dbn_dirs)
    output_dir = OSU.create_directory(opts["--output_dir"])

    # read dbns to pair correct lengths together
    all_dbns = read_all_dbn_dirs(dbn_dirs)

    # create images by horizontally concatenating previously made images from R2D2 output
    count = 0
    zero_padding = int(math.floor(math.log10(len(all_dbns))) + 1)
    for len in sorted(all_dbns):
        count += 1
        VIU.horizontal_image_concat(
            "%s/%s.png" % (output_dir, str(count).zfill(zero_padding)),
            all_dbns[len])
Beispiel #10
0
import glob
import SU
import OSU
import NAU
import re
import LucksLabUtils_config
import PAU
from itertools import cycle
from collections import namedtuple
import cPickle as pickle

# setup environment variables specific to the ICSE cluster at Cornell
LucksLabUtils_config.config("ICSE")
opts = OSU.getopts("o:c:r:n:p:", [
    "noshape", "shape", "constrain", "scaling_func=", "cluster_flag=",
    "job_name=", "sub_proc=", "arg_slice=", "load_results=",
    "generate_structs=", "structs_pickle_dir=", "cap_rhos=",
    "shape_intercept=", "shape_slope=", "restart"
])
print opts

reactivities_files = glob.glob(opts['-r'])
crystal_files = glob.glob(opts['-c'])
output_dir = opts['-o']
sample_n = int(opts['-n'])
num_proc = int(opts['-p'])
scaling_func = opts["--scaling_func"]
cluster_flag = opts["--cluster_flag"] == "True"
job_name = opts["--job_name"]
sub_proc = opts["--sub_proc"] == "True"
load_results = opts["--load_results"] == "True"
generate_structs = opts["--generate_structs"] == "True"
Version: 0.0.1
Author: Angela M Yu, 2014-2016

Copyright (C) 2016  Julius B. Lucks and Angela M Yu.
All rights reserved.
Distributed under the terms of the GNU General Public License, see 'LICENSE'.
"""

import OSU
import LucksLabUtils_config
from collections import defaultdict

# setup environment variables
LucksLabUtils_config.config("Quest_R2D2")
opts = OSU.getopts("o:", [
    "3_times_dirs=", "50_times_dir=", "47_times_dir=", "100_times_dir=",
    "file_prefix="
])
print opts

output_dir = OSU.create_directory(opts['-o'])
file_prefix = opts["--file_prefix"]

if "--100_times_dir" in opts:
    times_dirs = [
        "%s/%s%s/" % (opts["--100_times_dir"], file_prefix, i)
        for i in range(1, 101)
    ]
elif "--3_times_dirs" in opts and "--50_times_dir" in opts and "--47_times_dir" in opts:
    times_dirs = opts["--3_times_dirs"].split(",")
    times_dirs += [
        "%s/%s%s/" % (opts["--50_times_dir"], file_prefix, i)
Copyright (C) 2017  Julius B. Lucks and Angela M Yu.
All rights reserved.
Distributed under the terms of the GNU General Public License, see 'LICENSE'.
"""

import SU
import OSU
import VIU
import LucksLabUtils_config
import glob
import math

# setup environment variables
LucksLabUtils_config.config("Quest_R2D2")
opts = OSU.getopts("o:", ["pairs_dir=", "rhos_dir=", "max_length="])
print opts

output_dir = OSU.create_directory(opts['-o']) + "/"
pairs_dir = opts['--pairs_dir']
rhos_dir = opts['--rhos_dir'] if '--rhos_dir' in opts else None
max_length = int(opts['--max_length']) if '--max_length' in opts else -1

rhos = {}
if rhos_dir is not None:
    for rf in glob.glob(rhos_dir + "/*_reactivities.rho"):
        # read in each rho reactivitiy spectra
        with open(rf, "r") as f:
            rho = [line.split()[1] for line in f.readlines()]
            rhos[len(rho)] = [rho, rf]  # add in rho file here
    seq_start = min(rhos.keys())