├── .gitignore ├── Dockerfile ├── README.TXT ├── README.md ├── code ├── cfg │ ├── classification │ │ ├── M1.cfg │ │ └── M2.cfg │ ├── regression │ │ ├── allpool │ │ │ ├── M1.cfg │ │ │ └── M2.cfg │ │ └── maxpool │ │ │ ├── M1.cfg │ │ │ └── M2.cfg │ └── trainers │ │ ├── default.cfg │ │ └── quick.cfg ├── deepbind_scripts.pyproj ├── deepbind_scripts.sln ├── deepbind_scripts.v11.suo ├── deepbind_train_dream5.py ├── deepbind_train_encode.py ├── deepbind_train_rnac.py ├── deepbind_train_selex.py ├── deepbind_util.py ├── deepfind.py └── libs │ ├── deepity │ ├── deepity │ │ ├── __init__.py │ │ ├── _ext │ │ │ ├── __init__.py │ │ │ └── deepity_smat.py │ │ ├── _io_ │ │ │ ├── __init__.py │ │ │ ├── load.py │ │ │ ├── pydot.py │ │ │ └── write_svg.py │ │ ├── _lockfile │ │ │ ├── __init__.py │ │ │ ├── linklockfile.py │ │ │ ├── mkdirlockfile.py │ │ │ ├── pidlockfile.py │ │ │ └── sqlitelockfile.py │ │ ├── arial.ttf │ │ ├── arialbd.ttf │ │ ├── cour.ttf │ │ ├── data.py │ │ ├── dumpviz.py │ │ ├── globals.py │ │ ├── gradcheck.py │ │ ├── hpsearch.py │ │ ├── hypertrain.py │ │ ├── node.py │ │ ├── plug.py │ │ ├── report.py │ │ ├── report_plotter.py │ │ ├── sgd.py │ │ ├── std │ │ │ ├── __init__.py │ │ │ ├── chain.py │ │ │ ├── elemwise.py │ │ │ ├── full.py │ │ │ ├── loss.py │ │ │ ├── softmax.py │ │ │ └── trainable.py │ │ ├── tape2logo.py │ │ ├── trainer.py │ │ └── util.py │ ├── deepity_smat │ │ ├── blockwise_dot.cu │ │ ├── deepity_smat.cpp │ │ ├── dropout.cu │ │ ├── gradstep.cu │ │ ├── madd_bcast.cu │ │ ├── makefile │ │ └── maskout.cu │ └── vcproj │ │ ├── deepity.pyperf │ │ ├── deepity.pyproj │ │ ├── deepity.sln │ │ ├── deepity.v11.suo │ │ ├── deepity_smat.vcxproj │ │ ├── deepity_smat.vcxproj.filters │ │ ├── deepity_smat.vcxproj.user │ │ └── demo_mnist.nvact │ ├── kangaroo │ ├── kangaroo │ │ ├── __init__.py │ │ ├── _ext │ │ │ ├── __init__.py │ │ │ ├── corr1ord.py │ │ │ ├── dropoutord.py │ │ │ ├── kangaroo_smat.py │ │ │ └── poolrgn.py │ │ ├── basic │ │ │ ├── __init__.py │ │ │ ├── data.py │ │ │ ├── model.py │ │ │ └── report.py │ │ ├── cour.ttf │ │ ├── data.py │ │ ├── globals.py │ │ ├── gradmap.py │ │ ├── model.py │ │ ├── predict.py │ │ ├── simplify.py │ │ ├── statistics.py │ │ ├── train.py │ │ └── util.py │ ├── kangaroo_smat │ │ ├── autotune.cu │ │ ├── convseq.cu │ │ ├── convseq.cuh │ │ ├── convseq_bprop.cu │ │ ├── convseq_bprop.cuh │ │ ├── corr1ord.cu │ │ ├── corr1ord.cuh │ │ ├── corr1ord_bprop.cu │ │ ├── corr1ord_bprop.cuh │ │ ├── dropoutord.cu │ │ ├── kangaroo_smat.cpp │ │ ├── kangaroo_smat.h │ │ ├── makefile │ │ ├── poolrgn.cu │ │ ├── poolrgn.cuh │ │ ├── poolrgn_bprop.cu │ │ └── poolrgn_bprop.cuh │ └── vcproj │ │ ├── kangaroo.nvact │ │ ├── kangaroo.pyproj │ │ ├── kangaroo.sln │ │ ├── kangaroo.v11.suo │ │ ├── kangaroo_smat.vcxproj │ │ ├── kangaroo_smat.vcxproj.filters │ │ └── kangaroo_smat.vcxproj.user │ └── smat │ ├── py │ ├── README.TXT │ ├── data │ │ ├── mnist │ │ │ ├── mnist_test.npz │ │ │ └── mnist_train.npz │ │ └── rnac │ │ │ └── rnac_subset.npz │ ├── demo_convnet.py │ ├── demo_minimize.py │ ├── demo_nnet.py │ ├── run_tests.py │ ├── smat │ │ ├── __init__.py │ │ ├── smat.py │ │ ├── smat_dll.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── perftest.py │ │ │ ├── testutil.py │ │ │ └── unittest.py │ │ └── util.py │ └── vcproj │ │ ├── smat_py.nvact │ │ ├── smat_py.pyproj │ │ ├── smat_py.pyproj.user │ │ ├── smat_py.sln │ │ └── smat_py.v11.suo │ ├── src │ ├── base │ │ ├── assert.cpp │ │ ├── assert.h │ │ ├── config.h │ │ ├── logging.cpp │ │ ├── logging.h │ │ ├── optionset.cpp │ │ ├── optionset.h │ │ ├── os.cpp │ │ ├── os.h │ │ ├── random.cpp │ │ ├── random.h │ │ ├── range.h │ │ ├── sized_array.h │ │ ├── time.cpp │ │ ├── time.h │ │ ├── typelist.h │ │ ├── util.cpp │ │ └── util.h │ ├── makefile │ ├── nvcc_preinclude.h │ ├── smat │ │ ├── config.h │ │ ├── dtypes.cpp │ │ ├── dtypes.h │ │ ├── shape.cpp │ │ ├── shape.h │ │ ├── smat.cpp │ │ ├── smat.h │ │ ├── smat_ops.h │ │ └── vm │ │ │ ├── argument.cpp │ │ │ ├── argument.h │ │ │ ├── context.cpp │ │ │ ├── context.h │ │ │ ├── extension.cpp │ │ │ ├── extension.h │ │ │ ├── heap.cpp │ │ │ ├── heap.h │ │ │ ├── instruction.cpp │ │ │ ├── instruction.h │ │ │ ├── instruction_db.cpp │ │ │ ├── instruction_db.h │ │ │ ├── machine.cpp │ │ │ ├── machine.h │ │ │ └── util │ │ │ ├── autotune.cpp │ │ │ ├── autotune.h │ │ │ ├── specialization_table.h │ │ │ └── specialization_typelists.h │ ├── smat_batch │ │ ├── batch_dot.cpp │ │ └── smat_batch.cpp │ ├── smat_cuda │ │ ├── arange.cu │ │ ├── config.h │ │ ├── copy.cu │ │ ├── cuda_autotune.cpp │ │ ├── cuda_context.cpp │ │ ├── cuda_context.h │ │ ├── cuda_errors.cpp │ │ ├── cuda_errors.h │ │ ├── diff.cu │ │ ├── dot.cu │ │ ├── dropout.cu │ │ ├── elemwise2.cu │ │ ├── elemwise2.cuh │ │ ├── elemwise3.autotune.cu │ │ ├── elemwise3.cu │ │ ├── elemwise3.cuh │ │ ├── launch_util.cpp │ │ ├── launch_util.h │ │ ├── mask.cu │ │ ├── rand.cu │ │ ├── reduce.cu │ │ ├── reduce.cuh │ │ ├── reduce_x.cu │ │ ├── reduce_x.cuh │ │ ├── reduce_y.autotune.cu │ │ ├── reduce_y.autotune.cuh │ │ ├── reduce_y.cu │ │ ├── reduce_y.cuh │ │ ├── reducers.cuh │ │ ├── register_ext.cpp │ │ ├── repeat.cu │ │ ├── sanitycheck.cpp │ │ ├── tile.cu │ │ └── transpose.cu │ ├── smat_cudnn │ │ └── cudnn.cpp │ └── smat_ext_demo │ │ ├── demo.cpp │ │ ├── demo_clamp.cu │ │ └── demo_lerp.cu │ └── vcproj │ ├── ModelDefinition │ └── smat_design.uml │ ├── base.vcxproj │ ├── base.vcxproj.filters │ ├── base.vcxproj.user │ ├── python.psess │ ├── python140116.vsp │ ├── smat.classdiagram │ ├── smat.classdiagram.layout │ ├── smat.layerdiagram │ ├── smat.layerdiagram.layout │ ├── smat.layerdiagram.suppressions │ ├── smat.sln │ ├── smat.suo │ ├── smat.v11.suo │ ├── smat.vcxproj │ ├── smat.vcxproj.filters │ ├── smat.vcxproj.user │ ├── smat_batch.vcxproj │ ├── smat_batch.vcxproj.filters │ ├── smat_cuda.vcxproj │ ├── smat_cuda.vcxproj.filters │ ├── smat_cuda.vcxproj.user │ ├── smat_cuda_autotune.vcxproj │ ├── smat_cuda_autotune.vcxproj.andrew.nvuser │ ├── smat_cuda_autotune.vcxproj.filters │ ├── smat_cuda_autotune.vcxproj.user │ ├── smat_cudnn.vcxproj │ ├── smat_cudnn.vcxproj.filters │ ├── smat_cudnn.vcxproj.user │ ├── smat_design.modelproj │ ├── smat_ext_demo.vcxproj │ ├── smat_ext_demo.vcxproj.filters │ └── smat_ext_demo.vcxproj.user └── data ├── deepfind ├── README.txt ├── TFs_to_consider.txt ├── derived.avinput.gz ├── derived.seq.gz ├── derived_cons.npz ├── derived_feats.npz ├── matching_mask.npz ├── simulated.avinput.gz ├── simulated.seq.gz ├── simulated_cons.npz ├── simulated_feats.npz ├── tfs_derived │ ├── BHLHE41_FL_TGTGCT20NCGG_3_AD.npz │ ├── BRCA1_GM12878_BRCA1_(A300-000A)_Stanford.npz │ ├── CENPB_FL_TGCTGT20NGTC_4_AD.npz │ ├── CTCF_FL_TAGCGA20NGCT_4_AJ.npz │ ├── EGR1_FL_TACTAT20NATC_4_AA.npz │ ├── FOXA1_HepG2_FOXA1_(SC-101058)_HudsonAlpha.npz │ ├── GATA4_DBD_TAAAAT20NAAA_4_Y.npz │ ├── HNF4A_FL_TCCGTG40NTGC_3_AI.npz │ ├── Pou2f2_DBD_TAGATA20NTAT_3_Z.npz │ └── ZBTB7A_DBD_TGAATA20NGA_4_W.npz └── tfs_simulated │ ├── BHLHE41_FL_TGTGCT20NCGG_3_AD.npz │ ├── BRCA1_GM12878_BRCA1_(A300-000A)_Stanford.npz │ ├── CENPB_FL_TGCTGT20NGTC_4_AD.npz │ ├── CTCF_FL_TAGCGA20NGCT_4_AJ.npz │ ├── EGR1_FL_TACTAT20NATC_4_AA.npz │ ├── FOXA1_HepG2_FOXA1_(SC-101058)_HudsonAlpha.npz │ ├── GATA4_DBD_TAAAAT20NAAA_4_Y.npz │ ├── HNF4A_FL_TCCGTG40NTGC_3_AI.npz │ ├── Pou2f2_DBD_TAGATA20NTAT_3_Z.npz │ └── ZBTB7A_DBD_TGAATA20NGA_4_W.npz ├── dream5 ├── chipseq │ ├── TF_23_CHIP_100_dinuc.seq │ ├── TF_23_CHIP_100_full_genomic.seq │ ├── TF_23_CHIP_100_genomic.seq │ ├── TF_23_CHIP_51_dinuc.seq │ ├── TF_23_CHIP_51_full_genomic.seq │ ├── TF_23_CHIP_51_genomic.seq │ ├── TF_25_CHIP_100_dinuc.seq │ ├── TF_25_CHIP_100_full_genomic.seq │ ├── TF_25_CHIP_100_genomic.seq │ ├── TF_25_CHIP_51_dinuc.seq │ ├── TF_25_CHIP_51_full_genomic.seq │ ├── TF_25_CHIP_51_genomic.seq │ ├── TF_31_CHIP_100_dinuc.seq │ ├── TF_31_CHIP_100_full_genomic.seq │ ├── TF_31_CHIP_100_genomic.seq │ ├── TF_31_CHIP_51_dinuc.seq │ ├── TF_31_CHIP_51_full_genomic.seq │ ├── TF_31_CHIP_51_genomic.seq │ ├── TF_40_CHIP_100_dinuc.seq │ ├── TF_40_CHIP_100_full_genomic.seq │ ├── TF_40_CHIP_100_genomic.seq │ ├── TF_40_CHIP_51_dinuc.seq │ ├── TF_40_CHIP_51_full_genomic.seq │ ├── TF_40_CHIP_51_genomic.seq │ ├── TF_44_CHIP_100_dinuc.seq │ ├── TF_44_CHIP_100_full_genomic.seq │ ├── TF_44_CHIP_100_genomic.seq │ ├── TF_44_CHIP_51_dinuc.seq │ ├── TF_44_CHIP_51_full_genomic.seq │ └── TF_44_CHIP_51_genomic.seq └── pbm │ ├── probe_biases.npz │ ├── sequences.tsv.gz │ ├── targets.tsv.gz │ └── tfids.txt ├── encode ├── ARID3A_K562_ARID3A_(sc-8821)_Stanford_AC.seq.gz ├── ARID3A_K562_ARID3A_(sc-8821)_Stanford_B.seq.gz ├── CTCFL_K562_CTCFL_(SC-98982)_HudsonAlpha_AC.seq.gz ├── CTCFL_K562_CTCFL_(SC-98982)_HudsonAlpha_B.seq.gz ├── ELK1_GM12878_ELK1_(1277-1)_Stanford_AC.seq.gz ├── ELK1_GM12878_ELK1_(1277-1)_Stanford_B.seq.gz ├── FOXA1_HepG2_FOXA1_(SC-101058)_HudsonAlpha_AC.seq.gz ├── FOXA1_HepG2_FOXA1_(SC-101058)_HudsonAlpha_B.seq.gz ├── GABPA_GM12878_GABP_HudsonAlpha_AC.seq.gz ├── GABPA_GM12878_GABP_HudsonAlpha_B.seq.gz ├── MYC_H1-hESC_c-Myc_Stanford_AC.seq.gz ├── MYC_H1-hESC_c-Myc_Stanford_B.seq.gz ├── REST_GM12878_NRSF_HudsonAlpha_AC.seq.gz ├── REST_GM12878_NRSF_HudsonAlpha_B.seq.gz ├── SP1_GM12878_SP1_HudsonAlpha_AC.seq.gz ├── SP1_GM12878_SP1_HudsonAlpha_B.seq.gz ├── USF1_HepG2_USF-1_HudsonAlpha_AC.seq.gz ├── USF1_HepG2_USF-1_HudsonAlpha_B.seq.gz ├── ZBTB7A_HepG2_ZBTB7A_(SC-34508)_HudsonAlpha_AC.seq.gz └── ZBTB7A_HepG2_ZBTB7A_(SC-34508)_HudsonAlpha_B.seq.gz ├── rnac └── how_to_get_the_data.txt └── selex └── how_to_get_the_data.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | 30 | # Byte-compiled / optimized / DLL files 31 | __pycache__/ 32 | *.py[cod] 33 | *$py.class 34 | 35 | # C extensions 36 | *.so 37 | 38 | # Distribution / packaging 39 | .Python 40 | env/ 41 | build/ 42 | develop-eggs/ 43 | dist/ 44 | downloads/ 45 | eggs/ 46 | .eggs/ 47 | lib/ 48 | lib64/ 49 | parts/ 50 | sdist/ 51 | var/ 52 | *.egg-info/ 53 | .installed.cfg 54 | *.egg 55 | 56 | # PyInstaller 57 | # Usually these files are written by a python script from a template 58 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 59 | *.manifest 60 | *.spec 61 | 62 | # Installer logs 63 | pip-log.txt 64 | pip-delete-this-directory.txt 65 | 66 | # Unit test / coverage reports 67 | htmlcov/ 68 | .tox/ 69 | .coverage 70 | .coverage.* 71 | .cache 72 | nosetests.xml 73 | coverage.xml 74 | *,cover 75 | 76 | # Translations 77 | *.mo 78 | *.pot 79 | 80 | # Django stuff: 81 | *.log 82 | 83 | # Sphinx documentation 84 | docs/_build/ 85 | 86 | # PyBuilder 87 | target/ 88 | 89 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM kaixhin/cuda-caffe:7.0 2 | MAINTAINER Matt Edwards 3 | 4 | RUN apt-get update 5 | RUN apt-get install -y emacs24-nox nano curl 6 | 7 | # Set up the appropriate Python environment with conda. 8 | RUN curl -sS https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh > /root/miniconda.sh 9 | RUN chmod a+x /root/miniconda.sh 10 | RUN /root/miniconda.sh -b 11 | ENV PATH /root/miniconda2/bin:$PATH 12 | RUN conda install scipy numpy matplotlib=1.3.1 pil # matplotlib=1.3.1 downgrades everything 13 | 14 | # Bring DeepBind source code into the image. 15 | COPY code/libs /root/deepbind/libs 16 | 17 | # Build the DeepBind binaries. 18 | RUN make --directory /root/deepbind/libs/smat/src clean 19 | RUN make --directory /root/deepbind/libs/smat/src 20 | RUN make --directory /root/deepbind/libs/deepity/deepity_smat clean 21 | RUN make --directory /root/deepbind/libs/deepity/deepity_smat 22 | RUN make --directory /root/deepbind/libs/kangaroo/kangaroo_smat clean 23 | RUN make --directory /root/deepbind/libs/kangaroo/kangaroo_smat 24 | 25 | ENV LD_LIBRARY_PATH /root/deepbind/libs/deepity/build/release/bin:/root/deepbind/libs/smat/build/release/bin:/root/deepbind/libs/kangaroo/build/release/bin:$LD_LIBRARY_PATH 26 | 27 | # Bring in DeepBind data and scripts. 28 | COPY code/*py /root/deepbind/ 29 | COPY code/cfg /root/deepbind/cfg 30 | COPY data /root/data 31 | 32 | WORKDIR /root/deepbind 33 | 34 | CMD python deepbind_train_encode.py top calib,train,test,report 35 | -------------------------------------------------------------------------------- /code/cfg/classification/M1.cfg: -------------------------------------------------------------------------------- 1 | deepbind_model = [ 2 | motif_scan(num_motifs = 16, 3 | motif_len = 16, 4 | weight_decay = loguniform(1e-15,1e-3), 5 | init_scale = loguniform(1e-7,1e-3), 6 | ), 7 | bias(), 8 | rectify(), 9 | maxpool(), 10 | dropout(rate = choice([0.0, 0.0, 0.25, 0.5])), 11 | full(num_units = 1, 12 | weight_decay = loguniform(1e-10,1e-3), 13 | init_scale = loguniform(1e-5,1e-2), 14 | ), 15 | bias(), 16 | softmax(), 17 | ] 18 | 19 | return deepbind_model 20 | -------------------------------------------------------------------------------- /code/cfg/classification/M2.cfg: -------------------------------------------------------------------------------- 1 | deepbind_model = [ 2 | motif_scan(num_motifs = 16, 3 | motif_len = 16, 4 | weight_decay = loguniform(1e-15,1e-3), 5 | init_scale = loguniform(1e-7,1e-3), 6 | ), 7 | bias(), 8 | rectify(), 9 | maxpool(), 10 | dropout(rate = choice([0.0, 0.0, 0.25, 0.5])), 11 | full(num_units = 32, 12 | weight_decay = loguniform(1e-10,1e-3), 13 | init_scale = loguniform(1e-5,1e-2), 14 | ), 15 | bias(), 16 | relu(), 17 | full(num_units = 1, 18 | weight_decay = loguniform(1e-10,1e-3), 19 | init_scale = loguniform(1e-5,1e-2), 20 | ), 21 | bias(), 22 | softmax(), 23 | ] 24 | 25 | return deepbind_model 26 | -------------------------------------------------------------------------------- /code/cfg/regression/allpool/M1.cfg: -------------------------------------------------------------------------------- 1 | deepbind_model = [ 2 | motif_scan(num_motifs = 16, 3 | motif_len = 16, 4 | weight_decay = loguniform(1e-15,1e-3), 5 | init_scale = loguniform(1e-7,1e-3), 6 | ), 7 | bias(), 8 | rectify(), 9 | allpool(), 10 | dropout(rate = choice([0.0, 0.0, 0.25, 0.5])), 11 | full(num_units = 1, 12 | weight_decay = loguniform(1e-10,1e-3), 13 | init_scale = loguniform(1e-5,1e-2), 14 | ), 15 | bias(), 16 | ] 17 | 18 | return deepbind_model 19 | -------------------------------------------------------------------------------- /code/cfg/regression/allpool/M2.cfg: -------------------------------------------------------------------------------- 1 | deepbind_model = [ 2 | motif_scan(num_motifs = 16, 3 | motif_len = 16, 4 | weight_decay = loguniform(1e-15,1e-3), 5 | init_scale = loguniform(1e-7,1e-3), 6 | ), 7 | bias(), 8 | rectify(), 9 | allpool(), 10 | dropout(rate = choice([0.0, 0.0, 0.25, 0.5])), 11 | full(num_units = 32, 12 | weight_decay = loguniform(1e-10,1e-3), 13 | init_scale = loguniform(1e-5,1e-2), 14 | ), 15 | bias(), 16 | relu(), 17 | full(num_units = 1, 18 | weight_decay = loguniform(1e-10,1e-3), 19 | init_scale = loguniform(1e-5,1e-2), 20 | ), 21 | bias(), 22 | ] 23 | 24 | return deepbind_model 25 | -------------------------------------------------------------------------------- /code/cfg/regression/maxpool/M1.cfg: -------------------------------------------------------------------------------- 1 | deepbind_model = [ 2 | motif_scan(num_motifs = 16, 3 | motif_len = 16, 4 | weight_decay = loguniform(1e-15,1e-3), 5 | init_scale = loguniform(1e-7,1e-3), 6 | ), 7 | bias(), 8 | rectify(), 9 | maxpool(), 10 | dropout(rate = choice([0.0, 0.0, 0.25, 0.5])), 11 | full(num_units = 1, 12 | weight_decay = loguniform(1e-10,1e-3), 13 | init_scale = loguniform(1e-5,1e-2), 14 | ), 15 | bias(), 16 | ] 17 | 18 | return deepbind_model 19 | -------------------------------------------------------------------------------- /code/cfg/regression/maxpool/M2.cfg: -------------------------------------------------------------------------------- 1 | deepbind_model = [ 2 | motif_scan(num_motifs = 16, 3 | motif_len = 16, 4 | weight_decay = loguniform(1e-15,1e-3), 5 | init_scale = loguniform(1e-7,1e-3), 6 | ), 7 | bias(), 8 | rectify(), 9 | maxpool(), 10 | dropout(rate = choice([0.0, 0.0, 0.25, 0.5])), 11 | full(num_units = 32, 12 | weight_decay = loguniform(1e-10,1e-3), 13 | init_scale = loguniform(1e-5,1e-2), 14 | ), 15 | bias(), 16 | relu(), 17 | full(num_units = 1, 18 | weight_decay = loguniform(1e-10,1e-3), 19 | init_scale = loguniform(1e-5,1e-2), 20 | ), 21 | bias(), 22 | ] 23 | 24 | return deepbind_model 25 | -------------------------------------------------------------------------------- /code/cfg/trainers/default.cfg: -------------------------------------------------------------------------------- 1 | return sgd(rate = loguniform(0.0005,0.050), 2 | momentum = powuniform(0.95,0.99,0.5), 3 | batchsize = 64, 4 | max_epochs = 500, 5 | max_steps = 20000, 6 | checkpoints = 5, 7 | weight_decay_start = 100, 8 | ) 9 | -------------------------------------------------------------------------------- /code/cfg/trainers/quick.cfg: -------------------------------------------------------------------------------- 1 | return sgd(rate = loguniform(0.0005,0.050), 2 | momentum = powuniform(0.95,0.99,0.5), 3 | batchsize = 128, 4 | max_epochs = 5, 5 | max_steps = 1000, 6 | checkpoints = 2, 7 | weight_decay_start = 100, 8 | ) 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /code/deepbind_scripts.pyproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | 2.0 6 | {30f9199c-6330-4a07-83a3-e21d1722ccf6} 7 | 8 | deepbind_train_dream5.py 9 | 10 | . 11 | . 12 | 10.0 13 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 14 | Standard Python launcher 15 | -q calib,train TF_1 16 | 17 | 18 | False 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /code/deepbind_scripts.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "deepbind_scripts", "deepbind_scripts.pyproj", "{30F9199C-6330-4A07-83A3-E21D1722CCF6}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {30F9199C-6330-4A07-83A3-E21D1722CCF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {30F9199C-6330-4A07-83A3-E21D1722CCF6}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {30F9199C-6330-4A07-83A3-E21D1722CCF6}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {30F9199C-6330-4A07-83A3-E21D1722CCF6}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /code/deepbind_scripts.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gifford-lab/deepbind-docker/9a6e48d3ee550cc8c7bf06173a78442a6ba10ac8/code/deepbind_scripts.v11.suo -------------------------------------------------------------------------------- /code/libs/deepity/deepity/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | from .node import node,supernode 36 | from .plug import plug,connect,disconnect 37 | from .data import datasource,resident_datasource,make_predictions,count_errors,shuffled_repeat_iter 38 | from .sgd import sgd 39 | from .hypertrain import hypertrain,train,load_hparams_result,save_hparams_result,getinstdir,call_dumpviz, load_metrics, save_metrics 40 | from .trainer import trainer 41 | from .report import calc_auc, bootstrap_auc, calc_metrics 42 | from .globals import reset_backend,set_logging 43 | import _io_ as io 44 | -------------------------------------------------------------------------------- /code/libs/deepity/deepity/_ext/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | from deepity_smat import * 36 | -------------------------------------------------------------------------------- /code/libs/deepity/deepity/_io_/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | from load import load,deferred_load 36 | from write_svg import write_svg 37 | 38 | -------------------------------------------------------------------------------- /code/libs/deepity/deepity/_io_/write_svg.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | from . import pydot 36 | 37 | ########################################################################## 38 | 39 | def write_svg(filename,root_node): 40 | nodes = [] 41 | edges = [] 42 | _collect_dot_graph(root_node,nodes,edges) 43 | g = pydot.Dot(splines="ortho") 44 | g_nodes = [pydot.Node(name=node.__class__.__name__, 45 | shape="box") 46 | for node in nodes] 47 | for n in g_nodes: 48 | g.add_node(n) 49 | for tail,head in edges: 50 | g_tail = g_nodes[nodes.index(tail.node)] 51 | g_head = g_nodes[nodes.index(head.node)] 52 | g.add_edge(pydot.Edge(g_tail,g_head, 53 | taillabel=tail.name, 54 | headlabel=head.name, 55 | sametail=tail.name, 56 | samehead=head.name, 57 | fontname="courier", 58 | fontsize=10, 59 | arrowsize=0.4, 60 | dir="both", 61 | arrowtail="box", 62 | arrowhead="obox")) 63 | g.write_svg(filename) 64 | 65 | 66 | def _collect_dot_graph(node,nodes,edges): 67 | if node in nodes: 68 | return 69 | nodes.append(node) 70 | for head in node.iplugs: 71 | for tail in head.srcs: 72 | _collect_dot_graph(src.node,nodes,edges) 73 | for tail in node.oplugs: 74 | for head in tail.dsts: 75 | edge = (tail,head) 76 | if edge not in edges: 77 | edges.append(edge) 78 | _collect_dot_graph(dst.node,nodes,edges) 79 | -------------------------------------------------------------------------------- /code/libs/deepity/deepity/arial.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gifford-lab/deepbind-docker/9a6e48d3ee550cc8c7bf06173a78442a6ba10ac8/code/libs/deepity/deepity/arial.ttf -------------------------------------------------------------------------------- /code/libs/deepity/deepity/arialbd.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gifford-lab/deepbind-docker/9a6e48d3ee550cc8c7bf06173a78442a6ba10ac8/code/libs/deepity/deepity/arialbd.ttf -------------------------------------------------------------------------------- /code/libs/deepity/deepity/cour.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gifford-lab/deepbind-docker/9a6e48d3ee550cc8c7bf06173a78442a6ba10ac8/code/libs/deepity/deepity/cour.ttf -------------------------------------------------------------------------------- /code/libs/deepity/deepity/std/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | from elemwise import * 36 | from softmax import * 37 | from loss import * 38 | from full import * 39 | from chain import * 40 | from trainable import * 41 | -------------------------------------------------------------------------------- /code/libs/deepity/deepity/std/chain.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | from .. import globals 36 | from ..node import supernode 37 | 38 | class chain(supernode): 39 | """ 40 | A chain of nodes, automatically connected in sequence, like a neural net. 41 | Any remaining unconnected plug gets exported to the 'surface' of this supernode. 42 | """ 43 | def __init__(self,children,name=None): 44 | # First connect together each node in a chain, so that the supernode 45 | # only exposes the remaining (unconnected) plugs. 46 | for prev,next in zip(children[:-1],children[1:]): 47 | prev >> next 48 | 49 | super(chain,self).__init__(children,name) 50 | 51 | 52 | -------------------------------------------------------------------------------- /code/libs/deepity/deepity/std/trainable.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | from ..node import node 36 | from ..plug import plug,plug_null 37 | 38 | class trainable(node): 39 | """ 40 | A trainable node should be initialized with two things: 41 | 1. 'P' gets forward propagated to downstream plugs 42 | 2. 'dP' accumulates the backprop'd gradient contributions of 'value' 43 | A training algorithm can connect trainable nodes to a dependency graph, 44 | and have the backprop'd values accumulate in a giant contiguous vector 45 | of parameters (i.e. dvalue is a view into a larger gradient vector). 46 | """ 47 | def __init__(self,P,dP=None): 48 | super(trainable,self).__init__([],["Z"]) 49 | self.P = P 50 | self.dP = dP 51 | 52 | def _fprop(self): 53 | return self.P 54 | 55 | def enforce_constraints(self): 56 | dstnode = self.Z.dsts[0].origin().node 57 | if hasattr(dstnode,"enforce_constraints"): 58 | dstnode.enforce_constraints(self.P) 59 | 60 | def _bprop(self,dZ): 61 | self.dP[:] = dZ 62 | self.Z._bpval = plug_null 63 | 64 | def _calc_shapes(self,Z): 65 | pass 66 | -------------------------------------------------------------------------------- /code/libs/deepity/deepity/util.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | import os 36 | import time 37 | import tempfile 38 | 39 | ################################################# 40 | 41 | def splitlist(x,n): 42 | m = len(x) 43 | return [x[i:min(m,i+m//n)] for i in range(0,m,m//n)] 44 | 45 | ################################################# 46 | 47 | def makepath(dir): 48 | """ 49 | Makes a complete path if it does not exist already. 50 | Does not remove any existing files. 51 | Fixes periodic failure of os.makedirs on Windows. 52 | """ 53 | if os.path.exists(dir): 54 | return dir 55 | retries = 8 56 | while retries >= 0: 57 | try: 58 | time.sleep(0.001) 59 | os.makedirs(dir) 60 | retries = -1 61 | except Exception, e: 62 | if retries == 0: 63 | raise 64 | else: 65 | retries -= 1 66 | return dir 67 | 68 | ################################################# 69 | 70 | def hashed_filename(filename,**kwargs): 71 | # The cache is a temporary file that is hashed based on args+variant, 72 | # i.e. if we only want cols 1,2,3 for example, that will go into a different 73 | # temporary file than if we were asked for cols 2,3,4. 74 | filebase = os.path.basename(os.path.splitext(filename)[0]) 75 | args_hash = abs(hash(";".join(["%s=%s" % (key,val) for key,val in kwargs.iteritems()]))) 76 | cachepath = os.path.join(tempfile.gettempdir(),"%s.hash%s" % (filebase,args_hash)) 77 | return cachepath 78 | 79 | ################################################# 80 | # MATLAB-like tic/toc 81 | 82 | _tics = {None: 0.0} 83 | 84 | def tic(id=None): 85 | global _tics 86 | now = time.time() 87 | _tics[id] = now 88 | return now 89 | 90 | def toc(id=None): 91 | global _tics 92 | now = time.time() 93 | return now - _tics[id] 94 | 95 | 96 | -------------------------------------------------------------------------------- /code/libs/deepity/deepity_smat/madd_bcast.cu: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | #include 39 | using namespace sm; 40 | 41 | template 42 | __global__ void kernel_madd_bcast(const T* A, const T* b, T* dst, usize_t n, usize_t m, usize_t k) 43 | { 44 | DECL_KERNEL_VARS 45 | for (usize_t i = (usize_t)bdx*bx+tx; i < n; i += bdx*gdx) 46 | dst[i] += A[i]*b[(i/k) % m]; 47 | } 48 | 49 | void launch_madd_bcast(cudaStream_t stream, dtype_t dtype, 50 | const void* A, const void* b, void* dst, 51 | usize_t n, usize_t m, usize_t k) 52 | { 53 | launchcfg cfg = make_elemwise_launchcfg(n); 54 | if (dtype == f32) 55 | kernel_madd_bcast<<>>((const float*)A,(const float*)b,(float*)dst,n,m,k); 56 | else 57 | kernel_madd_bcast<<>>((const double*)A,(const double*)b,(double*)dst,n,m,k); 58 | } 59 | -------------------------------------------------------------------------------- /code/libs/deepity/deepity_smat/maskout.cu: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | #include 39 | using namespace sm; 40 | 41 | template 42 | __global__ void kernel_maskout(const bool* M, T* A, usize_t n) 43 | { 44 | DECL_KERNEL_VARS 45 | unsigned tid = bdx*bx + tx; 46 | for (usize_t i = (usize_t)tid; i < n; i += bdx*gdx) { 47 | if (!M[i]) 48 | A[i] = (T)0; 49 | } 50 | } 51 | 52 | template 53 | __global__ void kernel_calc_zmask(const T* Z, bool* M, usize_t n, usize_t m) 54 | { 55 | DECL_KERNEL_VARS 56 | unsigned tid = bdx*bx + tx; 57 | for (usize_t i = (usize_t)tid; i < (n*m)/2; i += bdx*gdx) { 58 | usize_t row = (i/m)*2; 59 | usize_t col = i%m; 60 | usize_t index = m*row+col; 61 | if (Z[index] >= Z[index+m]) { 62 | M[index] = true; 63 | } else { 64 | M[index+m] = true; 65 | } 66 | } 67 | } 68 | 69 | void launch_maskout(cudaStream_t stream, dtype_t dtype, const bool* M, void* A, usize_t n) 70 | { 71 | launchcfg cfg = make_elemwise_launchcfg(n); 72 | if (dtype == f32) 73 | kernel_maskout<<>>(M,(float*)A,n); 74 | else 75 | kernel_maskout<<>>(M,(double*)A,n); 76 | } 77 | 78 | void launch_calc_zmask(cudaStream_t stream, dtype_t dtype, const void* Z, bool* M, usize_t n, usize_t m) 79 | { 80 | launchcfg cfg = make_elemwise_launchcfg((n*m)/2); 81 | if (dtype == f32) 82 | kernel_calc_zmask<<>>((float* )Z,M,n,m); 83 | else 84 | kernel_calc_zmask<<>>((double*)Z,M,n,m); 85 | } 86 | -------------------------------------------------------------------------------- /code/libs/deepity/vcproj/deepity.pyperf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 581d3961-3143-4413-899b-f9723a3f8175 5 | deepity 6 | 7 | 8 | 9 | C:\Users\Andrew\AppData\Local\Temp\deepity_20140116.vsp 10 | 11 | 12 | -------------------------------------------------------------------------------- /code/libs/deepity/vcproj/deepity.pyproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | 2.0 6 | {581d3961-3143-4413-899b-f9723a3f8175} 7 | .. 8 | 9 | 10 | 11 | 12 | . 13 | . 14 | kangaroo 15 | kangaroo 16 | Standard Python launcher 17 | 18 | 19 | 20 | 21 | False 22 | False 23 | 24 | 25 | true 26 | false 27 | 28 | 29 | true 30 | false 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /code/libs/deepity/vcproj/deepity.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "deepity_smat", "deepity_smat.vcxproj", "{BA463704-8921-4A1A-970F-8E714C6452A9}" 5 | EndProject 6 | Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "deepity", "deepity.pyproj", "{581D3961-3143-4413-899B-F9723A3F8175}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|Mixed Platforms = Debug|Mixed Platforms 12 | Debug|Win32 = Debug|Win32 13 | Debug|x64 = Debug|x64 14 | Release|Any CPU = Release|Any CPU 15 | Release|Mixed Platforms = Release|Mixed Platforms 16 | Release|Win32 = Release|Win32 17 | Release|x64 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Debug|Any CPU.ActiveCfg = Debug|x64 21 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 22 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Debug|Mixed Platforms.Build.0 = Debug|x64 23 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Debug|Win32.ActiveCfg = Debug|x64 24 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Debug|x64.ActiveCfg = Debug|x64 25 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Debug|x64.Build.0 = Debug|x64 26 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Release|Any CPU.ActiveCfg = Release|x64 27 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Release|Mixed Platforms.ActiveCfg = Release|x64 28 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Release|Mixed Platforms.Build.0 = Release|x64 29 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Release|Win32.ActiveCfg = Release|x64 30 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Release|x64.ActiveCfg = Release|x64 31 | {BA463704-8921-4A1A-970F-8E714C6452A9}.Release|x64.Build.0 = Release|x64 32 | {581D3961-3143-4413-899B-F9723A3F8175}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {581D3961-3143-4413-899B-F9723A3F8175}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {581D3961-3143-4413-899B-F9723A3F8175}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 35 | {581D3961-3143-4413-899B-F9723A3F8175}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 36 | {581D3961-3143-4413-899B-F9723A3F8175}.Debug|Win32.ActiveCfg = Debug|Any CPU 37 | {581D3961-3143-4413-899B-F9723A3F8175}.Debug|x64.ActiveCfg = Debug|Any CPU 38 | {581D3961-3143-4413-899B-F9723A3F8175}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {581D3961-3143-4413-899B-F9723A3F8175}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {581D3961-3143-4413-899B-F9723A3F8175}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 41 | {581D3961-3143-4413-899B-F9723A3F8175}.Release|Mixed Platforms.Build.0 = Release|Any CPU 42 | {581D3961-3143-4413-899B-F9723A3F8175}.Release|Win32.ActiveCfg = Release|Any CPU 43 | {581D3961-3143-4413-899B-F9723A3F8175}.Release|x64.ActiveCfg = Release|Any CPU 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /code/libs/deepity/vcproj/deepity.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gifford-lab/deepbind-docker/9a6e48d3ee550cc8c7bf06173a78442a6ba10ac8/code/libs/deepity/vcproj/deepity.v11.suo -------------------------------------------------------------------------------- /code/libs/deepity/vcproj/deepity_smat.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hxx;hpp 7 | 8 | 9 | {45301eb6-c0c0-4517-ba98-587fe8cde372} 10 | .cu;.cuh 11 | 12 | 13 | 14 | 15 | CUDA Kernels 16 | 17 | 18 | CUDA Kernels 19 | 20 | 21 | CUDA Kernels 22 | 23 | 24 | CUDA Kernels 25 | 26 | 27 | CUDA Kernels 28 | 29 | 30 | 31 | 32 | Source Files 33 | 34 | 35 | -------------------------------------------------------------------------------- /code/libs/deepity/vcproj/deepity_smat.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(PYTHON27)\python.exe 5 | demo_mnist.py 6 | $(SolutionDir)..\..\deepity 7 | WindowsLocalDebugger 8 | 9 | 10 | $(PYTHON27)\python.exe 11 | 12 | 13 | $(SolutionDir)..\..\deepity 14 | WindowsLocalDebugger 15 | 16 | -------------------------------------------------------------------------------- /code/libs/kangaroo/kangaroo/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | import os.path 36 | import sys 37 | _parentdir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) 38 | sys.path.append(os.path.join(_parentdir, "smat_py")) 39 | sys.path.append(os.path.join(_parentdir, "deepity")) 40 | from .data import datasource, loadtxt 41 | from .model import sequencenet, loadcfg 42 | from .train import train, calibrate, load_calib, save_calib 43 | from .simplify import simplify 44 | from .predict import predict, load_modelinfos 45 | from .gradmap import save_gradientmaps 46 | from .statistics import statistics 47 | from .globals import set_randseed, set_logging, set_devices, flags 48 | -------------------------------------------------------------------------------- /code/libs/kangaroo/kangaroo/_ext/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | from corr1ord import * 36 | from poolrgn import * 37 | from dropoutord import * -------------------------------------------------------------------------------- /code/libs/kangaroo/kangaroo/_ext/dropoutord.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | import deepity 36 | import deepity._ext 37 | import numpy as np 38 | from smat import * 39 | from . import kangaroo_smat 40 | 41 | class dropoutord(deepity.std.elemwise): 42 | """ 43 | Dropout on ordinal sequence input. 44 | """ 45 | def __init__(self, rate): 46 | super(dropoutord,self).__init__(["X","regions"],["Z"]) 47 | self.rate = rate 48 | self.M = None 49 | 50 | def _fprop(self,X,regions): 51 | if X is None: 52 | return None 53 | 54 | if "train_mode" in deepity.globals.flags: 55 | Z,self.M = kangaroo_smat.dropoutord_fp_train(X, self.rate) 56 | if "reverse_complement" in deepity.globals.flags: 57 | # TODO: should be done on GPU 58 | _M = self.M.asnumpy() 59 | _R = regions.asnumpy() 60 | padsize = _M.size - _R[-1,-1] 61 | for i in range(0,len(_R),2): 62 | a,b = _R[i] 63 | c,d = _R[i+1] 64 | _M[c+padsize:d] = np.flipud(_M[a+padsize:b]) 65 | self.M = asarray(_M) 66 | _Z = X.asnumpy() 67 | _Z[~_M] = 254 68 | Z = asarray(_Z) 69 | pass 70 | else: 71 | Z = X 72 | return Z 73 | 74 | def _bprop(self,dZ): 75 | self.M = None 76 | return dZ 77 | -------------------------------------------------------------------------------- /code/libs/kangaroo/kangaroo/basic/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | from data import basic_datasource 36 | from model import basic_model 37 | from report import basic_report 38 | 39 | -------------------------------------------------------------------------------- /code/libs/kangaroo/kangaroo/basic/report.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | import deepity 36 | import deepity.report 37 | 38 | class basic_report(deepity.report.training_report): 39 | def __init__(self,logfile_pattern, task_ids, sample_ids): 40 | super(basic_report,self).__init__(logfile_pattern, task_ids, sample_ids) 41 | 42 | #def 43 | -------------------------------------------------------------------------------- /code/libs/kangaroo/kangaroo/cour.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gifford-lab/deepbind-docker/9a6e48d3ee550cc8c7bf06173a78442a6ba10ac8/code/libs/kangaroo/kangaroo/cour.ttf -------------------------------------------------------------------------------- /code/libs/kangaroo/kangaroo/globals.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | import os 36 | import sys 37 | import time 38 | import logging 39 | 40 | import os 41 | import os.path 42 | import copy 43 | import time 44 | import logging 45 | import deepity 46 | 47 | _logfile = None 48 | _randseed = None 49 | _devices = [0] 50 | _allow_multiprocessing = True 51 | 52 | flags = deepity.globals.flags 53 | 54 | def set_devices(devices): 55 | """List of device IDs that can be used by worker processes.""" 56 | global _devices 57 | _devices = devices 58 | 59 | 60 | def set_randseed(seed): 61 | """Random seed used each time a training session begins.""" 62 | global _randseed 63 | _randseed = seed 64 | 65 | 66 | def set_multiprocessing(enabled): 67 | global _allow_multiprocessing 68 | _allow_multiprocessing = enabled 69 | deepity.globals.set_multiprocessing(enabled) 70 | 71 | 72 | def set_logging(outdir): 73 | global _logfile 74 | _logfile = os.path.join(outdir, "kangaroo.log") 75 | deepity.set_logging(_logfile, level=1) 76 | logging.debug("\n----------------------------- %s -----------------------------" % time.strftime("%y-%m-%d %H-%M-%S",time.localtime())) 77 | 78 | 79 | def _set_default_logging(outdir): 80 | global _logfile 81 | if _logfile is None: 82 | set_logging(outdir) 83 | -------------------------------------------------------------------------------- /code/libs/kangaroo/kangaroo_smat/dropoutord.cu: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | #include 39 | using namespace sm; 40 | 41 | __global__ void kernel_dropoutord_fp_tr(curandState_t* state, const uint8_t* X, uint8_t* Z, bool* M, usize_t n, float rate) 42 | { 43 | DECL_KERNEL_VARS 44 | unsigned tid = bdx*bx + tx; 45 | curandState local_state = state[tid]; 46 | for (usize_t i = (usize_t)tid; i < n; i += bdx*gdx) { 47 | bool mask = (X[i] == 255) || (curand_uniform(&local_state) >= rate); 48 | M[i] = mask; 49 | Z[i] = mask ? X[i] : 254; 50 | } 51 | state[tid] = local_state; 52 | } 53 | 54 | 55 | void launch_dropoutord_fp_tr(cudaStream_t stream, 56 | const uint8_t* X, uint8_t* Z, bool* M, usize_t n, float rate) 57 | { 58 | launchcfg cfg = make_elemwise_launchcfg(n); 59 | kernel_dropoutord_fp_tr<<>>(thread_cudactx().curand_state(),X,Z,M,n,rate); 60 | } 61 | -------------------------------------------------------------------------------- /code/libs/kangaroo/kangaroo_smat/kangaroo_smat.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SMAT_EXT_KANGAROO_H__ 36 | #define __SMAT_EXT_KANGAROO_H__ 37 | 38 | enum padmode_t { 39 | pm_zero_output 40 | }; 41 | 42 | enum pooltype_t { 43 | pt_max, 44 | pt_avg, 45 | pt_sum, 46 | pt_all // max and avg pooling 47 | }; 48 | 49 | template struct device_tuple { }; 50 | template <> struct device_tuple { 51 | typedef ::float2 float2; 52 | static inline __device__ float2 make_float2(float x, float y) { return ::make_float2(x,y); } 53 | }; 54 | template <> struct device_tuple { 55 | typedef ::double2 float2; 56 | static inline __device__ float2 make_float2(double x, double y) { return ::make_double2(x,y); } 57 | }; 58 | 59 | #endif // __SMAT_EXT_KANGAROO_H__ 60 | -------------------------------------------------------------------------------- /code/libs/kangaroo/vcproj/kangaroo.pyproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | 2.0 6 | {581d3961-3143-4413-899b-f9723a3f8173} 7 | .. 8 | modular_demo.py 9 | 10 | 11 | . 12 | . 13 | kangaroo 14 | kangaroo 15 | Standard Python launcher 16 | 17 | 18 | 19 | 20 | False 21 | False 22 | 23 | 24 | true 25 | false 26 | 27 | 28 | true 29 | false 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /code/libs/kangaroo/vcproj/kangaroo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "kangaroo", "kangaroo.pyproj", "{581D3961-3143-4413-899B-F9723A3F8173}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kangaroo_smat", "kangaroo_smat.vcxproj", "{BA463704-8921-4A1A-970F-8E714C6452A7}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|Mixed Platforms = Debug|Mixed Platforms 12 | Debug|Win32 = Debug|Win32 13 | Debug|x64 = Debug|x64 14 | Release|Any CPU = Release|Any CPU 15 | Release|Mixed Platforms = Release|Mixed Platforms 16 | Release|Win32 = Release|Win32 17 | Release|x64 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {581D3961-3143-4413-899B-F9723A3F8173}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {581D3961-3143-4413-899B-F9723A3F8173}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {581D3961-3143-4413-899B-F9723A3F8173}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 23 | {581D3961-3143-4413-899B-F9723A3F8173}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 24 | {581D3961-3143-4413-899B-F9723A3F8173}.Debug|Win32.ActiveCfg = Debug|Any CPU 25 | {581D3961-3143-4413-899B-F9723A3F8173}.Debug|x64.ActiveCfg = Debug|Any CPU 26 | {581D3961-3143-4413-899B-F9723A3F8173}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {581D3961-3143-4413-899B-F9723A3F8173}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {581D3961-3143-4413-899B-F9723A3F8173}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 29 | {581D3961-3143-4413-899B-F9723A3F8173}.Release|Mixed Platforms.Build.0 = Release|Any CPU 30 | {581D3961-3143-4413-899B-F9723A3F8173}.Release|Win32.ActiveCfg = Release|Any CPU 31 | {581D3961-3143-4413-899B-F9723A3F8173}.Release|x64.ActiveCfg = Release|Any CPU 32 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Debug|Any CPU.ActiveCfg = Debug|x64 33 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 34 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Debug|Mixed Platforms.Build.0 = Debug|x64 35 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Debug|Win32.ActiveCfg = Debug|x64 36 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Debug|x64.ActiveCfg = Debug|x64 37 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Debug|x64.Build.0 = Debug|x64 38 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Release|Any CPU.ActiveCfg = Release|x64 39 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Release|Mixed Platforms.ActiveCfg = Release|x64 40 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Release|Mixed Platforms.Build.0 = Release|x64 41 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Release|Win32.ActiveCfg = Release|x64 42 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Release|x64.ActiveCfg = Release|x64 43 | {BA463704-8921-4A1A-970F-8E714C6452A7}.Release|x64.Build.0 = Release|x64 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /code/libs/kangaroo/vcproj/kangaroo.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gifford-lab/deepbind-docker/9a6e48d3ee550cc8c7bf06173a78442a6ba10ac8/code/libs/kangaroo/vcproj/kangaroo.v11.suo -------------------------------------------------------------------------------- /code/libs/kangaroo/vcproj/kangaroo_smat.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hxx;hpp 7 | 8 | 9 | {45301eb6-c0c0-4517-ba98-587fe8cde372} 10 | .cu;.cuh 11 | 12 | 13 | 14 | 15 | CUDA Kernels 16 | 17 | 18 | CUDA Kernels 19 | 20 | 21 | CUDA Kernels 22 | 23 | 24 | CUDA Kernels 25 | 26 | 27 | CUDA Kernels 28 | 29 | 30 | CUDA Kernels 31 | 32 | 33 | CUDA Kernels 34 | 35 | 36 | CUDA Kernels 37 | 38 | 39 | 40 | 41 | Source Files 42 | 43 | 44 | 45 | 46 | Source Files 47 | 48 | 49 | CUDA Kernels 50 | 51 | 52 | CUDA Kernels 53 | 54 | 55 | CUDA Kernels 56 | 57 | 58 | CUDA Kernels 59 | 60 | 61 | CUDA Kernels 62 | 63 | 64 | CUDA Kernels 65 | 66 | 67 | -------------------------------------------------------------------------------- /code/libs/kangaroo/vcproj/kangaroo_smat.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(PYTHON27)\python.exe 5 | 6 | 7 | $(SolutionDir)..\..\kangaroo 8 | WindowsLocalDebugger 9 | 10 | 11 | $(PYTHON27)\python.exe 12 | mutmap.py -w=20 data/single_scan/TERT.seq E:/Results/deepbind/encode/best GABPA_GM12878_GABP_HudsonAlpha 13 | E:/Sync/bind 14 | WindowsLocalDebugger 15 | PYTHONPATH=../smat_py;../deepity;../hpsearch 16 | 17 | -------------------------------------------------------------------------------- /code/libs/smat/py/data/mnist/mnist_test.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gifford-lab/deepbind-docker/9a6e48d3ee550cc8c7bf06173a78442a6ba10ac8/code/libs/smat/py/data/mnist/mnist_test.npz -------------------------------------------------------------------------------- /code/libs/smat/py/data/mnist/mnist_train.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gifford-lab/deepbind-docker/9a6e48d3ee550cc8c7bf06173a78442a6ba10ac8/code/libs/smat/py/data/mnist/mnist_train.npz -------------------------------------------------------------------------------- /code/libs/smat/py/data/rnac/rnac_subset.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gifford-lab/deepbind-docker/9a6e48d3ee550cc8c7bf06173a78442a6ba10ac8/code/libs/smat/py/data/rnac/rnac_subset.npz -------------------------------------------------------------------------------- /code/libs/smat/py/run_tests.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | import argparse 36 | import smat 37 | import smat.tests 38 | 39 | smat.set_backend_options(device=0) 40 | 41 | parser = argparse.ArgumentParser(description="Run the smat unit tests and/or performance tests.") 42 | parser.add_argument("-p","--perf",action="store_true",default=False,help="Run performance tests instead of unit tests.") 43 | parser.add_argument("-d","--device",type=int,default=None,help="The device to use, e.g. CUDA device.") 44 | parser.add_argument("-b","--backend",type=str,default=None,help="The backend to use. Currently only \"cuda\" is supported.") 45 | args = parser.parse_args() 46 | 47 | if args.backend is not None: 48 | smat.set_backend(args.backend) 49 | 50 | if args.device is not None: 51 | smat.set_backend_options(device=args.device) 52 | 53 | print smat.get_backend_info() 54 | print smat.get_heap_status() 55 | 56 | if args.perf: 57 | smat.tests.perftest() 58 | else: 59 | smat.tests.unittest() 60 | -------------------------------------------------------------------------------- /code/libs/smat/py/smat/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | from smat import * 36 | #import util 37 | -------------------------------------------------------------------------------- /code/libs/smat/py/smat/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without modification, 4 | # are permitted provided that the following conditions are met: 5 | # 6 | # 1. Redistributions of source code must retain the above copyright notice, this 7 | # list of conditions and the following disclaimer. 8 | # 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation and/or 11 | # other materials provided with the distribution. 12 | # 13 | # 3. Neither the name of the copyright holder nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software without 15 | # specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # Author's note: 29 | # This file was distributed as part of the Nature Biotechnology 30 | # supplementary software release for DeepBind. Users of DeepBind 31 | # are encouraged to instead use the latest source code and binaries 32 | # for scoring sequences at 33 | # http://tools.genes.toronto.edu/deepbind/ 34 | # 35 | from unittest import unittest 36 | from perftest import perftest 37 | -------------------------------------------------------------------------------- /code/libs/smat/py/vcproj/smat_py.pyproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | 2.0 6 | {9e1abf94-6740-4f44-9f1d-8a2cada98262} 7 | .. 8 | demo_convnet.py 9 | . 10 | . 11 | smat_py 12 | smat_py 13 | Standard Python launcher 14 | --show_filters 15 | 16 | 17 | 18 | 19 | False 20 | 21 | 22 | true 23 | false 24 | 25 | 26 | true 27 | false 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | Code 37 | 38 | 39 | 40 | Code 41 | 42 | 43 | 44 | 45 | Code 46 | 47 | 48 | Code 49 | 50 | 51 | 52 | Code 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /code/libs/smat/py/vcproj/smat_py.pyproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ProjectFiles 5 | 6 | -------------------------------------------------------------------------------- /code/libs/smat/py/vcproj/smat_py.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "smat_py", "smat_py.pyproj", "{9E1ABF94-6740-4F44-9F1D-8A2CADA98262}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {9E1ABF94-6740-4F44-9F1D-8A2CADA98262}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {9E1ABF94-6740-4F44-9F1D-8A2CADA98262}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {9E1ABF94-6740-4F44-9F1D-8A2CADA98262}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {9E1ABF94-6740-4F44-9F1D-8A2CADA98262}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /code/libs/smat/py/vcproj/smat_py.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gifford-lab/deepbind-docker/9a6e48d3ee550cc8c7bf06173a78442a6ba10ac8/code/libs/smat/py/vcproj/smat_py.v11.suo -------------------------------------------------------------------------------- /code/libs/smat/src/base/assert.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | SM_NAMESPACE_BEGIN 43 | 44 | using namespace std; 45 | 46 | BASE_EXPORT bool g_want_debug_break = true; 47 | 48 | BASE_EXPORT void assert_failed_print(const char* fmt, ...) 49 | { 50 | printf("\n"); 51 | va_list va; 52 | va_start(va,fmt); 53 | vprintf(fmt,va); 54 | } 55 | 56 | BASE_EXPORT SM_NORETURN void assert_failed(const char* fmt, ...) 57 | { 58 | va_list va; 59 | va_start(va,fmt); 60 | char buffer[2048]; 61 | vsnprintf(buffer,2048,fmt,va); 62 | throw runtime_error(buffer); 63 | } 64 | 65 | SM_NAMESPACE_END 66 | -------------------------------------------------------------------------------- /code/libs/smat/src/base/logging.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SM_LOGGING_H__ 36 | #define __SM_LOGGING_H__ 37 | 38 | #include 39 | #include 40 | 41 | #ifndef SM_ENABLE_LOGGING 42 | #define SM_ENABLE_LOGGING 43 | #endif 44 | 45 | #ifdef SM_ENABLE_LOGGING 46 | #define SM_LOG(id,...) {if (_SM::get_log_policy(id) != lp_ignore) _SM::log_entry(id,__VA_ARGS__); } 47 | #else 48 | #define SM_LOG(id,...) 49 | #endif 50 | 51 | SM_NAMESPACE_BEGIN 52 | 53 | enum logging_policy_t { 54 | lp_ignore = 0, 55 | lp_record = 1 << 0, 56 | lp_write = 1 << 1, 57 | lp_print = 1 << 2 58 | }; 59 | 60 | SM_INLINE logging_policy_t operator|(logging_policy_t a, logging_policy_t b) { return (logging_policy_t)((unsigned)a | (unsigned)(b)); } 61 | SM_INLINE logging_policy_t operator&(logging_policy_t a, logging_policy_t b) { return (logging_policy_t)((unsigned)a & (unsigned)(b)); } 62 | 63 | BASE_EXPORT void log_entry(const char* id, const char* fmt, ...); 64 | BASE_EXPORT void set_log_policy(const char* id, logging_policy_t p); 65 | BASE_EXPORT void set_log_capacity(size_t capacity); 66 | BASE_EXPORT logging_policy_t get_log_policy(const char* id); 67 | 68 | SM_NAMESPACE_END 69 | 70 | #endif // __SM_LOGGING_H__ 71 | -------------------------------------------------------------------------------- /code/libs/smat/src/base/os.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SM_OS_H__ 36 | #define __SM_OS_H__ 37 | 38 | #include 39 | #include 40 | 41 | SM_NAMESPACE_BEGIN 42 | 43 | BASE_EXPORT size_t get_system_memory_avail(); 44 | BASE_EXPORT size_t get_system_memory_total(); 45 | BASE_EXPORT size_t get_process_memory_used(); 46 | BASE_EXPORT const char* get_last_os_error(); 47 | 48 | typedef size_t dllhandle_t; 49 | BASE_EXPORT dllhandle_t load_dll(const char* name); 50 | BASE_EXPORT void unload_dll(dllhandle_t handle); 51 | BASE_EXPORT void* get_dll_proc(dllhandle_t dll, const char* procname); 52 | 53 | BASE_EXPORT const char* user_home_dir(); 54 | BASE_EXPORT void mkdir(const char* dir); 55 | BASE_EXPORT bool isdir(const char* dir); 56 | 57 | SM_NAMESPACE_END 58 | 59 | #endif // __SM_OS_H__ 60 | -------------------------------------------------------------------------------- /code/libs/smat/src/base/random.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | 39 | using namespace std; 40 | 41 | SM_NAMESPACE_BEGIN 42 | 43 | size_t g_rand_seed = 0; 44 | static mt19937 g_rand_gen; 45 | static uniform_real_distribution g_uniform_dbl; 46 | static uniform_real_distribution g_uniform_flt; 47 | static uniform_int_distribution g_uniform_int; 48 | static normal_distribution g_normal_dbl; 49 | static normal_distribution g_normal_flt; 50 | 51 | BASE_EXPORT void set_rand_seed(size_t seed) { g_rand_seed = seed; g_rand_gen.seed((unsigned long)seed); } 52 | BASE_EXPORT size_t bump_rand_seed() { return g_rand_seed *= 1234; } 53 | BASE_EXPORT double rand_double() { return g_uniform_dbl(g_rand_gen); } 54 | BASE_EXPORT float rand_float() { return g_uniform_flt(g_rand_gen); } 55 | BASE_EXPORT int rand_int() { return g_uniform_int(g_rand_gen); } 56 | BASE_EXPORT double randn_double() { return g_normal_dbl(g_rand_gen); } 57 | BASE_EXPORT float randn_float() { return g_normal_flt(g_rand_gen); } 58 | 59 | SM_NAMESPACE_END 60 | -------------------------------------------------------------------------------- /code/libs/smat/src/base/range.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SM_RANGE_H__ 36 | #define __SM_RANGE_H__ 37 | 38 | #include 39 | #ifdef _MSC_VER 40 | #include // for std::input_iterator_tag 41 | #else 42 | #include 43 | #endif 44 | 45 | SM_NAMESPACE_BEGIN 46 | 47 | template 48 | class _range { 49 | public: 50 | class const_iterator { 51 | public: 52 | SM_INLINE const_iterator() {} 53 | SM_INLINE const_iterator(T pos, T step = 1): _pos(pos), _step(step) {} 54 | SM_INLINE const_iterator& operator++() { _pos += _step; return *this; } 55 | SM_INLINE const_iterator& operator--() { _pos -= _step; return *this; } 56 | SM_INLINE bool operator==(const const_iterator& other) const { return _pos == other._pos; } 57 | SM_INLINE bool operator!=(const const_iterator& other) const { return _pos != other._pos; } 58 | SM_INLINE const T& operator*() const { return _pos; } 59 | 60 | typedef std::input_iterator_tag iterator_category; 61 | typedef T value_type; 62 | typedef void difference_type; 63 | typedef const T* pointer; 64 | typedef const T& reference; 65 | private: 66 | T _pos; 67 | T _step; 68 | }; 69 | 70 | SM_INLINE _range(T begin, T end, T step) : _begin(begin), _end(end), _step(step) {} 71 | SM_INLINE bool operator==(const _range &other) const { return _begin == other._begin && _end == other._end; } 72 | SM_INLINE const_iterator begin() const { return const_iterator(_begin,_step); } 73 | SM_INLINE const_iterator end() const { return const_iterator(_end,_step); } 74 | 75 | private: 76 | T _begin,_end,_step; 77 | }; 78 | 79 | template _range range(T count) { return _range(0,count,1); } 80 | template _range range(T begin, T end) { return _range(begin,end,1); } 81 | template _range range(T begin, T end, T step) { return _range(begin,end,step); } 82 | 83 | SM_NAMESPACE_END 84 | 85 | #endif // __SM_RANGE_H__ 86 | -------------------------------------------------------------------------------- /code/libs/smat/src/base/time.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | 37 | #ifdef _WIN32 38 | #define WIN32_LEAN_AND_MEAN 39 | #define VC_EXTRALEAN 40 | #define _WIN32_WINNT 0x0403 41 | #include 42 | #endif 43 | 44 | SM_NAMESPACE_BEGIN 45 | 46 | #ifdef _WIN32 47 | static ticks_t g_tickrate = 0; 48 | extern "C" ticks_t ticks() // this is not thread safe 49 | { 50 | ticks_t result = 0; 51 | QueryPerformanceCounter((LARGE_INTEGER*)&result); 52 | return result; 53 | } 54 | extern "C" ticks_t tickrate() 55 | { 56 | if (g_tickrate == 0) 57 | QueryPerformanceFrequency((LARGE_INTEGER*)&g_tickrate); 58 | return g_tickrate; 59 | } 60 | #else 61 | extern "C" ticks_t ticks() { return ::clock(); } 62 | extern "C" ticks_t tickrate() { return CLOCKS_PER_SEC; } 63 | #endif 64 | 65 | extern "C" double duration(ticks_t ticks) 66 | { 67 | return (double)ticks / tickrate(); 68 | } 69 | 70 | SM_NAMESPACE_END -------------------------------------------------------------------------------- /code/libs/smat/src/base/time.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SM_TIME_H__ 36 | #define __SM_TIME_H__ 37 | 38 | #include 39 | #ifndef _WIN32 40 | #include 41 | #endif 42 | 43 | SM_NAMESPACE_BEGIN 44 | 45 | #ifdef _WIN32 46 | typedef long long ticks_t; 47 | #else 48 | typedef ::clock_t ticks_t; 49 | #endif 50 | extern "C" BASE_EXPORT ticks_t ticks(); 51 | extern "C" BASE_EXPORT ticks_t tickrate(); // ticks per second 52 | extern "C" BASE_EXPORT double duration(ticks_t ticks); 53 | 54 | SM_NAMESPACE_END 55 | 56 | #endif // __SM_TIME_H__ 57 | -------------------------------------------------------------------------------- /code/libs/smat/src/nvcc_preinclude.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #undef _GLIBCXX_ATOMIC_BUILTINS 36 | #undef _GLIBCXX_USE_INT128 37 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat/shape.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | 39 | SM_NAMESPACE_BEGIN 40 | 41 | using namespace std; 42 | 43 | string shape2str(const shape_t& shape) 44 | { 45 | if (shape.z != 0) return format("(%lld,%lld,%lld)",(long long)shape.x,(long long)shape.y,(long long)shape.z); 46 | if (shape.y != 0) return format("(%lld,%lld)",(long long)shape.x,(long long)shape.y); 47 | return format("(%lld,)",(long long)shape.x); 48 | } 49 | 50 | coord_t fullstride(const shape_t& shape) 51 | { 52 | return coord_t(shape.x == 0 ? 0 : 1, 53 | shape.y == 0 ? 0 : shape.x, 54 | shape.z == 0 ? 0 : shape.x*shape.y); 55 | } 56 | 57 | void slice_t::bind(isize_t dim) 58 | { 59 | // "Bind" a slice to a specific dimension size, 60 | // meaning negative indices get wrapped, and 61 | // slice_end gets mapped to the actual dim size. 62 | if (first < 0) { 63 | first += dim; 64 | if (last <= 0) 65 | last += dim; 66 | } else if (last < 0) 67 | last += dim; 68 | if (last == slice_end) 69 | last = dim; 70 | SM_ASSERTMSG(first >= 0,"IndexError: Index out of range.\n"); 71 | SM_ASSERTMSG(first <= last,"IndexError: Invalid slice.\n"); 72 | SM_ASSERTMSG(last <= dim,"IndexError: Index out of range.\n"); 73 | } 74 | 75 | SM_NAMESPACE_END 76 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat/vm/extension.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SM_DLLS_H__ 36 | #define __SM_DLLS_H__ 37 | 38 | #include 39 | #include 40 | 41 | SM_NAMESPACE_BEGIN 42 | 43 | // load_extension,unload_extension: 44 | // Much like using load_dll and unload_dll, with two differences: 45 | // 46 | // 1) The search path automatically includes the smat "bin" 47 | // developer and install directories. 48 | // 49 | // 2) If the dll exports a "register_ext" symbol, it is 50 | // called automatically. 51 | // 52 | SM_EXPORT dllhandle_t load_extension(const char* dllname); 53 | SM_EXPORT void unload_extension(dllhandle_t handle); 54 | 55 | SM_NAMESPACE_END 56 | 57 | #endif // __SM_DLLS_H__ 58 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat/vm/instruction.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | 37 | SM_NAMESPACE_BEGIN 38 | 39 | using namespace std; 40 | 41 | /////////////////////////////////////////////////////////////// 42 | 43 | instruction::instruction(opcode_t opcode): opcode(opcode) { } 44 | instruction::instruction(opcode_t opcode, argument&& arg0): opcode(opcode) { arg[0] = move(arg0); } 45 | instruction::instruction(opcode_t opcode, argument&& arg0, argument&& arg1): opcode(opcode) { arg[0] = move(arg0); arg[1] = move(arg1); } 46 | instruction::instruction(opcode_t opcode, argument&& arg0, argument&& arg1, argument&& arg2): opcode(opcode) { arg[0] = move(arg0); arg[1] = move(arg1); arg[2] = move(arg2); } 47 | instruction::instruction(opcode_t opcode, argument&& arg0, argument&& arg1, argument&& arg2, argument&& arg3): opcode(opcode) { arg[0] = move(arg0); arg[1] = move(arg1); arg[2] = move(arg2); arg[3] = move(arg3); } 48 | instruction::instruction(opcode_t opcode, argument&& arg0, argument&& arg1, argument&& arg2, argument&& arg3, argument&& arg4): opcode(opcode) { arg[0] = move(arg0); arg[1] = move(arg1); arg[2] = move(arg2); arg[3] = move(arg3); arg[4] = move(arg4); } 49 | instruction::~instruction() { } 50 | 51 | instruction::instruction(instruction&& src) 52 | : opcode(src.opcode) 53 | { 54 | for (int i = 0; i < max_arg; ++i) 55 | arg[i] = move(src.arg[i]); 56 | } 57 | /////////////////////////////////////////////////////////////// 58 | 59 | SM_NAMESPACE_END 60 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat/vm/instruction.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SM_INSTRUCTION_H__ 36 | #define __SM_INSTRUCTION_H__ 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | SM_NAMESPACE_BEGIN 43 | 44 | typedef int opcode_t; 45 | 46 | // instruction 47 | // Instruction specification. 48 | // 49 | struct SM_EXPORT instruction { SM_MOVEABLE(instruction) SM_NOCOPY(instruction) 50 | public: 51 | #ifdef SM_CPP11 52 | typedef argument&& operand_ref; 53 | #else 54 | typedef argument& operand_ref; 55 | #endif 56 | enum { max_arg = 6 }; 57 | instruction(opcode_t opcode); 58 | instruction(opcode_t opcode, operand_ref arg0); 59 | instruction(opcode_t opcode, operand_ref arg0, operand_ref arg1); 60 | instruction(opcode_t opcode, operand_ref arg0, operand_ref arg1, operand_ref arg2); 61 | instruction(opcode_t opcode, operand_ref arg0, operand_ref arg1, operand_ref arg2, operand_ref arg3); 62 | instruction(opcode_t opcode, operand_ref arg0, operand_ref arg1, operand_ref arg2, operand_ref arg3, operand_ref arg4); 63 | ~instruction(); 64 | 65 | opcode_t opcode; // opcode for instruction 66 | argument arg[max_arg]; // operands for instruction 67 | }; 68 | 69 | SM_NAMESPACE_END 70 | 71 | #endif // __SM_INSTRUCTION_H__ 72 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat/vm/machine.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SM_MACHINE_H__ 36 | #define __SM_MACHINE_H__ 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | SM_NAMESPACE_BEGIN 43 | 44 | class optionset; 45 | class block_allocator; 46 | 47 | class SM_EXPORT machine { SM_NOCOPY(machine) 48 | public: 49 | machine(); 50 | virtual ~machine(); 51 | virtual void set_options(const optionset& opt); 52 | virtual void validate(instruction& instr, const instruction_info& info); 53 | virtual void execute(const instruction& instr, const instruction_info& info, const instruction_impl& impl); 54 | 55 | protected: 56 | void validate_dtypes(instruction& instr, const instruction_info& info); 57 | void validate_strides(instruction& instr, const instruction_info& info); 58 | friend class context; 59 | }; 60 | 61 | SM_NAMESPACE_END 62 | 63 | #endif // __SM_MACHINE_H__ 64 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/arange.cu: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | SM_NAMESPACE_BEGIN 43 | 44 | template 45 | __global__ void kernel_arange(T start, T* dst, usize_t size) 46 | { 47 | DECL_KERNEL_VARS 48 | for (usize_t i = (usize_t)bdx*bx+tx; i < size; i += bdx*gdx) 49 | dst[i] = start + (T)i; 50 | } 51 | 52 | template 53 | struct execute_arange_typed { // TODO: autotune this 54 | static void execute(opcode_t opcode, const argument& start, const argument& dst) 55 | { 56 | usize_t size = (usize_t)dst.size(); 57 | if (size > 0) { 58 | launchcfg cfg = make_elemwise_launchcfg(size); 59 | kernel_arange<<>>(start.get(),dst.get(),size); 60 | } 61 | } 62 | }; 63 | 64 | void execute_arange(opcode_t opcode, const argument& start, const argument& dst) 65 | { 66 | DECL_SPECIALIZATION_TABLE(T_N,execute_fn2,execute_arange_typed); 67 | specialization_table(dst.dtype)(opcode,start,dst); 68 | } 69 | 70 | SM_NAMESPACE_END 71 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/config.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SMAT_CUDA_CONFIG_H__ 36 | #define __SMAT_CUDA_CONFIG_H__ 37 | 38 | #include 39 | 40 | #ifdef SMAT_CUDA_EXPORTS 41 | #define SM_CUDA_EXPORT SM_DLLEXPORT 42 | #else 43 | #define SM_CUDA_EXPORT SM_DLLIMPORT 44 | #endif 45 | 46 | #define SM_DEVICE_INLINE __device__ __forceinline__ 47 | #define SM_DEVICE_HOST_INLINE __device__ __host__ __forceinline__ 48 | 49 | #endif // __SMAT_CUDA_CONFIG_H__ 50 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/cuda_autotune.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | 37 | SM_NAMESPACE_BEGIN 38 | 39 | void autotune_reduce_y(); 40 | 41 | extern "C" SM_DLLEXPORT void register_ext() 42 | { 43 | autotune_reduce_y(); 44 | } 45 | 46 | SM_NAMESPACE_END 47 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/cuda_context.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SM_CUDA_CONTEXT_H__ 36 | #define __SM_CUDA_CONTEXT_H__ 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | SM_NAMESPACE_BEGIN 46 | 47 | class SM_CUDA_EXPORT cuda_context: public context { 48 | public: 49 | cuda_context(); 50 | virtual ~cuda_context(); 51 | 52 | virtual void set_device(int device); 53 | virtual void set_randseed(size_t seed); // override 54 | virtual void set_options(const optionset& opt); // override 55 | virtual bool is_supported(dtype_t dt) const; // override 56 | virtual void sync(); // override 57 | virtual void autotune(); // override 58 | 59 | int device() const; 60 | cudaStream_t stream() const; 61 | cublasHandle_t cublas() const; 62 | curandGenerator_t curand() const; 63 | curandState* curand_state() const; 64 | const cudaDeviceProp& deviceprop() const; 65 | 66 | private: 67 | virtual void ensure_initialized() const; // override 68 | void set_curand_seed() const; 69 | 70 | int _device; 71 | bool _want_stream; 72 | mutable int _curr_device; 73 | mutable cudaDeviceProp _deviceprop; 74 | mutable cudaStream_t _stream; 75 | mutable cublasHandle_t _cublas; 76 | mutable curandGenerator_t _curand; 77 | mutable curandState* _curand_state; 78 | friend class cuda_block_allocator; 79 | }; 80 | 81 | SM_INLINE cuda_context& thread_cudactx() { return (cuda_context&)thread_ctx(); } // casts to cuda_context, for convenience 82 | 83 | SM_NAMESPACE_END 84 | 85 | #endif // __SM_CUDA_CONTEXT_H__ 86 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/cuda_errors.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | 37 | SM_NAMESPACE_BEGIN 38 | 39 | const char* get_cublas_err_str(cublasStatus_t s) 40 | { 41 | switch (s) { 42 | case CUBLAS_STATUS_SUCCESS: return "SUCCESS"; 43 | case CUBLAS_STATUS_NOT_INITIALIZED: return "NOT_INITIALIZED"; 44 | case CUBLAS_STATUS_ALLOC_FAILED: return "ALLOC_FAILED"; 45 | case CUBLAS_STATUS_INVALID_VALUE: return "INVALID_VALUE"; 46 | case CUBLAS_STATUS_ARCH_MISMATCH: return "ARCH_MISMATCH"; 47 | case CUBLAS_STATUS_MAPPING_ERROR: return "MAPPING_ERROR"; 48 | case CUBLAS_STATUS_EXECUTION_FAILED: return "EXECUTION_FAILED"; 49 | case CUBLAS_STATUS_INTERNAL_ERROR: return "INTERNAL_ERROR"; 50 | } 51 | return "UNKNOWN"; 52 | } 53 | 54 | const char* get_curand_err_str(curandStatus_t s) 55 | { 56 | switch (s) { 57 | case CURAND_STATUS_SUCCESS: return "SUCCESS"; 58 | case CURAND_STATUS_VERSION_MISMATCH: return "VERSION_MISMATCH"; 59 | case CUBLAS_STATUS_NOT_INITIALIZED: return "NOT_INITIALIZED"; 60 | case CURAND_STATUS_ALLOCATION_FAILED: return "ALLOCATION_FAILED"; 61 | case CURAND_STATUS_TYPE_ERROR: return "TYPE_ERROR"; 62 | case CURAND_STATUS_OUT_OF_RANGE: return "OUT_OF_RANGE"; 63 | case CURAND_STATUS_LENGTH_NOT_MULTIPLE: return "LENGTH_NOT_MULTIPLE"; 64 | case CURAND_STATUS_DOUBLE_PRECISION_REQUIRED: return "DOUBLE_PRECISION_REQUIRED"; 65 | case CURAND_STATUS_LAUNCH_FAILURE: return "LAUNCH_FAILURE"; 66 | case CURAND_STATUS_PREEXISTING_FAILURE: return "PREEXISTING_FAILURE"; 67 | case CURAND_STATUS_INITIALIZATION_FAILED: return "INITIALIZATION_FAILED"; 68 | case CURAND_STATUS_ARCH_MISMATCH: return "ARCH_MISMATCH"; 69 | case CURAND_STATUS_INTERNAL_ERROR: return "INTERNAL_ERROR"; 70 | } 71 | return "UNKNOWN"; 72 | } 73 | 74 | SM_NAMESPACE_END 75 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/cuda_errors.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SM_CUDA_ERRORS_H__ 36 | #define __SM_CUDA_ERRORS_H__ 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | // ccu(XXX,...) = checked call to cudaXXX(...) 46 | // ccb(XXX,...) = checked call to cublasXXX(...) 47 | // ccr(XXX,...) = checked call to curandXXX(...) 48 | // cce() = check cudaGetLastError and, if there is an error, report it 49 | #define ccu(func,...) { cudaError_t error = cuda##func(__VA_ARGS__); if (error != cudaSuccess) SM_ERROR(format("AssertionError: CUDA error in %s: %s.",#func,cudaGetErrorString(error)).c_str()); } 50 | #define ccb(func,...) { cublasStatus_t status = cublas##func(__VA_ARGS__); if (status != CUBLAS_STATUS_SUCCESS) SM_ERROR(format("AssertionError: CUBLAS error in %s: %s.",#func,get_cublas_err_str(status)).c_str()); } 51 | #define ccr(func,...) { curandStatus_t status = curand##func(__VA_ARGS__); if (status != CURAND_STATUS_SUCCESS) SM_ERROR(format("AssertionError: CURAND failed in %s: %s.",#func,get_curand_err_str(status)).c_str()); } 52 | #define cce() { cudaError_t error = cudaGetLastError(); if (error != cudaSuccess) SM_ERROR(format("AssertionError: CUDA error: %s.",cudaGetErrorString(error)).c_str()); } 53 | #ifdef _DEBUG 54 | #define cce_dbsync() { cudaDeviceSynchronize(); cce(); } 55 | #else 56 | #define cce_dbsync() { } 57 | #endif 58 | 59 | SM_NAMESPACE_BEGIN 60 | 61 | SM_CUDA_EXPORT const char* get_cublas_err_str(cublasStatus_t s); 62 | SM_CUDA_EXPORT const char* get_curand_err_str(curandStatus_t s); 63 | 64 | SM_NAMESPACE_END 65 | 66 | #endif // __SM_CUDA_ERRORS_H__ 67 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/diff.cu: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | SM_NAMESPACE_BEGIN 43 | 44 | template 45 | __global__ void kernel_diff_y(const T* src, T* dst, usize_t m, usize_t size) 46 | { 47 | DECL_KERNEL_VARS 48 | for (usize_t i = (usize_t)bdx*bx+tx; i < size; i += bdx*gdx) 49 | dst[i] = src[i+m]-src[i]; // could be implemented by oc_sub operation on two views of arg, but this should be marginally faster. 50 | } 51 | 52 | 53 | template 54 | struct execute_diff_typed { 55 | static void execute(opcode_t opcode, const argument& src, const argument& dst) 56 | { 57 | usize_t size = (usize_t)dst.size(); 58 | if (size == 0) 59 | return; 60 | if (opcode == oc_diff_x) { 61 | SM_UNIMPLEMENTED(); 62 | } else if (opcode == oc_diff_y) { 63 | launchcfg cfg = make_elemwise_launchcfg(size); 64 | kernel_diff_y<<>>(src.get(),dst.get(),dst.shape.x,size); 65 | } else { 66 | SM_UNREACHABLE(); 67 | } 68 | } 69 | }; 70 | 71 | void execute_diff(opcode_t opcode, const argument& src, const argument& dst) 72 | { 73 | DECL_SPECIALIZATION_TABLE(T_G,execute_fn2,execute_diff_typed); 74 | specialization_table(src.dtype)(opcode,src,dst); 75 | } 76 | 77 | SM_NAMESPACE_END 78 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/launch_util.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | 39 | SM_NAMESPACE_BEGIN 40 | 41 | launchcfg make_elemwise_launchcfg(usize_t size) 42 | { 43 | auto& dprop = thread_cudactx().deviceprop(); 44 | unsigned min_threads = dprop.warpSize; 45 | unsigned max_threads = 256; 46 | unsigned resident_blocks_per_multiprocessor = 8; 47 | unsigned max_blocks = 4*resident_blocks_per_multiprocessor*dprop.multiProcessorCount; 48 | unsigned block_size = max_threads; 49 | unsigned grid_size = max_blocks; 50 | 51 | if (size < min_threads) { 52 | // Array can be handled by the smallest block size. 53 | block_size = min_threads; 54 | grid_size = 1; 55 | } else if (size < max_blocks*min_threads) { 56 | // Array can be handled by several blocks of the smallest size. 57 | block_size = min_threads; 58 | grid_size = divup(size,block_size); 59 | } else if (size < max_blocks*max_threads) { 60 | // Array must be handled by max number of blocks, each of 61 | // larger-than-minimal size, but still a multiple of warp size. 62 | // In this case, each thread within a block should handle 63 | // multiple elements, looping until the entire grid has 64 | // processed 'size' unique elements. 65 | block_size = divup(divup(size,min_threads),max_blocks)*min_threads; 66 | grid_size = max_blocks; 67 | } else { 68 | // do nothing 69 | } 70 | 71 | return launchcfg(grid_size,block_size,0,thread_cudactx().stream()); 72 | } 73 | 74 | SM_NAMESPACE_END 75 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/mask.cu: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | SM_NAMESPACE_BEGIN 41 | 42 | template 43 | __global__ void kernel_apply_mask(T* A, const bool* M, unsigned size) 44 | { 45 | DECL_KERNEL_VARS 46 | for (unsigned i = bdx*bx + tx; i < size; i += bdx*gdx) 47 | if (!M[i]) 48 | A[i] = (T)0; 49 | } 50 | 51 | 52 | void execute_apply_mask(opcode_t opcode, const argument& A, const argument& M) 53 | { 54 | unsigned size = (unsigned)A.size(); 55 | launchcfg cfg = make_elemwise_launchcfg(size); 56 | if (A.dtype == f32) kernel_apply_mask<<>>(A.get(),M.get(),(unsigned)size); 57 | else if (A.dtype == f64) kernel_apply_mask<<>>(A.get(),M.get(),(unsigned)size); 58 | else { SM_UNIMPLEMENTED(); } 59 | } 60 | 61 | 62 | SM_NAMESPACE_END 63 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/reduce.cu: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | 39 | SM_NAMESPACE_BEGIN 40 | 41 | // Determines good launch config for reduce operation. 42 | launchcfg make_reduce_launchcfg(dtype_t dt, usize_t size) 43 | { 44 | // TODO: add autotuning mechanism 45 | unsigned maxthread = 128; 46 | unsigned maxblock = 2*8*thread_cudactx().deviceprop().multiProcessorCount; 47 | unsigned nthread = (size >= maxthread*2) ? maxthread : divup_pow2((size+1)/2); 48 | unsigned nblock = min(maxblock,(size + (nthread*2-1))/(nthread*2)); 49 | unsigned smem = nthread*dtype_size(dt); 50 | 51 | // When there is only one warp per block, we need to allocate two warps 52 | // worth of shared memory so that we don't index shared memory out of bounds. 53 | if (nthread <= 32) 54 | smem *= 2; 55 | 56 | return launchcfg(nblock,nthread,smem,thread_cudactx().stream()); 57 | } 58 | 59 | void execute_reduce(opcode_t opcode, const argument& src, const argument& dst) 60 | { 61 | #define LAUNCH_CASE(typesets,f,matched) \ 62 | if (opcode == oc_##f) { \ 63 | DECL_SPECIALIZATION_TABLE(typesets,execute_fn2,execute_reduce_typed::matched); \ 64 | specialization_table(src.dtype)(opcode,src,dst); \ 65 | return; \ 66 | } 67 | 68 | LAUNCH_CASE(T_G,max,matched) 69 | LAUNCH_CASE(T_G,min,matched) 70 | LAUNCH_CASE(T_G,sum,promoted) 71 | LAUNCH_CASE(T_G,mean,asfloat) 72 | LAUNCH_CASE(T_G,nnz,asuindex) 73 | SM_UNIMPLEMENTED() 74 | } 75 | 76 | SM_NAMESPACE_END 77 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/reduce_x.cu: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #include 36 | #include 37 | #include 38 | 39 | SM_NAMESPACE_BEGIN 40 | 41 | void execute_reduce(opcode_t opcode, const argument& src, const argument& dst); 42 | 43 | void execute_reduce_x(opcode_t opcode, const argument& src, const argument& dst) 44 | { 45 | if (src.shape.y == 1) { 46 | execute_reduce(opcode + (oc_max-oc_max_x),src,dst); 47 | return; 48 | } 49 | 50 | #define LAUNCH_CASE(typesets,f,matched) \ 51 | if (opcode == oc_##f##_x) { \ 52 | DECL_SPECIALIZATION_TABLE(typesets,execute_fn2,execute_reduce_x_typed::matched); \ 53 | specialization_table(src.dtype)(opcode,src,dst); \ 54 | return; \ 55 | } 56 | if (opcode == oc_max) 57 | opcode = opcode; 58 | LAUNCH_CASE(T_G,max,matched) 59 | LAUNCH_CASE(T_G,min,matched) 60 | LAUNCH_CASE(T_G,sum,promoted) 61 | LAUNCH_CASE(T_G,mean,asfloat) 62 | LAUNCH_CASE(T_G,nnz,asuindex) 63 | SM_UNIMPLEMENTED() 64 | } 65 | 66 | SM_NAMESPACE_END 67 | -------------------------------------------------------------------------------- /code/libs/smat/src/smat_cuda/reduce_y.autotune.cuh: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Andrew Delong and Babak Alipanahi All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modification, 4 | // are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, this 7 | // list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation and/or 11 | // other materials provided with the distribution. 12 | // 13 | // 3. Neither the name of the copyright holder nor the names of its contributors 14 | // may be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // Author's note: 29 | // This file was distributed as part of the Nature Biotechnology 30 | // supplementary software release for DeepBind. Users of DeepBind 31 | // are encouraged to instead use the latest source code and binaries 32 | // for scoring sequences at 33 | // http://tools.genes.toronto.edu/deepbind/ 34 | // 35 | #ifndef __SM_CUDA_REDUCE_Y_AUTOTUNE_H__ 36 | #define __SM_CUDA_REDUCE_Y_AUTOTUNE_H__ 37 | 38 | #include 39 | #include 40 | 41 | SM_NAMESPACE_BEGIN 42 | 43 | template