├── .github └── workflows │ └── build.yml ├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── IntaRNA.pc.in ├── LICENSE ├── Makefile.am ├── NEWS ├── R ├── IntaRNA_CSV_p-value.R ├── IntaRNA_plotRegions.R ├── Makefile.am ├── README.md └── plotRegions.example.png ├── README ├── README.md ├── _config.yml ├── autotools-init.sh ├── conda-build-env.yml ├── configure.ac ├── doc ├── Makefile.am ├── conda.txt ├── doxygen.cfg ├── figures │ ├── freepik-Icons-collection.zip │ ├── freepik-colored-arrows.zip │ ├── helixbased.svg │ ├── icon-no.39.png │ ├── icon-no.svg │ ├── icon-up.28.png │ ├── icon-up.38.png │ ├── icon-up.svg │ ├── icon-yes.39.png │ ├── icon-yes.svg │ ├── interaction-context.svg │ ├── pair-minE.png │ ├── pf_scale.problem.png │ └── profile-minE.png ├── galaxy-tool-shed.txt ├── handson │ ├── ChiX_NC_000913.fasta │ ├── GcvB.ST.fasta │ ├── GcvB.fasta │ ├── NC_000913.fa │ ├── OxyS.fasta │ ├── README.md │ ├── fhlA.fasta │ ├── ilvE.fasta │ └── phoB.fasta ├── how-to-release-new-version.md ├── latex-deps │ ├── adjcalc.sty │ ├── adjustbox.sty │ ├── collectbox.sty │ ├── tc-pgf.def │ ├── tocloft.sty │ ├── trimclip.sty │ └── xtab.sty └── recursions │ ├── IntaRNA-outNoLP.PredictorMfe2d.svg │ ├── IntaRNA-outNoLP.PredictorMfe2dHeuristic.svg │ ├── IntaRNA-outNoLP.PredictorMfe2dHeuristicSeed.svg │ ├── IntaRNA-outNoLP.PredictorMfe2dSeed.svg │ ├── IntaRNA.PredictorMfe2d.svg │ ├── IntaRNA.PredictorMfe2dHeuristic.svg │ ├── IntaRNA.PredictorMfe2dHeuristicSeed.svg │ └── IntaRNA.PredictorMfe2dSeed.svg ├── m4 ├── doxygen.m4 ├── m4-ax_boost_base.m4 ├── m4-ax_boost_filesystem.m4 ├── m4-ax_boost_iostreams.m4 ├── m4-ax_boost_program_options.m4 ├── m4-ax_boost_regex.m4 ├── m4-ax_boost_system.m4 ├── m4-ax_check_zlib.m4 ├── m4-ax_cxx_compile_stdcxx.m4 └── m4-ax_openmp.m4 ├── perl ├── IntaRNA-fuse.pl └── Makefile.am ├── python ├── CopomuS.py ├── Makefile.am ├── README.md ├── bin │ ├── Makefile.am │ └── build.py ├── copomus │ ├── CopomuS-logo.jpg │ ├── IntaRNA.py │ ├── Makefile.am │ ├── README.md │ ├── __init__.py │ ├── candidate_filters.py │ ├── candidate_selectors.py │ ├── indexing.py │ ├── measures.py │ ├── mutation.py │ └── mutation_generators.py ├── intarnapvalue │ ├── Makefile.am │ ├── README.md │ ├── __init__.py │ ├── __main__.py │ ├── dinucl_shuffle.py │ ├── intarna_pvalue.py │ └── test.py └── setup.py ├── src ├── .gitignore ├── IntaRNA │ ├── Accessibility.cpp │ ├── Accessibility.h │ ├── AccessibilityBasePair.cpp │ ├── AccessibilityBasePair.h │ ├── AccessibilityConstraint.cpp │ ├── AccessibilityConstraint.h │ ├── AccessibilityDisabled.h │ ├── AccessibilityFromStream.cpp │ ├── AccessibilityFromStream.h │ ├── AccessibilityVrna.cpp │ ├── AccessibilityVrna.h │ ├── HelixConstraint.h │ ├── HelixHandler.cpp │ ├── HelixHandler.h │ ├── HelixHandlerIdxOffset.h │ ├── HelixHandlerNoBulgeMax.cpp │ ├── HelixHandlerNoBulgeMax.h │ ├── HelixHandlerUnpaired.cpp │ ├── HelixHandlerUnpaired.h │ ├── IndexRange.cpp │ ├── IndexRange.h │ ├── IndexRangeList.cpp │ ├── IndexRangeList.h │ ├── Interaction.cpp │ ├── Interaction.h │ ├── InteractionEnergy.cpp │ ├── InteractionEnergy.h │ ├── InteractionEnergyBasePair.cpp │ ├── InteractionEnergyBasePair.h │ ├── InteractionEnergyIdxOffset.cpp │ ├── InteractionEnergyIdxOffset.h │ ├── InteractionEnergyVrna.cpp │ ├── InteractionEnergyVrna.h │ ├── InteractionRange.cpp │ ├── InteractionRange.h │ ├── Makefile.am │ ├── NussinovHandler.cpp │ ├── NussinovHandler.h │ ├── OutputConstraint.cpp │ ├── OutputConstraint.h │ ├── OutputHandler.cpp │ ├── OutputHandler.h │ ├── OutputHandlerCsv.cpp │ ├── OutputHandlerCsv.h │ ├── OutputHandlerEnsemble.cpp │ ├── OutputHandlerEnsemble.h │ ├── OutputHandlerHub.h │ ├── OutputHandlerInteractionList.cpp │ ├── OutputHandlerInteractionList.h │ ├── OutputHandlerText.cpp │ ├── OutputHandlerText.h │ ├── OutputStreamHandler.h │ ├── OutputStreamHandlerSortedCsv.cpp │ ├── OutputStreamHandlerSortedCsv.h │ ├── PredictionTracker.h │ ├── PredictionTrackerHub.h │ ├── PredictionTrackerPairMinE.cpp │ ├── PredictionTrackerPairMinE.h │ ├── PredictionTrackerProfileMinE.cpp │ ├── PredictionTrackerProfileMinE.h │ ├── PredictionTrackerProfileSpotProb.cpp │ ├── PredictionTrackerProfileSpotProb.h │ ├── PredictionTrackerSpotProb.cpp │ ├── PredictionTrackerSpotProb.h │ ├── PredictionTrackerSpotProbAll.cpp │ ├── PredictionTrackerSpotProbAll.h │ ├── Predictor.h │ ├── PredictorMfe.cpp │ ├── PredictorMfe.h │ ├── PredictorMfe2d.cpp │ ├── PredictorMfe2d.h │ ├── PredictorMfe2dHelixBlockHeuristic.cpp │ ├── PredictorMfe2dHelixBlockHeuristic.h │ ├── PredictorMfe2dHelixBlockHeuristicSeed.cpp │ ├── PredictorMfe2dHelixBlockHeuristicSeed.h │ ├── PredictorMfe2dHeuristic.cpp │ ├── PredictorMfe2dHeuristic.h │ ├── PredictorMfe2dHeuristicSeed.cpp │ ├── PredictorMfe2dHeuristicSeed.h │ ├── PredictorMfe2dHeuristicSeedExtension.cpp │ ├── PredictorMfe2dHeuristicSeedExtension.h │ ├── PredictorMfe2dSeed.cpp │ ├── PredictorMfe2dSeed.h │ ├── PredictorMfe2dSeedExtension.cpp │ ├── PredictorMfe2dSeedExtension.h │ ├── PredictorMfe2dSeedExtensionRIblast.cpp │ ├── PredictorMfe2dSeedExtensionRIblast.h │ ├── PredictorMfeEns.cpp │ ├── PredictorMfeEns.h │ ├── PredictorMfeEns2d.cpp │ ├── PredictorMfeEns2d.h │ ├── PredictorMfeEns2dHeuristic.cpp │ ├── PredictorMfeEns2dHeuristic.h │ ├── PredictorMfeEns2dHeuristicSeedExtension.cpp │ ├── PredictorMfeEns2dHeuristicSeedExtension.h │ ├── PredictorMfeEns2dSeedExtension.cpp │ ├── PredictorMfeEns2dSeedExtension.h │ ├── PredictorMfeEnsSeedOnly.cpp │ ├── PredictorMfeEnsSeedOnly.h │ ├── PredictorMfeSeedOnly.cpp │ ├── PredictorMfeSeedOnly.h │ ├── ReverseAccessibility.cpp │ ├── ReverseAccessibility.h │ ├── RnaSequence.cpp │ ├── RnaSequence.h │ ├── SeedConstraint.h │ ├── SeedHandler.cpp │ ├── SeedHandler.h │ ├── SeedHandlerExplicit.cpp │ ├── SeedHandlerExplicit.h │ ├── SeedHandlerIdxOffset.h │ ├── SeedHandlerMfe.cpp │ ├── SeedHandlerMfe.h │ ├── SeedHandlerNoBulge.cpp │ ├── SeedHandlerNoBulge.h │ ├── VrnaHandler.cpp │ ├── VrnaHandler.h │ ├── general.cpp │ ├── general.h │ └── intarna_config.h.in ├── Makefile.am ├── bin │ ├── CommandLineParsing.cpp │ ├── CommandLineParsing.h │ ├── IntaRNA.cpp │ └── Makefile.am ├── easylogging++.LICENCE.txt ├── easylogging++.cc └── easylogging++.h └── tests ├── .gitignore ├── AccessibilityBasePair_test.cpp ├── AccessibilityConstraint_test.cpp ├── AccessibilityFromStream_test.cpp ├── AccessibilityVrna_test.cpp ├── HelixConstraint_test.cpp ├── HelixHandlerNoBulgeMaxIdxOffset_test.cpp ├── HelixHandlerNoBulgeMaxSeedIdxOffset_test.cpp ├── HelixHandlerNoBulgeMaxSeed_test.cpp ├── HelixHandlerNoBulgeMax_test.cpp ├── HelixHandlerUnpairedIdxOffset_test.cpp ├── HelixHandlerUnpairedSeedIdxOffset_test.cpp ├── HelixHandlerUnpairedSeed_test.cpp ├── HelixHandlerUnpaired_test.cpp ├── IndexRangeList_test.cpp ├── IndexRange_test.cpp ├── InteractionEnergyBasePair_test.cpp ├── InteractionRange_test.cpp ├── Interaction_test.cpp ├── Makefile.am ├── NussinovHandler_test.cpp ├── OutputHandlerInteractionList_test.cpp ├── OutputStreamHandlerSortedCsv_test.cpp ├── PredictionTrackerProfileMinE_test.cpp ├── PredictionTrackerSpotProb_test.cpp ├── PredictorMfe2dHelixBlockHeuristicSeed_test.cpp ├── PredictorMfe2dHelixBlockHeuristic_test.cpp ├── RnaSequence_test.cpp ├── SeedHandlerExplicit_test.cpp ├── SeedHandlerIdxOffset_test.cpp ├── SeedHandlerMfe_test.cpp ├── SeedHandlerNoBulge_test.cpp ├── catch.hpp ├── data ├── .gitignore ├── Makefile.am ├── energyB-accN-exact-seed-modelS.parameter ├── energyB-accN-exact-seed-modelS.testresult ├── energyB-accN-exact-seed-modelX.parameter ├── energyB-accN-exact-seed-modelX.testresult ├── energyB-accN-exact.parameter ├── energyB-accN-exact.testresult ├── energyB-accN-heuristic-seed-modelS.parameter ├── energyB-accN-heuristic-seed-modelS.testresult ├── energyB-accN-heuristic-seed-modelX.parameter ├── energyB-accN-heuristic-seed-modelX.testresult ├── energyB-accN-heuristic.parameter ├── energyB-accN-heuristic.testresult ├── energyB-accN-noLP-exact-seed-modelS.parameter ├── energyB-accN-noLP-exact-seed-modelS.testresult ├── energyB-accN-noLP-exact-seed-modelX.parameter ├── energyB-accN-noLP-exact-seed-modelX.testresult ├── energyB-accN-noLP-exact.parameter ├── energyB-accN-noLP-exact.testresult ├── energyB-accN-noLP-heuristic-seed-modelS.parameter ├── energyB-accN-noLP-heuristic-seed-modelS.testresult ├── energyB-accN-noLP-heuristic-seed-modelX.parameter ├── energyB-accN-noLP-heuristic-seed-modelX.testresult ├── energyB-accN-noLP-heuristic.parameter ├── energyB-accN-noLP-heuristic.testresult ├── energyB-accN-outNoGUend.parameter ├── energyB-accN-outNoGUend.testresult ├── energyB-accN-overlapB-heuristic-seed-modelX.parameter ├── energyB-accN-overlapB-heuristic-seed-modelX.testresult ├── energyB-accN-overlapN-heuristic-seed-modelX.parameter ├── energyB-accN-overlapN-heuristic-seed-modelX.testresult ├── energyB-accN-overlapQ-heuristic-seed-modelX.parameter ├── energyB-accN-overlapQ-heuristic-seed-modelX.testresult ├── energyB-accN-overlapT-heuristic-seed-modelX.parameter └── energyB-accN-overlapT-heuristic-seed-modelX.testresult ├── runApiTests.cpp ├── runIntaRNA.sh └── testEasyLoggingSetup.icc /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | 10 | defaults: 11 | run: 12 | shell: bash -el {0} 13 | 14 | 15 | jobs: 16 | build: 17 | 18 | runs-on: ubuntu-latest 19 | 20 | steps: 21 | 22 | - name: Check out sources from github 23 | uses: actions/checkout@v2 24 | 25 | - name: Setup conda environment 26 | uses: conda-incubator/setup-miniconda@v2 27 | with: 28 | miniconda-version: "latest" 29 | environment-file: conda-build-env.yml 30 | activate-environment: conda-build-env 31 | 32 | - name: Build and test IntaRNA 33 | run: | 34 | ##### start IntaRNA build ##### 35 | pwd 36 | # generate autotools's files 37 | bash autotools-init.sh 38 | # run configure (without boost checks) 39 | ENVPREFIX=`conda info --base`/envs/conda-build-env 40 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ENVPREFIX/lib 41 | ./configure \ 42 | --prefix=$HOME/IntaRNA \ 43 | --with-vrna=$ENVPREFIX \ 44 | --with-boost=$ENVPREFIX \ 45 | --with-boost-libdir=$ENVPREFIX/lib \ 46 | --with-zlib=$ENVPREFIX 47 | # compile documentation 48 | # - make doxygen-doc 49 | # compile, test and install IntaRNA 50 | make -j 2 && make install 51 | make tests -j 2 52 | ##### check IntaRNA build ##### 53 | # run installed IntaRNA with help output 54 | $HOME/IntaRNA/bin/IntaRNA -h 55 | -------------------------------------------------------------------------------- /.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 | # eclipse files 31 | .project 32 | .settings 33 | .cproject 34 | .autotools 35 | .* 36 | 37 | # temporary autotools files 38 | config.* 39 | Makefile 40 | autom4te.cache 41 | configure 42 | missing 43 | install-sh 44 | depcomp 45 | aclocal.m4 46 | Makefile.in 47 | compile 48 | */.deps 49 | */.deps/* 50 | /intaRNA-*.tar.gz 51 | doxygen-doc 52 | doxygen-doc/* 53 | conf3108* 54 | test-driver 55 | 56 | 57 | # temp dir 58 | tmp 59 | tmp/* 60 | tests/logs 61 | tests/logs/* 62 | 63 | # python dir 64 | python/build 65 | python/dist 66 | python/intarnapvalue.* 67 | 68 | 69 | 70 | /1 71 | /RNAup 72 | /IntaRNA-1 73 | /IntaRNA-1.out2 74 | /q.fasta 75 | /q2.fasta 76 | /seq.fasta 77 | /t.fasta 78 | /t2.fasta 79 | /IntaRNA.pc 80 | /IntaRNA.exe.stackdump 81 | /py-compile 82 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | version 3.* 4 | ############################################################# 5 | 6 | - Martin Raden, nee Mann 7 | 8 | - Frank Gelhausen 9 | - Fabio Gutmann 10 | 11 | ############################################################# 12 | version 2.* 13 | ############################################################# 14 | 15 | - Martin Raden, nee Mann 16 | 17 | - Alex Gawronski 18 | - Rick Gelhausen 19 | - Sebastian Holler 20 | - Mostafa Mahmoud 21 | - Milad Miladi 22 | 23 | ############################################################# 24 | version 1.* 25 | ############################################################# 26 | 27 | - Anke Busch 28 | - Andreas Richter 29 | - Sven Siebert 30 | 31 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | see LICENSE file -------------------------------------------------------------------------------- /IntaRNA.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@PREFIX_PATH@ 2 | exec_prefix=${prefix}/bin 3 | libdir=${prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: IntaRNA 7 | Description: RNA-RNA interaction prediction C++ library 8 | Version: @VERSION@ 9 | Libs: @LIBS@ 10 | Cflags: 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Bioinformatics Group of Prof. Backofen, 4 | Institute for Computer Science, University Freiburg, Freiburg, Germany 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | # ACLOCAL_AMFLAGS=-I m4 3 | 4 | # enable gcc output coloring if not set already 5 | export GCC_COLORS ?= "error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01" 6 | 7 | # sub directories to check for Makefiles 8 | SUBDIRS = src python perl R tests doc . 9 | 10 | # list of all personalities to be installed 11 | PERSONALITIES=@PERSONALITIES@ 12 | 13 | # create tool links to activate respective personalities 14 | install-exec-hook: 15 | @echo " => creating personality links" 16 | @cd $(DESTDIR)$(bindir); \ 17 | for p in @PERSONALITIES@; do \ 18 | $(LN_S) -f IntaRNA$(EXEEXT) $$p$(EXEEXT); \ 19 | done 20 | 21 | ################################################################ 22 | # doxygen 23 | ################################################################ 24 | 25 | if enable_doxygen 26 | ## doxygen documentation make target 27 | @DX_RULES@ 28 | else 29 | ## generate mandatory targets otherwise generated by doxygen.m4 30 | DX_PHONY = 31 | endif 32 | 33 | ################################################################ 34 | # tests 35 | ################################################################ 36 | 37 | # global test directive # ensure all is compiled (need object files for tests) 38 | .PHONY: DX_PHONY tests test 39 | 40 | tests: all 41 | @echo 42 | @echo " => compiling and running tests ... will take a while ..." 43 | @echo 44 | @$(MAKE) clean-checkPROGRAMS -s -C tests 45 | @$(MAKE) check -s -C tests || (cat tests/test-suite.log && false) 46 | 47 | test: tests 48 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 2 | see Changelog file 3 | -------------------------------------------------------------------------------- /R/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | # scripts to be installed in $(bindir) and distributed 3 | 4 | dist_bin_SCRIPTS = \ 5 | IntaRNA_CSV_p-value.R \ 6 | IntaRNA_plotRegions.R 7 | 8 | 9 | -------------------------------------------------------------------------------- /R/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Auxiliary R scripts of the IntaRNA package 3 | 4 | - [IntaRNA_CSV_p-value.R](#intarnacsvpvaluer) 5 | - [IntaRNA_plotRegions.R](#intrarnaplotregionsr) 6 | 7 | 8 | # `IntaRNA_CSV_p-value.R` 9 | ### p-value estimates of IntaRNA energies from present energy distribution 10 | 11 | For genome-wide target sRNA predictions, we assume the set of energy values 12 | predicted for all target sufficiently diverse to be used as a background energy 13 | model for minimum energies of putative target sequences. Thus, we can fit a 14 | generalized extreme value (GEV) distribution to the data that is subsequently 15 | used to estimate p-values for each energy. 16 | 17 | The `IntaRNA_CSV_p-value.R` script takes an IntaRNA CSV output file (assumed to be 18 | sufficiently large and sane enough for GEV fitting) to compute respective 19 | p-value estimates. The output consists of the input table extended with a 20 | `p-value` column. If no output file is given or in- and output file names are 21 | equal, the input file is overwritten! 22 | You can (optionally) specify the column name for which p-values are to be 23 | estimated. Example calls are given below. 24 | 25 | ```bash 26 | # overwriting the input file with p-value-extended table 27 | Rscript --vanilla IntaRNA_CSV_p-value.R IntaRNA-output.csv 28 | # creating a new output file for p-value extension 29 | Rscript --vanilla IntaRNA_CSV_p-value.R IntaRNA-output.csv IntaRNA-output-with-pValue.csv 30 | # computing p-values for normalized energies (has to be present in file IN.csv) 31 | Rscript --vanilla IntaRNA_CSV_p-value.R IN.csv IN-pValue.csv E_norm 32 | ``` 33 | 34 | 35 | # `IntaRNA_plotRegions.R` 36 | ### Visualization of RRI-covered regions 37 | 38 | To visualize sequences' regions covered by RNA-RNA interactions predicted by 39 | IntaRNA, you can use `IntaRNA_plotRegions.R` by providing the following arguments (in 40 | the given order) 41 | 42 | 1. CSV-IntaRNA output file (semicolon separated) covering the columns `start,end,id` 43 | with suffix `1` or `2` to plot target or query regions, respectively 44 | 2. `1` or `2` to select whether to plot target or query regions 45 | 3. output file name with a file-format-specific suffix from `.pdf`, `.png`, 46 | `.svg`, `.eps`, `.ps`, `.jpeg`, `.tiff` 47 | 48 | An example is given below, when calling 49 | ```bash 50 | Rscript --vanilla IntaRNA_plotRegions.R pred.csv 1 plotRegions.example.png 51 | ``` 52 | 53 | with `pred.csv` containing 54 | ``` 55 | id1;start1;end1;id2;start2;end2 56 | b0001;266;273;query;116;123 57 | b0002;204;231;query;85;111 58 | b0003;229;262;query;96;125 59 | b0004;265;300;query;10;38 60 | b0005;281;295;query;5;22 61 | ``` 62 | 63 | will produce the output 64 | ![IntaRNA_plotRegions.R example](plotRegions.example.png) 65 | 66 | -------------------------------------------------------------------------------- /R/plotRegions.example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/R/plotRegions.example.png -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | ######### IntaRNA ################################################ 3 | 4 | To configure, compile and install do the following steps: 5 | - run ./configure [--help for additional configuration options] 6 | - run make 7 | - run make install 8 | 9 | In case you run into problems, please contact us! 10 | 11 | Also refer to README.md file for further information. 12 | 13 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate 2 | -------------------------------------------------------------------------------- /autotools-init.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Run this before configure 4 | # 5 | 6 | set -e -o pipefail 7 | 8 | #test -d config || mkdir config 9 | # Produce aclocal.m4, so autoconf gets the automake macros it needs 10 | echo "Creating aclocal.m4..." 11 | aclocal || exit $?; 12 | 13 | # Produce config.h raw file 14 | autoheader || exit $?; 15 | 16 | # Produce all the `Makefile.in's, verbosely, and create neat missing things 17 | # like `libtool', `install-sh', etc. 18 | automake --add-missing --gnu --copy || exit $?; 19 | 20 | # If there's a config.cache file, we may need to delete it. 21 | # If we have an existing configure script, save a copy for comparison. 22 | if [ -f config.cache ] && [ -f configure ]; then 23 | cp configure configure.$$.tmp 24 | fi 25 | 26 | # Produce ./configure 27 | echo "Creating configure..." 28 | autoconf || exit $?; 29 | 30 | echo "" 31 | echo "You can run ./configure [--prefix=$HOME] now." 32 | echo "" 33 | -------------------------------------------------------------------------------- /conda-build-env.yml: -------------------------------------------------------------------------------- 1 | 2 | name: intarna-build-env 3 | 4 | channels: 5 | - conda-forge 6 | - bioconda 7 | - defaults 8 | 9 | dependencies: 10 | - gcc_linux-64 11 | - gxx_linux-64 12 | - pkgconfig 13 | - zlib 14 | - boost-cpp 15 | - viennarna>=2.4.14 16 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | ################################################################ 3 | # extra files to be added to distribution 4 | ################################################################ 5 | 6 | EXTRA_DIST = \ 7 | conda.txt \ 8 | doxygen.cfg \ 9 | latex-deps/adjcalc.sty \ 10 | latex-deps/adjustbox.sty \ 11 | latex-deps/collectbox.sty \ 12 | latex-deps/tc-pgf.def \ 13 | latex-deps/tocloft.sty \ 14 | latex-deps/trimclip.sty \ 15 | latex-deps/xtab.sty 16 | 17 | -------------------------------------------------------------------------------- /doc/conda.txt: -------------------------------------------------------------------------------- 1 | 2 | # Conda distribution 3 | 4 | IntaRNA is also distributed via conda's bioconda channel. 5 | https://bioconda.github.io/recipes/intarna/README.html 6 | 7 | You will find the recipe here 8 | https://github.com/bioconda/bioconda-recipes/tree/master/recipes/intarna 9 | 10 | -------------------------------------------------------------------------------- /doc/figures/freepik-Icons-collection.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/doc/figures/freepik-Icons-collection.zip -------------------------------------------------------------------------------- /doc/figures/freepik-colored-arrows.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/doc/figures/freepik-colored-arrows.zip -------------------------------------------------------------------------------- /doc/figures/icon-no.39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/doc/figures/icon-no.39.png -------------------------------------------------------------------------------- /doc/figures/icon-up.28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/doc/figures/icon-up.28.png -------------------------------------------------------------------------------- /doc/figures/icon-up.38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/doc/figures/icon-up.38.png -------------------------------------------------------------------------------- /doc/figures/icon-up.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 31 | 33 | 37 | 41 | 42 | 43 | 65 | 67 | 68 | 70 | image/svg+xml 71 | 73 | 74 | 75 | 76 | 77 | 82 | 87 | 93 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /doc/figures/icon-yes.39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/doc/figures/icon-yes.39.png -------------------------------------------------------------------------------- /doc/figures/pair-minE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/doc/figures/pair-minE.png -------------------------------------------------------------------------------- /doc/figures/pf_scale.problem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/doc/figures/pf_scale.problem.png -------------------------------------------------------------------------------- /doc/figures/profile-minE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/doc/figures/profile-minE.png -------------------------------------------------------------------------------- /doc/galaxy-tool-shed.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/doc/galaxy-tool-shed.txt -------------------------------------------------------------------------------- /doc/handson/ChiX_NC_000913.fasta: -------------------------------------------------------------------------------- 1 | >ChiX_NC_000913 2 | acaccgtcgcttaaagtgacggcataataataaaaaaatgaaattcctctttgacgggccaatagcgatattggccattttttt 3 | 4 | 5 | -------------------------------------------------------------------------------- /doc/handson/GcvB.ST.fasta: -------------------------------------------------------------------------------- 1 | >GcvB|NC_003197 2 | ACUUCCUGAGCCGGAACGAAAAGUUUUAUCGGAAUGCGUGUUCUGAUGGGCUUUUGGCUUACGGUUGUGAUGUUGUGUUGUUGUGUUUGCAAUUGGUCUGCGAUUCAGACCACGGUAGCG 3 | AGACUACCCUUUUUCACUUCCUGUACAUUUACCCUGUCUGUCCAUAGUGAUUAAUGUAGCACCGCCAUAUUGCGGUGCUU 4 | -------------------------------------------------------------------------------- /doc/handson/GcvB.fasta: -------------------------------------------------------------------------------- 1 | >GcvB|NC_000913 2 | ACUUCCUGAGCCGGAACGAAAAGUUUUAUCGGAAUGCGUGUUCUGGUGAACUUUUGGCUUACGGUUGUGAUGUUGUGUUGUUGUGUUUGCAAUUGGUCUGCGAUUCAGACCAUGGUAGCA 3 | AAGCUACCUUUUUUCACUUCCUGUACAUUUACCCUGUCUGUCCAUAGUGAUUAAUGUAGCACCGCCUAAUUGCGGUGCUUU 4 | -------------------------------------------------------------------------------- /doc/handson/OxyS.fasta: -------------------------------------------------------------------------------- 1 | >OxyS|NC_000913|56..164|doi:10.1006/jmbi.2000.3942:Fig7 2 | GAAACGGAGCGGCACCUCUUUUAACCCUUGAAGUCACUGCCCGUUUCGAGAGUUUCUC 3 | AACUCGAAUAACUAAAGCCAACGUGAACUUUUGCGGAUCUCCAGGAUCCG 4 | -------------------------------------------------------------------------------- /doc/handson/fhlA.fasta: -------------------------------------------------------------------------------- 1 | >fhlA|NC000913|-53..+60|doi:10.1006/jmbi.2000.3942:Fig7 2 | AGUUAGUCAAUGACCUUUUGCACCGCUUUGCGGUGCUUUCCUGGAACAACAAAAUGU 3 | CAUAUACACCGAUGAGUGAUCUCGGACAACAAGGGUUGUUCGACAUCACUCGGAC 4 | -------------------------------------------------------------------------------- /doc/handson/ilvE.fasta: -------------------------------------------------------------------------------- 1 | >ilvE|NC_003197|STM3903|-200..+100|genom-subsequence 2 | GGTTTTCAGGTGTGCTCCATGAATATGGAAGCCGCGACCGATGCGCAGAATATAAATATTGAATTGACCGTTGCCAGTCCCCGGTCGGTCGACTTACTGTTTAGTCAGTTAAGTAAACTG 3 | GTAGATGTTGCGCATGTCGCGATCTGCCAGAGCGCTGCCACATCACAACAAATCCGCGCCTGAGCGCAAAAGGAAGAAAAATGACGACGAAAAAAGCTGATTATATTTGGTTCAATGGCG 4 | AGATGGTGCGCTGGGAAGACGCGAAGGTTCACGTAATGTCTCACGCGCTGCACTACGGT 5 | -------------------------------------------------------------------------------- /doc/handson/phoB.fasta: -------------------------------------------------------------------------------- 1 | >phoB|NC_000913|b1130|-200..+100|genom-subsequence 2 | GAGCTATCACGATGGTTGATGAGCTGAAATAAACCTCGTATCAGTGCCGGATGGCGATGCTGTCCGGCCTGCTTATTAAGATTATCCGCTTTTTATTTTTTCACTTTACCTCCCCTCCCC 3 | GCTGGTTTATTTAATGTTTACCCCCATAACCACATAATCGCGTTACACTATTTTAATAATTAAGACAGGGAGAAATAAAAATGCGCGTACTGGTTGTTGAAGACAATGCGTTGTTACGTC 4 | ACCACCTTAAAGTTCAGATTCAGGATGCTGGTCATCAGGTCGATGACGCAGAAGATGCC 5 | -------------------------------------------------------------------------------- /doc/how-to-release-new-version.md: -------------------------------------------------------------------------------- 1 | 2 | # steps when releasing a new version: 3 | 4 | - increase counter in configure.ac 5 | 6 | - create distribution source code tar ball 7 | - extract tar ball and check if compiling and tests working 8 | 9 | - prepare release on github: 10 | - fill changelog 11 | - upload source code tar ball 12 | - (upload win binary) 13 | - (upload linux binary) 14 | - (via cygwin) to get cygwin dlls used for compilation on Windows run 15 | - `for f in `ldd ./IntaRNA | grep "/usr/bin/" | awk '{print $3}'`; do cp $f .; done` 16 | - zip these together with `IntaRNA.exe` (and additional script files etc.) 17 | - (upload API docu pdf and html.zip) 18 | 19 | 20 | - publish release on github 21 | 22 | - update [bioconda recipe](https://github.com/bioconda/bioconda-recipes/tree/master/recipes/intarna) 23 | - should be automatically triggered by bioconda-bot with respective PR and notification 24 | - update [galaxy tool shed information](https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/intarna/intarna.xml) 25 | 26 | - update webserver 27 | 28 | - tweet release 29 | -------------------------------------------------------------------------------- /doc/latex-deps/tc-pgf.def: -------------------------------------------------------------------------------- 1 | %% Copyright (C) 2011-2012 by Martin Scharrer 2 | %% ---------------------------------------------------------------------- 3 | %% This work may be distributed and/or modified under the 4 | %% conditions of the LaTeX Project Public License, either version 1.3 5 | %% of this license or (at your option) any later version. 6 | %% The latest version of this license is in 7 | %% http://www.latex-project.org/lppl.txt 8 | %% and version 1.3 or later is part of all distributions of LaTeX 9 | %% version 2005/12/01 or later. 10 | %% 11 | %% This work has the LPPL maintenance status `maintained'. 12 | %% 13 | %% The Current Maintainer of this work is Martin Scharrer. 14 | %% 15 | %% This work consists of the files trimclip.dtx, adjustbox.ins 16 | %% and the derived files trimclip.sty, 17 | %% tc-dvips.def, tc-pdftex.def, tc-pgf.def and tc-xetex.def. 18 | %% Further author information are located in the .def files. 19 | %% 20 | \ProvidesFile{tc-pgf.def}[2012/05/13 v1.0 trimclip fall-back clipping driver using PGF] 21 | \RequirePackage{pgf} 22 | \def\@cliptoboxdim#1{% 23 | \setbox#1\hbox{\begin{pgfpicture}% 24 | \pgfpathmoveto{\pgfqpoint\z@{-\dp#1}}% 25 | \pgfpathlineto{\pgfqpoint\z@{\ht#1}}% 26 | \pgfpathlineto{\pgfqpoint{\wd#1}{\ht#1}}% 27 | \pgfpathlineto{\pgfqpoint{\wd#1}{-\dp#1}}% 28 | \pgfpathclose 29 | \pgfusepathqclip 30 | \pgfset{inner sep=\z@,outer sep=\z@,minimum size=\z@}% 31 | \pgfnode{rectangle}{base west}{\usebox#1}{}{}% 32 | \pgfsetbaselinepointnow{\pgfpoint\z@\z@}% 33 | \end{pgfpicture}}% 34 | } 35 | \endinput 36 | %% 37 | %% End of file `tc-pgf.def'. 38 | -------------------------------------------------------------------------------- /m4/m4-ax_boost_regex.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_boost_regex.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_BOOST_REGEX 8 | # 9 | # DESCRIPTION 10 | # 11 | # Test for Regex library from the Boost C++ libraries. The macro requires 12 | # a preceding call to AX_BOOST_BASE. Further documentation is available at 13 | # . 14 | # 15 | # This macro calls: 16 | # 17 | # AC_SUBST(BOOST_REGEX_LIB) 18 | # 19 | # And sets: 20 | # 21 | # HAVE_BOOST_REGEX 22 | # 23 | # LICENSE 24 | # 25 | # Copyright (c) 2008 Thomas Porschberg 26 | # Copyright (c) 2008 Michael Tindal 27 | # 28 | # Copying and distribution of this file, with or without modification, are 29 | # permitted in any medium without royalty provided the copyright notice 30 | # and this notice are preserved. This file is offered as-is, without any 31 | # warranty. 32 | 33 | #serial 23 34 | 35 | AC_DEFUN([AX_BOOST_REGEX], 36 | [ 37 | AC_ARG_WITH([boost-regex], 38 | AS_HELP_STRING([--with-boost-regex@<:@=special-lib@:>@], 39 | [use the Regex library from boost - it is possible to specify a certain library for the linker 40 | e.g. --with-boost-regex=boost_regex-gcc-mt-d-1_33_1 ]), 41 | [ 42 | if test "$withval" = "no"; then 43 | want_boost="no" 44 | elif test "$withval" = "yes"; then 45 | want_boost="yes" 46 | ax_boost_user_regex_lib="" 47 | else 48 | want_boost="yes" 49 | ax_boost_user_regex_lib="$withval" 50 | fi 51 | ], 52 | [want_boost="yes"] 53 | ) 54 | 55 | if test "x$want_boost" = "xyes"; then 56 | AC_REQUIRE([AC_PROG_CC]) 57 | CPPFLAGS_SAVED="$CPPFLAGS" 58 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" 59 | export CPPFLAGS 60 | 61 | LDFLAGS_SAVED="$LDFLAGS" 62 | LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" 63 | export LDFLAGS 64 | 65 | AC_CACHE_CHECK(whether the Boost::Regex library is available, 66 | ax_cv_boost_regex, 67 | [AC_LANG_PUSH([C++]) 68 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include 69 | ]], 70 | [[boost::regex r(); return 0;]])], 71 | ax_cv_boost_regex=yes, ax_cv_boost_regex=no) 72 | AC_LANG_POP([C++]) 73 | ]) 74 | if test "x$ax_cv_boost_regex" = "xyes"; then 75 | AC_DEFINE(HAVE_BOOST_REGEX,,[define if the Boost::Regex library is available]) 76 | BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` 77 | if test "x$ax_boost_user_regex_lib" = "x"; then 78 | for libextension in `ls $BOOSTLIBDIR/libboost_regex*.so* $BOOSTLIBDIR/libboost_regex*.dylib* $BOOSTLIBDIR/libboost_regex*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_regex.*\)\.so.*$;\1;' -e 's;^lib\(boost_regex.*\)\.dylib.*;\1;' -e 's;^lib\(boost_regex.*\)\.a.*$;\1;'` ; do 79 | ax_lib=${libextension} 80 | AC_CHECK_LIB($ax_lib, exit, 81 | [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break], 82 | [link_regex="no"]) 83 | done 84 | if test "x$link_regex" != "xyes"; then 85 | for libextension in `ls $BOOSTLIBDIR/boost_regex*.dll* $BOOSTLIBDIR/boost_regex*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_regex.*\)\.dll.*$;\1;' -e 's;^\(boost_regex.*\)\.a.*$;\1;'` ; do 86 | ax_lib=${libextension} 87 | AC_CHECK_LIB($ax_lib, exit, 88 | [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break], 89 | [link_regex="no"]) 90 | done 91 | fi 92 | 93 | else 94 | for ax_lib in $ax_boost_user_regex_lib boost_regex-$ax_boost_user_regex_lib; do 95 | AC_CHECK_LIB($ax_lib, main, 96 | [BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break], 97 | [link_regex="no"]) 98 | done 99 | fi 100 | if test "x$ax_lib" = "x"; then 101 | AC_MSG_ERROR(Could not find a version of the Boost::Regex library!) 102 | fi 103 | if test "x$link_regex" != "xyes"; then 104 | AC_MSG_ERROR(Could not link against $ax_lib !) 105 | fi 106 | fi 107 | 108 | CPPFLAGS="$CPPFLAGS_SAVED" 109 | LDFLAGS="$LDFLAGS_SAVED" 110 | fi 111 | ]) 112 | -------------------------------------------------------------------------------- /m4/m4-ax_boost_system.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_boost_system.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_BOOST_SYSTEM 8 | # 9 | # DESCRIPTION 10 | # 11 | # Test for System library from the Boost C++ libraries. The macro requires 12 | # a preceding call to AX_BOOST_BASE. Further documentation is available at 13 | # . 14 | # 15 | # This macro calls: 16 | # 17 | # AC_SUBST(BOOST_SYSTEM_LIB) 18 | # 19 | # And sets: 20 | # 21 | # HAVE_BOOST_SYSTEM 22 | # 23 | # LICENSE 24 | # 25 | # Copyright (c) 2008 Thomas Porschberg 26 | # Copyright (c) 2008 Michael Tindal 27 | # Copyright (c) 2008 Daniel Casimiro 28 | # 29 | # Copying and distribution of this file, with or without modification, are 30 | # permitted in any medium without royalty provided the copyright notice 31 | # and this notice are preserved. This file is offered as-is, without any 32 | # warranty. 33 | 34 | #serial 19 35 | 36 | AC_DEFUN([AX_BOOST_SYSTEM], 37 | [ 38 | AC_ARG_WITH([boost-system], 39 | AS_HELP_STRING([--with-boost-system@<:@=special-lib@:>@], 40 | [use the System library from boost - it is possible to specify a certain library for the linker 41 | e.g. --with-boost-system=boost_system-gcc-mt ]), 42 | [ 43 | if test "$withval" = "no"; then 44 | want_boost="no" 45 | elif test "$withval" = "yes"; then 46 | want_boost="yes" 47 | ax_boost_user_system_lib="" 48 | else 49 | want_boost="yes" 50 | ax_boost_user_system_lib="$withval" 51 | fi 52 | ], 53 | [want_boost="yes"] 54 | ) 55 | 56 | if test "x$want_boost" = "xyes"; then 57 | AC_REQUIRE([AC_PROG_CC]) 58 | AC_REQUIRE([AC_CANONICAL_BUILD]) 59 | CPPFLAGS_SAVED="$CPPFLAGS" 60 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" 61 | export CPPFLAGS 62 | 63 | LDFLAGS_SAVED="$LDFLAGS" 64 | LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" 65 | export LDFLAGS 66 | 67 | AC_CACHE_CHECK(whether the Boost::System library is available, 68 | ax_cv_boost_system, 69 | [AC_LANG_PUSH([C++]) 70 | CXXFLAGS_SAVE=$CXXFLAGS 71 | CXXFLAGS= 72 | 73 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], 74 | [[boost::system::error_category *a = 0;]])], 75 | ax_cv_boost_system=yes, ax_cv_boost_system=no) 76 | CXXFLAGS=$CXXFLAGS_SAVE 77 | AC_LANG_POP([C++]) 78 | ]) 79 | if test "x$ax_cv_boost_system" = "xyes"; then 80 | AC_SUBST(BOOST_CPPFLAGS) 81 | 82 | AC_DEFINE(HAVE_BOOST_SYSTEM,,[define if the Boost::System library is available]) 83 | BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` 84 | 85 | LDFLAGS_SAVE=$LDFLAGS 86 | if test "x$ax_boost_user_system_lib" = "x"; then 87 | for libextension in `ls -r $BOOSTLIBDIR/libboost_system* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do 88 | ax_lib=${libextension} 89 | AC_CHECK_LIB($ax_lib, exit, 90 | [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break], 91 | [link_system="no"]) 92 | done 93 | if test "x$link_system" != "xyes"; then 94 | for libextension in `ls -r $BOOSTLIBDIR/boost_system* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do 95 | ax_lib=${libextension} 96 | AC_CHECK_LIB($ax_lib, exit, 97 | [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break], 98 | [link_system="no"]) 99 | done 100 | fi 101 | 102 | else 103 | for ax_lib in $ax_boost_user_system_lib boost_system-$ax_boost_user_system_lib; do 104 | AC_CHECK_LIB($ax_lib, exit, 105 | [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break], 106 | [link_system="no"]) 107 | done 108 | 109 | fi 110 | if test "x$ax_lib" = "x"; then 111 | AC_MSG_ERROR(Could not find a version of the library!) 112 | fi 113 | if test "x$link_system" = "xno"; then 114 | AC_MSG_ERROR(Could not link against $ax_lib !) 115 | fi 116 | fi 117 | 118 | CPPFLAGS="$CPPFLAGS_SAVED" 119 | LDFLAGS="$LDFLAGS_SAVED" 120 | fi 121 | ]) 122 | -------------------------------------------------------------------------------- /perl/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | ################################################# 3 | # IntaRNA Perl interface files 4 | ################################################# 5 | 6 | dist_bin_SCRIPTS = 7 | 8 | 9 | -------------------------------------------------------------------------------- /python/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | # sub directories to check for Makefiles 3 | SUBDIRS = copomus intarnapvalue bin 4 | 5 | 6 | # scripts to be installed in $(bindir) directly 7 | 8 | dist_bin_SCRIPTS = \ 9 | CopomuS.py 10 | 11 | # auxiliary scripts to be part of distribution 12 | noinst_PYTHON = setup.py 13 | 14 | # install python modules 15 | if HAVE_PYTHON 16 | 17 | if INSTALL_INTARNAPVALUE 18 | 19 | # ensure pip is installed 20 | # create python directory if non-existing with current prefix 21 | install-exec-hook: 22 | @ $(PYTHON) -m ensurepip --default-pip 23 | @ $(MKDIR_P) -p ${pythondir} 24 | @ export PYTHONPATH=$PYTHONPATH:${pythondir}; \ 25 | $(PYTHON) setup.py install --prefix=${prefix} 26 | 27 | endif 28 | 29 | endif 30 | -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | 2 | # auxiliary tools 3 | 4 | ## [IntaRNApvalue](intarnapvalue) 5 | 6 | A tool for calculating p-values of IntaRNA energy scores. 7 | 8 | ## [CopomuS](copomus) 9 | 10 | The Compensatory Point Mutation Selector helps to identify the most promising 11 | base pairs from an IntaRNA mfe prediction to verify the interaction via 12 | compensatory mutation experiments. 13 | 14 | 15 | -------------------------------------------------------------------------------- /python/bin/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_PYTHON = build.py 3 | -------------------------------------------------------------------------------- /python/bin/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2019 4 | # Author: Fabio Gutmann 5 | 6 | import os 7 | import sys 8 | import subprocess 9 | from shutil import rmtree, move 10 | 11 | 12 | if __name__ == '__main__': 13 | build_dir = os.path.abspath(os.path.join(__file__, os.pardir)) 14 | main = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, 'intarnapvalue', '__main__.py')) 15 | 16 | subprocess.call( f'{sys.executable} -m PyInstaller -y -F "{main}"', shell=True ) 17 | 18 | os.remove(os.path.join(build_dir, '__main__.spec')) 19 | rmtree(os.path.join(build_dir, 'build')) 20 | os.mkdir(os.path.join(build_dir, 'build')) 21 | if os.name == 'posix': 22 | move(os.path.join(build_dir, 'dist', '__main__'), os.path.join(build_dir, 'build', 'IntaRNApvalue')) 23 | else: 24 | move(os.path.join(build_dir, 'dist', '__main__.exe'), os.path.join(build_dir, 'build', 'IntaRNApvalue.exe')) 25 | rmtree(os.path.join(build_dir, 'dist')) 26 | -------------------------------------------------------------------------------- /python/copomus/CopomuS-logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/python/copomus/CopomuS-logo.jpg -------------------------------------------------------------------------------- /python/copomus/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | dist_copomus_DATA = \ 3 | __init__.py \ 4 | candidate_filters.py \ 5 | candidate_selectors.py \ 6 | indexing.py \ 7 | IntaRNA.py \ 8 | measures.py \ 9 | mutation.py \ 10 | mutation_generators.py 11 | 12 | copomusdir = $(bindir)/copomus 13 | 14 | -------------------------------------------------------------------------------- /python/copomus/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['mutation', 'indexing', 'IntaRNA', 'measures'] 2 | -------------------------------------------------------------------------------- /python/copomus/indexing.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 2 | # Author: Fabio Gutmann 3 | 4 | 5 | def idx_to_array_index(idx: int, idxpos0: int): 6 | """ 7 | Converts a nucleotide index to an 0-included array index 8 | :param idx: The index to convert 9 | :param idxpos0: The start index 10 | :return: The index of the element in the array 11 | >>> idx_to_array_index(10, 5) 12 | 5 13 | >>> idx_to_array_index(10, -200) 14 | 209 15 | >>> idx_to_array_index(1, -1) 16 | 1 17 | """ 18 | return idx - idxpos0 - (1 if (idxpos0 < 0 < idx or idx < 0 < idxpos0) else 0) 19 | 20 | 21 | def array_index_to_idx(i: int, idxpos0: int): 22 | """ 23 | Converts a nucleotide index to an 0-included array index 24 | :param i: The array index 25 | :param idxpos0: The start index 26 | :return: The index of the element in the array 27 | >>> array_index_to_idx(5, 5) 28 | 10 29 | >>> array_index_to_idx(209, -200) 30 | 10 31 | >>> array_index_to_idx(1, -1) 32 | 1 33 | """ 34 | return idxpos0 + i + (1 if (idxpos0 < 0 < i or i < 0 < idxpos0) else 0) 35 | 36 | 37 | def add_sub_idx(i1: int, change: int): 38 | """ 39 | Adds or subtracts an index from another one and skips 0 if encountered. 40 | :param i1: The start index 41 | :param change: The change (+ or -) 42 | :return: The new index 43 | >>> add_sub_idx(-10, 10) 44 | 1 45 | >>> add_sub_idx(10, -10) 46 | -1 47 | >>> add_sub_idx(-5, 10) 48 | 6 49 | """ 50 | return i1 + change + (1 if i1 < 0 < i1+change+1 else -1 if i1+change-1 < 0 < i1 else 0) 51 | -------------------------------------------------------------------------------- /python/copomus/mutation.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 2 | # Author: Fabio Gutmann 3 | 4 | from dataclasses import dataclass, field 5 | from typing import List 6 | from copomus.indexing import idx_to_array_index 7 | 8 | 9 | @dataclass() 10 | class Mutation: 11 | measures: List[any] 12 | qw: str # wildtype sequences 13 | tw: str 14 | qidxpos0: int # indexing start of query 15 | tidxpos0: int 16 | query_n: int # index of mutation on query 17 | target_n: int 18 | bp_mm: str # mm base pair 19 | bp_ww: str = '' # ww base pair 20 | qm: str = '' # mutated sequences 21 | tm: str = '' 22 | ranks: dict = field(default_factory=dict) 23 | 24 | def __post_init__(self): 25 | mut_pos_q = idx_to_array_index(self.query_n, self.qidxpos0) 26 | mut_pos_t = idx_to_array_index(self.target_n, self.tidxpos0) 27 | self.bp_ww = f'{self.qw[mut_pos_q]}{self.tw[mut_pos_t]}' 28 | self.qm = self.qw[0:mut_pos_q] + self.bp_mm[0] + self.qw[mut_pos_q+1:] 29 | self.tm = self.tw[0:mut_pos_t] + self.bp_mm[1] + self.tw[mut_pos_t+1:] 30 | 31 | def __lt__(self, other): 32 | return self.measures < other.measures 33 | 34 | def __str__(self): 35 | return f'{self.bp_ww[0]}{self.query_n}{self.bp_mm[0]}&{self.bp_ww[1]}{self.target_n}{self.bp_mm[1]}' 36 | -------------------------------------------------------------------------------- /python/copomus/mutation_generators.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 2 | # Author: Fabio Gutmann 3 | 4 | from copy import deepcopy 5 | from copomus.indexing import idx_to_array_index 6 | from copomus.measures import get_measure 7 | from copomus.mutation import Mutation 8 | from typing import List, Tuple 9 | 10 | 11 | def gen_flip(query: str, target: str, qidxpos0: int, tidxpos0: int, bp_list: List[Tuple[int, int]], mms: List[str], 12 | alpha: float, beta: float) -> List[Mutation]: 13 | mutations = [] 14 | 15 | for q_index, t_index in bp_list: 16 | mm = [] 17 | for m in mms: 18 | mm.append(get_measure(m, alpha, beta)) 19 | 20 | q_index_a = idx_to_array_index(q_index, qidxpos0) 21 | t_index_a = idx_to_array_index(t_index, tidxpos0) 22 | 23 | bp_mm = f'{target[t_index_a]}{query[q_index_a]}' 24 | 25 | m = Mutation(deepcopy(mm), query, target, qidxpos0, tidxpos0, q_index, t_index, bp_mm) 26 | mutations.append(m) 27 | return mutations 28 | 29 | 30 | def gen_any(query: str, target: str, qidxpos0: int, tidxpos0: int, bp_list: List[Tuple[int, int]], mms: List[str], 31 | alpha: float, beta: float) -> List[Mutation]: 32 | mutations = [] 33 | 34 | possible_mutations = { 35 | 'AU': ['UA', 'UG', 'CG'], 36 | 'UA': ['AU', 'GU', 'GC'], 37 | 'GC': ['UA', 'UG', 'CG'], 38 | 'CG': ['AU', 'GU', 'GC'], 39 | 'GU': ['UA', 'UG', 'CG'], 40 | 'UG': ['AU', 'GU', 'GC'] 41 | } 42 | 43 | for q_index, t_index in bp_list: 44 | mm = [] 45 | for m in mms: 46 | mm.append(get_measure(m, alpha, beta)) 47 | 48 | q_index_a = idx_to_array_index(q_index, qidxpos0) 49 | t_index_a = idx_to_array_index(t_index, tidxpos0) 50 | 51 | pos = possible_mutations[f'{query[q_index_a]}{target[t_index_a]}'] 52 | 53 | for p in pos: 54 | bp_mm = f'{p[0]}{p[1]}' 55 | 56 | m = Mutation(deepcopy(mm), query, target, qidxpos0, tidxpos0, q_index, t_index, bp_mm) 57 | mutations.append(m) 58 | return mutations 59 | 60 | 61 | def gen_specific(query: str, target: str, qidxpos0: int, tidxpos0: int, mms: List[str], alpha: float, beta: float, 62 | encoding: str) -> List[Mutation]: 63 | mutations = [] 64 | 65 | mm = [] 66 | for m in mms: 67 | mm.append(get_measure(m, alpha, beta)) 68 | 69 | for mut in encoding.split(','): # split block mutations into single mutations 70 | q, t = mut.split('&') 71 | q_index = int(q[1:len(q)-1]) # mutation indices 72 | t_index = int(t[1:len(t)-1]) 73 | 74 | bp_mm = f'{q[len(q)-1]}{t[len(t)-1]}' 75 | 76 | m = Mutation(deepcopy(mm), query, target, qidxpos0, tidxpos0, q_index, t_index, bp_mm) 77 | mutations.append(m) 78 | return mutations 79 | 80 | 81 | def get_generator(string: str) -> any: 82 | """ 83 | Gets a mutation generator by its string name 84 | :param string: The string name 85 | :return: A reference to a generator function 86 | """ 87 | generators = { 88 | 'flip': gen_flip, 89 | 'any': gen_any, 90 | 'specific': gen_specific 91 | } 92 | return generators.get(string) 93 | -------------------------------------------------------------------------------- /python/intarnapvalue/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_PYTHON = \ 3 | __init__.py \ 4 | __main__.py \ 5 | dinucl_shuffle.py \ 6 | intarna_pvalue.py \ 7 | test.py 8 | -------------------------------------------------------------------------------- /python/intarnapvalue/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BackofenLab/IntaRNA/1c1f3068ad122bff4f509a7db0e1507d3a215714/python/intarnapvalue/__init__.py -------------------------------------------------------------------------------- /python/intarnapvalue/__main__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2019 4 | # Author: Fabio Gutmann 5 | 6 | from intarnapvalue import intarna_pvalue 7 | 8 | i = intarna_pvalue.IntaRNApvalue() 9 | -------------------------------------------------------------------------------- /python/intarnapvalue/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2019 4 | # Author: Fabio Gutmann 5 | 6 | from intarnapvalue import intarna_pvalue 7 | 8 | if __name__ == '__main__': 9 | import doctest 10 | doctest.testmod(intarna_pvalue) 11 | 12 | -------------------------------------------------------------------------------- /python/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | 4 | from setuptools import setup 5 | 6 | setup( 7 | name='intarnapvalue', 8 | version='0.1', 9 | description='Calculates p-values of IntaRNA energy scores', 10 | author='Fabio Gutmann', 11 | python_requires='>=3.6.0', 12 | url='https://github.com/BackofenLab/IntaRNA/', 13 | packages=['intarnapvalue'], 14 | # install_requires=['scipy', 'numpy'], 15 | include_package_data=True, 16 | classifiers=[ 17 | 'Programming Language :: Python', 18 | 'Programming Language :: Python :: 3', 19 | 'Programming Language :: Python :: 3.6', 20 | 'Programming Language :: Python :: 3.7', 21 | 'Programming Language :: Python :: Implementation :: CPython', 22 | 'Programming Language :: Python :: Implementation :: PyPy' 23 | ] 24 | ) 25 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | # autotools' temporary files 2 | .deps 3 | config.h 4 | config.h.in 5 | Makefile 6 | Makefile.in 7 | stamp-* 8 | 9 | # generated header 10 | intarna_config.h 11 | -------------------------------------------------------------------------------- /src/IntaRNA/AccessibilityBasePair.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IntaRNA/general.h" 3 | #include "IntaRNA/AccessibilityBasePair.h" 4 | 5 | 6 | 7 | namespace IntaRNA { 8 | 9 | ///////////////////////////////////////////////////////////////////////////// 10 | 11 | AccessibilityBasePair::AccessibilityBasePair(const RnaSequence& seq, 12 | const size_t maxLength, const AccessibilityConstraint * const accConstr_, 13 | const E_type bpEnergy, const Z_type _RT, const size_t minLoopLen) : 14 | Accessibility(seq, maxLength, accConstr_), 15 | logPu(seq.size(), seq.size()), 16 | basePairEnergy(bpEnergy), 17 | RT(_RT), 18 | basePairWeight( _RT == 0.0 ? 0.0 : Z_exp(E_2_Z(-bpEnergy) / _RT) ), 19 | minLoopLength(minLoopLen) 20 | { 21 | #if INTARNA_MULITHREADING 22 | #pragma omp critical(intarna_omp_logOutput) 23 | #endif 24 | { VLOG(2) <<"computing accessibility via Nussinov-like recursions..."; } 25 | 26 | // time logging 27 | TIMED_FUNC_IF(timerObj, VLOG_IS_ON(9)); 28 | 29 | if (accConstr_ != NULL && !accConstr_->isEmpty()) { 30 | INTARNA_NOT_IMPLEMENTED("AccessibilityBasePair: accessibility constraints not supported"); 31 | } 32 | if (RT == 0.0) { 33 | throw std::runtime_error("AccessibilityBasePair: RT == 0.0"); 34 | } 35 | const size_t N = seq.size(); 36 | // create temporary matrices for ED computation 37 | NussinovHandler::Z2dMatrix Q(N, N); 38 | NussinovHandler::Z2dMatrix Qb(N, N); 39 | NussinovHandler::Z2dMatrix Pbp(N, N); 40 | NussinovHandler::Z2dMatrix Pu(N, N); 41 | 42 | logPu.resize(N, N); 43 | 44 | // init temporary matrices 45 | for (size_t i = 0u; i < N; ++i) { 46 | for (size_t j = i; j < N; ++j) { 47 | Q(i, j) = -1.0; 48 | Qb(i, j) = -1.0; 49 | Pbp(i, j) = -1.0; 50 | Pu(i, j) = -1.0; 51 | } 52 | } 53 | // compute ED values 54 | for (size_t i = 0u; i < N; ++i) { 55 | for (size_t j = i; j < N; ++j) { 56 | logPu(i, j) = Z_2_E( -RT * Z_log(Z_type(NussinovHandler::getPu(i, j, seq, basePairWeight, minLoopLength, Q, Qb, Pbp, Pu))) ); 57 | } 58 | } 59 | } 60 | 61 | ///////////////////////////////////////////////////////////////////////////// 62 | 63 | 64 | AccessibilityBasePair::~AccessibilityBasePair() 65 | {} 66 | 67 | ///////////////////////////////////////////////////////////////////////////// 68 | 69 | 70 | E_type 71 | AccessibilityBasePair::getED( const size_t from, const size_t to ) const 72 | { 73 | if (from > to || to < 0 || from >= seq.size()) { 74 | throw std::runtime_error( "AccessibilityBasePair::getED("+toString(from)+","+toString(to) 75 | +") : Arguments must satisfy 0 <= from <= to < seq.length" ); 76 | } 77 | return logPu(from, to); 78 | }; 79 | 80 | } // namespace IntaRNA 81 | -------------------------------------------------------------------------------- /src/IntaRNA/AccessibilityBasePair.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_ACCESSIBILITYBASEPAIR_H_ 3 | #define INTARNA_ACCESSIBILITYBASEPAIR_H_ 4 | 5 | #include "IntaRNA/general.h" 6 | #include "IntaRNA/RnaSequence.h" 7 | #include "IntaRNA/Accessibility.h" 8 | #include "IntaRNA/AccessibilityConstraint.h" 9 | #include "IntaRNA/NussinovHandler.h" 10 | 11 | 12 | namespace IntaRNA { 13 | 14 | /** 15 | * Provides accessibility penalties for a Nussinov-like energy scoring where 16 | * each base pair is scored by #basePairEnergy independently from its structural 17 | * context. 18 | * 19 | * This implementation is mainly for teaching and testing purpose. 20 | * 21 | * @author Mostafa Mahmoud 22 | * @author Martin Mann 23 | * 24 | */ 25 | class AccessibilityBasePair: public Accessibility { 26 | 27 | public: 28 | /*** 29 | * Constructor of AccessibilityBasePair 30 | * @param seq The sequence the accessibility data belongs to 31 | * @param maxLength the maximal length of accessible regions (>0) to be 32 | * considered. 0 defaults to the full sequence's length, otherwise 33 | * is is internally set to min(maxLength,seq.length). 34 | * @param accConstr optional accessibility constraint 35 | * @param basePairEnergy The energy value of the base pairs 36 | * @param RT The temperature energy constant 37 | * @param minLoopLength the minimum loop length 38 | */ 39 | AccessibilityBasePair( 40 | const RnaSequence& seq, 41 | const size_t maxLength, 42 | const AccessibilityConstraint * const accConstr, 43 | const E_type basePairEnergy = Ekcal_2_E(-1.0), 44 | const Z_type RT = 1, 45 | const size_t minLoopLength = 3); 46 | 47 | /*** 48 | * Destructor of AccessibilityBasePair 49 | */ 50 | virtual ~AccessibilityBasePair(); 51 | 52 | /*** 53 | * Returns the accessibility energy value between the indices (from, to) 54 | * in the given sequence. 55 | * @param from The start index of the region 56 | * @param to The end index of the region 57 | * 58 | * @return The ED Value 59 | * 60 | * @throw std::runtime_error in case it does not hold 0 <= from <= to < seq.length 61 | */ 62 | virtual E_type getED( const size_t from, const size_t to ) const; 63 | 64 | protected: 65 | 66 | //! energy of an individual base pair 67 | const E_type basePairEnergy; 68 | //! temperature constant for normalization 69 | const Z_type RT; 70 | //! Boltzmann Energy weight 71 | const Z_type basePairWeight; 72 | //! minimum length of loops 73 | const size_t minLoopLength; 74 | 75 | /*** 76 | * Results of getED lookup table 77 | */ 78 | NussinovHandler::E2dMatrix logPu; 79 | 80 | }; 81 | 82 | } // namespace IntaRNA 83 | 84 | #endif /* INTARNA_ACCESSIBILITYBASEPAIR_H_ */ 85 | -------------------------------------------------------------------------------- /src/IntaRNA/AccessibilityDisabled.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AccessibilityDisabled.h 3 | * 4 | * Created on: 25.06.2014 5 | * Author: Mmann 6 | */ 7 | 8 | #ifndef INTARNA_ACCESSIBILITYDISABLED_H_ 9 | #define INTARNA_ACCESSIBILITYDISABLED_H_ 10 | 11 | #include "IntaRNA/Accessibility.h" 12 | 13 | 14 | namespace IntaRNA { 15 | 16 | /** 17 | * Implements the Accessibility interface but disables ED value computation, 18 | * i.e. all ED values are set to zero. 19 | * 20 | * @author Martin Mann 2014 21 | */ 22 | class AccessibilityDisabled: public Accessibility { 23 | 24 | public: 25 | 26 | /** 27 | * Construction 28 | * @param sequence the sequence the accessibility data belongs to 29 | * @param maxLength the maximal length of accessible regions to be 30 | * considered. 0 defaults to the sequence's length. 31 | * @param accConstr optional accessibility constraint 32 | */ 33 | AccessibilityDisabled( const RnaSequence& sequence 34 | , const size_t maxLength 35 | , const AccessibilityConstraint * const accConstr 36 | ); 37 | 38 | /** 39 | * destruction 40 | */ 41 | virtual ~AccessibilityDisabled(); 42 | 43 | /** 44 | * Always returns a zero accessibility energy value. 45 | * 46 | * @param from the start index of the regions (from <= to) 47 | * @param to the end index of the regions (to <= seq.length()) 48 | * 49 | * @return 0 if (j-1+1) <= maxLength or ED_UPPER_BOUND otherwise 50 | */ 51 | virtual 52 | E_type 53 | getED( const size_t from, const size_t to ) const; 54 | 55 | }; 56 | 57 | 58 | 59 | /////////////////////////////////////////////////////////////////////////////// 60 | 61 | inline 62 | AccessibilityDisabled::AccessibilityDisabled(const RnaSequence& seq 63 | , const size_t maxLength 64 | , const AccessibilityConstraint * const accConstr) 65 | : 66 | Accessibility(seq, maxLength, accConstr) 67 | { 68 | #if INTARNA_MULITHREADING 69 | #pragma omp critical(intarna_omp_logOutput) 70 | #endif 71 | { VLOG(2) <<"no accessibility requested..."; } 72 | } 73 | 74 | /////////////////////////////////////////////////////////////////////////////// 75 | 76 | inline 77 | AccessibilityDisabled::~AccessibilityDisabled() 78 | { 79 | } 80 | 81 | /////////////////////////////////////////////////////////////////////////////// 82 | 83 | inline 84 | E_type 85 | AccessibilityDisabled:: 86 | getED( const size_t from, const size_t to ) const 87 | { 88 | // input check 89 | checkIndices(from,to); 90 | 91 | if ((to-from+1) <= getMaxLength()) { 92 | // check for constrained end positions 93 | if (!getAccConstraint().isAccessible(from) || !getAccConstraint().isAccessible(to)) { 94 | // end position blocked --> omit accessibility 95 | return ED_UPPER_BOUND; 96 | } 97 | // else: no accessibility computation done --> always zero 98 | return (E_type)0; 99 | } else { 100 | // region length exceeds maximally allowed length -> no value 101 | return ED_UPPER_BOUND; 102 | } 103 | } 104 | 105 | /////////////////////////////////////////////////////////////////////////////// 106 | 107 | } // namespace 108 | 109 | #endif /* ACCESSIBILITYDISABLED_H_ */ 110 | -------------------------------------------------------------------------------- /src/IntaRNA/HelixHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "IntaRNA/HelixHandler.h" 2 | #include "IntaRNA/HelixHandlerNoBulgeMax.h" 3 | #include "IntaRNA/HelixHandlerUnpaired.h" 4 | 5 | namespace IntaRNA { 6 | 7 | HelixHandler* HelixHandler::getHelixHandler(const InteractionEnergy &energy, 8 | const HelixConstraint &helixConstraint, 9 | SeedHandler * const seedHandler) { 10 | 11 | if (helixConstraint.getMaxIL() == 0) { 12 | return new HelixHandlerNoBulgeMax(energy, helixConstraint, seedHandler); 13 | } else { 14 | return new HelixHandlerUnpaired(energy, helixConstraint, seedHandler); 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/IntaRNA/IndexRange.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "IntaRNA/IndexRange.h" 5 | 6 | namespace IntaRNA { 7 | 8 | //////////////////////////////////////////////////////////////// 9 | 10 | const size_t IndexRange::NA_INDEX = std::numeric_limits::max(); 11 | 12 | //////////////////////////////////////////////////////////////// 13 | 14 | const size_t IndexRange::LAST_INDEX = IndexRange::NA_INDEX-1; 15 | 16 | //////////////////////////////////////////////////////////////// 17 | 18 | const boost::regex IndexRange::regex("^"+std::string(IndexRange::regexString)+"$"); 19 | 20 | //////////////////////////////////////////////////////////////// 21 | 22 | std::vector 23 | IndexRange:: 24 | overlappingWindows(const size_t windowWidth, const size_t windowOverlap) const 25 | { 26 | #if INTARNA_IN_DEBUG_MODE 27 | // minimal width check 28 | if (windowWidth <= 2) { 29 | throw std::runtime_error("IndexRange::overlappingWindows("+toString(windowWidth)+","+toString(windowOverlap)+") : " 30 | +"window width must be at least 2"); 31 | } 32 | // ensure width exceeds overlap 33 | if (windowWidth <= windowOverlap) { 34 | throw std::runtime_error("IndexRange::overlappingWindows("+toString(windowWidth)+","+toString(windowOverlap)+") : " 35 | +"window width must be larger than the overlap"); 36 | } 37 | // ensure ascending range 38 | if (!isAscending()) { 39 | throw std::runtime_error("IndexRange::overlappingWindows() : only implemented for ascending ranges but called on "+toString(*this)); 40 | } 41 | #endif 42 | 43 | // check if range is smaller than window width 44 | if ((to - from + 1) <= windowWidth) 45 | { 46 | // return input index range 47 | return std::vector(1,IndexRange(from,to)); 48 | } 49 | 50 | // size_t numberOfWindows = ceil(double(to - from - windowOverlap + 1) / (windowWidth - windowOverlap)); 51 | size_t x = to - from + 1 - windowOverlap; 52 | size_t y = windowWidth - windowOverlap; 53 | 54 | #if INTARNA_IN_DEBUG_MODE 55 | // avoid overflows 56 | if (((std::numeric_limits::max)() - x) < y) 57 | { 58 | throw std::runtime_error("IndexRange::overlappingWindows("+toString(windowWidth)+","+toString(windowOverlap)+") : " 59 | + "an overflow occurred when calculating the number of windows for range "+toString(*this)); 60 | } 61 | #endif 62 | 63 | // allocate window container 64 | size_t numberOfWindows = (x + y - 1) / y; 65 | std::vector windows = std::vector(numberOfWindows); 66 | 67 | // compute windows and store 68 | int i = -1; 69 | size_t currentIndex = from; 70 | while (currentIndex + windowOverlap - 1 < to) 71 | { 72 | i++; 73 | windows[i] = IndexRange(currentIndex, currentIndex + windowWidth - 1); 74 | currentIndex = windows[i].to - windowOverlap + 1; 75 | } 76 | 77 | // handle last window (cut at upper boundary of this range) 78 | if (windows[i].to > to) 79 | { 80 | windows[i].to = to; 81 | } 82 | 83 | return windows; 84 | } 85 | 86 | //////////////////////////////////////////////////////////////// 87 | 88 | } // namespace 89 | -------------------------------------------------------------------------------- /src/IntaRNA/InteractionEnergy.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IntaRNA/InteractionEnergy.h" 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace IntaRNA { 9 | 10 | //////////////////////////////////////////////////////////////////////////// 11 | 12 | InteractionEnergy:: 13 | EnergyContributions 14 | InteractionEnergy:: 15 | getE_contributions( const Interaction & interaction ) const 16 | { 17 | 18 | // temporary access to range indices 19 | const size_t i1 = getIndex1(*interaction.basePairs.begin()); 20 | const size_t i2 = getIndex2(*interaction.basePairs.begin()); 21 | const size_t j1 = getIndex1(*interaction.basePairs.rbegin()); 22 | const size_t j2 = getIndex2(*interaction.basePairs.rbegin()); 23 | 24 | // fill contribution data structure 25 | EnergyContributions contr; 26 | contr.init = getE_init(); 27 | contr.ED1 = getED1( i1, j1 ); 28 | contr.ED2 = getED2( i2, j2 ); 29 | contr.dangleLeft = energyWithDangles ? Z_2_E((E_2_Z(getE_danglingLeft( i1, i2 ))*getPr_danglingLeft(i1,j1,i2,j2))) : E_type(0); 30 | contr.dangleRight = energyWithDangles ? Z_2_E((E_2_Z(getE_danglingRight( j1, j2 ))*getPr_danglingRight(i1,j1,i2,j2))) : E_type(0); 31 | contr.endLeft = getE_endLeft( i1, i2 ); 32 | contr.endRight = getE_endRight( j1, j2 ); 33 | contr.energyAdd = getEnergyAdd(); 34 | // compute loop energy 35 | contr.loops = interaction.energy 36 | - contr.init 37 | - contr.ED1 38 | - contr.ED2 39 | - contr.dangleLeft 40 | - contr.dangleRight 41 | - contr.endLeft 42 | - contr.endRight 43 | - contr.energyAdd 44 | ; 45 | 46 | // final contribution distribution 47 | return contr; 48 | } 49 | 50 | //////////////////////////////////////////////////////////////////////////// 51 | 52 | 53 | } // namespace 54 | -------------------------------------------------------------------------------- /src/IntaRNA/InteractionEnergyBasePair.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IntaRNA/InteractionEnergyBasePair.h" 3 | 4 | namespace IntaRNA { 5 | 6 | //////////////////////////////////////////////////////////////////////////// 7 | 8 | void InteractionEnergyBasePair::computeES(const RnaSequence &seq, 9 | NussinovHandler::E2dMatrix &logQ) { 10 | const size_t N = seq.size(); 11 | 12 | NussinovHandler::Z2dMatrix Q(N, N); 13 | NussinovHandler::Z2dMatrix Qb(N, N); 14 | 15 | logQ.resize(N, N); 16 | for (size_t i = 0u; i < N; ++i) { 17 | for (size_t j = i; j < N; ++j) { 18 | Q(i, j) = -1.0; 19 | Qb(i, j) = -1.0; 20 | } 21 | } 22 | 23 | for (size_t i = 0u; i < N; ++i) { 24 | for (size_t j = i; j < N; ++j) { 25 | const Z_type q_val = NussinovHandler::getQ(i, j, seq, basePairWeight, minLoopLength, Q, Qb); 26 | if (Z_equal(q_val, 1.0)) { 27 | logQ(i, j) = E_INF; 28 | } else { 29 | logQ(i, j) = getE(q_val); 30 | } 31 | } 32 | } 33 | } 34 | 35 | //////////////////////////////////////////////////////////////////////////// 36 | 37 | E_type 38 | InteractionEnergyBasePair:: 39 | getEall1() const 40 | { 41 | // compute Z if needed 42 | if (E_isINF(Eall1)) { 43 | Eall1 = computeIntraEall( accS1 ); 44 | } 45 | return Eall1; 46 | } 47 | 48 | //////////////////////////////////////////////////////////////////////////// 49 | 50 | E_type 51 | InteractionEnergyBasePair:: 52 | getEall2() const 53 | { 54 | // compute Z if needed 55 | if (E_isINF(Eall2)) { 56 | Eall2 = computeIntraEall( accS2.getAccessibilityOrigin() ); 57 | } 58 | return Eall2; 59 | } 60 | 61 | //////////////////////////////////////////////////////////////////////////// 62 | 63 | E_type 64 | InteractionEnergyBasePair:: 65 | computeIntraEall( const Accessibility & acc ) const 66 | { 67 | if ( !acc.getAccConstraint().isEmpty() ) { 68 | INTARNA_NOT_IMPLEMENTED("InteractionEnergyBasePair: accessibility constraints for ensemble energy computation not supported"); 69 | } 70 | 71 | const size_t N = acc.getSequence().size(); 72 | 73 | // check if any base pair can be formed 74 | if (N < minLoopLength) { 75 | return 0; 76 | } 77 | 78 | // create temporary matrices for ED computation 79 | NussinovHandler::Z2dMatrix Q(N, N); 80 | NussinovHandler::Z2dMatrix Qb(N, N); 81 | 82 | // init temporary matrices 83 | for (size_t i = 0u; i < N; ++i) { 84 | for (size_t j = i; j < N; ++j) { 85 | Q(i, j) = -1.0; 86 | Qb(i, j) = -1.0; 87 | } 88 | } 89 | 90 | // compute partition function and convert to ensemble energy 91 | return getE( NussinovHandler::getQ( 0, N-1, acc.getSequence(), basePairWeight, minLoopLength, Q, Qb) ); 92 | 93 | } 94 | 95 | //////////////////////////////////////////////////////////////////////////// 96 | 97 | } // namespace IntaRNA 98 | -------------------------------------------------------------------------------- /src/IntaRNA/InteractionEnergyIdxOffset.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IntaRNA/InteractionEnergyIdxOffset.h" 3 | 4 | namespace IntaRNA { 5 | 6 | 7 | } // namespace 8 | -------------------------------------------------------------------------------- /src/IntaRNA/InteractionRange.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IntaRNA/Interaction.h" 3 | #include "IntaRNA/InteractionRange.h" 4 | 5 | namespace IntaRNA { 6 | 7 | InteractionRange & 8 | InteractionRange:: 9 | operator= ( const Interaction & interaction ) 10 | { 11 | #if INTARNA_IN_DEBUG_MODE 12 | if (interaction.isEmpty()) 13 | throw std::runtime_error("InteractionRange::=(interaction) is empty!"); 14 | if (!interaction.isValid()) 15 | throw std::runtime_error("InteractionRange::=(interaction) not valid!"); 16 | #endif 17 | // init data 18 | s1 = interaction.s1; 19 | s2 = interaction.s2; 20 | r1.from = interaction.basePairs.begin()->first; 21 | r1.to = interaction.basePairs.rbegin()->first; 22 | r2.from = interaction.basePairs.begin()->second; 23 | r2.to = interaction.basePairs.rbegin()->second; 24 | energy = interaction.energy; 25 | 26 | #if INTARNA_IN_DEBUG_MODE 27 | if (!isSane()) 28 | throw std::runtime_error("InteractionRange::=(interaction)="+toString(*this)+" not sane!"); 29 | #endif 30 | return *this; 31 | } 32 | 33 | 34 | 35 | 36 | } // namespace 37 | -------------------------------------------------------------------------------- /src/IntaRNA/InteractionRange.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_INTERACTIONRANGE_H_ 3 | #define INTARNA_INTERACTIONRANGE_H_ 4 | 5 | #include "IntaRNA/general.h" 6 | #include "IntaRNA/IndexRange.h" 7 | #include "IntaRNA/RnaSequence.h" 8 | 9 | namespace IntaRNA { 10 | 11 | // dummy declaration to avoid inclusion loop 12 | class Interaction; 13 | 14 | /** 15 | * Represents two ranges that form an interaction 16 | */ 17 | class InteractionRange { 18 | public: 19 | 20 | //! the first interaction partner 21 | const RnaSequence * s1; 22 | 23 | //! the second interaction partner 24 | const RnaSequence * s2; 25 | 26 | //! the index range of s1 interacting with r2 27 | IndexRange r1; 28 | 29 | //! the index range of s2 interacting with r1 30 | IndexRange r2; 31 | 32 | //! the energy value associated with this interaction range 33 | E_type energy; 34 | 35 | public: 36 | 37 | /** 38 | * Construction of an interaction range given two index ranges 39 | * @param rna1 the first RNA interacting 40 | * @param rna2 the second RNA interacting 41 | * @param r1 the range of rna1 interacting 42 | * @param r2 the range of rna2 interacting 43 | * @param energy the energy value assigned to the range 44 | */ 45 | InteractionRange( 46 | const RnaSequence & rna1 47 | , const RnaSequence & rna2 48 | , const IndexRange & r1 = IndexRange(0,RnaSequence::lastPos) 49 | , const IndexRange & r2 = IndexRange(RnaSequence::lastPos,0) 50 | , const E_type energy = E_INF ) 51 | : s1(&rna1) 52 | , s2(&rna2) 53 | , r1(r1.from, (r1.to > rna1.size()?rna1.size()-1:r1.to)) 54 | , r2((r2.from > rna2.size()?rna2.size()-1:r2.from), r2.to) 55 | , energy(energy) 56 | { 57 | #if INTARNA_IN_DEBUG_MODE 58 | if (!isSane()) 59 | throw std::runtime_error("InteractionRange("+toString(*this)+") not sane!"); 60 | #endif 61 | } 62 | 63 | /** 64 | * Construction of an interaction range given two index ranges 65 | */ 66 | InteractionRange( const Interaction& interaction ) 67 | : s1(NULL), s2(NULL), r1(), r2(), energy(E_INF) 68 | { 69 | // copy data 70 | this->operator =(interaction); 71 | } 72 | 73 | /** 74 | * Destruction 75 | */ 76 | virtual ~InteractionRange() 77 | {} 78 | 79 | 80 | /** 81 | * Checks whether or not the range encoding is reasonable. 82 | * @return from <= to 83 | */ 84 | bool isSane() const 85 | { 86 | // range of first sequence ascending 87 | // range of second sequence descending 88 | return r1.isAscending() && r2.isDescending(); 89 | } 90 | 91 | /** 92 | * Prints the range's boundaries to stream 93 | * @param out the ostream to write to 94 | * @param r the InteractionRange object to add 95 | * @return the altered stream out 96 | */ 97 | friend std::ostream& operator<<(std::ostream& out, const InteractionRange& r) 98 | { 99 | return (out <<"("<r.r1) && r2= 0.0"); 33 | } 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | 37 | OutputConstraint::~OutputConstraint() 38 | { 39 | } 40 | 41 | ///////////////////////////////////////////////////////////////////////////// 42 | 43 | 44 | } // namespace 45 | -------------------------------------------------------------------------------- /src/IntaRNA/OutputConstraint.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_OUTPUTCONSTRAINT_H_ 3 | #define INTARNA_OUTPUTCONSTRAINT_H_ 4 | 5 | #include "IntaRNA/general.h" 6 | #include "IntaRNA/Accessibility.h" 7 | 8 | namespace IntaRNA { 9 | 10 | /** 11 | * 12 | * Data structure that contains all constraints to be applied to (suboptimal) 13 | * output generation. 14 | * 15 | * @author Martin Mann 16 | * 17 | */ 18 | class OutputConstraint 19 | { 20 | 21 | public: 22 | 23 | //! different possibilities to en-/disable overlapping of interaction sites 24 | //! if suboptimal solutions are enumerated 25 | enum ReportOverlap { 26 | OVERLAP_NONE = 0, 27 | OVERLAP_SEQ1 = 1, 28 | OVERLAP_SEQ2 = 2, 29 | OVERLAP_BOTH = 3 30 | }; 31 | 32 | 33 | public: 34 | 35 | //! the maximal number of (sub)optimal interactions to be reported to the output handler 36 | const size_t reportMax; 37 | 38 | //! defines whether and where overlapping interaction sites are allowed for reporting 39 | const ReportOverlap reportOverlap; 40 | 41 | //! upper bound (exclusive) for the energy of a reported interaction (E(interaction) < maxE) 42 | const E_type maxE; 43 | 44 | //! the maximal energy difference to the mfe of a reported interaction 45 | const E_type deltaE; 46 | 47 | //! whether or not only the best or all putative seeds are to be reported 48 | const bool bestSeedOnly; 49 | 50 | //! whether or not lonely (non-stacked) inter-molecular base pairs are to be considered 51 | const bool noLP; 52 | 53 | //! whether or not inter-molecular UG base pairs are allowed at interaction ends 54 | const bool noGUend; 55 | 56 | //! whether or not Zall has to be computed for output generation 57 | const bool needZall; 58 | 59 | //! whether or not interaction base pairs have to be traced for output generation 60 | const bool needBPs; 61 | 62 | //! maximal ED penalty of each interacting subsequence to be considered for output 63 | const E_type maxED; 64 | 65 | public: 66 | 67 | /** 68 | * Construction of an output constraint 69 | * 70 | * @param reportMax the maximal number of (sub)optimal interactions to be 71 | * reported to the output handler 72 | * @param reportOverlap defines whether and where overlapping interaction 73 | * sites are allowed for reporting 74 | * @param maxE upper bound (exclusive) for the energy of a reported interaction (E(interaction) < maxE) 75 | * @param deltaE maximal energy difference of a reported interaction to mfe 76 | * @param bestSeedOnly whether or not only the best seed is to be reported 77 | * @param noLP whether or not lonely (non-stacked) inter-molecular bps are allowed 78 | * @param noGUend whether or not inter-molecular UG base pairs are allowed at interaction ends 79 | * @param needZall whether or not Zall has to be computed for output generation 80 | * @param needBPs whether or not interaction base pairs have to be traced for output generation 81 | */ 82 | OutputConstraint( const size_t reportMax = 1 83 | , const ReportOverlap reportOverlap = OVERLAP_BOTH 84 | , const E_type maxE = 0.0 85 | , const E_type deltaE = E_INF 86 | , const bool bestSeedOnly = false 87 | , const bool noLP = false 88 | , const bool noGUend = false 89 | , const bool needZall = false 90 | , const bool needBPs = true 91 | , const E_type maxED = Accessibility::ED_UPPER_BOUND); 92 | 93 | //! destruction 94 | virtual ~OutputConstraint(); 95 | }; 96 | 97 | } // namespace 98 | 99 | #endif /* OUTPUTCONSTRAINT_H_ */ 100 | -------------------------------------------------------------------------------- /src/IntaRNA/OutputHandler.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IntaRNA/OutputHandler.h" 3 | 4 | namespace IntaRNA { 5 | 6 | //////////////////////////////////////////////////////////////////////////// 7 | 8 | 9 | //////////////////////////////////////////////////////////////////////////// 10 | 11 | 12 | } // namespace 13 | -------------------------------------------------------------------------------- /src/IntaRNA/OutputHandlerEnsemble.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IntaRNA/OutputHandlerEnsemble.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #if INTARNA_MULITHREADING 10 | #include 11 | #endif 12 | 13 | namespace IntaRNA { 14 | 15 | //////////////////////////////////////////////////////////////////////////// 16 | 17 | OutputHandlerEnsemble:: 18 | OutputHandlerEnsemble( 19 | const OutputConstraint & outConstraint, 20 | std::ostream & out, 21 | const InteractionEnergy & energy 22 | ) 23 | : OutputHandler(outConstraint) 24 | , out(out) 25 | , energy(energy) 26 | { 27 | } 28 | 29 | //////////////////////////////////////////////////////////////////////////// 30 | 31 | OutputHandlerEnsemble:: 32 | ~OutputHandlerEnsemble() 33 | { 34 | 35 | // ensure outputs do not intervene 36 | std::stringstream outTmp; 37 | outTmp 38 | <<"id1 " < 10 | 11 | namespace IntaRNA { 12 | 13 | /** 14 | * Interaction output handler that writes ensemble information to stream 15 | * in a simple linewise, key-value format. 16 | * 17 | * @author Martin Mann 2014 18 | */ 19 | class OutputHandlerEnsemble: public OutputHandler { 20 | public: 21 | 22 | /** 23 | * Construct a ensemble output handler. 24 | * 25 | * @param outConstraint the output constraint applied to find the reported 26 | * interaction 27 | * @param out the stream to write to 28 | * @param energy the interaction energy object used for computation 29 | */ 30 | OutputHandlerEnsemble( const OutputConstraint & outConstraint 31 | , std::ostream & out 32 | , const InteractionEnergy & energy 33 | ); 34 | 35 | /** 36 | * destruction, which 37 | * - prints ensemble information to stream and 38 | * - enforces a flush on the output stream. 39 | */ 40 | virtual ~OutputHandlerEnsemble(); 41 | 42 | /** 43 | * Does nothing but counts the call 44 | * (no individual interactions are reported) 45 | * 46 | * @param interaction the interaction to output 47 | */ 48 | virtual 49 | void 50 | add( const Interaction & interaction ); 51 | 52 | protected: 53 | 54 | //! counter of reported interactions 55 | using OutputHandler::reportedInteractions; 56 | 57 | //! aggregated overall partition function 58 | using OutputHandler::Z; 59 | 60 | //! the output stream to write the ensemble information to 61 | std::ostream & out; 62 | 63 | //! the interaction energy handler used for the energy computations 64 | const InteractionEnergy & energy; 65 | 66 | }; 67 | 68 | 69 | //////////////////////////////////////////////////////////////////////////// 70 | 71 | } // namespace 72 | 73 | #endif /* INTARNA_OUTPUTHANDLERENSEMBLE_H_ */ 74 | -------------------------------------------------------------------------------- /src/IntaRNA/OutputHandlerInteractionList.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "OutputHandlerInteractionList.h" 3 | 4 | #include 5 | 6 | namespace IntaRNA 7 | { 8 | 9 | ///////////////////////////////////////////////////////////////////////////// 10 | 11 | OutputHandlerInteractionList:: 12 | OutputHandlerInteractionList(const OutputConstraint & outConstraint 13 | , const size_t maxToStore) 14 | : OutputHandler(outConstraint) 15 | , storage() 16 | , maxToStore(maxToStore) 17 | { 18 | } 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | 22 | OutputHandlerInteractionList:: 23 | ~OutputHandlerInteractionList() 24 | { 25 | // cleanup stored interactions 26 | for( auto it = storage.begin(); it != storage.end(); it++ ) { 27 | delete (*it); 28 | } 29 | storage.clear(); 30 | } 31 | 32 | ///////////////////////////////////////////////////////////////////////////// 33 | 34 | void 35 | OutputHandlerInteractionList:: 36 | add( const Interaction & interaction ) 37 | { 38 | if (interaction.isEmpty()) { 39 | #if INTARNA_MULITHREADING 40 | #pragma omp critical(intarna_omp_OutputHandlerInteractionListUpdate) 41 | #endif 42 | { 43 | // count interaction 44 | reportedInteractions++; 45 | } 46 | return; 47 | } 48 | 49 | #if INTARNA_MULITHREADING 50 | #pragma omp critical(intarna_omp_OutputHandlerInteractionListUpdate) 51 | #endif 52 | { 53 | // count interaction 54 | reportedInteractions++; 55 | if (storage.size() < maxToStore || lessThan_StorageContainer( &interaction, *(storage.rbegin()) )) { 56 | // find where to insert this interaction 57 | StorageContainer::iterator insertPos = std::lower_bound( storage.begin(), storage.end(), &interaction, lessThan_StorageContainer ); 58 | // check if interaction is NOT already part of the list 59 | if ( insertPos == storage.end() || lessThan_StorageContainer( &interaction, *(insertPos) ) ) { 60 | // insert current interaction 61 | storage.insert( insertPos, new Interaction(interaction) ); 62 | // remove last element if needed 63 | if (storage.size() > maxToStore) { 64 | // delete object 65 | delete (*(storage.rbegin())); 66 | // remove pointer 67 | storage.resize(storage.size()-1); 68 | } 69 | } 70 | } 71 | } 72 | } 73 | 74 | ///////////////////////////////////////////////////////////////////////////// 75 | 76 | } /* namespace IntaRNA */ 77 | -------------------------------------------------------------------------------- /src/IntaRNA/OutputHandlerInteractionList.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef OUTPUTHANDLERINTERACTIONLIST_H_ 3 | #define OUTPUTHANDLERINTERACTIONLIST_H_ 4 | 5 | #include "OutputHandler.h" 6 | 7 | #include 8 | 9 | namespace IntaRNA 10 | { 11 | 12 | /** 13 | * OutputHandler that stores all reported interactions in a list 14 | * 15 | * NOTE: this handler does NOT support InteractionRange instances 16 | * 17 | */ 18 | class OutputHandlerInteractionList: public OutputHandler 19 | { 20 | protected: 21 | 22 | //! the container used internally for storing interactions 23 | typedef std::list StorageContainer; 24 | 25 | public: 26 | 27 | //! const iterator on stored interactions 28 | typedef StorageContainer::const_iterator const_iterator; 29 | //! iterator on stored interactions 30 | typedef StorageContainer::iterator iterator; 31 | 32 | public: 33 | 34 | /** 35 | * construction of empty container 36 | * @param maxToStore the maximal number of (best) elements to be stored 37 | * @param outConstraint the output constraint applied to find the reported 38 | * interaction 39 | */ 40 | OutputHandlerInteractionList( const OutputConstraint & outConstraint 41 | , const size_t maxToStore); 42 | 43 | //! destruction 44 | virtual ~OutputHandlerInteractionList(); 45 | 46 | /** 47 | * Adds a given RNA-RNA interaction to the storage/output. 48 | * 49 | * @param interaction the interaction to add 50 | */ 51 | virtual 52 | void 53 | add( const Interaction & interaction ); 54 | 55 | //! whether or not the container is empty 56 | //! @return true if no elements are stored 57 | bool empty() const; 58 | 59 | //! constant iterator to first stored interaction or end() if empty 60 | //! @return first stored interaction (pointer) or end() if empty 61 | const_iterator begin() const; 62 | 63 | //! constant iterator pointing AFTER last interaction (non-valid) 64 | //! @return iterator pointing after last element 65 | const_iterator end() const; 66 | 67 | //! iterator to first stored interaction or end() if empty 68 | //! @return first stored interaction (pointer) or end() if empty 69 | iterator begin(); 70 | 71 | //! iterator pointing AFTER last interaction (non-valid) 72 | //! @return iterator pointing after last element 73 | iterator end(); 74 | 75 | protected: 76 | 77 | //! counter of reported interactions 78 | using OutputHandler::reportedInteractions; 79 | 80 | //! container where interactions are stored 81 | StorageContainer storage; 82 | 83 | //! number of elements to store within storage (only maxToStore best) 84 | const size_t maxToStore; 85 | 86 | //! 'less-than' comparison struct dereferencing storage pointer 87 | static 88 | bool lessThan_StorageContainer( const Interaction * const a 89 | , const Interaction * const b ) 90 | { return *a < *b; } 91 | }; 92 | 93 | //////////////////////////////////////////////////////////////////////////// 94 | 95 | inline 96 | bool 97 | OutputHandlerInteractionList:: 98 | empty() const { 99 | return storage.empty(); 100 | } 101 | 102 | //////////////////////////////////////////////////////////////////////////// 103 | 104 | inline 105 | OutputHandlerInteractionList:: 106 | const_iterator 107 | OutputHandlerInteractionList:: 108 | begin() const { 109 | return storage.begin(); 110 | } 111 | 112 | //////////////////////////////////////////////////////////////////////////// 113 | 114 | inline 115 | OutputHandlerInteractionList:: 116 | const_iterator 117 | OutputHandlerInteractionList:: 118 | end() const { 119 | return storage.end(); 120 | } 121 | 122 | //////////////////////////////////////////////////////////////////////////// 123 | 124 | inline 125 | OutputHandlerInteractionList:: 126 | iterator 127 | OutputHandlerInteractionList:: 128 | begin() { 129 | return storage.begin(); 130 | } 131 | 132 | //////////////////////////////////////////////////////////////////////////// 133 | 134 | inline 135 | OutputHandlerInteractionList:: 136 | iterator 137 | OutputHandlerInteractionList:: 138 | end() { 139 | return storage.end(); 140 | } 141 | 142 | //////////////////////////////////////////////////////////////////////////// 143 | 144 | //////////////////////////////////////////////////////////////////////////// 145 | 146 | //////////////////////////////////////////////////////////////////////////// 147 | 148 | } /* namespace IntaRNA */ 149 | 150 | #endif /* OUTPUTHANDLERINTERACTIONLIST_H_ */ 151 | -------------------------------------------------------------------------------- /src/IntaRNA/OutputHandlerText.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_OUTPUTHANDLERTEXT_H_ 3 | #define INTARNA_OUTPUTHANDLERTEXT_H_ 4 | 5 | #include "IntaRNA/OutputConstraint.h" 6 | #include "IntaRNA/OutputHandler.h" 7 | #include "IntaRNA/InteractionEnergy.h" 8 | 9 | #include 10 | 11 | namespace IntaRNA { 12 | 13 | /** 14 | * Interaction output handler that writes all interactions directly to stream 15 | * in a simple text format. 16 | * 17 | * @author Martin Mann 2014 18 | */ 19 | class OutputHandlerText: public OutputHandler { 20 | public: 21 | 22 | /** 23 | * Construct a simple text output handler for interaction reporting. 24 | * 25 | * @param outConstraint the output constraint applied to find the reported 26 | * interaction 27 | * @param out the stream to write to 28 | * @param energy the interaction energy object used for computation 29 | * @param flankingLength maximal number of nucleotides flanking the 30 | * interaction to be printed in the output 31 | * @param detailedOutput if (true) detailed output is provided; normal 32 | * reduced output otherwise 33 | */ 34 | OutputHandlerText( const OutputConstraint & outConstraint 35 | , std::ostream & out 36 | , const InteractionEnergy & energy 37 | , const size_t flankingLength = 10 38 | , const bool detailedOutput = false 39 | ); 40 | 41 | /** 42 | * destruction, enforces a flush on the output stream. 43 | */ 44 | virtual ~OutputHandlerText(); 45 | 46 | /** 47 | * Write a given RNA-RNA interaction in simple text format to the output 48 | * stream. 49 | * 50 | * @param interaction the interaction to output 51 | */ 52 | virtual 53 | void 54 | add( const Interaction & interaction ); 55 | 56 | protected: 57 | 58 | //! counter of reported interactions 59 | using OutputHandler::reportedInteractions; 60 | 61 | //! aggregated overall partition function 62 | using OutputHandler::Z; 63 | 64 | //! the output stream to write the interaction text representation to 65 | std::ostream & out; 66 | 67 | //! the interaction energy handler used for the energy computations 68 | const InteractionEnergy & energy; 69 | 70 | //! number of flanking bases left/right of the interaction to print 71 | const size_t flankingLength; 72 | 73 | //! whether or not detailed output has to be provided 74 | const bool detailedOutput; 75 | 76 | }; 77 | 78 | 79 | //////////////////////////////////////////////////////////////////////////// 80 | 81 | } // namespace 82 | 83 | #endif /* OUTPUTHANDLERTEXT_H_ */ 84 | -------------------------------------------------------------------------------- /src/IntaRNA/OutputStreamHandler.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef OUTPUTSTREAMHANDLER_H_ 3 | #define OUTPUTSTREAMHANDLER_H_ 4 | 5 | #include "IntaRNA/general.h" 6 | 7 | namespace IntaRNA 8 | { 9 | 10 | /** 11 | * Provides access to the output stream for interaction reporting. 12 | * 13 | * @author: Martin Raden 2019 14 | */ 15 | class OutputStreamHandler 16 | { 17 | public: 18 | 19 | /** 20 | * construction 21 | * @param outStream the stream to write output to (non-NULL) 22 | */ 23 | OutputStreamHandler( std::ostream * outStream ); 24 | 25 | /** 26 | * destruction: if the provided outStream is a file stream, it is closed and 27 | * destroyed. 28 | */ 29 | virtual ~OutputStreamHandler(); 30 | 31 | /** 32 | * Access to the ostream to which output is to be written. 33 | * @return the output stream to write to 34 | */ 35 | virtual 36 | std::ostream& getOutStream(); 37 | 38 | protected: 39 | 40 | //! the stream to write output to 41 | std::ostream * outStream; 42 | }; 43 | 44 | ///////////////////////////////////////////////////////////////////////////// 45 | 46 | inline 47 | OutputStreamHandler:: 48 | OutputStreamHandler( std::ostream * os ) 49 | : outStream(os) 50 | { 51 | if (outStream == NULL) { 52 | throw std::runtime_error("OutputStreamHandler : provided outStream is NULL"); 53 | } 54 | } 55 | 56 | ///////////////////////////////////////////////////////////////////////////// 57 | 58 | inline 59 | OutputStreamHandler:: 60 | ~OutputStreamHandler() 61 | { 62 | // cleanup output stream 63 | deleteOutputStream(outStream); 64 | } 65 | 66 | ///////////////////////////////////////////////////////////////////////////// 67 | 68 | inline 69 | std::ostream& 70 | OutputStreamHandler:: 71 | getOutStream() 72 | { 73 | return *outStream; 74 | } 75 | 76 | ///////////////////////////////////////////////////////////////////////////// 77 | 78 | 79 | 80 | } /* namespace IntaRNA */ 81 | 82 | #endif /* OUTPUTSTREAMHANDLER_H_ */ 83 | -------------------------------------------------------------------------------- /src/IntaRNA/OutputStreamHandlerSortedCsv.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IntaRNA/OutputStreamHandlerSortedCsv.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | namespace IntaRNA { 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | 14 | OutputStreamHandlerSortedCsv:: 15 | ~OutputStreamHandlerSortedCsv() 16 | { 17 | 18 | //! type to capture the row's value to sort on (first) and the overall row data (second) 19 | typedef std::pair< std::string, std::string > RowData; 20 | 21 | //! list of all reported CSV rows to be sorted for final output 22 | std::vector< RowData > rows; 23 | 24 | // parse unsorted stream 25 | std::string curRow; 26 | while( outStreamUnsorted.rdbuf()->in_avail() > 0 ) { 27 | // parse next row 28 | std::getline( outStreamUnsorted, curRow, '\n' ); 29 | if (csvWithHeader && csvHeader.empty()) { 30 | csvHeader = curRow; 31 | continue; 32 | } 33 | // extract value for sorting 34 | std::vector values; 35 | boost::iter_split(values, curRow, boost::algorithm::first_finder(colSep)); 36 | // store data 37 | rows.push_back( RowData( (values.size() > colToSort) ? values.at(colToSort) : "", curRow ) ); 38 | } 39 | 40 | // sort all rows 41 | if (sortLexOrder) { 42 | // string-based lex-order sorting 43 | std::sort(rows.begin(), rows.end()); 44 | } else { 45 | // numerical sort 46 | if (listSep.empty()) { 47 | // single value sorting 48 | std::sort(rows.begin(), rows.end(), [&](const RowData& a, const RowData& b) { 49 | return std::stod(a.first) < std::stod(b.first); 50 | }); 51 | } else { 52 | // first-value sorting of possible list of values 53 | std::sort(rows.begin(), rows.end(), [&](const RowData& a, const RowData& b) { 54 | // check on first element of list 55 | return 56 | std::stod(a.first.substr( 0, a.first.find(listSep) )) 57 | < std::stod(b.first.substr( 0, b.first.find(listSep) )); 58 | }); 59 | } 60 | } 61 | 62 | #if INTARNA_MULITHREADING 63 | #pragma omp critical(intarna_omp_outputStreamUpdate) 64 | #endif 65 | { 66 | // write header if needed 67 | if (csvWithHeader) { 68 | (*outStream) <flush(); 76 | 77 | // disconnect outstream to avoid double deletion 78 | outStream = NULL; 79 | // delete wrapped handler 80 | INTARNA_CLEANUP(outStreamHandler); 81 | } 82 | 83 | ///////////////////////////////////////////////////////////////////////////// 84 | 85 | 86 | 87 | } /* namespace IntaRNA */ 88 | 89 | -------------------------------------------------------------------------------- /src/IntaRNA/OutputStreamHandlerSortedCsv.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef OUTPUTSTREAMHANDLERSORTEDCSV_H_ 3 | #define OUTPUTSTREAMHANDLERSORTEDCSV_H_ 4 | 5 | #include "IntaRNA/OutputStreamHandler.h" 6 | 7 | #include 8 | 9 | 10 | namespace IntaRNA 11 | { 12 | 13 | /** 14 | * Provides access to a temporal output stream for interaction reporting, which 15 | * is assumed to be populated by an OutputHandlerCsv. 16 | * On every flush(), the temporary stream is parsed and the sorted output is 17 | * reported to the final output stream. 18 | * 19 | * @author: Martin Raden 2019 20 | */ 21 | class OutputStreamHandlerSortedCsv : public OutputStreamHandler 22 | { 23 | public: 24 | 25 | /** 26 | * construction 27 | * @param outStreamHandler the OutputStreamHandler to write output to (non-NULL) and which is to destroy on destruction 28 | * @param colToSort the CSV column to sort 29 | * @param sortLexOrder whether or not lexicographic (or numerical) sorting is to be done 30 | * @param colSep the column separator used within the output 31 | * @param csvWithHeader whether or not the CSV output will contain a header line 32 | * @param listSep the separator used within a single column to represent multiple values 33 | */ 34 | OutputStreamHandlerSortedCsv( OutputStreamHandler * outStreamHandler 35 | , const size_t colToSort 36 | , const bool sortLexOrder 37 | , const std::string colSep 38 | , const bool csvWithHeader 39 | , const std::string listSep = "" 40 | ); 41 | 42 | /** 43 | * destruction: 44 | * - parses the unsorted CSV output 45 | * - writes the sorted CSV output to the final output stream 46 | * - calls flush() on the final output 47 | * - destruction of the underlying OutputStreamHandler 48 | */ 49 | virtual ~OutputStreamHandlerSortedCsv(); 50 | 51 | /** 52 | * Access to the ostream to which unsorted CSV output is to be written. 53 | * @return the output stream to write unsorted CSV output to 54 | */ 55 | virtual 56 | std::ostream& getOutStream(); 57 | 58 | 59 | protected: 60 | 61 | //! the underlying OutputStreamHandler to which the final output is reported 62 | OutputStreamHandler* outStreamHandler; 63 | 64 | //! the stream to write output to 65 | std::stringstream outStreamUnsorted; 66 | 67 | //! the CSV column to sort 68 | const size_t colToSort; 69 | 70 | //! whether or not lexicographic (or numerical) sorting is to be done 71 | const bool sortLexOrder; 72 | 73 | //! the column separator used within the output 74 | const std::string colSep; 75 | 76 | //! whether or not the CSV output will contain a header line 77 | const bool csvWithHeader; 78 | 79 | //! the parsed CSV header (empty if not parsed yet) 80 | std::string csvHeader; 81 | 82 | //! the separator used within a single column to represent multiple values 83 | const std::string listSep; 84 | }; 85 | 86 | ///////////////////////////////////////////////////////////////////////////// 87 | 88 | inline 89 | OutputStreamHandlerSortedCsv:: 90 | OutputStreamHandlerSortedCsv( OutputStreamHandler * osh 91 | , const size_t colToSort 92 | , const bool sortLexOrder 93 | , const std::string colSep 94 | , const bool csvWithHeader 95 | , const std::string listSep 96 | ) 97 | : OutputStreamHandler( osh == NULL ? &std::cout : &(osh->getOutStream()) ) 98 | , outStreamHandler(osh) 99 | , outStreamUnsorted() 100 | , colToSort(colToSort) 101 | , sortLexOrder(sortLexOrder) 102 | , colSep(colSep) 103 | , csvWithHeader(csvWithHeader) 104 | , csvHeader() 105 | , listSep(listSep) 106 | { 107 | if (osh == NULL) { 108 | throw std::runtime_error("OutputStreamHandlerSortedCsv() : outStreamHandler == NULL"); 109 | } 110 | if (colSep.empty()) { 111 | throw std::runtime_error("OutputStreamHandlerSortedCsv() : colSep is empty"); 112 | } 113 | } 114 | 115 | ///////////////////////////////////////////////////////////////////////////// 116 | 117 | inline 118 | std::ostream& 119 | OutputStreamHandlerSortedCsv:: 120 | getOutStream() 121 | { 122 | return outStreamUnsorted; 123 | } 124 | 125 | ///////////////////////////////////////////////////////////////////////////// 126 | 127 | 128 | 129 | } /* namespace IntaRNA */ 130 | 131 | #endif /* OUTPUTSTREAMHANDLERSORTEDCSV_H_ */ 132 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictionTracker.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_PREDICTIONTRACKER_H_ 3 | #define INTARNA_PREDICTIONTRACKER_H_ 4 | 5 | 6 | #include "IntaRNA/general.h" 7 | 8 | namespace IntaRNA { 9 | 10 | /** 11 | * Generic interface to track prediction progress of Predictor instances. 12 | * 13 | */ 14 | class PredictionTracker 15 | { 16 | 17 | public: 18 | 19 | /** 20 | * construction 21 | */ 22 | PredictionTracker(); 23 | 24 | /** 25 | * destruction 26 | */ 27 | virtual ~PredictionTracker(); 28 | 29 | /** 30 | * Informs the tracker that Predictor.updateOptima() was called with the 31 | * given data. 32 | * 33 | * @param i1 the index of the first sequence interacting with i2 34 | * @param j1 the index of the first sequence interacting with j2 35 | * @param i2 the index of the second sequence interacting with i1 36 | * @param j2 the index of the second sequence interacting with j1 37 | * @param energy the overall energy of the interaction site 38 | */ 39 | virtual 40 | void 41 | updateOptimumCalled( const size_t i1, const size_t j1 42 | , const size_t i2, const size_t j2 43 | , const E_type energy 44 | ) = 0; 45 | 46 | }; 47 | 48 | 49 | 50 | /////////////////////////////////////////////////////////////////////////// 51 | 52 | inline 53 | PredictionTracker::PredictionTracker() 54 | { 55 | } 56 | 57 | /////////////////////////////////////////////////////////////////////////// 58 | 59 | inline 60 | PredictionTracker::~PredictionTracker() 61 | { 62 | } 63 | 64 | /////////////////////////////////////////////////////////////////////////// 65 | 66 | 67 | } // namespace 68 | 69 | #endif /* PREDICTIONTRACKER_H_ */ 70 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfe2d.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_PREDICTORMFE2D_H_ 3 | #define INTARNA_PREDICTORMFE2D_H_ 4 | 5 | #include "IntaRNA/PredictorMfe.h" 6 | #include "IntaRNA/Interaction.h" 7 | 8 | #include 9 | 10 | namespace IntaRNA { 11 | 12 | /** 13 | * Memory efficient predictor for RNAup-like computation, i.e. full 14 | * DP-implementation without seed-heuristic, using 2D matrices 15 | * 16 | * @author Martin Mann 17 | * 18 | */ 19 | class PredictorMfe2d: public PredictorMfe { 20 | 21 | protected: 22 | 23 | //! matrix type to hold the mfe energies for interaction site starts 24 | typedef boost::numeric::ublas::matrix E2dMatrix; 25 | 26 | public: 27 | 28 | /** 29 | * Constructs a predictor and stores the energy and output handler 30 | * 31 | * @param energy the interaction energy handler 32 | * @param output the output handler to report mfe interactions to 33 | * @param predTracker the prediction tracker to be used or NULL if no 34 | * tracking is to be done; if non-NULL, the tracker gets deleted 35 | * on this->destruction. 36 | */ 37 | PredictorMfe2d( const InteractionEnergy & energy 38 | , OutputHandler & output 39 | , PredictionTracker * predTracker ); 40 | 41 | virtual ~PredictorMfe2d(); 42 | 43 | /** 44 | * Computes the mfe for the given sequence ranges (i1-j1) in the first 45 | * sequence and (i2-j2) in the second sequence and reports it to the output 46 | * handler. 47 | * 48 | * @param r1 the index range of the first sequence interacting with r2 49 | * @param r2 the index range of the second sequence interacting with r1 50 | * 51 | */ 52 | virtual 53 | void 54 | predict( const IndexRange & r1 = IndexRange(0,RnaSequence::lastPos) 55 | , const IndexRange & r2 = IndexRange(0,RnaSequence::lastPos) 56 | ); 57 | 58 | protected: 59 | 60 | //! access to the interaction energy handler of the super class 61 | using PredictorMfe::energy; 62 | 63 | //! access to the output handler of the super class 64 | using PredictorMfe::output; 65 | 66 | //! energy of all interaction hybrids that end in position p (seq1) and 67 | //! q (seq2) 68 | E2dMatrix hybridE_pq; 69 | 70 | protected: 71 | 72 | /** 73 | * Computes all entries of the hybridE matrix for interactions ending in 74 | * p=j1 and q=j2 and report all valid interactions to updateOptima() 75 | * 76 | * @param j1 end of the interaction within seq 1 77 | * @param j2 end of the interaction within seq 2 78 | * @param i1init smallest value for i1 79 | * @param i2init smallest value for i2 80 | * @param callUpdateOptima whether or not updateOptima() is to be called 81 | * 82 | */ 83 | virtual 84 | void 85 | fillHybridE( const size_t j1, const size_t j2 86 | , const size_t i1init, const size_t i2init 87 | , const bool callUpdateOptima 88 | ); 89 | 90 | /** 91 | * Fills a given interaction (boundaries given) with the according 92 | * hybridizing base pairs. 93 | * @param interaction IN/OUT the interaction to fill 94 | */ 95 | virtual 96 | void 97 | traceBack( Interaction & interaction ); 98 | 99 | }; 100 | 101 | } // namespace 102 | 103 | #endif /* INTARNA_PREDICTORMFE2D_H_ */ 104 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfe2dHelixBlockHeuristic.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_PREDICTORMFE2DHELIXBLOCKHEURISTIC_H_ 3 | #define INTARNA_PREDICTORMFE2DHELIXBLOCKHEURISTIC_H_ 4 | 5 | #include "IntaRNA/PredictorMfe2dHeuristic.h" 6 | #include "IntaRNA/Interaction.h" 7 | #include "IntaRNA/HelixHandlerIdxOffset.h" 8 | 9 | #include 10 | 11 | namespace IntaRNA { 12 | 13 | /** 14 | * Memory efficient interaction predictor that uses a heuristic to 15 | * find the mfe or a close-to-mfe interaction. 16 | * 17 | * To this end, for each interaction start i1,i2 only the optimal right side 18 | * interaction with boundaries j1,j2 is considered in the recursion instead of 19 | * all possible interaction ranges. 20 | * 21 | * Only maximal helices up to a given length are combined. 22 | * 23 | * This yields a quadratic time and space complexity. 24 | * 25 | * @author Rick Gelhausen 26 | * 27 | */ 28 | class PredictorMfe2dHelixBlockHeuristic: public PredictorMfe2dHeuristic { 29 | 30 | protected: 31 | 32 | //! matrix type to hold the mfe energies and boundaries for interaction site starts 33 | typedef PredictorMfe2dHeuristic::E2dMatrix E2dMatrix; 34 | 35 | public: 36 | 37 | /** 38 | * Constructs a predictor and stores the energy and output handler 39 | * 40 | * @param energy the interaction energy handler 41 | * @param output the output handler to report mfe interactions to 42 | * @param predTracker the prediction tracker to be used or NULL if no 43 | * tracking is to be done; if non-NULL, the tracker gets deleted 44 | * on this->destruction. 45 | */ 46 | PredictorMfe2dHelixBlockHeuristic( const InteractionEnergy & energy 47 | , OutputHandler & output 48 | , PredictionTracker * predTracker 49 | , const HelixConstraint & helixConstraint); 50 | 51 | virtual ~PredictorMfe2dHelixBlockHeuristic(); 52 | 53 | /** 54 | * Computes the mfe for the given sequence ranges (i1-j1) in the first 55 | * sequence and (i2-j2) in the second sequence and reports it to the output 56 | * handler. 57 | * 58 | * @param r1 the index range of the first sequence interacting with r2 59 | * @param r2 the index range of the second sequence interacting with r1 60 | * 61 | */ 62 | virtual 63 | void 64 | predict( const IndexRange & r1 = IndexRange(0,RnaSequence::lastPos) 65 | , const IndexRange & r2 = IndexRange(0,RnaSequence::lastPos) ); 66 | 67 | protected: 68 | 69 | //! access to the interaction energy handler of the super class 70 | using PredictorMfe2dHeuristic::energy; 71 | 72 | //! access to the output handler of the super class 73 | using PredictorMfe2dHeuristic::output; 74 | 75 | //! access to the list of reported interaction ranges of the super class 76 | using PredictorMfe2dHeuristic::reportedInteractions; 77 | 78 | //! energy of all interaction hybrids starting in i1,i2 79 | using PredictorMfe2dHeuristic::hybridE; 80 | 81 | //! helixHandler used only for creating HelixHandlerOffset 82 | //HelixHandler helixHandler; 83 | HelixHandlerIdxOffset helixHandler; 84 | 85 | protected: 86 | 87 | /** 88 | * Computes all entries of the hybridE matrix 89 | */ 90 | virtual 91 | void 92 | fillHybridE(); 93 | 94 | /** 95 | * Fills a given interaction (boundaries given) with the according 96 | * hybridizing base pairs. 97 | * @param interaction IN/OUT the interaction to fill 98 | */ 99 | virtual 100 | void 101 | traceBack( Interaction & interaction ); 102 | 103 | /** 104 | * Identifies the next best interaction with an energy equal to or higher 105 | * than the given interaction. The new interaction will not overlap any 106 | * index range stored in reportedInteractions. 107 | * 108 | * @param curBest IN/OUT the current best interaction to be replaced with one 109 | * of equal or higher energy not overlapping with any reported 110 | * interaction so far; an interaction with energy E_INF is set, if 111 | * there is no better interaction left 112 | */ 113 | virtual 114 | void 115 | getNextBest( Interaction & curBest ); 116 | 117 | /** 118 | * Overwrites function of super class to surpress the update. 119 | * 120 | * @param i1 interaction start in seq1 121 | * @param j1 interaction end in seq1 122 | * @param i2 interaction start in seq2 123 | * @param i2 interaction end in seq2 124 | * @param curInteraction the interaction information to be used for update 125 | */ 126 | virtual 127 | void 128 | updateMfe4leftEnd(const size_t i1, const size_t j1 129 | , const size_t i2, const size_t j2 130 | , const Interaction & curInteraction ); 131 | 132 | }; 133 | 134 | } // namespace 135 | 136 | #endif /* INTARNA_PREDICTORMFE2DHELIXBLOCKHEURISTIC_H_ */ 137 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfe2dHeuristic.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_PREDICTORMFE2DHEURISTIC_H_ 3 | #define INTARNA_PREDICTORMFE2DHEURISTIC_H_ 4 | 5 | #include "IntaRNA/PredictorMfe.h" 6 | #include "IntaRNA/Interaction.h" 7 | 8 | #include 9 | 10 | namespace IntaRNA { 11 | 12 | /** 13 | * Memory efficient interaction predictor that uses a heuristic to 14 | * find the mfe or a close-to-mfe interaction. 15 | * 16 | * To this end, for each interaction start i1,i2 only the optimal right side 17 | * interaction with boundaries j1,j2 is considered in the recursion instead of 18 | * all possible interaction ranges. 19 | * 20 | * This yields a quadratic time and space complexity. 21 | * 22 | * @author Martin Mann 23 | * 24 | */ 25 | class PredictorMfe2dHeuristic: public PredictorMfe { 26 | 27 | protected: 28 | 29 | //! matrix type to hold the mfe energies and boundaries for interaction site starts 30 | typedef boost::numeric::ublas::matrix E2dMatrix; 31 | 32 | public: 33 | 34 | /** 35 | * Constructs a predictor and stores the energy and output handler 36 | * 37 | * @param energy the interaction energy handler 38 | * @param output the output handler to report mfe interactions to 39 | * @param predTracker the prediction tracker to be used or NULL if no 40 | * tracking is to be done; if non-NULL, the tracker gets deleted 41 | * on this->destruction. 42 | */ 43 | PredictorMfe2dHeuristic( const InteractionEnergy & energy 44 | , OutputHandler & output 45 | , PredictionTracker * predTracker ); 46 | 47 | virtual ~PredictorMfe2dHeuristic(); 48 | 49 | /** 50 | * Computes the mfe for the given sequence ranges (i1-j1) in the first 51 | * sequence and (i2-j2) in the second sequence and reports it to the output 52 | * handler. 53 | * 54 | * @param r1 the index range of the first sequence interacting with r2 55 | * @param r2 the index range of the second sequence interacting with r1 56 | * 57 | */ 58 | virtual 59 | void 60 | predict( const IndexRange & r1 = IndexRange(0,RnaSequence::lastPos) 61 | , const IndexRange & r2 = IndexRange(0,RnaSequence::lastPos) ); 62 | 63 | protected: 64 | 65 | //! access to the interaction energy handler of the super class 66 | using PredictorMfe::energy; 67 | 68 | //! access to the output handler of the super class 69 | using PredictorMfe::output; 70 | 71 | //! access to the list of reported interaction ranges of the super class 72 | using PredictorMfe::reportedInteractions; 73 | 74 | //! energy of all interaction hybrids starting in i1,i2 75 | E2dMatrix hybridE; 76 | 77 | protected: 78 | 79 | /** 80 | * Computes all entries of the hybridE matrix 81 | * and reports all valid interactions via updateOptima() 82 | */ 83 | virtual 84 | void 85 | fillHybridE(); 86 | 87 | /** 88 | * Fills a given interaction (boundaries given) with the according 89 | * hybridizing base pairs. 90 | * @param interaction IN/OUT the interaction to fill 91 | */ 92 | virtual 93 | void 94 | traceBack( Interaction & interaction ); 95 | 96 | /** 97 | * Identifies the next best interaction with an energy equal to or higher 98 | * than the given interaction. The new interaction will not overlap any 99 | * index range stored in reportedInteractions. 100 | * 101 | * @param curBest IN/OUT the current best interaction to be replaced with one 102 | * of equal or higher energy not overlapping with any reported 103 | * interaction so far; an interaction with energy E_INF is set, if 104 | * there is no better interaction left 105 | */ 106 | virtual 107 | void 108 | getNextBest( Interaction & curBest ); 109 | 110 | /** 111 | * Overwrites function of super class to surpress the update. 112 | * 113 | * @param i1 interaction start in seq1 114 | * @param j1 interaction end in seq1 115 | * @param i2 interaction start in seq2 116 | * @param i2 interaction end in seq2 117 | * @param curInteraction the interaction information to be used for update 118 | */ 119 | virtual 120 | void 121 | updateMfe4leftEnd(const size_t i1, const size_t j1 122 | , const size_t i2, const size_t j2 123 | , const Interaction & curInteraction ); 124 | 125 | }; 126 | 127 | } // namespace 128 | 129 | #endif /* INTARNA_PREDICTORMFE2DHEURISTIC_H_ */ 130 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfe2dHeuristicSeed.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_PREDICTORMFE2DHEURISTICSEED_H_ 3 | #define INTARNA_PREDICTORMFE2DHEURISTICSEED_H_ 4 | 5 | #include "IntaRNA/PredictorMfe2dHeuristic.h" 6 | #include "IntaRNA/SeedHandlerIdxOffset.h" 7 | 8 | namespace IntaRNA { 9 | 10 | 11 | /** 12 | * Memory efficient interaction predictor that uses both qualitative heuristics 13 | * (interactions have to have a seed interaction) and performance heuristics 14 | * (not all possible interactions considered) 15 | * 16 | * To this end, for each interaction start i1,i2 only the optimal right side 17 | * interaction with boundaries j1,j2 is considered in the recursion instead of 18 | * all possible interaction ranges. 19 | * 20 | * This yields a quadratic time and space complexity. 21 | * 22 | * @author Martin Mann 23 | * 24 | */ 25 | class PredictorMfe2dHeuristicSeed: public PredictorMfe2dHeuristic { 26 | 27 | 28 | //! matrix type to hold the mfe energies and boundaries for interaction site starts 29 | typedef PredictorMfe2dHeuristic::E2dMatrix E2dMatrix; 30 | 31 | public: 32 | 33 | /** 34 | * Constructs a predictor and stores the energy and output handler 35 | * 36 | * @param energy the interaction energy handler 37 | * @param output the output handler to report mfe interactions to 38 | * @param predTracker the prediction tracker to be used or NULL if no 39 | * tracking is to be done; if non-NULL, the tracker gets deleted 40 | * on this->destruction. 41 | * @param seedHandler the seed handler to be applied 42 | */ 43 | PredictorMfe2dHeuristicSeed( const InteractionEnergy & energy 44 | , OutputHandler & output 45 | , PredictionTracker * predTracker 46 | , SeedHandler* seedHandler ); 47 | 48 | virtual ~PredictorMfe2dHeuristicSeed(); 49 | 50 | /** 51 | * Computes the mfe for the given sequence ranges (i1-j1) in the first 52 | * sequence and (i2-j2) in the second sequence and reports it to the output 53 | * handler. 54 | * 55 | * @param r1 the index range of the first sequence interacting with r2 56 | * @param r2 the index range of the second sequence interacting with r1 57 | * 58 | */ 59 | virtual 60 | void 61 | predict( const IndexRange & r1 = IndexRange(0,RnaSequence::lastPos) 62 | , const IndexRange & r2 = IndexRange(0,RnaSequence::lastPos)); 63 | 64 | protected: 65 | 66 | //! access to the interaction energy handler of the super class 67 | using PredictorMfe2dHeuristic::energy; 68 | 69 | //! access to the output handler of the super class 70 | using PredictorMfe2dHeuristic::output; 71 | 72 | //! access to the list of reported interaction ranges of the super class 73 | using PredictorMfe2dHeuristic::reportedInteractions; 74 | 75 | //! energy of all interaction hybrids that end in position p (seq1) and 76 | //! q (seq2) 77 | using PredictorMfe2dHeuristic::hybridE; 78 | 79 | //! the best hybridization energy including a seed for start i1,i2 80 | E2dMatrix hybridE_seed; 81 | 82 | //! handler to generate and access seed information with idx offset 83 | SeedHandlerIdxOffset seedHandler; 84 | 85 | protected: 86 | 87 | /** 88 | * Fills a given interaction (boundaries given) with the according 89 | * hybridizing base pairs. 90 | * @param interaction IN/OUT the interaction to fill 91 | */ 92 | virtual 93 | void 94 | traceBack( Interaction & interaction ); 95 | 96 | 97 | /** 98 | * Computes all entries of both hybridE matrices 99 | * and reports all valid interactions via updateOptima() 100 | */ 101 | virtual 102 | void 103 | fillHybridE(); 104 | 105 | 106 | /** 107 | * Identifies the next best interaction (containing a seed) 108 | * with an energy equal to or higher 109 | * than the given interaction. The new interaction will not overlap any 110 | * index range stored in reportedInteractions. 111 | * 112 | * @param curBest IN/OUT the current best interaction to be replaced with one 113 | * of equal or higher energy not overlapping with any reported 114 | * interaction so far; an interaction with energy E_INF is set, if 115 | * there is no better interaction left 116 | */ 117 | virtual 118 | void 119 | getNextBest( Interaction & curBest ); 120 | 121 | 122 | }; 123 | 124 | ////////////////////////////////////////////////////////////////////////// 125 | ////////////////////////////////////////////////////////////////////////// 126 | ////////////////////////////////////////////////////////////////////////// 127 | 128 | } // namespace 129 | 130 | #endif /* INTARNA_PREDICTORMFE2DHEURISTICSEED_H_ */ 131 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfe2dSeed.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PredictorMfe2dSeed.h 3 | * 4 | * Created on: 13.10.2016 5 | * Author: Mmann 6 | */ 7 | 8 | #ifndef INTARNA_PREDICTORMFE2DSEED_H_ 9 | #define INTARNA_PREDICTORMFE2DSEED_H_ 10 | 11 | #include "IntaRNA/PredictorMfe2d.h" 12 | #include "IntaRNA/SeedHandlerIdxOffset.h" 13 | 14 | namespace IntaRNA { 15 | 16 | /** 17 | * Implements seed-based space-efficient interaction prediction. 18 | * 19 | * Note, for each seed start (i1,i2) only the mfe seed is considered for the 20 | * overall interaction computation instead of considering all possible seeds 21 | * starting at (i1,i2). 22 | * 23 | * @author Martin Mann 24 | * 25 | */ 26 | class PredictorMfe2dSeed: public PredictorMfe2d { 27 | 28 | protected: 29 | 30 | //! matrix type to hold the mfe energies for interaction site starts 31 | typedef PredictorMfe2d::E2dMatrix E2dMatrix; 32 | 33 | public: 34 | 35 | 36 | /** 37 | * Constructs a predictor and stores the energy and output handler 38 | * 39 | * @param energy the interaction energy handler 40 | * @param output the output handler to report mfe interactions to 41 | * @param predTracker the prediction tracker to be used or NULL if no 42 | * tracking is to be done; if non-NULL, the tracker gets deleted 43 | * on this->destruction. 44 | * @param seedHandler the seed handler to be used 45 | */ 46 | PredictorMfe2dSeed( 47 | const InteractionEnergy & energy 48 | , OutputHandler & output 49 | , PredictionTracker * predTracker 50 | , SeedHandler * seedHandler ); 51 | 52 | 53 | /** 54 | * data cleanup 55 | */ 56 | virtual ~PredictorMfe2dSeed(); 57 | 58 | 59 | /** 60 | * Computes the mfe for the given sequence ranges (i1-j1) in the first 61 | * sequence and (i2-j2) in the second sequence and reports it to the output 62 | * handler. 63 | * 64 | * Each considered interaction contains a seed according to the seed handler 65 | * constraints. 66 | * 67 | * @param r1 the index range of the first sequence interacting with r2 68 | * @param r2 the index range of the second sequence interacting with r1 69 | * 70 | */ 71 | virtual 72 | void 73 | predict( const IndexRange & r1 = IndexRange(0,RnaSequence::lastPos) 74 | , const IndexRange & r2 = IndexRange(0,RnaSequence::lastPos) ); 75 | 76 | 77 | protected: 78 | 79 | 80 | //! access to the interaction energy handler of the super class 81 | using PredictorMfe2d::energy; 82 | 83 | //! access to the output handler of the super class 84 | using PredictorMfe2d::output; 85 | 86 | //! energy of all interaction hybrids that end in position p (seq1) and 87 | //! q (seq2) and do not necessarily contain a seed interaction 88 | using PredictorMfe2d::hybridE_pq; 89 | 90 | //! the seed handler (with idx offset) 91 | SeedHandlerIdxOffset seedHandler; 92 | 93 | //! for fixed interaction end p=j1,q=j2: each cell (i1,i2) provides the mfe 94 | //! for the interaction i1..j1 with i2..j2 given that the range contains 95 | //! a valid seed interaction 96 | E2dMatrix hybridE_pq_seed; 97 | 98 | protected: 99 | 100 | /** 101 | * Computes all entries of both hybridE matrices for interactions ending in 102 | * p=j1 and q=j2 and reports all valid interactions via updateOptima() 103 | * 104 | * @param j1 end of the interaction within seq 1 105 | * @param j2 end of the interaction within seq 2 106 | * @param i1init smallest value for i1 107 | * @param i2init smallest value for i2 108 | * @param callUpdateOptima whether or not to call updateOptima() 109 | */ 110 | virtual 111 | void 112 | fillHybridE( const size_t j1, const size_t j2 113 | , const size_t i1init, const size_t i2init 114 | , const bool callUpdateOptima 115 | ); 116 | 117 | /** 118 | * Fills a given interaction (boundaries given) with the according 119 | * hybridizing base pairs using hybridE_seed. 120 | * @param interaction IN/OUT the interaction to fill 121 | */ 122 | virtual 123 | void 124 | traceBack( Interaction & interaction ); 125 | 126 | }; 127 | 128 | ////////////////////////////////////////////////////////////////////////// 129 | ////////////////////////////////////////////////////////////////////////// 130 | ////////////////////////////////////////////////////////////////////////// 131 | 132 | } // namespace 133 | 134 | #endif /* INTARNA_PREDICTORMFE2DSEED_H_ */ 135 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfeEns.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IntaRNA/PredictorMfeEns.h" 3 | 4 | #include 5 | #include 6 | 7 | namespace IntaRNA { 8 | 9 | //////////////////////////////////////////////////////////////////////////// 10 | 11 | PredictorMfeEns::PredictorMfeEns( 12 | const InteractionEnergy & energy 13 | , OutputHandler & output 14 | , PredictionTracker * predTracker 15 | ) 16 | : PredictorMfe(energy,output,predTracker) 17 | { 18 | } 19 | 20 | //////////////////////////////////////////////////////////////////////////// 21 | 22 | PredictorMfeEns::~PredictorMfeEns() 23 | { 24 | } 25 | 26 | 27 | //////////////////////////////////////////////////////////////////////////// 28 | 29 | void 30 | PredictorMfeEns:: 31 | initZ() 32 | { 33 | // reset storage 34 | Z_partition.clear(); 35 | } 36 | 37 | //////////////////////////////////////////////////////////////////////////// 38 | 39 | void 40 | PredictorMfeEns:: 41 | updateZ( const size_t i1, const size_t j1 42 | , const size_t i2, const size_t j2 43 | , const Z_type partZ 44 | , const bool isHybridZ ) 45 | { 46 | // check if something to be done 47 | if (Z_equal(partZ,0) || Z_isINF(Zall)) 48 | return; 49 | // handle whether or not partZ includes ED values or not 50 | Z_type partZ_withED = 0, partZ_noED = 0; 51 | if (isHybridZ) { 52 | #if INTARNA_IN_DEBUG_MODE 53 | if ( (std::numeric_limits::max() - (partZ*energy.getBoltzmannWeight(energy.getE(i1,j1,i2,j2, E_type(0))))) <= Zall) { 54 | LOG(WARNING) <<"PredictorMfeEns::updateZ() : partition function overflow! Recompile with larger partition function data type!"; 55 | } 56 | #endif 57 | // add ED penalties etc. 58 | partZ_noED = partZ; 59 | partZ_withED = partZ*energy.getBoltzmannWeight(energy.getE(i1,j1,i2,j2, E_type(0))); 60 | } else { 61 | #if INTARNA_IN_DEBUG_MODE 62 | if ( (std::numeric_limits::max() - partZ) <= Zall) { 63 | LOG(WARNING) <<"PredictorMfeEns::updateZ() : partition function overflow! Recompile with larger partition function data type!"; 64 | } 65 | #endif 66 | // remove ED 67 | partZ_noED = partZ / energy.getBoltzmannWeight(energy.getE(i1,j1,i2,j2, E_type(0)));; 68 | partZ_withED = partZ; 69 | } 70 | 71 | // increase overall partition function 72 | Zall += partZ_withED; 73 | 74 | // store partial Z (without ED) 75 | Interaction::Boundary key(i1,j1,i2,j2); 76 | auto keyEntry = Z_partition.find(key); 77 | if ( Z_partition.find(key) == Z_partition.end() ) { 78 | Z_partition[key] = partZ_noED; 79 | } else { 80 | // update entry 81 | keyEntry->second += partZ_noED; 82 | } 83 | 84 | } 85 | 86 | //////////////////////////////////////////////////////////////////////////// 87 | 88 | void 89 | PredictorMfeEns:: 90 | updateOptimaUsingZ() 91 | { 92 | for (auto it = Z_partition.begin(); it != Z_partition.end(); ++it) 93 | { 94 | // if partition function is > 0 95 | if (Z_isNotINF(it->second) && it->second > 0) { 96 | PredictorMfe::updateOptima( it->first.i1, it->first.j1, it->first.i2, it->first.j2, energy.getE(it->second), true, false ); 97 | } 98 | } 99 | } 100 | 101 | //////////////////////////////////////////////////////////////////////////// 102 | 103 | void 104 | PredictorMfeEns:: 105 | reportOptima() 106 | { 107 | // update optima from Z information 108 | updateOptimaUsingZ(); 109 | 110 | // call super-class function 111 | PredictorMfe::reportOptima(); 112 | } 113 | 114 | //////////////////////////////////////////////////////////////////////////// 115 | 116 | void 117 | PredictorMfeEns:: 118 | traceBack( Interaction & interaction ) 119 | { 120 | // check if something to trace 121 | if (interaction.basePairs.size() < 2) { 122 | return; 123 | } 124 | 125 | #if INTARNA_IN_DEBUG_MODE 126 | // sanity checks 127 | if ( interaction.basePairs.size() != 2 ) { 128 | throw std::runtime_error("PredictorMfeEns::traceBack() : given interaction does not contain boundaries only"); 129 | } 130 | #endif 131 | 132 | // ensure sorting 133 | interaction.sort(); 134 | 135 | // check for single base pair interaction 136 | if (interaction.basePairs.at(0).first == interaction.basePairs.at(1).first) { 137 | // delete second boundary (identical to first) 138 | interaction.basePairs.resize(1); 139 | // update done 140 | return; 141 | } 142 | 143 | #if INTARNA_IN_DEBUG_MODE 144 | // sanity checks 145 | if ( ! interaction.isValid() ) { 146 | throw std::runtime_error("PredictorMfeEns2d::traceBack() : given interaction is not valid"); 147 | } 148 | #endif 149 | 150 | } 151 | 152 | //////////////////////////////////////////////////////////////////////////// 153 | 154 | 155 | } // namespace 156 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfeEns.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_PREDICTORMFEENS_H_ 3 | #define INTARNA_PREDICTORMFEENS_H_ 4 | 5 | 6 | #include "IntaRNA/PredictorMfe.h" 7 | 8 | #include "IntaRNA/IndexRangeList.h" 9 | 10 | #include 11 | #include 12 | 13 | namespace IntaRNA { 14 | 15 | /** 16 | * Generic Predictor interface for ensemble-based MFE interaction computation 17 | * 18 | * @author Martin Raden 19 | * 20 | */ 21 | class PredictorMfeEns : public PredictorMfe { 22 | 23 | 24 | public: 25 | 26 | /** 27 | * Construction call the super constructor 28 | * 29 | * @param energy the interaction energy handler 30 | * @param output the output handler to report optimal interactions to 31 | * @param predTracker the prediction tracker to be used or NULL if no 32 | * tracking is to be done; if non-NULL, the tracker gets deleted 33 | * on this->destruction. 34 | */ 35 | PredictorMfeEns( const InteractionEnergy & energy 36 | , OutputHandler & output 37 | , PredictionTracker * predTracker ); 38 | 39 | virtual ~PredictorMfeEns(); 40 | 41 | protected: 42 | 43 | //! data container to encode a site with respective partition function 44 | struct ZPartition { 45 | size_t i1; 46 | size_t j1; 47 | size_t i2; 48 | size_t j2; 49 | Z_type partZ; 50 | }; 51 | 52 | //! access to the interaction energy handler of the super class 53 | using PredictorMfe::energy; 54 | 55 | //! access to the output handler of the super class 56 | using PredictorMfe::output; 57 | 58 | //! access to the prediction tracker of the super class 59 | using PredictorMfe::predTracker; 60 | 61 | //! map storing the partition of Zall for all considered interaction sites 62 | std::unordered_map Z_partition; 63 | 64 | 65 | /** 66 | * Initializes the hybridization partition functions. 67 | * Will be called by predict(). 68 | */ 69 | virtual 70 | void 71 | initZ(); 72 | 73 | /** 74 | * Updates the local hybridization partition functions as well as Zall. 75 | * 76 | * Note: avoid other Zall updates via updateOptima(.., incrementZall=false)! 77 | * 78 | * Note: if called multiple time for the same boundaries then the 79 | * reported partition functions have to represent disjoint interaction sets! 80 | * 81 | * @param i1 the index of the first sequence interacting with i2 82 | * @param j1 the index of the first sequence interacting with j2 83 | * @param i2 the index of the second sequence interacting with i1 84 | * @param j2 the index of the second sequence interacting with j1 85 | * @param partFunct the partition function of the interaction 86 | * @param isHybridZ whether or not the given Z is only covering 87 | * hybridization energy terms (init+loops) or the total 88 | * interaction energy 89 | */ 90 | virtual 91 | void 92 | updateZ( const size_t i1, const size_t j1 93 | , const size_t i2, const size_t j2 94 | , const Z_type partFunct 95 | , const bool isHybridZ ); 96 | 97 | /** 98 | * Calls for the stored Z_partition information updateOptima() before 99 | * calling reportOptima() from its super class. 100 | */ 101 | virtual 102 | void 103 | reportOptima(); 104 | 105 | /** 106 | * Reports interaction boundaries only (no base pair tracking) 107 | * @param interaction the interaction to be traced 108 | */ 109 | virtual 110 | void 111 | traceBack( Interaction & interaction ); 112 | 113 | private: 114 | 115 | /** 116 | * Calls updateOptima() for each entry of Z_partition. 117 | */ 118 | virtual 119 | void 120 | updateOptimaUsingZ(); 121 | 122 | }; 123 | 124 | } // namespace 125 | 126 | #endif /* INTARNA_PREDICTORMFEENS_H_ */ 127 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfeEns2d.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_PREDICTORMFEENS2D_H_ 3 | #define INTARNA_PREDICTORMFEENS2D_H_ 4 | 5 | #include "IntaRNA/PredictorMfeEns.h" 6 | #include "IntaRNA/Interaction.h" 7 | 8 | #include 9 | 10 | namespace IntaRNA { 11 | 12 | /** 13 | * Memory efficient ensemble predictor for RNAup-like computation, i.e. full 14 | * DP-implementation without seed-heuristic, using 2D matrices 15 | * 16 | * @author Martin Raden 17 | * @author Frank Gelhausen 18 | * 19 | */ 20 | class PredictorMfeEns2d: public PredictorMfeEns { 21 | 22 | protected: 23 | 24 | //! matrix type to hold the partition functions for interaction site starts 25 | typedef boost::numeric::ublas::matrix Z2dMatrix; 26 | 27 | public: 28 | 29 | /** 30 | * Constructs a predictor and stores the energy and output handler 31 | * 32 | * @param energy the interaction energy handler 33 | * @param output the output handler to report mfe interactions to 34 | * @param predTracker the prediction tracker to be used or NULL if no 35 | * tracking is to be done; if non-NULL, the tracker gets deleted 36 | * on this->destruction. 37 | */ 38 | PredictorMfeEns2d( const InteractionEnergy & energy 39 | , OutputHandler & output 40 | , PredictionTracker * predTracker ); 41 | 42 | virtual ~PredictorMfeEns2d(); 43 | 44 | /** 45 | * Computes the mfe for the given sequence ranges (i1-j1) in the first 46 | * sequence and (i2-j2) in the second sequence and reports it to the output 47 | * handler. 48 | * 49 | * @param r1 the index range of the first sequence interacting with r2 50 | * @param r2 the index range of the second sequence interacting with r1 51 | * 52 | */ 53 | virtual 54 | void 55 | predict( const IndexRange & r1 = IndexRange(0,RnaSequence::lastPos) 56 | , const IndexRange & r2 = IndexRange(0,RnaSequence::lastPos) 57 | ); 58 | 59 | protected: 60 | 61 | //! access to the interaction energy handler of the super class 62 | using PredictorMfeEns::energy; 63 | 64 | //! access to the output handler of the super class 65 | using PredictorMfeEns::output; 66 | 67 | //! energy of all interaction hybrids that end in position p (seq1) and 68 | //! q (seq2) 69 | Z2dMatrix hybridZ; 70 | 71 | protected: 72 | 73 | /** 74 | * Computes all entries of the hybridE matrix for interactions ending in 75 | * p=j1 and q=j2 and report all valid interactions to updateZ() 76 | * 77 | * @param j1 end of the interaction within seq 1 78 | * @param j2 end of the interaction within seq 2 79 | * @param i1init smallest value for i1 80 | * @param i2init smallest value for i2 81 | * @param callUpdateZ whether or not updateZ() is to be called 82 | * 83 | */ 84 | virtual 85 | void 86 | fillHybridZ( const size_t j1, const size_t j2 87 | , const size_t i1init, const size_t i2init 88 | , const bool callUpdateZ 89 | ); 90 | 91 | }; 92 | 93 | } // namespace 94 | 95 | #endif /* INTARNA_PREDICTORMFEENS2D_H_ */ 96 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfeEns2dHeuristic.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_PREDICTORMFEENS2DHEURISTIC_H_ 3 | #define INTARNA_PREDICTORMFEENS2DHEURISTIC_H_ 4 | 5 | #include "IntaRNA/PredictorMfeEns2d.h" 6 | #include "IntaRNA/Interaction.h" 7 | 8 | #include 9 | 10 | namespace IntaRNA { 11 | 12 | /** 13 | * Memory efficient ensemble interaction predictor that uses a heuristic to 14 | * find the mfe or a close-to-mfe interaction. 15 | * 16 | * To this end, for each interaction start i1,i2 only the optimal right side 17 | * interaction with boundaries j1,j2 is considered in the recursion instead of 18 | * all possible interaction ranges. 19 | * 20 | * This yields a quadratic time and space complexity. 21 | * 22 | * @author Martin Raden 23 | * @author Frank Gelhausen 24 | * 25 | */ 26 | class PredictorMfeEns2dHeuristic: public PredictorMfeEns2d { 27 | 28 | protected: 29 | 30 | //! matrix type to hold the mfe energies and boundaries for interaction site starts 31 | typedef boost::numeric::ublas::matrix Z2dMatrix; 32 | 33 | public: 34 | 35 | /** 36 | * Constructs a predictor and stores the energy and output handler 37 | * 38 | * @param energy the interaction energy handler 39 | * @param output the output handler to report mfe interactions to 40 | * @param predTracker the prediction tracker to be used or NULL if no 41 | * tracking is to be done; if non-NULL, the tracker gets deleted 42 | * on this->destruction. 43 | */ 44 | PredictorMfeEns2dHeuristic( const InteractionEnergy & energy 45 | , OutputHandler & output 46 | , PredictionTracker * predTracker ); 47 | 48 | virtual ~PredictorMfeEns2dHeuristic(); 49 | 50 | /** 51 | * Computes the mfe for the given sequence ranges (i1-j1) in the first 52 | * sequence and (i2-j2) in the second sequence and reports it to the output 53 | * handler. 54 | * 55 | * @param r1 the index range of the first sequence interacting with r2 56 | * @param r2 the index range of the second sequence interacting with r1 57 | * 58 | */ 59 | virtual 60 | void 61 | predict( const IndexRange & r1 = IndexRange(0,RnaSequence::lastPos) 62 | , const IndexRange & r2 = IndexRange(0,RnaSequence::lastPos) ); 63 | 64 | protected: 65 | 66 | //! access to the interaction energy handler of the super class 67 | using PredictorMfeEns2d::energy; 68 | 69 | //! access to the output handler of the super class 70 | using PredictorMfeEns2d::output; 71 | 72 | //! access to the list of reported interaction ranges of the super class 73 | using PredictorMfeEns2d::reportedInteractions; 74 | 75 | //! energy of all interaction hybrids starting in i1,i2 76 | Z2dMatrix hybridZ; 77 | 78 | protected: 79 | 80 | /** 81 | * Computes all entries of the hybridE matrix 82 | * and reports all valid interactions via updateOptima() 83 | */ 84 | virtual 85 | void 86 | fillHybridZ(); 87 | 88 | /** 89 | * Identifies the next best interaction (containing a seed) 90 | * with an energy equal to or higher 91 | * than the given interaction. The new interaction will not overlap any 92 | * index range stored in reportedInteractions. 93 | * 94 | * @param curBest IN/OUT the current best interaction to be replaced with one 95 | * of equal or higher energy not overlapping with any reported 96 | * interaction so far; an interaction with energy E_INF is set, if 97 | * there is no better interaction left 98 | */ 99 | virtual 100 | void 101 | getNextBest( Interaction & curBest ); 102 | 103 | /** 104 | * Overwrites function of super class to surpress the update. 105 | * 106 | * @param i1 interaction start in seq1 107 | * @param j1 interaction end in seq1 108 | * @param i2 interaction start in seq2 109 | * @param i2 interaction end in seq2 110 | * @param curInteraction the interaction information to be used for update 111 | */ 112 | virtual 113 | void 114 | updateMfe4leftEnd(const size_t i1, const size_t j1 115 | , const size_t i2, const size_t j2 116 | , const Interaction & curInteraction ); 117 | 118 | }; 119 | 120 | } // namespace 121 | 122 | #endif /* INTARNA_PREDICTORMFEENS2DHEURISTIC_H_ */ 123 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfeEns2dSeedExtension.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INTARNA_PREDICTORMFEENS2DSEEDEXTENSION_H_ 3 | #define INTARNA_PREDICTORMFEENS2DSEEDEXTENSION_H_ 4 | 5 | #include "IntaRNA/PredictorMfeEns.h" 6 | #include "IntaRNA/SeedHandlerIdxOffset.h" 7 | 8 | namespace IntaRNA { 9 | 10 | /** 11 | * Implements seed-based space-efficient interaction prediction 12 | * based on minimizing ensemble free energy of interaction sites. 13 | * 14 | * Note, for each seed start (i1,i2) only the mfe seed is considered for the 15 | * overall interaction computation instead of considering all possible seeds 16 | * starting at (i1,i2). 17 | * 18 | * @author Frank Gelhausen 19 | * @author Martin Raden 20 | * 21 | */ 22 | class PredictorMfeEns2dSeedExtension: public PredictorMfeEns { 23 | 24 | protected: 25 | 26 | //! matrix type to hold the partition functions for interaction site starts 27 | typedef boost::numeric::ublas::matrix Z2dMatrix; 28 | 29 | public: 30 | 31 | 32 | /** 33 | * Constructs a predictor and stores the energy and output handler 34 | * 35 | * @param energy the interaction energy handler 36 | * @param output the output handler to report mfe interactions to 37 | * @param predTracker the prediction tracker to be used or NULL if no 38 | * tracking is to be done; if non-NULL, the tracker gets deleted 39 | * on this->destruction. 40 | * @param seedHandler the seed handler to be used 41 | */ 42 | PredictorMfeEns2dSeedExtension( 43 | const InteractionEnergy & energy 44 | , OutputHandler & output 45 | , PredictionTracker * predTracker 46 | , SeedHandler * seedHandler ); 47 | 48 | 49 | /** 50 | * data cleanup 51 | */ 52 | virtual ~PredictorMfeEns2dSeedExtension(); 53 | 54 | 55 | /** 56 | * Computes the mfe for the given sequence ranges (i1-j1) in the first 57 | * sequence and (i2-j2) in the second sequence and reports it to the output 58 | * handler. 59 | * 60 | * Each considered interaction contains a seed according to the seed handler 61 | * constraints. 62 | * 63 | * @param r1 the index range of the first sequence interacting with r2 64 | * @param r2 the index range of the second sequence interacting with r1 65 | * 66 | */ 67 | virtual 68 | void 69 | predict( const IndexRange & r1 = IndexRange(0,RnaSequence::lastPos) 70 | , const IndexRange & r2 = IndexRange(0,RnaSequence::lastPos) ); 71 | 72 | 73 | protected: 74 | 75 | 76 | //! access to the interaction energy handler of the super class 77 | using PredictorMfeEns::energy; 78 | 79 | //! access to the output handler of the super class 80 | using PredictorMfeEns::output; 81 | 82 | //! partition function of all interaction hybrids that start on the left side of the seed including E_init 83 | Z2dMatrix hybridZ_left; 84 | 85 | //! the seed handler (with idx offset) 86 | SeedHandlerIdxOffset seedHandler; 87 | 88 | //! partition function of all interaction hybrids that start on the right side of the seed excluding E_init 89 | Z2dMatrix hybridZ_right; 90 | 91 | protected: 92 | 93 | /** 94 | * Computes all entries of the hybridE matrix for interactions ending in 95 | * p=j1 and q=j2 and report all valid interactions to updateOptima() 96 | * 97 | * @param j1 end of the interaction within seq 1 98 | * @param j2 end of the interaction within seq 2 99 | * 100 | */ 101 | virtual 102 | void 103 | fillHybridZ_left( const size_t j1, const size_t j2 ); 104 | 105 | /** 106 | * Computes all entries of the hybridE matrix for interactions starting in 107 | * i1 and i2 and report all valid interactions to updateOptima() 108 | * 109 | * Note: (i1,i2) have to be complementary (right-most base pair of seed) 110 | * 111 | * @param i1 end of the interaction within seq 1 112 | * @param i2 end of the interaction within seq 2 113 | * 114 | */ 115 | virtual 116 | void 117 | fillHybridZ_right( const size_t i1, const size_t i2 ); 118 | 119 | /** 120 | * adds seed information and calls traceBack() of super class 121 | * @param interaction IN/OUT the interaction to fill 122 | */ 123 | virtual 124 | void 125 | traceBack( Interaction & interaction ); 126 | 127 | /** 128 | * Returns the hybridization energy of the non overlapping part of seeds 129 | * starting at si and sj 130 | * 131 | * @param si1 the index of seed1 in the first sequence 132 | * @param si2 the index of seed1 in the second sequence 133 | * @param sj1 the index of seed2 in the first sequence 134 | * @param sj2 the index of seed2 in the second sequence 135 | */ 136 | virtual 137 | E_type 138 | getNonOverlappingEnergy( const size_t si1, const size_t si2, const size_t sj1, const size_t sj2 ); 139 | 140 | // debug function 141 | void 142 | printMatrix( const Z2dMatrix & matrix ); 143 | 144 | }; 145 | 146 | } // namespace 147 | 148 | #endif /* INTARNA_PREDICTORMFEENS2DSEEDEXTENSION_H_ */ 149 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfeEnsSeedOnly.h: -------------------------------------------------------------------------------- 1 | #ifndef INTARNA_PREDICTORMFEENSSEEDONLY_H_ 2 | #define INTARNA_PREDICTORMFEENSSEEDONLY_H_ 3 | 4 | #include "IntaRNA/PredictorMfeEns.h" 5 | #include "IntaRNA/PredictorMfeSeedOnly.h" 6 | #include "IntaRNA/SeedHandlerIdxOffset.h" 7 | 8 | namespace IntaRNA { 9 | 10 | /** 11 | * Ensemble-based prediction of seed interaction only. 12 | * 13 | * @author Martin Raden 14 | * 15 | */ 16 | class PredictorMfeEnsSeedOnly: public PredictorMfeEns { 17 | 18 | public: 19 | 20 | 21 | /** 22 | * Constructs a predictor and stores the energy and output handler 23 | * 24 | * @param energy the interaction energy handler 25 | * @param output the output handler to report mfe interactions to 26 | * @param predTracker the prediction tracker to be used or NULL if no 27 | * tracking is to be done; if non-NULL, the tracker gets deleted 28 | * on this->destruction. 29 | * @param seedHandler the seed handler to be used 30 | */ 31 | PredictorMfeEnsSeedOnly( 32 | const InteractionEnergy & energy 33 | , OutputHandler & output 34 | , PredictionTracker * predTracker 35 | , SeedHandler * seedHandler ); 36 | 37 | /** 38 | * data cleanup 39 | */ 40 | virtual ~PredictorMfeEnsSeedOnly(); 41 | 42 | /** 43 | * Computes the mfe seed for the given sequence ranges (i1-j1) in the first 44 | * sequence and (i2-j2) in the second sequence and reports it to the output 45 | * handler. 46 | * 47 | * @param r1 the index range of the first sequence interacting with r2 48 | * @param r2 the index range of the second sequence interacting with r1 49 | * 50 | */ 51 | virtual 52 | void 53 | predict( const IndexRange & r1 = IndexRange(0,RnaSequence::lastPos) 54 | , const IndexRange & r2 = IndexRange(0,RnaSequence::lastPos) ); 55 | 56 | 57 | protected: 58 | 59 | 60 | //! access to the interaction energy handler of the super class 61 | using PredictorMfeEns::energy; 62 | 63 | //! access to the output handler of the super class 64 | using PredictorMfeEns::output; 65 | 66 | //! access to the output handler of the super class 67 | using PredictorMfeEns::reportedInteractions; 68 | 69 | //! the seed handler (with idx offset) 70 | SeedHandlerIdxOffset seedHandler; 71 | 72 | //! last position of a seed of interest (in index-range of seedHandler) 73 | size_t seedLastPos1; 74 | //! last position of a seed of interest (in index-range of seedHandler) 75 | size_t seedLastPos2; 76 | 77 | protected: 78 | 79 | /** 80 | * Fills a given interaction (boundaries given) with the according 81 | * hybridizing base pairs using hybridE_seed. 82 | * @param interaction IN/OUT the interaction to fill 83 | */ 84 | virtual 85 | void 86 | traceBack( Interaction & interaction ); 87 | 88 | }; 89 | 90 | ////////////////////////////////////////////////////////////////////////// 91 | 92 | } // namespace 93 | 94 | #endif /* INTARNA_PREDICTORMFEENSSEEDONLY_H_ */ 95 | -------------------------------------------------------------------------------- /src/IntaRNA/PredictorMfeSeedOnly.h: -------------------------------------------------------------------------------- 1 | #ifndef INTARNA_PREDICTORMFESEEDONLY_H_ 2 | #define INTARNA_PREDICTORMFESEEDONLY_H_ 3 | 4 | #include "IntaRNA/PredictorMfe.h" 5 | #include "IntaRNA/SeedHandlerIdxOffset.h" 6 | 7 | namespace IntaRNA { 8 | 9 | /** 10 | * Prediction of seed interaction only. 11 | * 12 | * @author Martin Mann 13 | * 14 | */ 15 | class PredictorMfeSeedOnly: public PredictorMfe { 16 | 17 | public: 18 | 19 | 20 | /** 21 | * Constructs a predictor and stores the energy and output handler 22 | * 23 | * @param energy the interaction energy handler 24 | * @param output the output handler to report mfe interactions to 25 | * @param predTracker the prediction tracker to be used or NULL if no 26 | * tracking is to be done; if non-NULL, the tracker gets deleted 27 | * on this->destruction. 28 | * @param seedHandler the seed handler to be used 29 | */ 30 | PredictorMfeSeedOnly( 31 | const InteractionEnergy & energy 32 | , OutputHandler & output 33 | , PredictionTracker * predTracker 34 | , SeedHandler * seedHandler ); 35 | 36 | 37 | /** 38 | * data cleanup 39 | */ 40 | virtual ~PredictorMfeSeedOnly(); 41 | 42 | 43 | /** 44 | * Computes the mfe seed for the given sequence ranges (i1-j1) in the first 45 | * sequence and (i2-j2) in the second sequence and reports it to the output 46 | * handler. 47 | * 48 | * @param r1 the index range of the first sequence interacting with r2 49 | * @param r2 the index range of the second sequence interacting with r1 50 | * 51 | */ 52 | virtual 53 | void 54 | predict( const IndexRange & r1 = IndexRange(0,RnaSequence::lastPos) 55 | , const IndexRange & r2 = IndexRange(0,RnaSequence::lastPos) ); 56 | 57 | 58 | protected: 59 | 60 | 61 | //! access to the interaction energy handler of the super class 62 | using PredictorMfe::energy; 63 | 64 | //! access to the output handler of the super class 65 | using PredictorMfe::output; 66 | 67 | //! access to the output handler of the super class 68 | using PredictorMfe::reportedInteractions; 69 | 70 | //! the seed handler (with idx offset) 71 | SeedHandlerIdxOffset seedHandler; 72 | 73 | //! last position of a seed of interest (in index-range of seedHandler) 74 | size_t seedLastPos1; 75 | //! last position of a seed of interest (in index-range of seedHandler) 76 | size_t seedLastPos2; 77 | 78 | protected: 79 | 80 | /** 81 | * Fills a given interaction (boundaries given) with the according 82 | * hybridizing base pairs using hybridE_seed. 83 | * @param interaction IN/OUT the interaction to fill 84 | */ 85 | virtual 86 | void 87 | traceBack( Interaction & interaction ); 88 | 89 | }; 90 | 91 | ////////////////////////////////////////////////////////////////////////// 92 | ////////////////////////////////////////////////////////////////////////// 93 | ////////////////////////////////////////////////////////////////////////// 94 | 95 | } // namespace 96 | 97 | #endif /* INTARNA_PREDICTORMFESEEDONLY_H_ */ 98 | -------------------------------------------------------------------------------- /src/IntaRNA/ReverseAccessibility.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ReverseAccessibility.cpp 3 | * 4 | * Created on: 30.06.2014 5 | * Author: Mmann 6 | */ 7 | 8 | #include "IntaRNA/ReverseAccessibility.h" 9 | 10 | namespace IntaRNA { 11 | 12 | //////////////////////////////////////////////////////////////////////////// 13 | 14 | std::string 15 | ReverseAccessibility:: 16 | getReversedString( const RnaSequence & seq ) 17 | { 18 | const RnaSequence::String_type& seqAsString = seq.asString(); 19 | // create string container 20 | std::string revStr(seqAsString.size(),'_'); 21 | // copy in reversed order 22 | std::string::reverse_iterator revStrIt = revStr.rbegin(); 23 | for (RnaSequence::String_type::const_iterator nuc = seqAsString.begin(); 24 | nuc != seqAsString.end(); ++nuc,++revStrIt) 25 | { 26 | *revStrIt = *nuc; 27 | } 28 | // return reversed string 29 | return revStr; 30 | } 31 | 32 | //////////////////////////////////////////////////////////////////////////// 33 | 34 | std::string 35 | ReverseAccessibility:: 36 | getReversedString( const std::string & seqAsString ) 37 | { 38 | // create string container 39 | std::string revStr(seqAsString.size(),'_'); 40 | // copy in reversed order 41 | std::string::reverse_iterator revStrIt = revStr.rbegin(); 42 | for (RnaSequence::String_type::const_iterator nuc = seqAsString.begin(); 43 | nuc != seqAsString.end(); ++nuc,++revStrIt) 44 | { 45 | *revStrIt = *nuc; 46 | } 47 | // return reversed string 48 | return revStr; 49 | } 50 | 51 | //////////////////////////////////////////////////////////////////////////// 52 | 53 | } // namespace 54 | -------------------------------------------------------------------------------- /src/IntaRNA/RnaSequence.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IntaRNA/RnaSequence.h" 3 | #include 4 | 5 | namespace IntaRNA { 6 | 7 | 8 | // setup static members 9 | std::locale RnaSequence::codeLocale = std::locale(); 10 | 11 | // setup allowed alphabet in lower and upper case 12 | const std::string RnaSequence::SequenceAlphabet = "ACGUN"; 13 | const std::string RnaSequence::SequenceAlphabetIUPAC = "aAuUcCgGtTrRyYsSwWkKmMbBdDhHvVnN"; 14 | 15 | // setup GU base pair code information 16 | int RnaSequence::bpGUcodes[] = { BP_pair[RnaSequence::getCodeForChar('G')][RnaSequence::getCodeForChar('U')] 17 | ,BP_pair[RnaSequence::getCodeForChar('U')][RnaSequence::getCodeForChar('G')]}; 18 | 19 | 20 | //////////////////////////////////////////////////////////////////////////// 21 | 22 | const size_t RnaSequence::lastPos = std::string::npos; 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | 26 | 27 | } // namespace 28 | -------------------------------------------------------------------------------- /src/IntaRNA/VrnaHandler.h: -------------------------------------------------------------------------------- 1 | #ifndef VIENNAHANDLER_H_ 2 | #define VIENNAHANDLER_H_ 3 | 4 | #include "IntaRNA/general.h" 5 | #include 6 | 7 | extern "C" { 8 | #include 9 | #include 10 | } 11 | 12 | namespace IntaRNA { 13 | 14 | /** 15 | * Central hub for Vienna RNA package related stuff 16 | * 17 | * @author Martin Mann 18 | * 19 | */ 20 | class VrnaHandler { 21 | 22 | public: 23 | 24 | static constexpr const char* Turner99 = "Turner99"; 25 | static constexpr const char* Turner04 = "Turner04"; 26 | static constexpr const char* Andronescu07 = "Andronescu07"; 27 | 28 | protected: 29 | 30 | //! VRNA parameter model 31 | vrna_md_t model; 32 | 33 | //! the RT constant used for the current setup 34 | Z_type RT; 35 | 36 | public: 37 | 38 | /** 39 | * Construction with global VRNA folding parameter setup 40 | * 41 | * @param vrnaParamFile name of a VRNA parameter file to be used for 42 | * parameter setup 43 | * @param temperature Folding temperature in Celsius 44 | * @param noGUclosue whether or not GU base pairs are allowed at helix ends 45 | * @param noLP whether or not lonely base pairs are considered 46 | */ 47 | VrnaHandler( 48 | Z_type temperature = 37.0 49 | , const std::string & vrnaParamFile = std::string(Turner04) 50 | , const bool noGUclosure = false 51 | , const bool noLP = false ); 52 | 53 | /** 54 | * destruction 55 | */ 56 | virtual ~VrnaHandler(); 57 | 58 | /** 59 | * Generates a new VRNA parameter model according to the global and local settings 60 | * 61 | * NOTE: you have to call vrna_md_defaults_reset() to broadcast 62 | * the model details before using non-VRNA-API-3 functions. 63 | * 64 | * @param max_bp_span Maximal distance between base pair partners within one RNA 65 | * or -1 if no constraint needed 66 | * @param window_size Size of the sliding window for locally folding within one RNA 67 | * or -1 if no constraint needed 68 | * @oaram pfScale can be used to scale pf_scale of VRNA partition function computation. 69 | * Note: only used for values >= 1.0, all other values are ignored. 70 | * @return the model to be used for VRNA computations 71 | */ 72 | vrna_md_t 73 | getModel( 74 | const int max_bp_span = -1, 75 | const int window_size = -1, 76 | const double pfScale = getPfScaleDefault() ) const; 77 | 78 | /** 79 | * Provides RT for the current setup 80 | * @return R*temperature 81 | */ 82 | Z_type 83 | getRT() const; 84 | 85 | /** 86 | * Provides RT for the given temperature 87 | * @return R*temperature 88 | */ 89 | static 90 | Z_type 91 | getRT( const Z_type temperature ); 92 | 93 | 94 | /** 95 | * Provides the default value of the ViennaRNA package for the pf_scale factor 96 | * model.sfact to be used in argument parsing etc. 97 | * @return the default model.sfact value from the ViennaRNA package 98 | */ 99 | static 100 | double 101 | getPfScaleDefault(); 102 | 103 | 104 | 105 | }; 106 | 107 | //////////////////////////////////////////////////////////////////////////// 108 | //////////////////////////////////////////////////////////////////////////// 109 | //////////////////////////////////////////////////////////////////////////// 110 | 111 | inline 112 | Z_type 113 | VrnaHandler:: 114 | getRT() const 115 | { 116 | return RT; 117 | } 118 | 119 | //////////////////////////////////////////////////////////////////////////// 120 | 121 | } // namespace 122 | 123 | #endif /* VIENNAHANDLER_H_ */ 124 | -------------------------------------------------------------------------------- /src/IntaRNA/general.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IntaRNA/general.h" 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace IntaRNA { 13 | 14 | ///////////////////////////////////////////////////////////////////// 15 | 16 | std::ostream * 17 | newOutputStream( const std::string & out ) 18 | { 19 | // check if empty or whitespace string 20 | if (boost::regex_match( out, boost::regex(R"(^\s*$)"), boost::match_perl)) { 21 | return NULL; 22 | } 23 | // open according stream 24 | if (boost::iequals(out,"STDOUT")) { 25 | return & std::cout; 26 | } else 27 | if (boost::iequals(out,"STDERR")) { 28 | return & std::cerr; 29 | } else { 30 | // file output 31 | namespace bio = boost::iostreams; 32 | bio::filtering_ostream* fstream = new bio::filtering_ostream(); 33 | BOOST_IOS::openmode fopenmode = BOOST_IOS::out; 34 | 35 | // gzipped output file stream 36 | if (out.size()>3 && boost::iequals(out.substr(out.size()-3,3),".gz")) { 37 | // gzip compression 38 | fstream->push( bio::gzip_compressor() ); 39 | // binary output 40 | fopenmode = BOOST_IOS::out | BOOST_IOS::binary; 41 | } 42 | 43 | // register final file 44 | fstream->push( bio::file_descriptor_sink( out, fopenmode ) ); 45 | 46 | // check if all went fine so far 47 | if (fstream->is_complete()) { 48 | return fstream; 49 | } else { 50 | INTARNA_CLEANUP(fstream); 51 | return NULL; 52 | } 53 | } 54 | } 55 | 56 | ///////////////////////////////////////////////////////////////////// 57 | 58 | void 59 | deleteOutputStream( std::ostream *& outStream ) 60 | { 61 | // check if something to be done 62 | if (outStream == NULL) { 63 | return; 64 | } 65 | // flush content 66 | outStream->flush(); 67 | 68 | // handle file output 69 | namespace bio = boost::iostreams; 70 | bio::filtering_ostream * outFile = dynamic_cast(outStream); 71 | if (outFile != NULL) { 72 | // ensure devices are closed on destruction 73 | outFile->set_auto_close(true); 74 | // close all file handles 75 | outFile->clear(); 76 | // delete stream 77 | INTARNA_CLEANUP(outStream); 78 | } 79 | 80 | // ensure NULL setting 81 | outStream = NULL; 82 | } 83 | 84 | ///////////////////////////////////////////////////////////////////// 85 | 86 | std::istream * 87 | newInputStream( const std::string & in ) 88 | { 89 | // check if empty or whitespace string 90 | if (boost::regex_match( in, boost::regex(R"(^\s*$)"), boost::match_perl)) { 91 | return NULL; 92 | } 93 | // open according stream 94 | if (boost::iequals(in,"STDIN")) { 95 | return & std::cin; 96 | } else { 97 | // file input 98 | namespace bio = boost::iostreams; 99 | bio::filtering_istream* fstream = new bio::filtering_istream(); 100 | BOOST_IOS::openmode fopenmode = BOOST_IOS::in; 101 | 102 | // gzipped input file stream 103 | if (in.size()>3 && boost::iequals(in.substr(in.size()-3,3),".gz")) { 104 | // gzip compression 105 | fstream->push( bio::gzip_decompressor() ); 106 | // binary input 107 | fopenmode = BOOST_IOS::in | BOOST_IOS::binary; 108 | } 109 | 110 | // register final file 111 | fstream->push( bio::file_descriptor_source( in, fopenmode ) ); 112 | 113 | // check if all went fine so far 114 | if (fstream->is_complete()) { 115 | return fstream; 116 | } else { 117 | INTARNA_CLEANUP(fstream); 118 | return NULL; 119 | } 120 | } 121 | } 122 | 123 | ///////////////////////////////////////////////////////////////////// 124 | 125 | void 126 | deleteInputStream( std::istream *& inStream ) 127 | { 128 | // check if something to be done 129 | if (inStream == NULL) { 130 | return; 131 | } 132 | 133 | // handle file input 134 | namespace bio = boost::iostreams; 135 | bio::filtering_ostream * inFile = dynamic_cast(inStream); 136 | if (inFile != NULL) { 137 | // ensure devices are closed on destruction 138 | inFile->set_auto_close(true); 139 | // close all file handles 140 | inFile->clear(); 141 | // delete stream 142 | INTARNA_CLEANUP(inStream); 143 | } 144 | 145 | // ensure NULL setting 146 | inStream = NULL; 147 | } 148 | 149 | ///////////////////////////////////////////////////////////////////// 150 | 151 | 152 | } // namespace 153 | -------------------------------------------------------------------------------- /src/IntaRNA/intarna_config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef INTARNA_CONFIG_H 2 | #define INTARNA_CONFIG_H 3 | 4 | 5 | /* 6 | * The following pre-processor definitions specify whether 7 | * or not certain features were activated upon build-time 8 | */ 9 | 10 | /* Name of package */ 11 | #ifndef INTARNA_PACKAGE 12 | #define INTARNA_PACKAGE "@PACKAGE@" 13 | #endif 14 | 15 | /* Define to the address where bug reports for this package should be sent. */ 16 | #ifndef INTARNA_PACKAGE_BUGREPORT 17 | #define INTARNA_PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" 18 | #endif 19 | 20 | /* Define to the full name of this package. */ 21 | #ifndef INTARNA_PACKAGE_NAME 22 | #define INTARNA_PACKAGE_NAME "@PACKAGE_NAME@" 23 | #endif 24 | 25 | /* Define to the full name and version of this package. */ 26 | #ifndef INTARNA_PACKAGE_STRING 27 | #define INTARNA_PACKAGE_STRING "@PACKAGE_STRING@" 28 | #endif 29 | 30 | /* Define to the one symbol short name of this package. */ 31 | #ifndef INTARNA_PACKAGE_TARNAME 32 | #define INTARNA_PACKAGE_TARNAME "@PACKAGE_TARNAME@" 33 | #endif 34 | 35 | /* Define to the home page for this package. */ 36 | #ifndef INTARNA_PACKAGE_URL 37 | #define INTARNA_PACKAGE_URL "@PACKAGE_URL@" 38 | #endif 39 | 40 | /* Define to the version of this package. */ 41 | #ifndef INTARNA_PACKAGE_VERSION 42 | #define INTARNA_PACKAGE_VERSION "@PACKAGE_VERSION@" 43 | #endif 44 | 45 | /* Version number of package */ 46 | #ifndef INTARNA_VERSION 47 | #define INTARNA_VERSION "@VERSION@" 48 | #endif 49 | 50 | 51 | /* multi-threading support */ 52 | #ifndef INTARNA_MULITHREADING 53 | #define INTARNA_MULITHREADING @INTARNA_MULITHREADING@ 54 | #endif 55 | 56 | #endif // INTARNA_CONFIG_H 57 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | # sub directories to check for Makefiles 3 | SUBDIRS = . IntaRNA bin 4 | 5 | ################################################################ 6 | # extra files to be added to distribution 7 | ################################################################ 8 | 9 | EXTRA_DIST = easylogging++.LICENCE.txt 10 | 11 | ############################################################################### 12 | # THE INTARNA LIBRARY 13 | ############################################################################### 14 | 15 | # the library names to build (note we are building static libs only) 16 | lib_LIBRARIES = libeasylogging.a 17 | 18 | # where to install the headers on the system 19 | libeasylogging_adir = $(includedir) 20 | 21 | # the list of header files that belong to the library (to be installed later) 22 | libeasylogging_a_HEADERS = easylogging++.h 23 | 24 | # the sources to add to the library and to add to the source distribution 25 | libeasylogging_a_SOURCES = easylogging++.cc 26 | 27 | ############################################################################### 28 | 29 | -------------------------------------------------------------------------------- /src/bin/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | ### std-options 3 | # check that installed programs support the --help and --version options 4 | # basic check that the program's run-time dependencies are satisfied 5 | ### subdir-objects 6 | # Place generated object files (.o) into the same directory as their source 7 | # files, in order to avoid collisions when non-recursive make is used. 8 | AUTOMAKE_OPTIONS = std-options subdir-objects 9 | 10 | AM_DEFAULT_SOURCE_EXT = .cpp 11 | 12 | ############################################################################### 13 | 14 | # the programs to be build 15 | bin_PROGRAMS = IntaRNA 16 | 17 | ############################################################################### 18 | # THE INTARNA BINARY 19 | ############################################################################### 20 | 21 | # generated intaRNA sources 22 | nodist_IntaRNA_SOURCES = \ 23 | ../config.h \ 24 | IntaRNA/intarna_config.h 25 | 26 | # intaRNA sources 27 | IntaRNA_SOURCES = IntaRNA.cpp \ 28 | CommandLineParsing.h \ 29 | CommandLineParsing.cpp 30 | 31 | IntaRNA_LDADD = $(top_builddir)/src/IntaRNA/libIntaRNA.a \ 32 | $(top_builddir)/src/libeasylogging.a 33 | 34 | ############################################################################### 35 | 36 | -------------------------------------------------------------------------------- /src/easylogging++.LICENCE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2012-2018 Zuhd Web Services 4 | Copyright (c) 2012-2018 @abumusamq 5 | 6 | https://github.com/zuhd-org/ 7 | https://zuhd.org 8 | https://muflihun.com 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy of 11 | this software and associated documentation files (the "Software"), to deal in 12 | the Software without restriction, including without limitation the rights to 13 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 14 | the Software, and to permit persons to whom the Software is furnished to do so, 15 | subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 22 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 23 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 24 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | /*.log 2 | /*.trs 3 | -------------------------------------------------------------------------------- /tests/AccessibilityBasePair_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "catch.hpp" 3 | 4 | #undef NDEBUG 5 | 6 | #include 7 | #include "IntaRNA/AccessibilityBasePair.h" 8 | 9 | using namespace IntaRNA; 10 | 11 | 12 | 13 | TEST_CASE("AccessibilityBasePair", "[AccessibilityBasePair]") { 14 | 15 | // setup easylogging++ stuff if not already done 16 | #include "testEasyLoggingSetup.icc" 17 | 18 | SECTION("ED test long") { 19 | 20 | const std::string seq = "gguccacguccaa"; 21 | RnaSequence rna("test", seq); 22 | AccessibilityBasePair acc(rna, 10, NULL); 23 | 24 | // std::cout <<"\n\n########\n"; 25 | // for (int i =0; i 7 | #include "IntaRNA/AccessibilityVrna.h" 8 | 9 | using namespace IntaRNA; 10 | 11 | 12 | 13 | TEST_CASE("AccessibilityVrna", "[AccessibilityVrna]") { 14 | 15 | // setup easylogging++ stuff if not already done 16 | #include "testEasyLoggingSetup.icc" 17 | 18 | 19 | SECTION("ED test short") { 20 | 21 | const std::string seq = "GG"; 22 | RnaSequence rna("test", seq); 23 | VrnaHandler vrnaHandler(37,"Turner04",false,false); 24 | AccessibilityVrna acc(rna, 2, NULL,vrnaHandler,2); 25 | 26 | REQUIRE( E_equal( acc.getED(0, 0), 0 ) ); 27 | REQUIRE( E_equal( acc.getED(1, 1), 0 ) ); 28 | REQUIRE( E_equal( acc.getED(0, 1), 0 ) ); 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/HelixConstraint_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "catch.hpp" 3 | 4 | #undef NDEBUG 5 | 6 | #include "IntaRNA/HelixConstraint.h" 7 | 8 | using namespace IntaRNA; 9 | 10 | TEST_CASE( "HelixConstraint", "[HelixConstraint]" ) { 11 | 12 | SECTION( "getter", "[HelixConstraint]" ) { 13 | 14 | size_t minBP= 2, maxBP = 10, maxIL=2, maxED=0, maxE=0; 15 | bool evaFullED=true; 16 | 17 | HelixConstraint hC( minBP, maxBP, maxIL, maxED, maxE, evaFullED); 18 | 19 | // check data access 20 | REQUIRE( hC.getMinBasePairs() == 2 ); 21 | REQUIRE( hC.getMaxBasePairs() == 10 ); 22 | REQUIRE( hC.getMaxIL() == 2 ); 23 | REQUIRE( hC.getMaxED() == 0 ); 24 | REQUIRE( hC.getMaxE() == 0 ); 25 | REQUIRE( hC.evalFullE() == evaFullED ); 26 | REQUIRE( hC.getMaxLength1() == 28 ); 27 | REQUIRE( hC.getMaxLength2() == 28 ); 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /tests/IndexRange_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #include "catch.hpp" 5 | 6 | #undef NDEBUG 7 | 8 | #include "IntaRNA/IndexRange.h" 9 | 10 | using namespace IntaRNA; 11 | 12 | #include 13 | 14 | TEST_CASE( "IndexRange", "[IndexRange]" ) { 15 | 16 | // setup easylogging++ stuff if not already done 17 | #include "testEasyLoggingSetup.icc" 18 | 19 | 20 | IndexRange range; 21 | 22 | SECTION("check default construction") { 23 | REQUIRE( range.isAscending() ); 24 | REQUIRE( range.from == 0 ); 25 | REQUIRE( range.to > range.from ); 26 | REQUIRE_FALSE( range.isDescending() ); 27 | REQUIRE( range.to > std::numeric_limits::max()-1 ); 28 | } 29 | 30 | SECTION("check ordering") { 31 | 32 | IndexRange r2; 33 | 34 | // equal 35 | REQUIRE_FALSE( range < r2 ); 36 | 37 | // equal from 38 | r2.to = 10; 39 | REQUIRE_FALSE( range < r2 ); 40 | REQUIRE( r2 < range ); 41 | REQUIRE( r2.isAscending() ); 42 | REQUIRE_FALSE( r2.isDescending() ); 43 | 44 | // from ordered 45 | r2.from = 10; 46 | REQUIRE( range < r2 ); 47 | REQUIRE( r2.isDescending() ); 48 | REQUIRE( r2.isAscending() ); 49 | } 50 | 51 | 52 | SECTION("check string en-/decoding") { 53 | 54 | // write to string 55 | std::stringstream s; 56 | range = (4,8); 57 | s < windows = r3.overlappingWindows(windowWidth, windowsOverlap); 76 | 77 | REQUIRE ( windows.size() == 3 ); 78 | REQUIRE ( windows[0] == rw1 ); 79 | REQUIRE ( windows[1] == rw2 ); 80 | REQUIRE ( windows[2] == rw3 ); 81 | 82 | // second example: starting with index 123, the last window is smaller than windowWidth 83 | IndexRange r4 = IndexRange(123, 151); 84 | IndexRange rw4 = IndexRange(123, 132); 85 | IndexRange rw5 = IndexRange(130, 139); 86 | IndexRange rw6 = IndexRange(137, 146); 87 | IndexRange rw7 = IndexRange(144, 151); 88 | windows = r4.overlappingWindows(windowWidth, windowsOverlap); 89 | 90 | REQUIRE ( windows.size() == 4 ); 91 | REQUIRE ( windows[0] == rw4 ); 92 | REQUIRE ( windows[1] == rw5 ); 93 | REQUIRE ( windows[2] == rw6 ); 94 | REQUIRE ( windows[3] == rw7 ); 95 | 96 | // third example: one window is enough for the whole IndexRange 97 | IndexRange r5 = IndexRange(453, 458); 98 | windows = r5.overlappingWindows(windowWidth, windowsOverlap); 99 | 100 | REQUIRE ( windows.size() == 1 ); 101 | REQUIRE ( windows[0] == r5 ); 102 | } 103 | 104 | 105 | } 106 | 107 | -------------------------------------------------------------------------------- /tests/InteractionEnergyBasePair_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "catch.hpp" 3 | 4 | #undef NDEBUG 5 | 6 | #include 7 | #include "IntaRNA/InteractionEnergyBasePair.h" 8 | #include "IntaRNA/AccessibilityDisabled.h" 9 | 10 | using namespace IntaRNA; 11 | 12 | TEST_CASE( "InteractionEnergyBasePair", "[InteractionEnergyBasePair]" ) { 13 | 14 | // setup easylogging++ stuff if not already done 15 | #include "testEasyLoggingSetup.icc" 16 | 17 | RnaSequence rna("test","ACGU"); 18 | 19 | AccessibilityDisabled acc(rna,rna.size(),NULL); 20 | ReverseAccessibility rAcc(acc); 21 | 22 | size_t maxLoop1 = 1, maxLoop2 = 2; 23 | InteractionEnergyBasePair energy( acc, rAcc, maxLoop1, maxLoop2, true, 1, Ekcal_2_E(-1.0), 1); 24 | 25 | SECTION("data access") { 26 | // check 27 | REQUIRE( &energy.getAccessibility1() == &acc ); 28 | REQUIRE( &energy.getAccessibility2().getAccessibilityOrigin() == &acc ); 29 | REQUIRE( energy.getMaxInternalLoopSize1() == maxLoop1 ); 30 | REQUIRE( energy.getMaxInternalLoopSize2() == maxLoop2 ); 31 | 32 | REQUIRE( energy.getAccessibility1().getSequence().asString().at(0) == 'A' ); 33 | REQUIRE( energy.getAccessibility2().getSequence().asString().at(0) == 'U' ); 34 | 35 | } 36 | 37 | SECTION("energy computation" ) { 38 | 39 | // dangling end check 40 | REQUIRE( energy.getE_danglingLeft(0,0) == 0.0 ); 41 | REQUIRE( energy.getE_danglingLeft(2,2) == 0.0 ); 42 | REQUIRE( energy.getE_danglingRight(0,0) == 0.0 ); 43 | REQUIRE( energy.getE_danglingRight(2,2) == 0.0 ); 44 | 45 | // dangling end check 46 | REQUIRE( energy.getE_danglingLeft(0,0) == 0.0 ); 47 | REQUIRE( energy.getE_danglingLeft(2,2) == 0.0 ); 48 | REQUIRE( energy.getE_danglingRight(0,0) == 0.0 ); 49 | REQUIRE( energy.getE_danglingRight(2,2) == 0.0 ); 50 | 51 | // init only, but interior loop called 52 | REQUIRE( energy.getE_interLeft( 0,0, 0,0 ) > 0.0 ); 53 | 54 | // base pairs possible 55 | REQUIRE( energy.getE_interLeft( 0,1, 0,1 ) < 0.0 ); 56 | 57 | // base pairs overlapping 58 | REQUIRE_FALSE( energy.getE_interLeft( 0,0, 0,1 ) < 0.0 ); 59 | REQUIRE_FALSE( energy.getE_interLeft( 0,1, 0,0 ) < 0.0 ); 60 | 61 | // base pairs not possible 62 | REQUIRE_FALSE( energy.getE_interLeft( 0,0, 1,1 ) < 0.0 ); 63 | REQUIRE_FALSE( energy.getE_interLeft( 0,1, 2,3 ) < 0.0 ); 64 | REQUIRE_FALSE( energy.getE_interLeft( 0,1, 0,2 ) < 0.0 ); 65 | REQUIRE_FALSE( energy.getE_interLeft( 0,2, 1,2 ) < 0.0 ); 66 | 67 | // loop size exceeded 68 | REQUIRE_FALSE( energy.getE_interLeft( 0,3, 1,2 ) < 0.0 ); 69 | REQUIRE_FALSE( energy.getE_interLeft( 1,2, 0,3 ) < 0.0 ); 70 | REQUIRE_FALSE( energy.getE_interLeft( 0,3, 0,3 ) < 0.0 ); 71 | 72 | } 73 | 74 | SECTION("ES computation") { 75 | REQUIRE( E_equal(energy.getES1(0, 3), Ekcal_2_E(-1.313186)) ); 76 | REQUIRE( E_equal(energy.getES2(0, 3), Ekcal_2_E(-1.313186)) ); 77 | REQUIRE( E_isINF(energy.getES1(0, 2)) ); 78 | REQUIRE( E_isINF(energy.getES1(1, 2)) ); 79 | REQUIRE( E_isINF(energy.getES2(0, 2)) ); 80 | REQUIRE( E_isINF(energy.getES2(1, 2)) ); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /tests/InteractionRange_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "catch.hpp" 4 | 5 | #undef NDEBUG 6 | 7 | #include "IntaRNA/InteractionRange.h" 8 | 9 | using namespace IntaRNA; 10 | 11 | TEST_CASE( "InteractionRange", "[InteractionRange]" ) { 12 | 13 | // setup easylogging++ stuff if not already done 14 | #include "testEasyLoggingSetup.icc" 15 | 16 | RnaSequence r("test","AACCGGUU"); 17 | 18 | 19 | SECTION("empty construction") { 20 | 21 | InteractionRange range( r, r ); 22 | 23 | REQUIRE( range.isSane() ); 24 | REQUIRE( range.s1 == &r ); 25 | REQUIRE( range.s2 == &r ); 26 | REQUIRE( range.r1.isAscending() ); 27 | REQUIRE_FALSE( range.r1.isDescending() ); 28 | REQUIRE( range.r2.isDescending() ); 29 | REQUIRE_FALSE( range.r2.isAscending() ); 30 | REQUIRE( range.r1.from < r.size() ); 31 | REQUIRE( (range.r1.to < r.size() || range.r1.to == RnaSequence::lastPos) ); 32 | REQUIRE( range.r2.from < r.size() ); 33 | REQUIRE( (range.r2.to < r.size() || range.r2.to == RnaSequence::lastPos) ); 34 | 35 | } 36 | 37 | // TODO init with interaction 38 | 39 | // TODO check operators 40 | 41 | } 42 | -------------------------------------------------------------------------------- /tests/Interaction_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "catch.hpp" 4 | 5 | #undef NDEBUG 6 | 7 | #include "IntaRNA/Interaction.h" 8 | #include "IntaRNA/InteractionRange.h" 9 | 10 | using namespace IntaRNA; 11 | 12 | TEST_CASE( "Interaction", "[Interaction]" ) { 13 | 14 | // setup easylogging++ stuff if not already done 15 | #include "testEasyLoggingSetup.icc" 16 | 17 | RnaSequence r("test","AACCGGUU"); 18 | 19 | SECTION("empty construction") { 20 | 21 | Interaction inter( r, r ); 22 | 23 | REQUIRE( inter.isEmpty() ); 24 | REQUIRE( inter.s1 == &r ); 25 | REQUIRE( inter.s2 == &r ); 26 | REQUIRE_FALSE( inter.isValid() ); 27 | } 28 | 29 | SECTION("add base pairs and sort") { 30 | 31 | Interaction inter( r, r ); 32 | 33 | inter.basePairs.push_back( Interaction::BasePair( 1, 6 ) ); 34 | REQUIRE_FALSE( inter.isEmpty() ); 35 | REQUIRE( inter.isValid() ); 36 | REQUIRE( Interaction::dotBracket(inter) == "(&)"); 37 | REQUIRE( Interaction::dotBar(inter) == "2|&7|"); 38 | 39 | inter.basePairs.push_back( Interaction::BasePair( 0, 7 ) ); 40 | REQUIRE_FALSE( inter.isEmpty() ); 41 | REQUIRE_FALSE( inter.isValid() ); 42 | 43 | inter.sort(); 44 | REQUIRE( inter.isValid() ); 45 | REQUIRE( Interaction::dotBracket(inter) == "((&))"); 46 | REQUIRE( Interaction::dotBar(inter) == "1||&7||"); 47 | 48 | inter.basePairs.push_back( Interaction::BasePair( 3, 4 ) ); 49 | REQUIRE( inter.isValid() ); 50 | REQUIRE( Interaction::dotBracket(inter) == "((.(&).))"); 51 | REQUIRE( Interaction::dotBar(inter) == "1||.|&5|.||"); 52 | 53 | } 54 | 55 | 56 | SECTION("init with interaction range") { 57 | 58 | InteractionRange range(r,r, IndexRange(0,2), IndexRange(7,5)); 59 | REQUIRE( range.isSane() ); 60 | 61 | Interaction inter(range); 62 | REQUIRE_FALSE( inter.isEmpty() ); 63 | REQUIRE( inter.isValid() ); 64 | REQUIRE( inter.basePairs.size() == 2 ); 65 | REQUIRE( inter.basePairs.at(0).first == 0 ); 66 | REQUIRE( inter.basePairs.at(0).second == 7 ); 67 | REQUIRE( inter.basePairs.at(1).first == 2 ); 68 | REQUIRE( inter.basePairs.at(1).second == 5 ); 69 | 70 | } 71 | 72 | SECTION("assign interaction range") { 73 | 74 | InteractionRange range(r,r, IndexRange(0,2), IndexRange(7,5)); 75 | REQUIRE( range.isSane() ); 76 | 77 | // empty interaction 78 | Interaction inter(r,r); 79 | REQUIRE( inter.isEmpty() ); 80 | 81 | // assignment operator 82 | inter = range; 83 | REQUIRE_FALSE( inter.isEmpty() ); 84 | REQUIRE( inter.isValid() ); 85 | REQUIRE( inter.basePairs.size() == 2 ); 86 | REQUIRE( inter.basePairs.at(0).first == 0 ); 87 | REQUIRE( inter.basePairs.at(0).second == 7 ); 88 | REQUIRE( inter.basePairs.at(1).first == 2 ); 89 | REQUIRE( inter.basePairs.at(1).second == 5 ); 90 | 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | # sub directories to check for Makefiles 3 | SUBDIRS = data . 4 | 5 | # ensure parallel test build and run 6 | AUTOMAKE_OPTIONS = parallel-tests 7 | 8 | # setup environment needed for the tests 9 | AM_TESTS_ENVIRONMENT = export INTARNABINPATH=$(abs_top_builddir); 10 | 11 | # list of tests to run 12 | TESTS = runApiTests$(EXEEXT) $(dist_check_SCRIPTS) 13 | # how to handle the tests 14 | TEST_EXTENSIONS = $(EXEEXT) .sh 15 | SH_LOG_COMPILER = $(SHELL) 16 | 17 | # the script needed for tests 18 | dist_check_SCRIPTS = runIntaRNA.sh 19 | 20 | # the program to build 21 | check_PROGRAMS = runApiTests 22 | 23 | # test sources 24 | runApiTests_SOURCES = \ 25 | catch.hpp \ 26 | testEasyLoggingSetup.icc \ 27 | AccessibilityConstraint_test.cpp \ 28 | AccessibilityFromStream_test.cpp \ 29 | AccessibilityBasePair_test.cpp \ 30 | AccessibilityVrna_test.cpp \ 31 | HelixConstraint_test.cpp \ 32 | HelixHandlerNoBulgeMax_test.cpp \ 33 | HelixHandlerNoBulgeMaxSeed_test.cpp \ 34 | HelixHandlerNoBulgeMaxIdxOffset_test.cpp \ 35 | HelixHandlerNoBulgeMaxSeedIdxOffset_test.cpp \ 36 | HelixHandlerUnpaired_test.cpp \ 37 | HelixHandlerUnpairedIdxOffset_test.cpp \ 38 | HelixHandlerUnpairedSeed_test.cpp \ 39 | HelixHandlerUnpairedSeedIdxOffset_test.cpp \ 40 | IndexRange_test.cpp \ 41 | IndexRangeList_test.cpp \ 42 | Interaction_test.cpp \ 43 | InteractionEnergyBasePair_test.cpp \ 44 | InteractionRange_test.cpp \ 45 | PredictionTrackerProfileMinE_test.cpp \ 46 | PredictionTrackerSpotProb_test.cpp \ 47 | PredictorMfe2dHelixBlockHeuristic_test.cpp \ 48 | PredictorMfe2dHelixBlockHeuristicSeed_test.cpp \ 49 | NussinovHandler_test.cpp \ 50 | RnaSequence_test.cpp \ 51 | OutputStreamHandlerSortedCsv_test.cpp \ 52 | OutputHandlerInteractionList_test.cpp \ 53 | SeedHandlerExplicit_test.cpp \ 54 | SeedHandlerNoBulge_test.cpp \ 55 | SeedHandlerMfe_test.cpp \ 56 | SeedHandlerIdxOffset_test.cpp \ 57 | runApiTests.cpp 58 | 59 | # add IntaRNA lib for linking 60 | LIBS= -L$(top_builddir)/src/IntaRNA -lIntaRNA \ 61 | -L$(top_builddir)/src -leasylogging \ 62 | @LIBS@ 63 | 64 | # add source include for compilation 65 | runApiTests_CXXFLAGS = -I$(top_builddir)/src \ 66 | @AM_CXXFLAGS@ @CXXFLAGS@ \ 67 | -DELPP_NO_LOG_TO_FILE 68 | 69 | 70 | -------------------------------------------------------------------------------- /tests/NussinovHandler_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "catch.hpp" 3 | 4 | #undef NDEBUG 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "IntaRNA/NussinovHandler.h" 11 | 12 | using namespace IntaRNA; 13 | 14 | 15 | TEST_CASE("NussinovHandler", "[NussinovHandler]") { 16 | 17 | // setup easylogging++ stuff if not already done 18 | #include "testEasyLoggingSetup.icc" 19 | 20 | SECTION("Dot bracket representation") { 21 | 22 | const std::vector> seqs = {{"gguccacguccaa", 3}, {"ggugcccg", 2}, {"gguccacguccaagguc", 6}}; 23 | for (const std::pair &seq_nuss : seqs) { 24 | const std::string &seq = seq_nuss.first; 25 | const size_t nussinovValue = seq_nuss.second; 26 | RnaSequence rna("test", seq); 27 | size_t minLoopLen = 2; 28 | std::string dotRep = NussinovHandler::dotBracket(0, seq.size() - 1, rna, minLoopLen); 29 | std::vector open; 30 | size_t nuss = 0; 31 | for (size_t i = 0; i < dotRep.size(); ++i) { 32 | if (dotRep[i] == '(') { 33 | open.push_back(i); 34 | ++nuss; 35 | } 36 | if (dotRep[i] == ')') { 37 | REQUIRE_FALSE(open.empty()); 38 | size_t j = open.back(); 39 | REQUIRE(i > minLoopLen + j); 40 | REQUIRE(RnaSequence::areComplementary(rna, rna, j, i)); 41 | open.pop_back(); 42 | } 43 | } 44 | REQUIRE(nuss == nussinovValue); 45 | } 46 | // 0123456789ABCDEFG 47 | // _______[_______]_ 48 | const std::string seq = "gguccacguccaagguc"; 49 | REQUIRE(seq.size() == 17); 50 | RnaSequence rna("test", seq); 51 | size_t minLoopLen = 2; 52 | std::string dotRep = NussinovHandler::dotBracket(7, 15, rna, minLoopLen); 53 | std::vector open; 54 | size_t nuss = 0; 55 | for (size_t i = 0; i < dotRep.size(); ++i) { 56 | if (dotRep[i] == '(') { 57 | open.push_back(i); 58 | ++nuss; 59 | } 60 | if (dotRep[i] == ')') { 61 | REQUIRE_FALSE(open.empty()); 62 | size_t j = open.back(); 63 | REQUIRE(i > minLoopLen + j); 64 | REQUIRE(RnaSequence::areComplementary(rna, rna, j + 7, i + 7)); 65 | open.pop_back(); 66 | } 67 | } 68 | REQUIRE(nuss == 3u); 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /tests/OutputHandlerInteractionList_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "catch.hpp" 3 | 4 | #undef NDEBUG 5 | 6 | #include "IntaRNA/OutputHandlerInteractionList.h" 7 | #include 8 | 9 | using namespace IntaRNA; 10 | 11 | /** 12 | * Dummy class for testing the add result 13 | */ 14 | bool OHIL_equalInteraction( const Interaction& i1 , const Interaction& i2 ) { 15 | return !(i1 < i2) && !(i2 < i1); 16 | }; 17 | 18 | TEST_CASE( "OutputHandlerInteractionList", "[OutputHandlerInteractionList]" ) { 19 | 20 | // setup easylogging++ stuff if not already done 21 | #include "testEasyLoggingSetup.icc" 22 | 23 | RnaSequence r("test","AACCGGUU"); 24 | 25 | OutputConstraint oc; 26 | 27 | SECTION("sorting") { 28 | 29 | Interaction i1(r,r); 30 | i1.basePairs.push_back( Interaction::BasePair(0,7)); 31 | i1.basePairs.push_back( Interaction::BasePair(1,6)); 32 | i1.energy = 0; 33 | REQUIRE( i1.isValid() ); 34 | 35 | OutputHandlerInteractionList out(oc, 2); 36 | REQUIRE( out.empty() ); 37 | 38 | out.add(i1); 39 | REQUIRE( ! out.empty() ); 40 | auto outIt = out.begin(); 41 | REQUIRE( OHIL_equalInteraction( **outIt, i1) ); 42 | outIt++; 43 | REQUIRE( outIt == out.end() ); 44 | 45 | Interaction i2(i1); 46 | i2.energy = -1; 47 | REQUIRE( i2.isValid() ); 48 | 49 | // insert (should be new first element) 50 | out.add(i2); 51 | REQUIRE( ! out.empty() ); 52 | outIt = out.begin(); 53 | REQUIRE( OHIL_equalInteraction( **outIt, i2) ); 54 | outIt++; 55 | REQUIRE( outIt != out.end() ); 56 | REQUIRE( OHIL_equalInteraction( **outIt, i1) ); 57 | outIt++; 58 | REQUIRE( outIt == out.end() ); 59 | 60 | } 61 | 62 | 63 | SECTION("double insertion") { 64 | 65 | Interaction i(r,r); 66 | i.basePairs.push_back( Interaction::BasePair(0,7)); 67 | i.basePairs.push_back( Interaction::BasePair(1,6)); 68 | i.energy = 0; 69 | REQUIRE( i.isValid() ); 70 | 71 | OutputHandlerInteractionList out(oc,2); 72 | REQUIRE( out.empty() ); 73 | 74 | out.add(i); 75 | REQUIRE( ! out.empty() ); 76 | auto outIt = out.begin(); 77 | REQUIRE( OHIL_equalInteraction( **outIt, i) ); 78 | outIt++; 79 | REQUIRE( outIt == out.end() ); 80 | 81 | // insert a second time (should cause no insertion) 82 | out.add(i); 83 | REQUIRE( ! out.empty() ); 84 | outIt = out.begin(); 85 | REQUIRE( OHIL_equalInteraction( **outIt, i) ); 86 | outIt++; 87 | REQUIRE( outIt == out.end() ); 88 | 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /tests/OutputStreamHandlerSortedCsv_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "catch.hpp" 3 | 4 | #undef NDEBUG 5 | 6 | #include "IntaRNA/OutputStreamHandlerSortedCsv.h" 7 | #include "IntaRNA/InteractionEnergyBasePair.h" 8 | #include "IntaRNA/AccessibilityDisabled.h" 9 | 10 | #include 11 | 12 | using namespace IntaRNA; 13 | 14 | TEST_CASE( "OutputStreamHandlerSortedCsv", "[OutputStreamHandlerSortedCsv]" ) { 15 | 16 | // setup easylogging++ stuff if not already done 17 | #include "testEasyLoggingSetup.icc" 18 | 19 | const std::string csvUnsorted = 20 | "id1,start1,E,id2\n" 21 | "eee,45|000,+5,cc\n" 22 | "bbb,00|105,-5,ee\n" 23 | "aaa,7|0005,20,bb\n" 24 | "ege,005|23,00,aa\n" 25 | ; 26 | const std::string csvSorted0 = 27 | "id1,start1,E,id2\n" 28 | "aaa,7|0005,20,bb\n" 29 | "bbb,00|105,-5,ee\n" 30 | "eee,45|000,+5,cc\n" 31 | "ege,005|23,00,aa\n" 32 | ; 33 | const std::string csvSorted1 = 34 | "id1,start1,E,id2\n" 35 | "bbb,00|105,-5,ee\n" 36 | "ege,005|23,00,aa\n" 37 | "aaa,7|0005,20,bb\n" 38 | "eee,45|000,+5,cc\n" 39 | ; 40 | const std::string csvSorted2 = 41 | "id1,start1,E,id2\n" 42 | "bbb,00|105,-5,ee\n" 43 | "ege,005|23,00,aa\n" 44 | "eee,45|000,+5,cc\n" 45 | "aaa,7|0005,20,bb\n" 46 | ; 47 | const std::string csvSorted3 = 48 | "id1,start1,E,id2\n" 49 | "ege,005|23,00,aa\n" 50 | "aaa,7|0005,20,bb\n" 51 | "eee,45|000,+5,cc\n" 52 | "bbb,00|105,-5,ee\n" 53 | ; 54 | 55 | SECTION("sort id1") { 56 | std::stringstream outStream; 57 | { 58 | OutputStreamHandlerSortedCsv oshSorted( new OutputStreamHandler(&outStream), 0, true, ",", true); 59 | oshSorted.getOutStream() << csvUnsorted; 60 | } // ensure oshSorted is destroyed 61 | REQUIRE( outStream.str() == csvSorted0 ); 62 | } 63 | 64 | SECTION("sort start1 list") { 65 | std::stringstream outStream; 66 | { 67 | OutputStreamHandlerSortedCsv oshSorted( new OutputStreamHandler(&outStream), 1, false, ",", true,"|"); 68 | oshSorted.getOutStream() << csvUnsorted; 69 | } // ensure oshSorted is destroyed 70 | REQUIRE( outStream.str() == csvSorted1 ); 71 | } 72 | 73 | SECTION("sort E") { 74 | std::stringstream outStream; 75 | { 76 | OutputStreamHandlerSortedCsv oshSorted( new OutputStreamHandler(&outStream), 2, false, ",", true); 77 | oshSorted.getOutStream() << csvUnsorted; 78 | } // ensure oshSorted is destroyed 79 | REQUIRE( outStream.str() == csvSorted2 ); 80 | } 81 | 82 | SECTION("sort E pseudo list") { 83 | std::stringstream outStream; 84 | { 85 | OutputStreamHandlerSortedCsv oshSorted( new OutputStreamHandler(&outStream), 2, false, ",", true, "|"); 86 | oshSorted.getOutStream() << csvUnsorted; 87 | } // ensure oshSorted is destroyed 88 | REQUIRE( outStream.str() == csvSorted2 ); 89 | } 90 | 91 | SECTION("sort id2") { 92 | std::stringstream outStream; 93 | { 94 | OutputStreamHandlerSortedCsv oshSorted( new OutputStreamHandler(&outStream), 3, true, ",", true); 95 | oshSorted.getOutStream() << csvUnsorted; 96 | } // ensure oshSorted is destroyed 97 | REQUIRE( outStream.str() == csvSorted3 ); 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /tests/PredictionTrackerProfileMinE_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "catch.hpp" 3 | 4 | #undef NDEBUG 5 | 6 | #include "IntaRNA/PredictionTrackerProfileMinE.h" 7 | #include "IntaRNA/AccessibilityDisabled.h" 8 | #include "IntaRNA/ReverseAccessibility.h" 9 | #include "IntaRNA/InteractionEnergyBasePair.h" 10 | 11 | #include 12 | 13 | using namespace IntaRNA; 14 | 15 | 16 | TEST_CASE( "PredictionTrackerProfileMinE", "[PredictionTrackerProfileMinE]" ) { 17 | 18 | // setup easylogging++ stuff if not already done 19 | #include "testEasyLoggingSetup.icc" 20 | 21 | // setup dummy data 22 | RnaSequence r1("r1","AACCG"); 23 | RnaSequence r2("r2","AGUUNNNN"); 24 | AccessibilityDisabled acc1(r1, 0, NULL); 25 | AccessibilityDisabled acc2(r2, 0, NULL); 26 | ReverseAccessibility racc( acc2 ); 27 | InteractionEnergyBasePair energy( acc1, racc ); 28 | 29 | SECTION("empty output") { 30 | // output streams 31 | std::stringstream s1out, s2out; 32 | 33 | // create and directly destroy 34 | PredictionTrackerProfileMinE * tracker = new PredictionTrackerProfileMinE( energy, &s1out, &s2out, "X"); 35 | // destroy to flush output 36 | delete tracker; tracker = NULL; 37 | 38 | // LOG(DEBUG)<<"1.s1:\n"<updateOptimumCalled( 0,1, 4,5, 2.0 ); 54 | // destroy to flush output 55 | delete tracker; tracker = NULL; 56 | 57 | // LOG(DEBUG)<<"2.s1:\n"<updateOptimumCalled( 0,1, 4,5, 2.0 ); 74 | tracker->updateOptimumCalled( 1,2, 5,6, 1.0 ); 75 | // destroy to flush output 76 | delete tracker; tracker = NULL; 77 | 78 | // LOG(DEBUG)<<"3.s1:\n"< 12 | 13 | using namespace IntaRNA; 14 | 15 | 16 | TEST_CASE( "PredictionTrackerSpotProb", "[PredictionTrackerSpotProb]" ) { 17 | 18 | // setup easylogging++ stuff if not already done 19 | #include "testEasyLoggingSetup.icc" 20 | 21 | // setup dummy data 22 | RnaSequence r1("r1","AACCG"); 23 | RnaSequence r2("r2","AGUUNNNN"); 24 | AccessibilityDisabled acc1(r1, 0, NULL); 25 | AccessibilityDisabled acc2(r2, 0, NULL); 26 | ReverseAccessibility racc( acc2 ); 27 | InteractionEnergyBasePair energy( acc1, racc ); 28 | 29 | SECTION("empty tracking") { 30 | // output streams 31 | std::stringstream out; 32 | 33 | // create and directly destroy 34 | PredictionTrackerSpotProb * tracker = new PredictionTrackerSpotProb( energy, "", out); 35 | // destroy to flush output 36 | delete tracker; tracker = NULL; 37 | 38 | // LOG(DEBUG)<<"empty tracking: "<updateOptimumCalled( 0,1, 4,5, 2.0 ); 70 | // destroy to flush output 71 | delete tracker; tracker = NULL; 72 | 73 | // check output 74 | REQUIRE( out.str() == "spot;probability\n0&0;1\n1&1;0\n" ); 75 | } 76 | 77 | 78 | SECTION("single update - match") { 79 | // output streams 80 | std::stringstream out; 81 | 82 | // create 83 | PredictionTrackerSpotProb * tracker = new PredictionTrackerSpotProb( energy, "1&4", out); 84 | // add range 85 | // AACCG 86 | // 01234567 87 | // NNNNUUGA.AGUUNNNN 88 | tracker->updateOptimumCalled( 0,1, 4,5, 2.0 ); 89 | // destroy to flush output 90 | delete tracker; tracker = NULL; 91 | 92 | // check output 93 | REQUIRE( out.str() == "spot;probability\n0&0;0\n1&4;1\n" ); 94 | } 95 | 96 | 97 | SECTION("single update - mix") { 98 | // output streams 99 | std::stringstream out; 100 | 101 | // create 102 | PredictionTrackerSpotProb * tracker = new PredictionTrackerSpotProb( energy, "1&3,5&4", out); 103 | // add range 104 | // AACCG 105 | // 01234567 01234567 106 | // NNNNUUGA.AGUUNNNN 107 | tracker->updateOptimumCalled( 0,1, 4,5, 2.0 ); // 1&3 108 | // destroy to flush output 109 | delete tracker; tracker = NULL; 110 | 111 | // check output 112 | REQUIRE( out.str() == "spot;probability\n0&0;0\n1&3;1\n5&4;0\n" ); 113 | } 114 | 115 | SECTION("double update - mix") { 116 | // output streams 117 | std::stringstream out; 118 | 119 | // create 120 | PredictionTrackerSpotProb * tracker = new PredictionTrackerSpotProb( energy, "1&3,5&4", out); 121 | // add range 122 | // AACCG 123 | // 01234567 01234567 124 | // NNNNUUGA.AGUUNNNN 125 | tracker->updateOptimumCalled( 0,1, 4,5, 2.0 ); // 1&3 126 | tracker->updateOptimumCalled( 4,4, 5,5, 2.0 ); // none 127 | // destroy to flush output 128 | delete tracker; tracker = NULL; 129 | 130 | // check output 131 | REQUIRE( out.str() == "spot;probability\n0&0;0.5\n1&3;0.5\n5&4;0\n" ); 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /tests/PredictorMfe2dHelixBlockHeuristicSeed_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "catch.hpp" 3 | 4 | #undef NDEBUG 5 | #define protected public 6 | 7 | #include "IntaRNA/RnaSequence.h" 8 | #include "IntaRNA/AccessibilityDisabled.h" 9 | #include "IntaRNA/HelixConstraint.h" 10 | #include "IntaRNA/InteractionEnergyBasePair.h" 11 | #include "IntaRNA/Interaction.h" 12 | #include "IntaRNA/ReverseAccessibility.h" 13 | #include "IntaRNA/PredictorMfe2dHelixBlockHeuristicSeed.h" 14 | #include "IntaRNA/SeedHandlerMfe.h" 15 | #include "IntaRNA/OutputHandlerInteractionList.h" 16 | 17 | using namespace IntaRNA; 18 | 19 | TEST_CASE( "PredictorMfe2dHelixBlockHeuristicSeed", "[PredictorMfe2dHelixBlockHeuristicSeed]") { 20 | 21 | SECTION("Predictor: Case 1", "[PredictorMfe2dHelixBlockHeuristicSeed]") { 22 | 23 | RnaSequence r1("r1", "GGGAAGG"); 24 | RnaSequence r2("r2", "CCAACCC"); 25 | AccessibilityDisabled acc1(r1, 0, NULL); 26 | AccessibilityDisabled acc2(r2, 0, NULL); 27 | ReverseAccessibility racc(acc2); 28 | InteractionEnergyBasePair energy(acc1, racc); 29 | 30 | HelixConstraint hc(2, 4, 0, 999, 0, false); 31 | // seedBP / seedMaxUP / seedTMaxUP / seedQMaxUP / seedMaxE / seedMaxED / seedTRange / seedQRange / seedTQ 32 | SeedConstraint sC(3, 0, 0, 0, 0, AccessibilityDisabled::ED_UPPER_BOUND, 0, IndexRangeList(""), IndexRangeList(""), 33 | "", false, false, false ); 34 | 35 | OutputConstraint outC(1, OutputConstraint::OVERLAP_SEQ2, 0, 100); 36 | OutputHandlerInteractionList out(outC,1); 37 | 38 | PredictorMfe2dHelixBlockHeuristicSeed pLSH(energy, out, NULL, hc, new SeedHandlerMfe(energy, sC)); 39 | 40 | IndexRange idx1(0, r1.lastPos); 41 | IndexRange idx2(0, r2.lastPos); 42 | 43 | pLSH.predict(idx1, idx2); 44 | 45 | REQUIRE_FALSE(out.empty()); 46 | REQUIRE(out.reported() == 1); 47 | 48 | const Interaction *interaction((*out.begin())); 49 | REQUIRE(interaction->basePairs.begin()->first == 0); 50 | REQUIRE(interaction->basePairs.begin()->second == 6); 51 | 52 | REQUIRE(interaction->basePairs.rbegin()->first == 6); 53 | REQUIRE(interaction->basePairs.rbegin()->second == 0); 54 | 55 | REQUIRE(interaction->dotBracket(*interaction) == "(((..((&))..)))"); 56 | } 57 | 58 | SECTION("Predictor: Case 2", "[PredictorMfe2dHelixBlockHeuristicSeed]") { 59 | 60 | RnaSequence r1("r1", "GGGAGG"); 61 | RnaSequence r2("r2", "CCAACCC"); 62 | AccessibilityDisabled acc1(r1, 0, NULL); 63 | AccessibilityDisabled acc2(r2, 0, NULL); 64 | ReverseAccessibility racc(acc2); 65 | InteractionEnergyBasePair energy(acc1, racc); 66 | 67 | HelixConstraint hc(2, 4, 0, 999, 0, false); 68 | // seedBP / seedMaxUP / seedTMaxUP / seedQMaxUP / seedMaxE / seedMaxED / seedTRange / seedQRange / seedTQ 69 | SeedConstraint sC(3, 0, 0, 0, 0, AccessibilityDisabled::ED_UPPER_BOUND, 0, IndexRangeList(""), IndexRangeList(""), 70 | "", false, false, false ); 71 | 72 | SeedHandlerMfe sH(energy, sC); 73 | OutputConstraint outC(1, OutputConstraint::OVERLAP_SEQ2, 0, 100); 74 | OutputHandlerInteractionList out(outC,1); 75 | 76 | PredictorMfe2dHelixBlockHeuristicSeed pLSH(energy, out, NULL, hc, new SeedHandlerMfe(energy, sC)); 77 | 78 | IndexRange idx1(0, r1.lastPos); 79 | IndexRange idx2(0, r2.lastPos); 80 | 81 | pLSH.predict(idx1, idx2); 82 | 83 | REQUIRE_FALSE(out.empty()); 84 | REQUIRE(out.reported() == 1); 85 | 86 | const Interaction *interaction((*out.begin())); 87 | 88 | REQUIRE(interaction->basePairs.begin()->first == 0); 89 | REQUIRE(interaction->basePairs.begin()->second == 6); 90 | 91 | REQUIRE(interaction->basePairs.rbegin()->first == 5); 92 | REQUIRE(interaction->basePairs.rbegin()->second == 0); 93 | 94 | REQUIRE(interaction->dotBracket(*interaction) == "(((.((&))..)))"); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /tests/RnaSequence_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "catch.hpp" 3 | 4 | #undef NDEBUG 5 | 6 | #include "IntaRNA/RnaSequence.h" 7 | 8 | using namespace IntaRNA; 9 | 10 | TEST_CASE( "RnaSequence", "[RNAsequence]" ) { 11 | 12 | // setup easylogging++ stuff if not already done 13 | #include "testEasyLoggingSetup.icc" 14 | 15 | 16 | SECTION( "sequence with non-ACGU" ) { 17 | bool exceptionRaised = ! RnaSequence::isValidSequenceIUPAC("ACUGAC_error"); 18 | REQUIRE( exceptionRaised ); 19 | } 20 | 21 | SECTION( "getter", "[RNAsequence]" ) { 22 | 23 | std::string id= "test", seq="AAAUUUGGGCCC"; 24 | 25 | RnaSequence rna(id, seq); 26 | 27 | // check data access 28 | REQUIRE( rna.size() == seq.size() ); 29 | REQUIRE( rna.getId() == id ); 30 | REQUIRE( rna.asString() == seq ); 31 | REQUIRE( rna.asCodes().size() == seq.size() ); 32 | } 33 | 34 | 35 | SECTION( "areComplementary()" ) { 36 | 37 | std::string id= "test", seq="AAAUUUGGGCCC"; 38 | 39 | RnaSequence rna(id, seq); 40 | 41 | // check complementarity 42 | REQUIRE( RnaSequence::areComplementary( rna, rna, 0, 3) ); 43 | REQUIRE_FALSE( RnaSequence::areComplementary( rna, rna, 0, 6) ); 44 | REQUIRE_FALSE( RnaSequence::areComplementary( rna, rna, 0, 9) ); 45 | REQUIRE( RnaSequence::areComplementary( rna, rna, 3, 6) ); 46 | REQUIRE_FALSE( RnaSequence::areComplementary( rna, rna, 3, 9) ); 47 | REQUIRE( RnaSequence::areComplementary( rna, rna, 6, 9) ); 48 | 49 | } 50 | 51 | SECTION( "isGU()" ) { 52 | 53 | std::string id= "test", seq="AAAUUUGGGCCC"; 54 | 55 | RnaSequence rna(id, seq); 56 | 57 | // check complementarity 58 | REQUIRE( RnaSequence::isGU( rna, rna, 3, 6) ); 59 | REQUIRE( RnaSequence::isGU( rna, rna, 7, 4) ); 60 | REQUIRE_FALSE( RnaSequence::isGU( rna, rna, 0, 3) ); 61 | REQUIRE_FALSE( RnaSequence::isGU( rna, rna, 3, 0) ); 62 | REQUIRE_FALSE( RnaSequence::isGU( rna, rna, 0, 6) ); 63 | REQUIRE_FALSE( RnaSequence::isGU( rna, rna, 6, 0) ); 64 | REQUIRE_FALSE( RnaSequence::isGU( rna, rna, 0, 9) ); 65 | REQUIRE_FALSE( RnaSequence::isGU( rna, rna, 9, 0) ); 66 | REQUIRE_FALSE( RnaSequence::isGU( rna, rna, 3, 9) ); 67 | REQUIRE_FALSE( RnaSequence::isGU( rna, rna, 9, 3) ); 68 | REQUIRE_FALSE( RnaSequence::isGU( rna, rna, 6, 9) ); 69 | REQUIRE_FALSE( RnaSequence::isGU( rna, rna, 9, 6) ); 70 | 71 | } 72 | 73 | SECTION( "operator==()" ) { 74 | 75 | std::string id= "test", seq="AAAUUUGGGCCC"; 76 | 77 | RnaSequence rna(id, seq); 78 | 79 | // check equality 80 | REQUIRE( rna == rna ); 81 | REQUIRE( rna == RnaSequence(id,seq) ); 82 | REQUIRE( RnaSequence(id,seq) == rna ); 83 | REQUIRE_FALSE( rna == RnaSequence(id,seq+"A") ); 84 | REQUIRE_FALSE( RnaSequence(id,seq+"A") == rna ); 85 | REQUIRE_FALSE( rna == RnaSequence(id+"2",seq) ); 86 | REQUIRE_FALSE( RnaSequence(id+"2",seq) == rna ); 87 | REQUIRE_FALSE( rna == RnaSequence(id+"2",seq+"A") ); 88 | REQUIRE_FALSE( RnaSequence(id+"2",seq+"A") == rna ); 89 | } 90 | 91 | SECTION( "getInOutIndex() + getIndex()" ) { 92 | 93 | std::string id= "test", seq="AAAUUUGGGCCC"; 94 | 95 | RnaSequence rna(id, seq, 0); 96 | // check index conversion 97 | REQUIRE( rna.getInOutIndex(0) == 0 ); 98 | REQUIRE( rna.getIndex(rna.getInOutIndex(0)) == 0 ); 99 | REQUIRE( rna.getInOutIndex(3) == 3 ); 100 | REQUIRE( rna.getIndex(rna.getInOutIndex(3)) == 3 ); 101 | 102 | rna = RnaSequence(id, seq, -3); 103 | // check index conversion 104 | REQUIRE( rna.getInOutIndex(0) == -3 ); 105 | REQUIRE( rna.getIndex(rna.getInOutIndex(0)) == 0 ); 106 | REQUIRE( rna.getInOutIndex(3) == 1 ); 107 | REQUIRE( rna.getIndex(rna.getInOutIndex(3)) == 3 ); 108 | 109 | rna = RnaSequence(id, seq, 3); 110 | // check index conversion 111 | REQUIRE( rna.getInOutIndex(0) == 3 ); 112 | REQUIRE( rna.getIndex(rna.getInOutIndex(0)) == 0 ); 113 | REQUIRE( rna.getInOutIndex(3) == 6 ); 114 | REQUIRE( rna.getIndex(rna.getInOutIndex(3)) == 3 ); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /tests/SeedHandlerIdxOffset_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "catch.hpp" 3 | 4 | #undef NDEBUG 5 | #define protected public 6 | 7 | #include "IntaRNA/RnaSequence.h" 8 | #include "IntaRNA/AccessibilityDisabled.h" 9 | #include "IntaRNA/InteractionEnergyBasePair.h" 10 | #include "IntaRNA/SeedHandlerNoBulge.h" 11 | #include "IntaRNA/SeedHandlerIdxOffset.h" 12 | 13 | #include 14 | 15 | using namespace IntaRNA; 16 | 17 | TEST_CASE( "SeedHandlerMfe with offset", "[SeedHandlerIdxOffset]") { 18 | 19 | SECTION("SeedHandlerMfe: Case 1 - offset 1", "[SeedHandlerIdxOffset]") { 20 | RnaSequence r1("r1", "GGGGGG"); 21 | RnaSequence r2("r2", "CCCCCG"); 22 | AccessibilityDisabled acc1(r1, 0, NULL); 23 | AccessibilityDisabled acc2(r2, 0, NULL); 24 | ReverseAccessibility racc(acc2); 25 | InteractionEnergyBasePair energy(acc1, racc); 26 | 27 | // seedBP / seedMaxUP / seedTMaxUP / seedQMaxUP / seedMaxE / seedMaxED / seedTRange / seedQRange / seedTQ 28 | SeedConstraint sC(3,0,0,0,0 29 | , AccessibilityDisabled::ED_UPPER_BOUND 30 | , 0 31 | , IndexRangeList("") 32 | , IndexRangeList("") 33 | , "" 34 | , false, false, false ); 35 | 36 | SeedHandlerNoBulge shOrig(energy, sC); 37 | SeedHandlerIdxOffset shIO( &shOrig, false ); 38 | 39 | shIO.setOffset1(1); 40 | shIO.setOffset2(1); 41 | 42 | ////////////////////////////////////////////////////////////////////////////////////////////////////////// 43 | ///////////////////////////////////////////// FILLSEED //////////////////////////////////////////////// 44 | ////////////////////////////////////////////////////////////////////////////////////////////////////////// 45 | 46 | // we omit 3 of 12 possible seeds (with i1==0) 47 | REQUIRE(shIO.fillSeed(0,energy.size1()-shIO.getOffset1()-1, 0,energy.size2()-shIO.getOffset2()-1) == 9); 48 | 49 | size_t i1=10, i2=10; 50 | 51 | // generate sorted list of seed starts without offset 52 | std::set< Interaction::BasePair > ioSeeds; 53 | while (shIO.updateToNextSeed(i1,i2)) { 54 | ioSeeds.insert( Interaction::BasePair(i1+shIO.getOffset1(),i2+shIO.getOffset2()) ); 55 | } 56 | 57 | i1=10; i2=10; 58 | size_t count = 0; 59 | // check for list of seed starts without offset 60 | while (shOrig.updateToNextSeed(i1,i2, shIO.getOffset1(), 10, shIO.getOffset2(), 10)) { 61 | count++; 62 | REQUIRE( ioSeeds.find( Interaction::BasePair(i1,i2) ) != ioSeeds.end() ); 63 | } 64 | REQUIRE( count == 9 ); 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /tests/data/.gitignore: -------------------------------------------------------------------------------- 1 | /*.testout 2 | -------------------------------------------------------------------------------- /tests/data/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | EXTRA_DIST = *.parameter *.testresult 3 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-exact-seed-modelS.parameter: -------------------------------------------------------------------------------- 1 | model=S 2 | mode=M 3 | noSeed=false 4 | seedBP=3 5 | energy=B 6 | tAcc=N 7 | qAcc=N 8 | target=CCAACCCACC 9 | query=GGGG 10 | outMode=C 11 | outNumber=10 12 | outOverlap=B 13 | outDeltaE=0 14 | outNoLP=false 15 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-exact-seed-modelS.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;7;query;1;4;CCAACCC&GGGG;(...(((&))));-4 3 | target;2;7;query;1;4;CAACCC&GGGG;(..(((&))));-4 4 | target;5;9;query;1;4;CCCAC&GGGG;(((.(&))));-4 5 | target;5;10;query;1;4;CCCACC&GGGG;(((..(&))));-4 6 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-exact-seed-modelX.parameter: -------------------------------------------------------------------------------- 1 | model=X 2 | mode=M 3 | noSeed=false 4 | seedBP=3 5 | energy=B 6 | tAcc=N 7 | qAcc=N 8 | target=CCAACCCACC 9 | query=GGGG 10 | outMode=C 11 | outNumber=10 12 | outOverlap=B 13 | outDeltaE=0 14 | outNoLP=false 15 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-exact-seed-modelX.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;7;query;1;4;CCAACCC&GGGG;(...(((&))));-4 3 | target;2;7;query;1;4;CAACCC&GGGG;(..(((&))));-4 4 | target;5;9;query;1;4;CCCAC&GGGG;(((.(&))));-4 5 | target;5;10;query;1;4;CCCACC&GGGG;(((..(&))));-4 6 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-exact.parameter: -------------------------------------------------------------------------------- 1 | mode=M 2 | noSeed=true 3 | model=S 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | target=CCAACACC 8 | query=GG 9 | outMode=C 10 | outNumber=20 11 | outOverlap=B 12 | outDeltaE=0 13 | outNoLP=false 14 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-exact.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;2;query;1;2;CC&GG;((&));-2 3 | target;1;5;query;1;2;CCAAC&GG;(...(&));-2 4 | target;1;7;query;1;2;CCAACAC&GG;(.....(&));-2 5 | target;1;8;query;1;2;CCAACACC&GG;(......(&));-2 6 | target;2;5;query;1;2;CAAC&GG;(..(&));-2 7 | target;2;7;query;1;2;CAACAC&GG;(....(&));-2 8 | target;2;8;query;1;2;CAACACC&GG;(.....(&));-2 9 | target;5;7;query;1;2;CAC&GG;(.(&));-2 10 | target;5;8;query;1;2;CACC&GG;(..(&));-2 11 | target;7;8;query;1;2;CC&GG;((&));-2 12 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-heuristic-seed-modelS.parameter: -------------------------------------------------------------------------------- 1 | model=S 2 | mode = H 3 | seedBP=3 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | target=CCAACCCACC 8 | query=GGGG 9 | outMode=C 10 | outNumber=10 11 | outOverlap=B 12 | outDeltaE=0 13 | outNoLP=false 14 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-heuristic-seed-modelS.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;7;query;1;4;CCAACCC&GGGG;(...(((&))));-4 3 | target;2;7;query;1;4;CAACCC&GGGG;(..(((&))));-4 4 | target;5;9;query;1;4;CCCAC&GGGG;(((.(&))));-4 5 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-heuristic-seed-modelX.parameter: -------------------------------------------------------------------------------- 1 | model=X 2 | mode = H 3 | seedBP=3 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | target=CCAACCCACC 8 | query=GGGG 9 | outMode=C 10 | outNumber=10 11 | outOverlap=B 12 | outDeltaE=0 13 | outNoLP=false 14 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-heuristic-seed-modelX.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;7;query;1;4;CCAACCC&GGGG;(...(((&))));-4 3 | target;2;7;query;1;4;CAACCC&GGGG;(..(((&))));-4 4 | target;5;9;query;1;4;CCCAC&GGGG;(((.(&))));-4 5 | target;5;10;query;1;4;CCCACC&GGGG;(((..(&))));-4 6 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-heuristic.parameter: -------------------------------------------------------------------------------- 1 | mode=H 2 | noSeed=true 3 | model=S 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | target=CCAACCCACC 8 | query=GGGG 9 | outMode=C 10 | outNumber=10 11 | outOverlap=B 12 | outDeltaE=0 13 | outNoLP=false 14 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-heuristic.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;6;query;1;4;CCAACC&GGGG;((..((&))));-4 3 | target;2;7;query;1;4;CAACCC&GGGG;(..(((&))));-4 4 | target;5;9;query;1;4;CCCAC&GGGG;(((.(&))));-4 5 | target;6;10;query;1;4;CCACC&GGGG;((.((&))));-4 6 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-exact-seed-modelS.parameter: -------------------------------------------------------------------------------- 1 | model=S 2 | mode=M 3 | noSeed=false 4 | seedBP=3 5 | energy=B 6 | tAcc=N 7 | qAcc=N 8 | target=CCAACCCACC 9 | query=GGGG 10 | outMode=C 11 | outNumber=10 12 | outOverlap=B 13 | outDeltaE=0 14 | outNoLP=true 15 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-exact-seed-modelS.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;5;7;query;1;3;CCC&GGG;(((&)));-3 3 | target;5;7;query;2;4;CCC&GGG;(((&)));-3 4 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-exact-seed-modelX.parameter: -------------------------------------------------------------------------------- 1 | model=X 2 | mode=M 3 | noSeed=false 4 | seedBP=3 5 | energy=B 6 | tAcc=N 7 | qAcc=N 8 | target=CCAACCCACC 9 | query=GGGG 10 | outMode=C 11 | outNumber=10 12 | outOverlap=B 13 | outDeltaE=0 14 | outNoLP=true 15 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-exact-seed-modelX.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;5;7;query;1;3;CCC&GGG;(((&)));-3 3 | target;5;7;query;2;4;CCC&GGG;(((&)));-3 4 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-exact.parameter: -------------------------------------------------------------------------------- 1 | mode = M 2 | noSeed=true 3 | model=S 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | target=CCAACCCACC 8 | query=GGGG 9 | outMode=C 10 | outNumber=10 11 | outOverlap=B 12 | outDeltaE=0 13 | outNoLP=true 14 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-exact.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;6;query;1;4;CCAACC&GGGG;((..((&))));-4 3 | target;1;7;query;1;4;CCAACCC&GGGG;((...((&))));-4 4 | target;1;10;query;1;4;CCAACCCACC&GGGG;((......((&))));-4 5 | target;5;10;query;1;4;CCCACC&GGGG;((..((&))));-4 6 | target;6;10;query;1;4;CCACC&GGGG;((.((&))));-4 7 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-heuristic-seed-modelS.parameter: -------------------------------------------------------------------------------- 1 | model=S 2 | mode=H 3 | seedBP=3 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | target=CCAACCCACC 8 | query=GGGG 9 | outMode=C 10 | outNumber=10 11 | outOverlap=B 12 | outDeltaE=0 13 | outNoLP=true 14 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-heuristic-seed-modelS.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;5;7;query;1;3;CCC&GGG;(((&)));-3 3 | target;5;7;query;2;4;CCC&GGG;(((&)));-3 4 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-heuristic-seed-modelX.parameter: -------------------------------------------------------------------------------- 1 | model=X 2 | mode=H 3 | seedBP=3 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | target=CCAACCCACC 8 | query=GGGG 9 | outMode=C 10 | outNumber=10 11 | outOverlap=B 12 | outDeltaE=0 13 | outNoLP=true 14 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-heuristic-seed-modelX.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;5;7;query;1;3;CCC&GGG;(((&)));-3 3 | target;5;7;query;2;4;CCC&GGG;(((&)));-3 4 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-heuristic.parameter: -------------------------------------------------------------------------------- 1 | mode = H 2 | noSeed = true 3 | model=S 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | target=CCAACCCACC 8 | query=GGGG 9 | outMode=C 10 | outNumber=10 11 | outOverlap=B 12 | outDeltaE=0 13 | outNoLP=true 14 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-noLP-heuristic.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;6;query;1;4;CCAACC&GGGG;((..((&))));-4 3 | target;5;10;query;1;4;CCCACC&GGGG;((..((&))));-4 4 | target;6;10;query;1;4;CCACC&GGGG;((.((&))));-4 5 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-outNoGUend.parameter: -------------------------------------------------------------------------------- 1 | query = ggggggggggggggggggggg 2 | target = uuuuuucccuaaauccuucuuu 3 | energy=B 4 | noSeed = true 5 | tAcc=N 6 | outNoGUend = true 7 | tRegion=8-17 8 | qRegion=4-14 9 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-outNoGUend.testresult: -------------------------------------------------------------------------------- 1 | 2 | target 3 | 8 16 4 | | | 5 | 5'-UUUUUUC UAAAU UUCUUU-3' 6 | CC CC 7 | || || 8 | GG GG 9 | 3'-GGG...GGGG ----- GGG-5' 10 | | | 11 | 7 4 12 | query 13 | 14 | interaction energy = -4 kcal/mol 15 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-overlapB-heuristic-seed-modelX.parameter: -------------------------------------------------------------------------------- 1 | model=X 2 | mode = H 3 | seedBP=2 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | tIntLenMax=2 8 | qIntLenMax=2 9 | target=CCAACCCACC 10 | query=GGGG 11 | outMode=C 12 | outNumber=10 13 | outOverlap=B 14 | outDeltaE=0 15 | outNoLP=false 16 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-overlapB-heuristic-seed-modelX.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;2;query;1;2;CC&GG;((&));-2 3 | target;1;2;query;2;3;CC&GG;((&));-2 4 | target;1;2;query;3;4;CC&GG;((&));-2 5 | target;5;6;query;1;2;CC&GG;((&));-2 6 | target;5;6;query;2;3;CC&GG;((&));-2 7 | target;5;6;query;3;4;CC&GG;((&));-2 8 | target;6;7;query;1;2;CC&GG;((&));-2 9 | target;6;7;query;2;3;CC&GG;((&));-2 10 | target;6;7;query;3;4;CC&GG;((&));-2 11 | target;9;10;query;1;2;CC&GG;((&));-2 12 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-overlapN-heuristic-seed-modelX.parameter: -------------------------------------------------------------------------------- 1 | model=X 2 | mode = H 3 | seedBP=2 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | tIntLenMax=2 8 | qIntLenMax=2 9 | target=CCAACCCACC 10 | query=GGGG 11 | outMode=C 12 | outNumber=10 13 | outOverlap=N 14 | outDeltaE=0 15 | outNoLP=false 16 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-overlapN-heuristic-seed-modelX.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;2;query;1;2;CC&GG;((&));-2 3 | target;5;6;query;3;4;CC&GG;((&));-2 4 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-overlapQ-heuristic-seed-modelX.parameter: -------------------------------------------------------------------------------- 1 | model=X 2 | mode = H 3 | seedBP=2 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | tIntLenMax=2 8 | qIntLenMax=2 9 | target=CCAACCCACC 10 | query=GGGG 11 | outMode=C 12 | outNumber=10 13 | outOverlap=Q 14 | outDeltaE=0 15 | outNoLP=false 16 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-overlapQ-heuristic-seed-modelX.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;2;query;1;2;CC&GG;((&));-2 3 | target;5;6;query;3;4;CC&GG;((&));-2 4 | target;9;10;query;3;4;CC&GG;((&));-2 5 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-overlapT-heuristic-seed-modelX.parameter: -------------------------------------------------------------------------------- 1 | model=X 2 | mode = H 3 | seedBP=2 4 | energy=B 5 | tAcc=N 6 | qAcc=N 7 | tIntLenMax=2 8 | qIntLenMax=2 9 | target=CCAACCCACC 10 | query=GGGG 11 | outMode=C 12 | outNumber=10 13 | outOverlap=T 14 | outDeltaE=0 15 | outNoLP=false 16 | -------------------------------------------------------------------------------- /tests/data/energyB-accN-overlapT-heuristic-seed-modelX.testresult: -------------------------------------------------------------------------------- 1 | id1;start1;end1;id2;start2;end2;subseqDP;hybridDP;E 2 | target;1;2;query;1;2;CC&GG;((&));-2 3 | target;1;2;query;3;4;CC&GG;((&));-2 4 | -------------------------------------------------------------------------------- /tests/runApiTests.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifdef HAVE_CONFIG_H 4 | #include 5 | #endif 6 | 7 | //! central compiler flag whether or not debug mode is enabled 8 | #define IN_DEBUG_MODE ((defined(_DEBUG)) || (!defined (NDEBUG))) 9 | 10 | //////////////// CENTRAL LOGGING LIB ////////////////// 11 | 12 | #include "easylogging++.h" 13 | 14 | // initialize logging for binary 15 | INITIALIZE_EASYLOGGINGPP 16 | 17 | 18 | //////////////// SETUP TESTING LIB ///////////////////// 19 | 20 | // make this the main test runner 21 | #define CATCH_CONFIG_MAIN 22 | 23 | #include "catch.hpp" 24 | 25 | 26 | 27 | // don't do anything else, its done via the compiler.. 28 | 29 | -------------------------------------------------------------------------------- /tests/runIntaRNA.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | if [[ -z "${GENOUT}" ]]; then 5 | GENERATE_OUTPUT=false 6 | else 7 | GENERATE_OUTPUT=true 8 | fi 9 | 10 | # subdirectory of test data 11 | datadir=data 12 | 13 | # list of all test names (parameter file in data subfolder) 14 | IntaRNA_tests=`cd $datadir; for f in *.parameter; do printf "${f%.*} "; done` 15 | 16 | DIFFERENCES=false 17 | 18 | ## ---------------------------------------- 19 | ## call test and compare output 20 | ## 21 | ## @param $1 the name of the test; shall not contain special symbols 22 | ## and white space, since this is used to derive file names 23 | ## @param $2 target directory, which is wiped after the test 24 | ## @param $3 options for diff 25 | ## 26 | function calltest { 27 | name="$1" 28 | diffopts="${2:-"--normal"}" 29 | 30 | resultfile=$datadir/$name.testout 31 | reference_resultsfile=$datadir/$name.testresult 32 | 33 | difftmp=testDiff.tmp 34 | 35 | shift 2 36 | 37 | testCall="$INTARNABINPATH/src/bin/IntaRNA --parameterFile=$datadir/$name.parameter --default-log-file=/dev/null" 38 | 39 | echo " IntaRNA TEST $name" 40 | # echo CALL $testCall 41 | #echo 42 | 43 | $testCall 2>&1 | grep -v INFO > $resultfile 44 | 45 | if [ -e "$reference_resultsfile" ] ; then 46 | if ! diff "$reference_resultsfile" "$resultfile" "${diffopts}" > $difftmp; then 47 | # echo "==================== OK" 48 | #else 49 | DIFFERENCES=true 50 | echo "============================================================" 51 | cat $difftmp 52 | echo "==================== DIFFERENT" 53 | fi 54 | rm -f $difftmp 55 | else 56 | echo "============================================================" 57 | echo "WARNING: file '$reference_resultsfile' does not exist!" 58 | echo "==================== NO_REFERENCE" 59 | DIFFERENCES=true 60 | 61 | if $GENERATE_OUTPUT ; then 62 | echo "Write new reference '$reference_resultsfile'." 63 | \cp $resultfile "$reference_resultsfile" 64 | fi 65 | fi 66 | 67 | } 68 | 69 | 70 | 71 | # run all tests 72 | for t in $IntaRNA_tests; do 73 | calltest $t 74 | done 75 | 76 | # check if differences in diffs 77 | if $DIFFERENCES ; then 78 | exit -1 79 | fi 80 | -------------------------------------------------------------------------------- /tests/testEasyLoggingSetup.icc: -------------------------------------------------------------------------------- 1 | 2 | #ifndef TESTEASYLOGGINGPPSETUP_ICC_ 3 | #define TESTEASYLOGGINGPPSETUP_ICC_ 4 | 5 | // set overall logging style 6 | el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Format, std::string("# %level : %msg")); 7 | el::Loggers::reconfigureAllLoggers(el::ConfigurationType::ToFile, std::string("false")); 8 | el::Loggers::reconfigureAllLoggers(el::ConfigurationType::ToStandardOutput, std::string("true")); 9 | // set additional logging flags 10 | el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog); 11 | el::Loggers::addFlag(el::LoggingFlag::LogDetailedCrashReason); 12 | el::Loggers::addFlag(el::LoggingFlag::AllowVerboseIfModuleNotSpecified); 13 | 14 | 15 | #endif /* TESTEASYLOGGINGPPSETUP_ICC_ */ 16 | --------------------------------------------------------------------------------