How to use the kipoi.utils.load_module function in kipoi

To help you get started, we’ve selected a few kipoi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kipoi / models / rbp_eclip / dump_dataloader_files.py View on Github external
"""Dump the RBP data
"""
import os
import numpy as np
import pickle
from kipoi.utils import load_module
from concise.preprocessing.splines import encodeSplines
from concise.utils.position import ALL_LANDMARKS
from glob import glob
rbp = "UPF1"
pipeline_obj_path = "dataloader_files/position_transformer.pkl"
# -----------------

# load the data module from eclip
data = load_module(os.path.expanduser("~/projects-work/code_spline_trans/Scripts/RBP/Eclip/predictive_models/data.py"))
DIR_ROOT = data.DIR_ROOT
PROC_DIR = DIR_ROOT + "/processed"
RBP_ALL = [os.path.basename(x).replace(".csv", "")
           for x in glob(PROC_DIR + "/design_matrix/train/*.csv") if "extended" not in x]


def dump_position_transformer(rbp):
    out_path = "{0}/dataloader_files/position_transformer.pkl".format(rbp)
    print("Dumping for rbp: {rbp} to path: {out_path}".format(rbp=rbp, out_path=out_path))
    train, valid, test = data.data_extended(rbp)
    pipeline_obj = (train[3], train[4].steps[1][1], train[5])
    os.makedirs(os.path.dirname(out_path), exist_ok=True)

    # save to pkl
    with open(out_path, "wb") as f:
        pickle.dump(pipeline_obj, f)