├── test ├── data │ ├── empty.bed │ ├── empty.txt │ ├── contig_ploidies.txt │ ├── malformed_regions.txt │ ├── missing_region.txt │ ├── human_skip_regions2.txt │ ├── regions.txt │ ├── regions.bed │ ├── hla_regions.txt │ ├── config.txt │ ├── human_skip_regions.txt │ └── test_utils.hpp ├── regression │ └── regression.py ├── CMakeLists.txt ├── unit │ ├── core │ │ ├── callers │ │ │ └── caller_tests.cpp │ │ ├── models │ │ │ ├── kmer_mapper_tests.cpp │ │ │ ├── coalescent_model_tests.cpp │ │ │ ├── indel_error_model_tests.cpp │ │ │ ├── individual_model_tests.cpp │ │ │ ├── snv_error_model_tests.cpp │ │ │ ├── germline_likelihood_model_tests.cpp │ │ │ ├── haplotype_likelihood_cache_tests.cpp │ │ │ └── haplotype_likelihood_model_tests.cpp │ │ └── tools │ │ │ ├── local_reassembler.cpp │ │ │ ├── vcf_extractor_tests.cpp │ │ │ ├── phaser_tests.cpp │ │ │ ├── genome_walker_tests.cpp │ │ │ ├── haplotype_generator_tests.cpp │ │ │ ├── variant_generator_tests.cpp │ │ │ └── cigar_scanner_tests.cpp │ ├── readpipe │ │ ├── downsampler_tests.cpp │ │ └── read_pipe_tests.cpp │ ├── utils │ │ ├── read_stats_tests.cpp │ │ ├── mappable_algorithm_tests.cpp │ │ └── maths_tests.cpp │ ├── logging │ │ └── progress_meter_tests.cpp │ ├── unit_test_main.cpp │ ├── concepts │ │ └── mappable_tests.cpp │ └── basics │ │ └── genomic_region_tests.cpp ├── mock │ ├── CMakeLists.txt │ ├── mock_read_manager.cpp │ ├── mock_variant_generator.cpp │ ├── mock_read_manager.hpp │ ├── mock_variant_generator.hpp │ └── utils.hpp ├── benchmark │ └── benchmark_utils.hpp └── README.md ├── website ├── static │ ├── .nojekyll │ └── img │ │ ├── favicon.ico │ │ └── guides │ │ └── duplicates.png ├── docs │ ├── guides │ │ ├── phasing.md │ │ ├── haplotypes.md │ │ ├── discovery.md │ │ ├── filtering │ │ │ └── thresholds.md │ │ ├── advanced │ │ │ └── configs.md │ │ ├── models │ │ │ └── polyclone.md │ │ ├── preprocessing.md │ │ └── errorModels.md │ └── introduction.md ├── babel.config.js ├── src │ ├── pages │ │ ├── markdown-page.md │ │ └── index.module.css │ └── components │ │ └── HomepageFeatures.module.css ├── .gitignore ├── blog │ └── 2021-06-10-welcome.md ├── README.md └── package.json ├── .gitattributes ├── logo.png ├── lib ├── CMakeLists.txt ├── tandem │ ├── libdivsufsort │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── date │ └── CMakeLists.txt └── ranger │ └── CMakeLists.txt ├── resources ├── forests │ ├── somatic.v0.7.4.forest.gz │ └── germline.v0.7.4.forest.gz └── configs │ ├── mitochondria.config │ └── PacBioCCS.config ├── .travis ├── install.sh ├── run.sh └── run_project_build.sh ├── src ├── utils │ ├── read_stats.cpp │ ├── system_utils.hpp │ ├── system_utils.cpp │ ├── free_memory.hpp │ ├── compression.hpp │ ├── hash_functions.hpp │ ├── reorder.hpp │ ├── path_utils.hpp │ ├── kmer_mapper.cpp │ ├── random_select.hpp │ ├── compression.cpp │ └── genotype_reader.hpp ├── core │ ├── types │ │ ├── phylogeny.cpp │ │ ├── cancer_genotype.cpp │ │ └── calls │ │ │ ├── call_types.hpp │ │ │ ├── denovo_call.cpp │ │ │ ├── germline_variant_call.cpp │ │ │ ├── call_wrapper.cpp │ │ │ ├── call_wrapper.hpp │ │ │ ├── denovo_call.hpp │ │ │ └── cnv_call.cpp │ ├── models │ │ ├── reference │ │ │ ├── individual_reference_likelihood_model.cpp │ │ │ └── individual_reference_likelihood_model.hpp │ │ ├── error │ │ │ ├── snv_error_model.cpp │ │ │ ├── indel_error_model.cpp │ │ │ ├── snv_error_model.hpp │ │ │ ├── indel_error_model.hpp │ │ │ └── error_model_factory.hpp │ │ ├── genotype │ │ │ └── uniform_genotype_prior_model.hpp │ │ └── mutation │ │ │ └── somatic_mutation_model.cpp │ ├── octopus.hpp │ ├── tools │ │ ├── coretools.hpp │ │ ├── vargen │ │ │ ├── utils │ │ │ │ └── global_aligner.hpp │ │ │ └── downloader.hpp │ │ ├── vcf_header_factory.hpp │ │ └── haplotype_filter.hpp │ ├── csr │ │ ├── facets │ │ │ ├── facet.cpp │ │ │ ├── samples.cpp │ │ │ ├── genotypes.cpp │ │ │ ├── pedigree.cpp │ │ │ ├── overlapping_reads.cpp │ │ │ ├── reference_context.cpp │ │ │ ├── repeat_context.cpp │ │ │ ├── genotypes.hpp │ │ │ ├── samples.hpp │ │ │ ├── pedigree.hpp │ │ │ ├── overlapping_reads.hpp │ │ │ ├── reads_summary.hpp │ │ │ ├── ploidies.cpp │ │ │ ├── ploidies.hpp │ │ │ ├── reference_context.hpp │ │ │ ├── repeat_context.hpp │ │ │ ├── reads_summary.cpp │ │ │ └── alleles.hpp │ │ ├── filters │ │ │ ├── variant_filter_utils.hpp │ │ │ └── passing_filter.cpp │ │ └── measures │ │ │ ├── measure_factory.hpp │ │ │ ├── posterior_probability.hpp │ │ │ ├── classification_confidence.hpp │ │ │ ├── quality.hpp │ │ │ ├── phase_length.hpp │ │ │ ├── gc_content.hpp │ │ │ ├── model_posterior.hpp │ │ │ ├── str_length.hpp │ │ │ ├── str_period.hpp │ │ │ ├── assigned_depth.hpp │ │ │ ├── max_read_length.hpp │ │ │ ├── mismatch_count.hpp │ │ │ ├── read_side_bias.hpp │ │ │ ├── variant_length.hpp │ │ │ ├── phylogeny_posterior.hpp │ │ │ ├── is_transversion.hpp │ │ │ ├── base_mismatch_count.hpp │ │ │ ├── somatic_haplotype_count.hpp │ │ │ ├── base_mismatch_quality.hpp │ │ │ ├── clipped_read_fraction.hpp │ │ │ ├── duplicate_concordance.hpp │ │ │ ├── misaligned_read_count.hpp │ │ │ ├── supplementary_fraction.hpp │ │ │ ├── ambiguous_read_fraction.hpp │ │ │ ├── denovo_contamination.hpp │ │ │ ├── normal_contamination.hpp │ │ │ ├── mapping_quality_divergence.hpp │ │ │ ├── error_rate.hpp │ │ │ ├── allele_depth.hpp │ │ │ ├── median_somatic_mapping_quality.hpp │ │ │ ├── mean_likelihood.hpp │ │ │ ├── allele_frequency.hpp │ │ │ ├── alt_allele_count.hpp │ │ │ ├── error_rate_stdev.hpp │ │ │ ├── genotype_quality.hpp │ │ │ ├── median_base_quality.hpp │ │ │ ├── allele_frequency_bias.hpp │ │ │ ├── allele_mapping_quality.hpp │ │ │ ├── duplicate_allele_depth.hpp │ │ │ ├── duplicate_allele_fraction.hpp │ │ │ ├── base_mismatch_fraction.hpp │ │ │ ├── is_denovo.hpp │ │ │ ├── is_refcall.hpp │ │ │ ├── is_somatic.hpp │ │ │ ├── mismatch_fraction.hpp │ │ │ ├── read_end_bias.hpp │ │ │ ├── read_tail_bias.hpp │ │ │ ├── quality_by_depth.hpp │ │ │ ├── mean_mapping_quality.hpp │ │ │ ├── quality.cpp │ │ │ ├── mapping_quality_zero_count.hpp │ │ │ ├── model_posterior_by_depth.hpp │ │ │ ├── filtered_read_fraction.hpp │ │ │ ├── posterior_probability_by_depth.hpp │ │ │ ├── strand_disequilibrium.hpp │ │ │ ├── depth.hpp │ │ │ ├── phylogeny_posterior.cpp │ │ │ ├── genotype_quality_by_depth.hpp │ │ │ ├── posterior_probability.cpp │ │ │ └── gc_content.cpp │ └── callers │ │ ├── caller_factory.cpp │ │ └── caller_factory.hpp ├── io │ ├── variant │ │ └── vcf.hpp │ ├── pedigree │ │ └── pedigree_reader.hpp │ ├── region │ │ └── region_parser.hpp │ └── read │ │ └── read_writer.cpp ├── readpipe │ └── read_pipe_fwd.hpp ├── logging │ ├── error_handler.hpp │ ├── main_logging.hpp │ └── main_logging.cpp ├── config │ ├── version.h.in │ ├── system.h.in │ ├── common.cpp │ └── common.hpp ├── concepts │ ├── equitable.hpp │ ├── indexed.hpp │ └── comparable.hpp ├── exceptions │ ├── user_error.hpp │ ├── system_error.hpp │ ├── error.cpp │ ├── unimplemented_feature_error.cpp │ ├── program_error.hpp │ ├── unimplemented_feature_error.hpp │ ├── unwritable_file_error.hpp │ ├── unwritable_file_error.cpp │ ├── missing_file_error.hpp │ ├── file_open_error.hpp │ ├── missing_index_error.cpp │ ├── missing_index_error.hpp │ ├── missing_file_error.cpp │ ├── file_open_error.cpp │ ├── error.hpp │ └── malformed_file_error.hpp ├── basics │ ├── tandem_repeat.cpp │ ├── trio.cpp │ └── trio.hpp └── timers.hpp ├── .travis.yml ├── .dockerignore ├── .github └── ISSUE_TEMPLATE │ └── bug_report.md ├── Dockerfile └── LICENSE /test/data/empty.bed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/data/empty.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /website/static/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/data/contig_ploidies.txt: -------------------------------------------------------------------------------- 1 | Y=1 2 | MT=1 -------------------------------------------------------------------------------- /test/data/malformed_regions.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 3:30-100o1 3 | -------------------------------------------------------------------------------- /test/data/missing_region.txt: -------------------------------------------------------------------------------- 1 | 1:0- 2 | 2 3 | foo 4 | 4 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.forest.gz filter=lfs diff=lfs merge=lfs -text 2 | -------------------------------------------------------------------------------- /test/regression/regression.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | 4 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luntergroup/octopus/HEAD/logo.png -------------------------------------------------------------------------------- /website/docs/guides/phasing.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: phasing 3 | title: Phasing 4 | --- -------------------------------------------------------------------------------- /lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(tandem) 2 | add_subdirectory(ranger) 3 | add_subdirectory(date) -------------------------------------------------------------------------------- /website/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luntergroup/octopus/HEAD/website/static/img/favicon.ico -------------------------------------------------------------------------------- /website/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /website/static/img/guides/duplicates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luntergroup/octopus/HEAD/website/static/img/guides/duplicates.png -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | enable_testing() 2 | add_subdirectory(mock) 3 | add_subdirectory(unit) 4 | # add_subdirectory(regression) 5 | # add_subdirectory(benchmark) 6 | -------------------------------------------------------------------------------- /website/docs/guides/haplotypes.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: haplotypes 3 | title: Haplotype Proposal 4 | --- 5 | 6 | ## Growth 7 | 8 | ## Lagging 9 | 10 | ## Backtracking -------------------------------------------------------------------------------- /website/docs/guides/discovery.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: discovery 3 | title: Variant Discovery 4 | --- 5 | 6 | ## Pileups 7 | 8 | ## Local reassembly 9 | 10 | ## Input VCF -------------------------------------------------------------------------------- /website/src/pages/markdown-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Markdown page example 3 | --- 4 | 5 | # Markdown page example 6 | 7 | You don't need React to write simple standalone pages. 8 | -------------------------------------------------------------------------------- /resources/forests/somatic.v0.7.4.forest.gz: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:907f9ffe205db86a167352a71394fe6b115c04e76f643a78b37d9de11a2fb4b7 3 | size 88376313 4 | -------------------------------------------------------------------------------- /resources/forests/germline.v0.7.4.forest.gz: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:926866d922430204e527e685559373066801e1b288835480a44b0bc07ae8fe3d 3 | size 373801411 4 | -------------------------------------------------------------------------------- /test/unit/core/callers/caller_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/unit/readpipe/downsampler_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/unit/utils/read_stats_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/data/human_skip_regions2.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | 11 12 | 12 13 | 13 14 | 14 15 | 15 16 | 16 17 | 17 18 | 18 19 | 19 20 | 20 21 | 21 22 | 22 23 | X 24 | Y -------------------------------------------------------------------------------- /test/unit/core/models/kmer_mapper_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/unit/logging/progress_meter_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/unit/core/models/coalescent_model_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/unit/core/models/indel_error_model_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/unit/core/models/individual_model_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/unit/core/models/snv_error_model_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/unit/core/models/germline_likelihood_model_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/unit/core/models/haplotype_likelihood_cache_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/unit/core/models/haplotype_likelihood_model_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/data/regions.txt: -------------------------------------------------------------------------------- 1 | 1:100000-200000 2 | 3 3 | 4 4 | 5:592839-592939 5 | 5:1000000-2000000 6 | 10:5000000- 7 | 15:10000-20000 8 | 15:20000-30000 9 | 15:30000-40000 10 | 18:10000-20000 11 | 18:30000-40000 12 | 18:50000-60000 13 | X -------------------------------------------------------------------------------- /.travis/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -x 5 | 6 | if [[ "$(uname -s)" == 'Darwin' ]]; then 7 | brew update || brew update 8 | brew unlink cmake 9 | brew upgrade cmake 10 | brew install gcc || brew link --overwrite gcc 11 | fi 12 | -------------------------------------------------------------------------------- /src/utils/read_stats.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "read_stats.hpp" 5 | 6 | namespace octopus { 7 | 8 | } // namespace octopus 9 | -------------------------------------------------------------------------------- /test/data/regions.bed: -------------------------------------------------------------------------------- 1 | 1 100000 200000 2 | 3 100000 200000 3 | 4 100000 200000 4 | 5 592839 592939 5 | 5 1000000 2000000 6 | 10 5000000 7 | 15 10000 20000 8 | 15 20000 30000 9 | 15 30000 40000 10 | 18 10000 20000 11 | 18 30000 40000 12 | 18 50000 60000 13 | X 100000 200000 14 | -------------------------------------------------------------------------------- /src/core/types/phylogeny.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "phylogeny.hpp" 5 | 6 | namespace octopus { 7 | 8 | 9 | 10 | } // namespace octopus 11 | -------------------------------------------------------------------------------- /test/unit/unit_test_main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | // Generates main 5 | #define BOOST_TEST_MODULE octopus unit tests 6 | 7 | #include 8 | -------------------------------------------------------------------------------- /test/mock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MOCK_SOURCES 2 | mock_reference.hpp 3 | mock_reference.cpp 4 | ) 5 | 6 | add_library(Mock ${MOCK_SOURCES}) 7 | 8 | target_include_directories(Mock PUBLIC ${octopus_SOURCE_DIR}/lib ${octopus_SOURCE_DIR}/src) 9 | 10 | target_link_libraries(Mock Octopus) 11 | -------------------------------------------------------------------------------- /website/src/components/HomepageFeatures.module.css: -------------------------------------------------------------------------------- 1 | /* stylelint-disable docusaurus/copyright-header */ 2 | 3 | .features { 4 | display: flex; 5 | align-items: center; 6 | padding: 2rem 0; 7 | width: 100%; 8 | } 9 | 10 | .featureSvg { 11 | height: 200px; 12 | width: 200px; 13 | } 14 | -------------------------------------------------------------------------------- /.travis/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z $DOCKER_IMAGE ]; then 4 | # Run with native 5 | .travis/run_project_build.sh 6 | else 7 | # Run with docker 8 | docker run -v$(pwd):/home/conan $DOCKER_IMAGE bash -c "CC=${CC} CXX=${CXX} ASAN=${ASAN} .travis/run_project_build.sh" 9 | fi 10 | -------------------------------------------------------------------------------- /test/mock/mock_read_manager.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "mock_read_manager.hpp" 5 | 6 | namespace octopus { namespace test { 7 | 8 | 9 | 10 | } // namespace test 11 | } // namespace octopus 12 | -------------------------------------------------------------------------------- /test/data/hla_regions.txt: -------------------------------------------------------------------------------- 1 | 6:29,690,822-29,717,432 2 | 6:29,794,350-29,799,548 3 | 6:29,854,439-29,860,076 4 | 6:29,909,260-29,914,705 5 | 6:31,320,151-31,326,581 6 | 6:31,235,509-31,241,047 7 | 6:30,456,690-30,462,845 8 | 6:33,030,330-33,060,358 9 | 6:33,079,213-33,098,080 10 | 6:32,971,604-32,978,159 11 | 6:32,472,179-32,786,639 -------------------------------------------------------------------------------- /src/core/models/reference/individual_reference_likelihood_model.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "individual_reference_likelihood_model.hpp" 5 | 6 | namespace octopus { 7 | 8 | 9 | } // namespace octopus 10 | -------------------------------------------------------------------------------- /test/mock/mock_variant_generator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "mock_variant_generator.hpp" 5 | 6 | namespace octopus { namespace test { 7 | 8 | 9 | 10 | } // namespace test 11 | } // namespace octopus 12 | -------------------------------------------------------------------------------- /website/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /website/blog/2021-06-10-welcome.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: welcome 3 | title: Welcome 4 | author: Daniel Cooke 5 | author_title: Octopus author and Bioinformatics Engineer @ Invitae 6 | author_url: https://github.com/dancooke 7 | author_image_url: https://github.com/dancooke.png 8 | tags: [welcome, octopus] 9 | --- 10 | 11 | Welcome to the new Octopus website! 12 | -------------------------------------------------------------------------------- /src/core/types/cancer_genotype.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "cancer_genotype.hpp" 5 | 6 | 7 | 8 | namespace octopus { 9 | 10 | namespace debug { 11 | 12 | 13 | 14 | } // namespace debug 15 | 16 | } // namespace octopus 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: linux 2 | services: 3 | - docker 4 | sudo: required 5 | language: python 6 | 7 | env: 8 | matrix: 9 | - DOCKER_IMAGE=lasote/conanclang60 10 | CC=clang 11 | CXX=clang++ 12 | - DOCKER_IMAGE=lasote/conangcc8 13 | CC=gcc 14 | CXX=g++ 15 | 16 | install: 17 | - ./.travis/install.sh 18 | 19 | script: 20 | - ./.travis/run.sh 21 | -------------------------------------------------------------------------------- /test/mock/mock_read_manager.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef mock_read_manager_hpp 5 | #define mock_read_manager_hpp 6 | 7 | namespace octopus { namespace test { 8 | 9 | 10 | 11 | } // namespace test 12 | } // namespace octopus 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /resources/configs/mitochondria.config: -------------------------------------------------------------------------------- 1 | ### Author: Daniel Cooke (daniel.cooke@invitae.com) 2 | ### Date: 22/06/2022 3 | ### Octopus version: v0.8.0 4 | 5 | caller=polyclone 6 | disable-downsampling=true 7 | no-reads-with-distant-segments=true 8 | min-candidate-credible-vaf-probability=0.25 9 | max-vb-seeds=30 10 | filter-expression=QUAL < 30 | MQ < 10 | SB > 0.95 | BQ < 15 11 | -------------------------------------------------------------------------------- /src/utils/system_utils.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef system_utils_hpp 5 | #define system_utils_hpp 6 | 7 | #include 8 | 9 | namespace octopus { 10 | 11 | std::size_t get_max_open_files(); 12 | 13 | } // namespace octopus 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/core/models/reference/individual_reference_likelihood_model.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef individual_reference_likelihood_model_hpp 5 | #define individual_reference_likelihood_model_hpp 6 | 7 | namespace octopus { 8 | 9 | 10 | } // namespace octopus 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /website/docs/guides/filtering/thresholds.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: thresholds 3 | title: Hard Thresholds 4 | --- 5 | 6 | Octopus currently provides simple threshold based filtering. A number of measures that can be used to define a Boolean filter expression. Currently, Octopus only supports expressions with OR operations and the less than (<) and greater than (>) comparators. Furthermore, measure name must appear on the left hand side of each condition in the expression. -------------------------------------------------------------------------------- /src/utils/system_utils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "system_utils.hpp" 5 | 6 | #include 7 | 8 | namespace octopus { 9 | 10 | std::size_t get_max_open_files() 11 | { 12 | struct rlimit lim; 13 | getrlimit(RLIMIT_NOFILE, &lim); 14 | return lim.rlim_cur; 15 | } 16 | 17 | } // namespace octopus 18 | -------------------------------------------------------------------------------- /lib/tandem/libdivsufsort/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SOURCES 2 | config.h 3 | lfs.h 4 | divsufsort_private.h 5 | divsufsort.h 6 | divsufsort.c 7 | sssort.c 8 | trsort.c 9 | utils.c 10 | ) 11 | 12 | add_library(libdivsufsort STATIC ${SOURCES}) 13 | set_target_properties(libdivsufsort PROPERTIES LINKER_LANGUAGE C) 14 | 15 | if(CMAKE_COMPILER_IS_GNUCC) 16 | target_compile_options(libdivsufsort PRIVATE -fomit-frame-pointer) 17 | endif() 18 | -------------------------------------------------------------------------------- /src/io/variant/vcf.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef vcf_hpp 5 | #define vcf_hpp 6 | 7 | #include "io/variant/vcf_type.hpp" 8 | #include "io/variant/vcf_header.hpp" 9 | #include "io/variant/vcf_record.hpp" 10 | #include "io/variant/vcf_reader.hpp" 11 | #include "io/variant/vcf_writer.hpp" 12 | #include "io/variant/vcf_utils.hpp" 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /test/unit/readpipe/read_pipe_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #define BOOST_TEST_DYN_LINK 5 | 6 | #include 7 | 8 | #include "readpipe/read_pipe.hpp" 9 | 10 | BOOST_AUTO_TEST_SUITE(Components) 11 | BOOST_AUTO_TEST_SUITE(IO) 12 | 13 | // TODO 14 | 15 | BOOST_AUTO_TEST_SUITE_END() // IO 16 | BOOST_AUTO_TEST_SUITE_END() // Components 17 | -------------------------------------------------------------------------------- /test/unit/core/tools/local_reassembler.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | namespace octopus { namespace test { 7 | 8 | BOOST_AUTO_TEST_SUITE(core) 9 | BOOST_AUTO_TEST_SUITE(reassembler) 10 | 11 | 12 | 13 | BOOST_AUTO_TEST_SUITE_END() 14 | BOOST_AUTO_TEST_SUITE_END() 15 | 16 | } // namespace test 17 | } // namespace octopus 18 | -------------------------------------------------------------------------------- /test/data/config.txt: -------------------------------------------------------------------------------- 1 | working-directory = ~/Genomics/giab 2 | reference = ~/Genomics/References/human_g1k_v37.fasta 3 | #reads = ~/Genomics/Illumina/NA12878.mapped.ILLUMINA.bwa.CEU.high_coverage_pcr_free.20130906.chr22.bam 4 | reads = ~/Genomics/Illumina/NA12878.mapped.ILLUMINA.bwa.CEU.low_coverage.20121211.bam 5 | disable-assembly-candidate-generator = ON 6 | disable-call-filtering = ON 7 | output = octopus_calls_debug.vcf 8 | 9 | #skip-regions-file = 10 | #organism-ploidy = 11 | #contig-ploidies = -------------------------------------------------------------------------------- /src/utils/free_memory.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef free_memory_hpp 5 | #define free_memory_hpp 6 | 7 | #include 8 | 9 | namespace octopus { 10 | 11 | template 12 | void free_memory(Container& c) 13 | { 14 | Container tmp {}; 15 | using std::swap; 16 | swap(tmp, c); 17 | } 18 | 19 | } // namespace octopus 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /test/unit/core/tools/vcf_extractor_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | namespace octopus { namespace test { 7 | 8 | BOOST_AUTO_TEST_SUITE(core) 9 | BOOST_AUTO_TEST_SUITE(vcf_extractor) 10 | 11 | 12 | 13 | BOOST_AUTO_TEST_SUITE_END() 14 | BOOST_AUTO_TEST_SUITE_END() 15 | 16 | } // namespace test 17 | } // namespace octopus 18 | -------------------------------------------------------------------------------- /src/core/octopus.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef octopus_hpp 5 | #define octopus_hpp 6 | 7 | #include 8 | 9 | #include "calling_components.hpp" 10 | 11 | namespace octopus { 12 | 13 | struct UserCommandInfo 14 | { 15 | std::string command, options; 16 | }; 17 | 18 | void run_octopus(GenomeCallingComponents& components, UserCommandInfo info); 19 | 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/core/tools/coretools.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef coretools_hpp 5 | #define coretools_hpp 6 | 7 | #include "core/tools/vargen/variant_generator.hpp" 8 | #include "core/tools/vargen/variant_generator_builder.hpp" 9 | #include "core/tools/hapgen/haplotype_generator.hpp" 10 | #include "core/tools/phaser/phaser.hpp" 11 | #include "core/tools/bad_region_detector.hpp" 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/io/pedigree/pedigree_reader.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef pedigree_reader_hpp 5 | #define pedigree_reader_hpp 6 | 7 | #include 8 | 9 | #include "basics/pedigree.hpp" 10 | 11 | namespace octopus {namespace io { 12 | 13 | Pedigree read_pedigree(const boost::filesystem::path& ped_file); 14 | 15 | } // namespace io 16 | } // namespace octopus 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /test/unit/core/tools/phaser_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | #include "core/tools/phaser/phaser.hpp" 7 | 8 | namespace octopus { namespace test { 9 | 10 | BOOST_AUTO_TEST_SUITE(core) 11 | BOOST_AUTO_TEST_SUITE(phaser) 12 | 13 | 14 | 15 | BOOST_AUTO_TEST_SUITE_END() 16 | BOOST_AUTO_TEST_SUITE_END() 17 | 18 | } // namespace test 19 | } // namespace octopus 20 | -------------------------------------------------------------------------------- /test/unit/core/tools/genome_walker_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | #include "core/tools/hapgen/genome_walker.hpp" 7 | 8 | namespace octopus { namespace test { 9 | 10 | BOOST_AUTO_TEST_SUITE(core) 11 | BOOST_AUTO_TEST_SUITE(genome_walker) 12 | 13 | 14 | 15 | BOOST_AUTO_TEST_SUITE_END() 16 | BOOST_AUTO_TEST_SUITE_END() 17 | 18 | } // namespace test 19 | } // namespace octopus 20 | -------------------------------------------------------------------------------- /lib/date/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(DATE_SOURCES 2 | date.h 3 | tz.h 4 | tz.cpp 5 | tz_private.h 6 | ios.h 7 | ptz.h) 8 | 9 | add_library(date-tz STATIC ${DATE_SOURCES}) 10 | 11 | set(WarningIgnores 12 | -Wno-unused-parameter 13 | -Wno-unused-function 14 | -Wno-missing-braces) 15 | 16 | add_compile_options(-Wall -Wextra -Werror ${WarningIgnores}) 17 | 18 | # find_package(CURL REQUIRED) 19 | # target_include_directories(date-tz SYSTEM PRIVATE ${CURL_INCLUDE_DIRS}) 20 | # target_link_libraries(date-tz PRIVATE ${CURL_LIBRARIES}) 21 | 22 | -------------------------------------------------------------------------------- /src/readpipe/read_pipe_fwd.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef read_pipe_fwd_hpp 5 | #define read_pipe_fwd_hpp 6 | 7 | #include "readpipe/transformers/read_transform.hpp" 8 | #include "readpipe/transformers/read_transformer.hpp" 9 | #include "readpipe/filtering/read_filter.hpp" 10 | #include "readpipe/filtering/read_filterer.hpp" 11 | #include "readpipe/downsampling/downsampler.hpp" 12 | #include "readpipe/read_pipe.hpp" 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /test/unit/concepts/mappable_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | #include "basics/contig_region.hpp" 7 | #include "concepts/mappable.hpp" 8 | 9 | namespace octopus { namespace test { 10 | 11 | BOOST_AUTO_TEST_SUITE(concepts) 12 | BOOST_AUTO_TEST_SUITE(mappable) 13 | 14 | 15 | 16 | BOOST_AUTO_TEST_SUITE_END() 17 | BOOST_AUTO_TEST_SUITE_END() 18 | 19 | } // namespace test 20 | } // namespace octopus 21 | -------------------------------------------------------------------------------- /src/core/csr/facets/facet.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "facet.hpp" 5 | 6 | namespace octopus { namespace csr { 7 | 8 | bool operator==(const Facet& lhs, const Facet& rhs) noexcept 9 | { 10 | return lhs.name() == rhs.name(); 11 | } 12 | 13 | bool operator==(const FacetWrapper& lhs, const FacetWrapper& rhs) noexcept 14 | { 15 | return *lhs.base() == *rhs.base(); 16 | } 17 | 18 | } // namespace csr 19 | } // namespace octopus 20 | -------------------------------------------------------------------------------- /test/unit/core/tools/haplotype_generator_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | #include "core/tools/hapgen/haplotype_generator.hpp" 7 | 8 | namespace octopus { namespace test { 9 | 10 | BOOST_AUTO_TEST_SUITE(core) 11 | BOOST_AUTO_TEST_SUITE(haplotype_generator) 12 | 13 | 14 | 15 | BOOST_AUTO_TEST_SUITE_END() 16 | BOOST_AUTO_TEST_SUITE_END() 17 | 18 | } // namespace test 19 | } // namespace octopus 20 | -------------------------------------------------------------------------------- /test/unit/core/tools/variant_generator_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | #include "core/tools/vargen/variant_generator.hpp" 7 | 8 | namespace octopus { namespace test { 9 | 10 | BOOST_AUTO_TEST_SUITE(core) 11 | BOOST_AUTO_TEST_SUITE(variant_generator) 12 | 13 | 14 | 15 | BOOST_AUTO_TEST_SUITE_END() 16 | BOOST_AUTO_TEST_SUITE_END() 17 | 18 | } // namespace test 19 | } // namespace octopus 20 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.gitignore 5 | **/.project 6 | **/.settings 7 | **/.toolstarget 8 | **/.vs 9 | **/.vscode 10 | **/*.*proj.user 11 | **/*.dbmdl 12 | **/*.jfm 13 | **/azds.yaml 14 | **/bin 15 | **/charts 16 | **/docker-compose* 17 | **/Dockerfile* 18 | **/node_modules 19 | **/npm-debug.log 20 | **/obj 21 | **/secrets.dev.yaml 22 | **/values.dev.yaml 23 | **/.travis.yml 24 | README.md 25 | CONTRIBUTING.md 26 | logo.png 27 | **/doc 28 | **/cmake-build-debug 29 | **/test 30 | **/resources/forests/* 31 | **/build/* 32 | !**/build/cmake -------------------------------------------------------------------------------- /src/core/csr/facets/samples.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "samples.hpp" 5 | 6 | #include 7 | 8 | namespace octopus { namespace csr { 9 | 10 | const std::string Samples::name_ {"Samples"}; 11 | 12 | Samples::Samples(std::vector samples) : samples_ {std::move(samples)} {} 13 | 14 | Facet::ResultType Samples::do_get() const 15 | { 16 | return std::cref(samples_); 17 | } 18 | 19 | } // namespace csr 20 | } // namespace octopus 21 | -------------------------------------------------------------------------------- /src/logging/error_handler.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef error_handler_hpp 5 | #define error_handler_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "exceptions/error.hpp" 11 | 12 | namespace octopus { 13 | 14 | void log_error(const Error& error); 15 | void log_error(const std::bad_alloc& error); 16 | void log_error(const std::exception& error); 17 | 18 | void log_unknown_error(); 19 | 20 | } // namepace octopus 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /lib/tandem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(libdivsufsort) 2 | 3 | add_library(tandem STATIC tandem.hpp tandem.cpp) 4 | 5 | set(WarningIgnores 6 | -Wno-unused-parameter 7 | -Wno-unused-function 8 | -Wno-missing-braces 9 | ) 10 | 11 | add_compile_options(-Wall -Wextra -Werror ${WarningIgnores}) 12 | target_link_libraries(tandem libdivsufsort) 13 | set_target_properties(tandem PROPERTIES LINKER_LANGUAGE CXX) 14 | 15 | check_ipo_supported(RESULT ipo_supported) 16 | if(ipo_supported) 17 | set_property(TARGET tandem PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) 18 | endif() 19 | -------------------------------------------------------------------------------- /src/core/csr/facets/genotypes.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "genotypes.hpp" 5 | 6 | #include 7 | 8 | namespace octopus { namespace csr { 9 | 10 | const std::string Genotypes::name_ {"Genotypes"}; 11 | 12 | Genotypes::Genotypes(GenotypeMap genotypes) : genotypes_ {std::move(genotypes)} {} 13 | 14 | Facet::ResultType Genotypes::do_get() const 15 | { 16 | return std::cref(genotypes_); 17 | } 18 | 19 | } // namespace csr 20 | } // namespace octopus 21 | -------------------------------------------------------------------------------- /src/core/csr/facets/pedigree.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "pedigree.hpp" 5 | 6 | #include 7 | 8 | namespace octopus { namespace csr { 9 | 10 | const std::string Pedigree::name_ {"Pedigree"}; 11 | 12 | Pedigree::Pedigree(octopus::Pedigree pedigree) 13 | : pedigree_ {std::move(pedigree)} 14 | {} 15 | 16 | Facet::ResultType Pedigree::do_get() const 17 | { 18 | return std::cref(pedigree_); 19 | } 20 | 21 | } // namespace csr 22 | } // namespace octopus 23 | -------------------------------------------------------------------------------- /src/core/types/calls/call_types.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef call_types_hpp 5 | #define call_types_hpp 6 | 7 | #include "call.hpp" 8 | #include "variant_call.hpp" 9 | #include "germline_variant_call.hpp" 10 | #include "reference_call.hpp" 11 | #include "somatic_call.hpp" 12 | #include "denovo_call.hpp" 13 | #include "denovo_reference_reversion_call.hpp" 14 | #include "cell_variant_call.hpp" 15 | #include "polyclone_variant_call.hpp" 16 | #include "cnv_call.hpp" 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/config/version.h.in: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef version_hpp 5 | #define version_hpp 6 | 7 | /* 8 | * These values are automatically set according to their cmake variables. 9 | */ 10 | #define VERSION_MAJOR @octopus_VERSION_MAJOR@ 11 | #define VERSION_MINOR @octopus_VERSION_MINOR@ 12 | #define VERSION_PATCH @octopus_VERSION_PATCH@ 13 | #define VERSION_RELEASE "@octopus_VERSION_RELEASE@" 14 | #define GIT_BRANCH "@GIT_BRANCH@" 15 | #define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@" 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/core/csr/facets/overlapping_reads.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "overlapping_reads.hpp" 5 | 6 | #include 7 | 8 | namespace octopus { namespace csr { 9 | 10 | const std::string OverlappingReads::name_ {"OverlappingReads"}; 11 | 12 | OverlappingReads::OverlappingReads(ReadMap reads) : reads_ {std::move(reads)} {} 13 | 14 | Facet::ResultType OverlappingReads::do_get() const 15 | { 16 | return std::cref(reads_); 17 | } 18 | 19 | } // namespace csr 20 | } // namespace octopus 21 | -------------------------------------------------------------------------------- /resources/configs/PacBioCCS.config: -------------------------------------------------------------------------------- 1 | ### Author: Daniel Cooke (dcooke@well.ox.ac.uk) 2 | ### Date: 03/03/2020 3 | ### Octopus version: v0.7.0 4 | 5 | # Fragment long reads into linked chunks 6 | max-read-length=500 7 | split-long-reads=true 8 | read-linkage=LINKED 9 | 10 | # Setup variant discovery for noisy reads 11 | variant-discovery-mode=PACBIO 12 | force-pileup-candidates=true 13 | max-assembly-region-size=1000 14 | max-assembly-region-overlap=500 15 | 16 | # Setup likelihood model for noisy reads 17 | max-indel-errors=16 18 | sequence-error-model=.PacBioCCS 19 | 20 | max-haplotypes=400 21 | min-protected-haplotype-posterior=1e-5 22 | -------------------------------------------------------------------------------- /test/unit/utils/mappable_algorithm_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "basics/contig_region.hpp" 9 | #include "concepts/mappable.hpp" 10 | #include "utils/mappable_algorithms.hpp" 11 | 12 | namespace octopus { namespace test { 13 | 14 | BOOST_AUTO_TEST_SUITE(utils) 15 | BOOST_AUTO_TEST_SUITE(mappable_algorithms) 16 | 17 | 18 | 19 | BOOST_AUTO_TEST_SUITE_END() 20 | BOOST_AUTO_TEST_SUITE_END() 21 | 22 | } // namespace test 23 | } // namespace octopus 24 | -------------------------------------------------------------------------------- /src/core/types/calls/denovo_call.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "denovo_call.hpp" 5 | 6 | #include "utils/string_utils.hpp" 7 | 8 | namespace octopus { 9 | 10 | void DenovoCall::decorate(VcfRecord::Builder& record) const 11 | { 12 | record.set_denovo(); 13 | if (posterior_) { 14 | record.set_info("PP", utils::to_string(posterior_->score())); 15 | } 16 | } 17 | 18 | std::unique_ptr DenovoCall::do_clone() const 19 | { 20 | return std::make_unique(*this); 21 | } 22 | 23 | } // namespace octopus 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **Version** 11 | 12 | ```shell 13 | $ octopus --version 14 | // PASTE OUTPUT HERE 15 | ``` 16 | 17 | **Command** 18 | Command line to install octopus: 19 | ```shell 20 | $ 21 | ``` 22 | 23 | Command line to run octopus: 24 | ```shell 25 | $ octopus 26 | ``` 27 | 28 | **Additional context** 29 | Add any other context about the problem here, e.g. 30 | 31 | - Reference [e.g. hg19]. Please provide link to fasta if atypical. 32 | - BAM files (if possible). 33 | -------------------------------------------------------------------------------- /src/core/types/calls/germline_variant_call.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "germline_variant_call.hpp" 5 | 6 | #include "utils/string_utils.hpp" 7 | 8 | namespace octopus { 9 | 10 | void GermlineVariantCall::decorate(VcfRecord::Builder& record) const 11 | { 12 | if (posterior_) { 13 | record.set_info("PP", utils::to_string(posterior_->score())); 14 | } 15 | } 16 | 17 | std::unique_ptr GermlineVariantCall::do_clone() const 18 | { 19 | return std::make_unique(*this); 20 | } 21 | 22 | } // namespace octopus 23 | -------------------------------------------------------------------------------- /src/config/system.h.in: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef system_hpp 5 | #define system_hpp 6 | 7 | /* 8 | * These values are automatically set according to their cmake variables. 9 | */ 10 | #define SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@" 11 | #define SYSTEM_NAME "@CMAKE_SYSTEM_NAME@" 12 | #define SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@" 13 | #define COMPILER_NAME "@CMAKE_CXX_COMPILER_ID@" 14 | #define COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@" 15 | #define BOOSTLIB_VERSION "@Boost_LIB_VERSION@" 16 | #define BUILD_TYPE "@CMAKE_BUILD_TYPE@" 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /website/docs/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: introduction 3 | title: Introduction 4 | description: Octopus is a haplotype-based variant caller with multiple calling modes. 5 | sidebar_position: 1 6 | --- 7 | 8 | Octopus is a mapping-based variant caller that implements several calling models within a unified haplotype-aware framework. Each calling model is designed for a particular kind of experimental design. Octopus takes inspiration from particle filtering by constructing a tree of haplotypes and dynamically pruning and extending the tree based on haplotype posterior probabilities in a sequential manner. This allows octopus to implicitly consider all possible haplotypes at a given loci in reasonable time. -------------------------------------------------------------------------------- /src/utils/compression.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef compression_hpp 5 | #define compression_hpp 6 | 7 | #include 8 | 9 | namespace octopus { namespace utils { 10 | 11 | std::string compress(const std::string& data); 12 | std::string decompress(const std::string& data); 13 | 14 | struct Compress 15 | { 16 | std::string operator()(const std::string str) const; 17 | }; 18 | 19 | struct Decompress 20 | { 21 | std::string operator()(const std::string str) const; 22 | }; 23 | 24 | } // namespace utils 25 | } // namespace octopus 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/concepts/equitable.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef equitable_hpp 5 | #define equitable_hpp 6 | 7 | namespace octopus { 8 | 9 | /** 10 | A class that is derived from Equitable must implement operator== and will then have 11 | operator!= defined. 12 | */ 13 | template 14 | class Equitable {}; 15 | 16 | template 17 | inline bool operator!=(const Equitable& lhs, const Equitable& rhs) 18 | { 19 | return !operator==(static_cast(lhs), static_cast(rhs)); 20 | } 21 | 22 | } // namespace octopus 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/core/csr/facets/reference_context.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "reference_context.hpp" 5 | 6 | #include 7 | 8 | namespace octopus { namespace csr { 9 | 10 | const std::string ReferenceContext::name_ {"ReferenceContext"}; 11 | 12 | ReferenceContext::ReferenceContext(const ReferenceGenome& reference, GenomicRegion region) 13 | : result_ {std::make_unique(region, reference)} 14 | {} 15 | 16 | Facet::ResultType ReferenceContext::do_get() const 17 | { 18 | return std::cref(*result_); 19 | } 20 | 21 | } // namespace csr 22 | } // namespace octopus 23 | -------------------------------------------------------------------------------- /src/exceptions/user_error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef user_error_hpp 5 | #define user_error_hpp 6 | 7 | #include 8 | 9 | #include "error.hpp" 10 | 11 | namespace octopus { 12 | 13 | /** 14 | A UserError is used for any error caused by bad user input, e.g. missing files, incorrect file types, 15 | or invalid command line values. 16 | */ 17 | class UserError : public Error 18 | { 19 | virtual std::string do_type() const override { return "user"; } 20 | public: 21 | virtual ~UserError() = default; 22 | }; 23 | 24 | } // namespace octopus 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /website/src/pages/index.module.css: -------------------------------------------------------------------------------- 1 | /* stylelint-disable docusaurus/copyright-header */ 2 | 3 | /** 4 | * CSS files with the .module.css suffix will be treated as CSS modules 5 | * and scoped locally. 6 | */ 7 | 8 | .heroBanner { 9 | padding: 4rem 0; 10 | text-align: center; 11 | position: relative; 12 | overflow: hidden; 13 | } 14 | 15 | @media screen and (max-width: 966px) { 16 | .heroBanner { 17 | padding: 2rem; 18 | } 19 | } 20 | 21 | .buttons { 22 | display: flex; 23 | flex-wrap: wrap; 24 | align-items: center; 25 | justify-content: center; 26 | margin: 10px 0 0; 27 | } 28 | 29 | .buttons > a { 30 | margin: 0 5px; 31 | } 32 | 33 | .social { 34 | margin-top: 20px; 35 | } -------------------------------------------------------------------------------- /src/config/common.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "common.hpp" 5 | 6 | namespace octopus { 7 | 8 | bool DEBUG_MODE {false}, TRACE_MODE {false}; 9 | 10 | namespace logging { 11 | 12 | boost::optional get_debug_log() 13 | { 14 | if (DEBUG_MODE) { 15 | return DebugLogger {}; 16 | } 17 | return boost::none; 18 | } 19 | 20 | boost::optional get_trace_log() 21 | { 22 | if (TRACE_MODE) { 23 | return TraceLogger {}; 24 | } 25 | return boost::none; 26 | } 27 | 28 | } // namespace debug 29 | 30 | } // namespace octopus 31 | -------------------------------------------------------------------------------- /src/exceptions/system_error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef system_error_hpp 5 | #define system_error_hpp 6 | 7 | #include 8 | 9 | #include "error.hpp" 10 | 11 | namespace octopus { 12 | 13 | /** 14 | A SystemError is any error that is not directly attributable to either the user or the program, 15 | e.g. if a file goes missing or we run out of memory. 16 | */ 17 | class SystemError : public Error 18 | { 19 | virtual std::string do_type() const override { return "system"; } 20 | public: 21 | virtual ~SystemError() = default; 22 | }; 23 | 24 | } // namespace octopus 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/core/csr/filters/variant_filter_utils.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef variant_filter_utils_hpp 5 | #define variant_filter_utils_hpp 6 | 7 | #include "io/variant/vcf_reader.hpp" 8 | #include "io/variant/vcf_writer.hpp" 9 | 10 | namespace octopus { namespace csr { 11 | 12 | void copy_somatics(const VcfReader& source, VcfWriter& dest); 13 | void copy_somatics(VcfReader::Path source, VcfReader::Path dest); 14 | 15 | void copy_denovos(const VcfReader& source, VcfWriter& dest); 16 | void copy_denovos(VcfReader::Path source, VcfReader::Path dest); 17 | 18 | } // namespace csr 19 | } // namespace octopus 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/core/csr/facets/repeat_context.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "repeat_context.hpp" 5 | 6 | #include 7 | 8 | #include "utils/repeat_finder.hpp" 9 | 10 | namespace octopus { namespace csr { 11 | 12 | const std::string RepeatContext::name_ {"RepeatContext"}; 13 | 14 | RepeatContext::RepeatContext(const ReferenceGenome& reference, GenomicRegion region) 15 | : result_ {find_exact_tandem_repeats(reference.fetch_sequence(region), region, 1, 20)} 16 | {} 17 | 18 | Facet::ResultType RepeatContext::do_get() const 19 | { 20 | return std::cref(result_); 21 | } 22 | 23 | } // namespace csr 24 | } // namespace octopus 25 | -------------------------------------------------------------------------------- /test/benchmark/benchmark_utils.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef Octopus_benchmark_utils_hpp 5 | #define Octopus_benchmark_utils_hpp 6 | 7 | #include 8 | 9 | template 10 | D benchmark(F f, unsigned num_tests) 11 | { 12 | D total {0}; 13 | 14 | for (; num_tests > 0; --num_tests) { 15 | const auto start = std::chrono::system_clock::now(); 16 | f(); 17 | const auto end = std::chrono::system_clock::now(); 18 | total += std::chrono::duration_cast(end - start); 19 | } 20 | 21 | return D {total / num_tests}; 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /test/unit/core/tools/cigar_scanner_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | #include "core/tools/vargen/variant_generator.hpp" 7 | 8 | namespace octopus { namespace test { 9 | 10 | namespace { 11 | auto make_cigar_scanner() 12 | { 13 | using Builder = VariantGenerator::Builder; 14 | return Builder().add_generator(Builder::Generator::Alignment); 15 | } 16 | } 17 | 18 | BOOST_AUTO_TEST_SUITE(core) 19 | BOOST_AUTO_TEST_SUITE(cigar_scanner) 20 | 21 | 22 | 23 | BOOST_AUTO_TEST_SUITE_END() 24 | BOOST_AUTO_TEST_SUITE_END() 25 | 26 | } // namespace test 27 | } // namespace octopus 28 | -------------------------------------------------------------------------------- /src/basics/tandem_repeat.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "tandem_repeat.hpp" 5 | 6 | namespace octopus { 7 | 8 | unsigned count_periods(const TandemRepeat& repeat) noexcept 9 | { 10 | return region_size(repeat) / repeat.period(); 11 | } 12 | 13 | bool operator==(const TandemRepeat& lhs, const TandemRepeat& rhs) noexcept 14 | { 15 | return is_same_region(lhs, rhs) && lhs.period() == rhs.period(); 16 | } 17 | 18 | bool operator<(const TandemRepeat& lhs, const TandemRepeat& rhs) noexcept 19 | { 20 | return is_same_region(lhs, rhs) ? lhs.period() < rhs.period() : mapped_region(lhs) < mapped_region(rhs); 21 | } 22 | 23 | } // namespace octopus 24 | -------------------------------------------------------------------------------- /src/core/models/error/snv_error_model.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "snv_error_model.hpp" 5 | 6 | namespace octopus { 7 | 8 | std::unique_ptr SnvErrorModel::clone() const 9 | { 10 | return do_clone(); 11 | } 12 | 13 | void SnvErrorModel::evaluate(const Haplotype& haplotype, 14 | MutationVector& forward_snv_mask, PenaltyVector& forward_snv_priors, 15 | MutationVector& reverse_snv_mask, PenaltyVector& reverse_snv_priors) const 16 | { 17 | do_evaluate(haplotype, forward_snv_mask, forward_snv_priors, reverse_snv_mask, reverse_snv_priors); 18 | } 19 | 20 | } // namespace octopus 21 | -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | This folder contains all of the tests for octopus. These can be divded into three categories: 2 | 3 | NOTE: Many of the tests use real data. In order to run the tests the files specified in 'test_common.h' must be present in your system. 4 | 5 | 1. Component unit tests: these tests cover functionality requirments of the major components of octopus. They are designed to ensure expected functionality, especially at edge cases, and avoid common bugs (e.g. off-by-one errors). Note many of the tests here are run on real data. 6 | 2. Benchmarks: these tests contain benchmarks for various key components. Generally these are tests that have directed design decisions (e.g. using virtual methods). 7 | 3. Data: these are tests on real data, usually 1000G. They are designed to measure and improve calling performance. 8 | -------------------------------------------------------------------------------- /src/exceptions/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "error.hpp" 5 | 6 | #include 7 | 8 | namespace octopus { 9 | 10 | std::string Error::type() const 11 | { 12 | return do_type(); 13 | } 14 | 15 | std::string Error::where() const 16 | { 17 | return do_where(); 18 | } 19 | 20 | std::string Error::why() const 21 | { 22 | return do_why(); 23 | } 24 | 25 | std::string Error::help() const 26 | { 27 | return do_help(); 28 | } 29 | 30 | const char* Error::what() const noexcept 31 | { 32 | std::ostringstream ss {}; 33 | 34 | what_ = ss.str(); 35 | 36 | ss << "type: " << type(); 37 | 38 | return what_.c_str(); 39 | } 40 | 41 | } // namespace octopus 42 | -------------------------------------------------------------------------------- /src/core/csr/measures/measure_factory.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef measure_factory_hpp 5 | #define measure_factory_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "utils/string_utils.hpp" 12 | #include "measure.hpp" 13 | 14 | namespace octopus { namespace csr { 15 | 16 | MeasureWrapper make_measure(std::string name); 17 | 18 | std::vector make_measures(std::vector names); 19 | 20 | std::vector get_all_measure_names(); 21 | 22 | void print_help(const std::vector& measures, std::ostream& os); 23 | void print_all_measures_help(std::ostream& os); 24 | 25 | } // namespace csr 26 | } // namespace octopus 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/core/tools/vargen/utils/global_aligner.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef global_aligner_hpp 5 | #define global_aligner_hpp 6 | 7 | #include 8 | 9 | #include "basics/cigar_string.hpp" 10 | 11 | namespace octopus { namespace coretools { 12 | 13 | struct Model 14 | { 15 | using ScoreType = short; 16 | ScoreType match = 2; 17 | ScoreType mismatch = -3; 18 | ScoreType gap_open = -8; 19 | ScoreType gap_extend = -1; 20 | }; 21 | 22 | struct Alignment 23 | { 24 | CigarString cigar; 25 | int score; 26 | }; 27 | 28 | Alignment align(const std::string& target, const std::string& query, Model model = Model {}); 29 | 30 | } // namespace coretools 31 | } // namespace octopus 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/exceptions/unimplemented_feature_error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "unimplemented_feature_error.hpp" 5 | 6 | #include 7 | 8 | namespace octopus { 9 | 10 | UnimplementedFeatureError::UnimplementedFeatureError(std::string feature, std::string where) 11 | : feature_ {std::move(feature)} 12 | , where_ {std::move(where)} 13 | {} 14 | 15 | std::string UnimplementedFeatureError::do_why() const 16 | { 17 | return feature_ + " is not currently implemented"; 18 | } 19 | 20 | std::string UnimplementedFeatureError::do_help() const 21 | { 22 | return "submit a feature request"; 23 | } 24 | 25 | std::string UnimplementedFeatureError::do_where() const 26 | { 27 | return where_; 28 | } 29 | 30 | } // namespace octopus 31 | -------------------------------------------------------------------------------- /src/logging/main_logging.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef main_logging_hpp 5 | #define main_logging_hpp 6 | 7 | #include 8 | 9 | #include "config/option_parser.hpp" 10 | 11 | #include "logging.hpp" 12 | 13 | namespace octopus { 14 | 15 | namespace detail { 16 | std::string make_banner(); 17 | } 18 | 19 | void log_program_startup(); // Always uses InfoLogger 20 | 21 | void log_command_line_options(const options::OptionMap& options); 22 | 23 | template 24 | void log_program_end(Log& log) 25 | { 26 | log << detail::make_banner(); 27 | } 28 | 29 | inline void log_program_end() 30 | { 31 | logging::InfoLogger log {}; 32 | log_program_end(log); 33 | } 34 | 35 | } // namespace octopus 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ARCH="amd64" 2 | FROM ${ARCH}/ubuntu:impish 3 | 4 | ARG DEBIAN_FRONTEND=noninteractive 5 | ENV TZ=Europe/London 6 | 7 | # Get dependencies 8 | RUN apt-get -y update \ 9 | && apt-get -y install \ 10 | build-essential \ 11 | libboost-all-dev \ 12 | libgmp-dev \ 13 | cmake \ 14 | libhts-dev \ 15 | python3-pip \ 16 | git \ 17 | && pip3 install distro 18 | 19 | # Install Octopus 20 | ARG THREADS=4 21 | ARG CPU=haswell 22 | COPY . /opt/octopus 23 | RUN /opt/octopus/scripts/install.py \ 24 | --threads $THREADS \ 25 | --architecture $CPU 26 | 27 | # Cleanup git - only needed during install for commit info 28 | RUN apt-get purge -y git \ 29 | && rm -r /opt/octopus/.git \ 30 | && apt-get clean \ 31 | && rm -rf /var/lib/apt/lists/* 32 | 33 | ENV PATH="/opt/octopus/bin:${PATH}" 34 | 35 | ENTRYPOINT ["octopus"] 36 | -------------------------------------------------------------------------------- /src/core/csr/facets/genotypes.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef genotypes_hpp 5 | #define genotypes_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "facet.hpp" 11 | 12 | namespace octopus { namespace csr { 13 | 14 | class Genotypes : public Facet 15 | { 16 | public: 17 | using ResultType = std::reference_wrapper; 18 | 19 | Genotypes() = default; 20 | Genotypes(GenotypeMap genotypes); 21 | 22 | private: 23 | static const std::string name_; 24 | 25 | GenotypeMap genotypes_; 26 | 27 | const std::string& do_name() const noexcept override { return name_; } 28 | Facet::ResultType do_get() const override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /website/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. 4 | 5 | ## Installation 6 | 7 | ```console 8 | yarn install 9 | ``` 10 | 11 | ## Local Development 12 | 13 | ```console 14 | yarn start 15 | ``` 16 | 17 | This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. 18 | 19 | ## Build 20 | 21 | ```console 22 | yarn build 23 | ``` 24 | 25 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 26 | 27 | ## Deployment 28 | 29 | ```console 30 | GIT_USER= USE_SSH=true yarn deploy 31 | ``` 32 | 33 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 34 | -------------------------------------------------------------------------------- /website/docs/guides/advanced/configs.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: configs 3 | title: Config files 4 | --- 5 | 6 | The `--config` command line option is a handy way configure Octopus. The argument is a text file containing settings for any subset of options (other than `config` itself). Each line of the file contains a parameter setting in the format 7 | 8 | ```shell 9 | parameter = argument 10 | ``` 11 | 12 | Comment lines are allowed in the config file are proceeded with `#`. 13 | 14 | It is perfectly fine to specify a config file and explicit command line options, e.g.: 15 | 16 | ```shell 17 | $ octopus --config my-config.config -R reference.fa -I reads.bam -o octopus.vcf 18 | ``` 19 | 20 | Explicit command line options that are in the config file are ignored. 21 | 22 | The [configs](https://github.com/luntergroup/octopus/tree/develop/configs) directory in the main source tree will be used to store useful config files. -------------------------------------------------------------------------------- /src/core/models/error/indel_error_model.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "indel_error_model.hpp" 5 | 6 | #include "core/types/haplotype.hpp" 7 | 8 | namespace octopus { 9 | 10 | std::unique_ptr IndelErrorModel::clone() const 11 | { 12 | return do_clone(); 13 | } 14 | 15 | void IndelErrorModel::set_penalties(const Haplotype& haplotype, PenaltyVector& gap_open_penalities, PenaltyType& gap_extend_penalty) const 16 | { 17 | do_set_penalties(haplotype, gap_open_penalities, gap_extend_penalty); 18 | } 19 | 20 | void IndelErrorModel::set_penalties(const Haplotype& haplotype, PenaltyVector& gap_open_penalities, PenaltyVector& gap_extend_penalties) const 21 | { 22 | do_set_penalties(haplotype, gap_open_penalities, gap_extend_penalties); 23 | } 24 | 25 | } // namespace octopus 26 | -------------------------------------------------------------------------------- /src/exceptions/program_error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | #include "error.hpp" 7 | #include "config/config.hpp" 8 | 9 | #ifndef program_error_hpp 10 | #define program_error_hpp 11 | 12 | namespace octopus { 13 | 14 | /** 15 | A ProgramError is any error that octopus is responsible for. Note the error itself may not be a 16 | bug, but in these cases they should be handled. 17 | */ 18 | class ProgramError : public Error 19 | { 20 | virtual std::string do_type() const override { return "program"; } 21 | virtual std::string do_help() const override 22 | { 23 | return "Run in debug mode and send the log file to " + config::BugReport; 24 | } 25 | public: 26 | virtual ~ProgramError() = default; 27 | }; 28 | 29 | } // namespace octopus 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/exceptions/unimplemented_feature_error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef unimplemented_feature_error_hpp 5 | #define unimplemented_feature_error_hpp 6 | 7 | #include 8 | 9 | #include "program_error.hpp" 10 | 11 | namespace octopus { 12 | 13 | class UnimplementedFeatureError : public ProgramError 14 | { 15 | public: 16 | UnimplementedFeatureError() = delete; 17 | UnimplementedFeatureError(std::string feature, std::string where); 18 | 19 | virtual ~UnimplementedFeatureError() override = default; 20 | 21 | private: 22 | virtual std::string do_why() const override; 23 | virtual std::string do_help() const override; 24 | virtual std::string do_where() const override; 25 | 26 | std::string feature_, where_; 27 | }; 28 | 29 | } // namespace octopus 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /test/data/human_skip_regions.txt: -------------------------------------------------------------------------------- 1 | GL000207.1 2 | GL000226.1 3 | GL000229.1 4 | GL000231.1 5 | GL000210.1 6 | GL000239.1 7 | GL000235.1 8 | GL000201.1 9 | GL000247.1 10 | GL000245.1 11 | GL000197.1 12 | GL000203.1 13 | GL000246.1 14 | GL000249.1 15 | GL000196.1 16 | GL000248.1 17 | GL000244.1 18 | GL000238.1 19 | GL000202.1 20 | GL000234.1 21 | GL000232.1 22 | GL000206.1 23 | GL000240.1 24 | GL000236.1 25 | GL000241.1 26 | GL000243.1 27 | GL000242.1 28 | GL000230.1 29 | GL000237.1 30 | GL000233.1 31 | GL000204.1 32 | GL000198.1 33 | GL000208.1 34 | GL000191.1 35 | GL000227.1 36 | GL000228.1 37 | GL000214.1 38 | GL000221.1 39 | GL000209.1 40 | GL000218.1 41 | GL000220.1 42 | GL000213.1 43 | GL000211.1 44 | GL000199.1 45 | GL000217.1 46 | GL000216.1 47 | GL000215.1 48 | GL000205.1 49 | GL000219.1 50 | GL000224.1 51 | GL000223.1 52 | GL000195.1 53 | GL000212.1 54 | GL000222.1 55 | GL000200.1 56 | GL000193.1 57 | GL000194.1 58 | GL000225.1 59 | GL000192.1 -------------------------------------------------------------------------------- /src/core/csr/facets/samples.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef samples_hpp 5 | #define samples_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "facet.hpp" 12 | 13 | namespace octopus { namespace csr { 14 | 15 | class Samples : public Facet 16 | { 17 | public: 18 | using ResultType = std::reference_wrapper>; 19 | 20 | Samples() = default; 21 | 22 | Samples(std::vector samples); 23 | 24 | private: 25 | static const std::string name_; 26 | 27 | std::vector samples_; 28 | 29 | const std::string& do_name() const noexcept override { return name_; } 30 | Facet::ResultType do_get() const override; 31 | }; 32 | 33 | } // namespace csr 34 | } // namespace octopus 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/concepts/indexed.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef indexed_hpp 5 | #define indexed_hpp 6 | 7 | #include 8 | #include 9 | 10 | namespace octopus { 11 | 12 | template 13 | class Indexed {}; 14 | 15 | template 16 | IndexType index_of(const Indexed& indexed) noexcept 17 | { 18 | return static_cast(indexed).index(); 19 | } 20 | 21 | template 22 | struct is_indexed : std::false_type {}; 23 | template 24 | struct is_indexed()))>::value> > : std::true_type {}; 25 | 26 | template 27 | constexpr bool is_indexed_v = is_indexed::value; 28 | 29 | } // namespace octopus 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/core/csr/measures/posterior_probability.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef posterior_probability_hpp 5 | #define posterior_probability_hpp 6 | 7 | #include 8 | 9 | #include "measure.hpp" 10 | 11 | namespace octopus { 12 | 13 | class VcfRecord; 14 | 15 | namespace csr { 16 | 17 | class PosteriorProbability : public Measure 18 | { 19 | const static std::string name_; 20 | std::unique_ptr do_clone() const override; 21 | ValueType get_value_type() const override; 22 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 23 | ResultCardinality do_cardinality() const noexcept override; 24 | const std::string& do_name() const override; 25 | std::string do_describe() const override; 26 | }; 27 | 28 | } // namespace csr 29 | } // namespace octopus 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/utils/hash_functions.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef hash_functions_hpp 5 | #define hash_functions_hpp 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace octopus { namespace utils 14 | { 15 | struct StringRefHash 16 | { 17 | std::size_t operator()(const boost::string_ref& str) const 18 | { 19 | return boost::hash_range(str.begin(), str.end()); 20 | } 21 | }; 22 | 23 | struct FilepathHash 24 | { 25 | std::size_t operator()(const boost::filesystem::path& path) const 26 | { 27 | return std::hash()(path.string()); 28 | } 29 | }; 30 | } // namespace utils 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/facets/pedigree.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef csr_pedigree_hpp 5 | #define csr_pedigree_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "basics/pedigree.hpp" 12 | #include "facet.hpp" 13 | 14 | namespace octopus { namespace csr { 15 | 16 | class Pedigree : public Facet 17 | { 18 | public: 19 | using ResultType = std::reference_wrapper; 20 | 21 | Pedigree() = default; 22 | Pedigree(octopus::Pedigree pedigree); 23 | 24 | private: 25 | static const std::string name_; 26 | 27 | octopus::Pedigree pedigree_; 28 | 29 | const std::string& do_name() const noexcept override { return name_; } 30 | Facet::ResultType do_get() const override; 31 | }; 32 | 33 | } // namespace csr 34 | } // namespace octopus 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/core/csr/measures/classification_confidence.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef classification_confidence_hpp 5 | #define classification_confidence_hpp 6 | 7 | #include 8 | 9 | #include "measure.hpp" 10 | 11 | namespace octopus { 12 | 13 | class VcfRecord; 14 | 15 | namespace csr { 16 | 17 | class ClassificationConfidence : public Measure 18 | { 19 | const static std::string name_; 20 | std::unique_ptr do_clone() const override; 21 | ValueType get_value_type() const override; 22 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 23 | ResultCardinality do_cardinality() const noexcept override; 24 | const std::string& do_name() const override; 25 | std::string do_describe() const override; 26 | }; 27 | 28 | } // namespace csr 29 | } // namespace octopus 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/core/csr/measures/quality.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef quality_hpp 5 | #define quality_hpp 6 | 7 | #include 8 | 9 | #include "measure.hpp" 10 | 11 | namespace octopus { 12 | 13 | class VcfRecord; 14 | 15 | namespace csr { 16 | 17 | class Quality : public Measure 18 | { 19 | const static std::string name_; 20 | std::unique_ptr do_clone() const override; 21 | ValueType get_value_type() const override; 22 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 23 | ResultCardinality do_cardinality() const noexcept override; 24 | const std::string& do_name() const override; 25 | std::string do_describe() const override; 26 | bool is_required_vcf_field() const noexcept override { return true; } 27 | }; 28 | 29 | } // namespace csr 30 | } // namespace octopus 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/utils/reorder.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef reorder_hpp 5 | #define reorder_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace octopus { 13 | 14 | template 15 | ValueIterator reorder(OrderIterator order_begin, OrderIterator order_end, ValueIterator v) 16 | { 17 | using ValueType = typename std::iterator_traits::value_type; 18 | const auto n = std::distance(order_begin, order_end); 19 | std::vector buffer {}; 20 | buffer.reserve(n); 21 | std::transform(order_begin, order_end, std::back_inserter(buffer), [&] (auto idx) { return std::move(*std::next(v, idx)); }); 22 | return std::copy_n(std::make_move_iterator(std::begin(buffer)), n, v); 23 | } 24 | 25 | } // namespace octopus 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/core/csr/facets/overlapping_reads.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef overlapping_reads_hpp 5 | #define overlapping_reads_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "facet.hpp" 11 | #include "config/common.hpp" 12 | #include "basics/aligned_read.hpp" 13 | 14 | namespace octopus { namespace csr { 15 | 16 | class OverlappingReads : public Facet 17 | { 18 | public: 19 | using ResultType = std::reference_wrapper; 20 | 21 | OverlappingReads() = default; 22 | 23 | OverlappingReads(ReadMap reads); 24 | 25 | private: 26 | static const std::string name_; 27 | 28 | ReadMap reads_; 29 | 30 | const std::string& do_name() const noexcept override { return name_; } 31 | Facet::ResultType do_get() const override; 32 | }; 33 | 34 | } // namespace csr 35 | } // namespace octopus 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/core/csr/facets/reads_summary.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef reads_summary_hpp 5 | #define reads_summary_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "facet.hpp" 11 | #include "config/common.hpp" 12 | #include "basics/aligned_read.hpp" 13 | 14 | namespace octopus { namespace csr { 15 | 16 | class ReadsSummary : public Facet 17 | { 18 | public: 19 | using ResultType = std::reference_wrapper; 20 | 21 | ReadsSummary() = default; 22 | 23 | ReadsSummary(const ReadMap& reads); 24 | 25 | private: 26 | static const std::string name_; 27 | 28 | ReadsSummaryMap result_; 29 | 30 | const std::string& do_name() const noexcept override { return name_; } 31 | Facet::ResultType do_get() const override; 32 | }; 33 | 34 | } // namespace csr 35 | } // namespace octopus 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /test/unit/utils/maths_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "utils/maths.hpp" 9 | 10 | namespace octopus { namespace test { 11 | 12 | static constexpr double tolerance {1e-10}; 13 | 14 | BOOST_AUTO_TEST_SUITE(utils) 15 | BOOST_AUTO_TEST_SUITE(maths) 16 | 17 | BOOST_AUTO_TEST_CASE(log_sum_exp_handles_edge_cases) 18 | { 19 | using octopus::maths::log_sum_exp; 20 | static constexpr double zero {0.0}; 21 | static constexpr double lnHalf {-0.6931471805599453}; 22 | BOOST_CHECK_CLOSE(log_sum_exp(lnHalf, lnHalf), zero, tolerance); 23 | BOOST_CHECK_CLOSE(log_sum_exp(zero, zero), -lnHalf, tolerance); 24 | } 25 | 26 | BOOST_AUTO_TEST_SUITE_END() 27 | BOOST_AUTO_TEST_SUITE_END() 28 | 29 | } // namespace test 30 | } // namespace octopus 31 | -------------------------------------------------------------------------------- /src/core/csr/measures/phase_length.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef phase_length_hpp 5 | #define phase_length_hpp 6 | 7 | #include 8 | 9 | #include "measure.hpp" 10 | 11 | namespace octopus { 12 | 13 | class VcfRecord; 14 | 15 | namespace csr { 16 | 17 | class PhaseLength : public Measure 18 | { 19 | const static std::string name_; 20 | std::unique_ptr do_clone() const override; 21 | ValueType get_value_type() const override; 22 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 23 | ResultCardinality do_cardinality() const noexcept override; 24 | const std::string& do_name() const override; 25 | std::string do_describe() const override; 26 | std::vector do_requirements() const override; 27 | }; 28 | 29 | } // namespace csr 30 | } // namespace octopus 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/gc_content.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef gc_content_hpp 5 | #define gc_content_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class GCContent : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/model_posterior.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef model_posterior_hpp 5 | #define model_posterior_hpp 6 | 7 | #include 8 | 9 | #include "measure.hpp" 10 | 11 | namespace octopus { 12 | 13 | class VcfRecord; 14 | 15 | namespace csr { 16 | 17 | class ModelPosterior : public Measure 18 | { 19 | const static std::string name_; 20 | std::unique_ptr do_clone() const override; 21 | ValueType get_value_type() const override; 22 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 23 | ResultCardinality do_cardinality() const noexcept override; 24 | const std::string& do_name() const override; 25 | std::string do_describe() const override; 26 | std::vector do_requirements() const override; 27 | }; 28 | 29 | } // namespace csr 30 | } // namespace octopus 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/str_length.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef str_length_hpp 5 | #define str_length_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class STRLength : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/str_period.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef str_period_hpp 5 | #define str_period_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class STRPeriod : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /test/mock/mock_variant_generator.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef mock_variant_generator_hpp 5 | #define mock_variant_generator_hpp 6 | 7 | #include "core/tools/vargen/variant_generator.hpp" 8 | 9 | namespace octopus { namespace test { namespace mock { 10 | 11 | class MockVariantGenerator : public VariantGenerator 12 | { 13 | public: 14 | MockVariantGenerator() = delete; 15 | 16 | MockVariantGenerator(const MockVariantGenerator&) = default; 17 | MockVariantGenerator& operator=(const MockVariantGenerator&) = default; 18 | MockVariantGenerator(MockVariantGenerator&&) = default; 19 | MockVariantGenerator& operator=(MockVariantGenerator&&) = default; 20 | 21 | ~MockVariantGenerator() override = default; 22 | 23 | private: 24 | 25 | }; 26 | 27 | } // namespace mock 28 | } // namespace test 29 | } // namespace octopus 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/core/callers/caller_factory.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "caller_factory.hpp" 5 | 6 | #include 7 | 8 | #include "io/reference/reference_genome.hpp" 9 | #include "readpipe/read_pipe.hpp" 10 | 11 | namespace octopus { 12 | 13 | CallerFactory::CallerFactory(CallerBuilder template_builder) 14 | : template_builder_ {std::move(template_builder)} 15 | {} 16 | 17 | CallerFactory& CallerFactory::set_reference(const ReferenceGenome& reference) noexcept 18 | { 19 | template_builder_.set_reference(reference); 20 | return *this; 21 | } 22 | 23 | CallerFactory& CallerFactory::set_read_pipe(ReadPipe& read_pipe) noexcept 24 | { 25 | template_builder_.set_read_pipe(read_pipe); 26 | return *this; 27 | } 28 | 29 | std::unique_ptr CallerFactory::make(const ContigName& contig) const 30 | { 31 | return template_builder_.build(contig); 32 | } 33 | 34 | } // namespace octopus 35 | -------------------------------------------------------------------------------- /src/core/csr/measures/assigned_depth.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef assigned_depth_hpp 5 | #define assigned_depth_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class AssignedDepth : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/max_read_length.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef max_read_length_hpp 5 | #define max_read_length_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class MaxReadLength : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/mismatch_count.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef mismatch_count_hpp 5 | #define mismatch_count_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class MismatchCount : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/read_side_bias.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef read_side_bias_hpp 5 | #define read_side_bias_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class ReadSideBias : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/variant_length.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef variant_length_hpp 5 | #define variant_length_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class VariantLength : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/phylogeny_posterior.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef phylogeny_posterior_hpp 5 | #define phylogeny_posterior_hpp 6 | 7 | #include 8 | 9 | #include "measure.hpp" 10 | 11 | namespace octopus { 12 | 13 | class VcfRecord; 14 | 15 | namespace csr { 16 | 17 | class PhylogenyPosterior : public Measure 18 | { 19 | const static std::string name_; 20 | std::unique_ptr do_clone() const override; 21 | ValueType get_value_type() const override; 22 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 23 | ResultCardinality do_cardinality() const noexcept override; 24 | const std::string& do_name() const override; 25 | std::string do_describe() const override; 26 | bool is_required_vcf_field() const noexcept override { return true; } 27 | }; 28 | 29 | } // namespace csr 30 | } // namespace octopus 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/io/region/region_parser.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef region_parser_hpp 5 | #define region_parser_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include "io/reference/reference_genome.hpp" 13 | #include "basics/genomic_region.hpp" 14 | 15 | namespace octopus { namespace io { 16 | 17 | // Requires reference access to get contig sizes for partially specified regions (e.g. "4") 18 | GenomicRegion parse_region(std::string region, const ReferenceGenome& reference); 19 | 20 | enum class NonreferenceContigPolicy { exception, ignore }; 21 | 22 | std::deque 23 | extract_regions(const boost::filesystem::path& file_name, 24 | const ReferenceGenome& reference, 25 | NonreferenceContigPolicy policy = NonreferenceContigPolicy::exception); 26 | 27 | } // namespace io 28 | } // namespace octopus 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/core/csr/measures/is_transversion.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef is_transversion_hpp 5 | #define is_transversion_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class IsTransversion : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | boost::optional do_aggregator() const noexcept override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/base_mismatch_count.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef base_mismatch_count_hpp 5 | #define base_mismatch_count_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class BaseMismatchCount : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/somatic_haplotype_count.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef somatic_haplotype_count_hpp 5 | #define somatic_haplotype_count_hpp 6 | 7 | #include 8 | 9 | #include "measure.hpp" 10 | 11 | namespace octopus { 12 | 13 | class VcfRecord; 14 | 15 | namespace csr { 16 | 17 | class SomaticHaplotypeCount : public Measure 18 | { 19 | const static std::string name_; 20 | 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/base_mismatch_quality.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef base_mismatch_quality_hpp 5 | #define base_mismatch_quality_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class BaseMismatchQuality : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/clipped_read_fraction.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef clipped_read_fraction_hpp 5 | #define clipped_read_fraction_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class ClippedReadFraction : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/duplicate_concordance.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef duplicate_concordance_hpp 5 | #define duplicate_concordance_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class DuplicateConcordance : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/misaligned_read_count.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef misaligned_read_count_hpp 5 | #define misaligned_read_count_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class MisalignedReadCount : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/supplementary_fraction.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef supplementary_count_hpp 5 | #define supplementary_count_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class SupplementaryFraction : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/exceptions/unwritable_file_error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef unwritable_file_error_hpp 5 | #define unwritable_file_error_hpp 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include "user_error.hpp" 13 | 14 | namespace octopus { 15 | 16 | class UnwritableFileError : public UserError 17 | { 18 | public: 19 | using Path = boost::filesystem::path; 20 | 21 | UnwritableFileError() = delete; 22 | 23 | UnwritableFileError(Path file); 24 | 25 | UnwritableFileError(Path file, std::string type); 26 | 27 | virtual ~UnwritableFileError() override = default; 28 | 29 | private: 30 | virtual std::string do_why() const override; 31 | virtual std::string do_help() const override; 32 | 33 | Path file_; 34 | boost::optional type_; 35 | }; 36 | 37 | } // namespace octopus 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/exceptions/unwritable_file_error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "unwritable_file_error.hpp" 5 | 6 | #include 7 | #include 8 | 9 | namespace octopus { 10 | 11 | UnwritableFileError::UnwritableFileError(Path file) : file_ {std::move(file)} {} 12 | 13 | UnwritableFileError::UnwritableFileError(Path file, std::string type) 14 | : file_ {std::move(file)} 15 | , type_ {std::move(type)} 16 | {} 17 | 18 | std::string UnwritableFileError::do_why() const 19 | { 20 | std::ostringstream ss {}; 21 | ss << "the "; 22 | if (type_) { 23 | ss << *type_ << ' '; 24 | } 25 | ss << "file you specified " << file_ << ' '; 26 | ss << "is not writable"; 27 | return ss.str(); 28 | } 29 | 30 | std::string UnwritableFileError::do_help() const 31 | { 32 | return "ensure the specified path is correct and the location is writable (check permissions)"; 33 | } 34 | 35 | } // namespace octopus 36 | -------------------------------------------------------------------------------- /src/core/csr/measures/ambiguous_read_fraction.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef ambiguous_read_fraction_hpp 5 | #define ambiguous_read_fraction_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class AmbiguousReadFraction : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/csr/measures/denovo_contamination.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef denovo_contamination_hpp 5 | #define denovo_contamination_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class DeNovoContamination : public Measure 19 | { 20 | const static std::string name_; 21 | 22 | std::unique_ptr do_clone() const override; 23 | ValueType get_value_type() const override; 24 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 25 | ResultCardinality do_cardinality() const noexcept override; 26 | const std::string& do_name() const override; 27 | std::string do_describe() const override; 28 | std::vector do_requirements() const override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/core/csr/measures/normal_contamination.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef somatic_contamination_hpp 5 | #define somatic_contamination_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class NormalContamination : public Measure 19 | { 20 | const static std::string name_; 21 | 22 | std::unique_ptr do_clone() const override; 23 | ValueType get_value_type() const override; 24 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 25 | ResultCardinality do_cardinality() const noexcept override; 26 | const std::string& do_name() const override; 27 | std::string do_describe() const override; 28 | std::vector do_requirements() const override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /.travis/run_project_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "CC = ${CC}" 4 | echo "CXX = ${CXX}" 5 | echo "ASAN = ${ASAN}" 6 | cmake --version; 7 | ${CC} --version; 8 | ${CXX} --version; 9 | 10 | echo "COMMIT $(git rev-parse HEAD)" 11 | echo "BRANCHES" 12 | git branch 13 | echo "----------" 14 | 15 | if [ -n "${ASAN}" ]; then 16 | echo "Building with AddressSanitizer enabled..." 17 | SAN_FLAGS="-fsanitize=address -fsanitize=undefined -g -O1" 18 | export CXXFLAGS=${SAN_FLAGS} 19 | export LDFLAGS=${SAN_FLAGS} 20 | fi 21 | 22 | # Install apt-get dependencies 23 | sudo apt-get update 24 | sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ 25 | libicu-dev \ 26 | curl \ 27 | libcurl4-openssl-dev \ 28 | libbz2-dev \ 29 | liblzma-dev \ 30 | zlib1g-dev \ 31 | libcrypto++-dev \ 32 | libboost-all-dev 33 | 34 | # Install htslib 35 | git clone https://github.com/samtools/htslib.git 36 | cd htslib && autoheader && autoconf && ./configure && make && sudo make install 37 | cd .. 38 | 39 | ./scripts/install.py --threads 1 --clean -c $CC -cxx $CXX 40 | -------------------------------------------------------------------------------- /src/core/csr/measures/mapping_quality_divergence.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef mapping_quality_divergence_hpp 5 | #define mapping_quality_divergence_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class MappingQualityDivergence : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | }; 29 | 30 | } // namespace csr 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/utils/path_utils.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef path_utils_hpp 5 | #define path_utils_hpp 6 | 7 | #include 8 | #include 9 | 10 | namespace octopus { 11 | 12 | namespace fs = boost::filesystem; 13 | 14 | enum class WorkingDirectoryResolvePolicy { prefer_working_directory, prefer_run_directory }; 15 | enum class SymblinkResolvePolicy { resolve, dont_resolve }; 16 | 17 | boost::optional get_home_directory(); 18 | 19 | bool is_shorthand_user_path(const fs::path& path) noexcept; 20 | 21 | fs::path expand_user_path(const fs::path& path); 22 | 23 | fs::path 24 | resolve_path(const fs::path& path, const fs::path& working_directory, 25 | WorkingDirectoryResolvePolicy wd_policy = WorkingDirectoryResolvePolicy::prefer_working_directory, 26 | SymblinkResolvePolicy symblink_policy = SymblinkResolvePolicy::dont_resolve); 27 | 28 | } // namespace octopus 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /website/docs/guides/models/polyclone.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: polyclone 3 | title: Polyclone 4 | --- 5 | 6 | The `polyclone` calling model is for calling variation in a pooled sample of haploid clones where the number and mixture composition of clones is unknown, as is sometimes the case in bacteria or virus sequencing studies. 7 | 8 | ## Usage 9 | 10 | If your sample contains an unknown mix of haploid clones (e.g. some bacteria or viral samples), use the `polyclone` calling model: 11 | 12 | ```shell 13 | $ octopus -R H37Rv.fa -I mycobacterium_tuberculosis.bam -C polyclone 14 | ``` 15 | 16 | This model will automatically detect the number of subclones in your sample (up to the maximum given by `--max-clones`). 17 | 18 | ## Performance considerations 19 | 20 | The most important parameter in this model is `--max-clones` which determines the maximum number of haplotypes that octopus will try to use to fit the data. This is a bit like setting the 'ploidy' for the sample. Higher values of `--max-clones` may lead to longer runtimes and more memory usage - we do not recommend values above 10. -------------------------------------------------------------------------------- /src/core/csr/facets/ploidies.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "ploidies.hpp" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace octopus { namespace csr { 11 | 12 | const std::string Ploidies::name_ {"Ploidies"}; 13 | 14 | Ploidies::Ploidies(const PloidyMap& ploidies, const GenomicRegion& region, const std::vector& samples) 15 | { 16 | const auto local_ploidies = get_ploidies(samples, region.contig_name(), ploidies); 17 | ploidies_.reserve(samples.size()); 18 | std::transform(std::cbegin(samples), std::cend(samples), std::cbegin(local_ploidies), 19 | std::inserter(ploidies_, std::begin(ploidies_)), 20 | [] (const auto& sample, auto ploidy) { return std::make_pair(sample, ploidy); }); 21 | } 22 | 23 | Facet::ResultType Ploidies::do_get() const 24 | { 25 | return std::cref(ploidies_); 26 | } 27 | 28 | } // namespace csr 29 | } // namespace octopus 30 | -------------------------------------------------------------------------------- /src/core/csr/measures/error_rate.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef error_rate_hpp 5 | #define error_rate_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class ErrorRate : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | boost::optional do_aggregator() const noexcept override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /website/docs/guides/preprocessing.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: preprocessing 3 | title: Read Preprocessing 4 | --- 5 | 6 | The basic idea of read pre-processing is to remove or modify reads containing artifact sequences that are likely to mislead variant calling or increase runtime by introducing spurious candidates. 7 | 8 | ## Deduplication 9 | 10 | Read duplicates can arise during sequencing in several ways, and are library-prep and technology dependent: 11 | 12 | ![Docusaurus](/img/guides/duplicates.png) 13 | 14 | See [here](https://www.cureffi.org/2012/12/11/how-pcr-duplicates-arise-in-next-generation-sequencing/) and [here](http://core-genomics.blogspot.com/2016/05/increased-read-duplication-on-patterned.html) for more detailed discussions on how duplicates arise. 15 | 16 | Duplicates can be problematic for variant calling as they can introduce systematic error (e.g. copying errors during PCR). Removing them is usually recommended for WGS libraries, but this remains somewhat [controversial](https://bmcbioinformatics.biomedcentral.com/articles/10.1186/s12859-016-1097-3). 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/core/csr/facets/ploidies.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef ploidies_hpp 5 | #define ploidies_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "config/common.hpp" 12 | #include "basics/genomic_region.hpp" 13 | #include "basics/ploidy_map.hpp" 14 | #include "facet.hpp" 15 | 16 | namespace octopus { namespace csr { 17 | 18 | class Ploidies : public Facet 19 | { 20 | public: 21 | using ResultType = std::reference_wrapper; 22 | 23 | Ploidies() = default; 24 | Ploidies(const PloidyMap& ploidies, const GenomicRegion& region, const std::vector& samples); 25 | 26 | private: 27 | static const std::string name_; 28 | 29 | LocalPloidyMap ploidies_; 30 | 31 | const std::string& do_name() const noexcept override { return name_; } 32 | Facet::ResultType do_get() const override; 33 | }; 34 | 35 | } // namespace csr 36 | } // namespace octopus 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/core/csr/measures/allele_depth.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef allele_count_hpp 5 | #define allele_count_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class AlleleDepth : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | boost::optional do_aggregator() const noexcept override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/core/csr/measures/median_somatic_mapping_quality.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef median_somatic_mapping_quality_hpp 5 | #define median_somatic_mapping_quality_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class MedianSomaticMappingQuality : public Measure 19 | { 20 | const static std::string name_; 21 | 22 | std::unique_ptr do_clone() const override; 23 | ValueType get_value_type() const override; 24 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 25 | ResultCardinality do_cardinality() const noexcept override; 26 | const std::string& do_name() const override; 27 | std::string do_describe() const override; 28 | std::vector do_requirements() const override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/core/csr/measures/mean_likelihood.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef mean_likelihood_hpp 5 | #define mean_likelihood_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class MeanLikelihood : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | boost::optional do_aggregator() const noexcept override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/core/csr/measures/allele_frequency.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef allele_frequency_hpp 5 | #define allele_frequency_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class AlleleFrequency : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | boost::optional do_aggregator() const noexcept override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/core/csr/measures/alt_allele_count.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef alt_allele_count_hpp 5 | #define alt_allele_count_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class AltAlleleCount : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | boost::optional do_aggregator() const noexcept override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/core/csr/measures/error_rate_stdev.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef error_rate_stdev_hpp 5 | #define error_rate_stdev_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class ErrorRateStdev : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | boost::optional do_aggregator() const noexcept override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/core/csr/measures/genotype_quality.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef genotype_quality_hpp 5 | #define genotype_quality_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class GenotypeQuality : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | bool is_required_vcf_field() const noexcept override { return true; } 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/timers.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef timers_hpp 5 | #define timers_hpp 6 | 7 | //#define BENCHMARK 8 | 9 | #include 10 | 11 | #include 12 | 13 | // variant caller timers 14 | extern boost::timer::cpu_timer init_timer; 15 | extern boost::timer::cpu_timer haplotype_likelihood_timer; 16 | extern boost::timer::cpu_timer latent_timer; 17 | extern boost::timer::cpu_timer calling_timer; 18 | extern boost::timer::cpu_timer phasing_timer; 19 | extern boost::timer::cpu_timer output_timer; 20 | 21 | using TimerArray = std::array; 22 | 23 | extern TimerArray misc_timer; 24 | 25 | inline void resume(boost::timer::cpu_timer& timer) 26 | { 27 | #ifdef BENCHMARK 28 | timer.resume(); 29 | #endif 30 | } 31 | 32 | inline void pause(boost::timer::cpu_timer& timer) 33 | { 34 | #ifdef BENCHMARK 35 | timer.stop(); 36 | #endif 37 | } 38 | 39 | void init_timers(); 40 | 41 | void print_all_timers(); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/core/csr/measures/median_base_quality.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef median_base_quality_hpp 5 | #define median_base_quality_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class MedianBaseQuality : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | boost::optional do_aggregator() const noexcept override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/core/csr/measures/allele_frequency_bias.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef allele_frequency_bias_hpp 5 | #define allele_frequency_bias_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class AlleleFrequencyBias : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | boost::optional do_aggregator() const noexcept override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/core/csr/measures/allele_mapping_quality.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef allele_mapping_quality_hpp 5 | #define allele_mapping_quality_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class AlleleMappingQuality : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | boost::optional do_aggregator() const noexcept override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/core/csr/measures/duplicate_allele_depth.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef duplicate_allele_depth_hpp 5 | #define duplicate_allele_depth_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class DuplicateAlleleDepth : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | boost::optional do_aggregator() const noexcept override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Daniel Cooke 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/core/csr/measures/duplicate_allele_fraction.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef duplicate_allele_fraction_hpp 5 | #define duplicate_allele_fraction_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class DuplicateAlleleFraction : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | boost::optional do_aggregator() const noexcept override; 29 | }; 30 | 31 | } // namespace csr 32 | } // namespace octopus 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /website/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start", 8 | "build": "docusaurus build", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "docusaurus deploy", 11 | "clear": "docusaurus clear", 12 | "serve": "docusaurus serve", 13 | "write-translations": "docusaurus write-translations", 14 | "write-heading-ids": "docusaurus write-heading-ids" 15 | }, 16 | "dependencies": { 17 | "@docusaurus/core": "2.0.0-beta.0", 18 | "@docusaurus/preset-classic": "2.0.0-beta.0", 19 | "@mdx-js/react": "^1.6.21", 20 | "@svgr/webpack": "^5.5.0", 21 | "clsx": "^1.1.1", 22 | "file-loader": "^6.2.0", 23 | "react": "^17.0.1", 24 | "react-dom": "^17.0.1", 25 | "url-loader": "^4.1.1" 26 | }, 27 | "browserslist": { 28 | "production": [ 29 | ">0.5%", 30 | "not dead", 31 | "not op_mini all" 32 | ], 33 | "development": [ 34 | "last 1 chrome version", 35 | "last 1 firefox version", 36 | "last 1 safari version" 37 | ] 38 | } 39 | } -------------------------------------------------------------------------------- /src/core/csr/measures/base_mismatch_fraction.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef base_mismatch_fraction_hpp 5 | #define base_mismatch_fraction_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | #include "depth.hpp" 12 | 13 | namespace octopus { 14 | 15 | class VcfRecord; 16 | 17 | namespace csr { 18 | 19 | class BaseMismatchFraction : public Measure 20 | { 21 | Depth depth_; 22 | const static std::string name_; 23 | std::unique_ptr do_clone() const override; 24 | ValueType get_value_type() const override; 25 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 26 | ResultCardinality do_cardinality() const noexcept override; 27 | const std::string& do_name() const override; 28 | std::string do_describe() const override; 29 | std::vector do_requirements() const override; 30 | public: 31 | BaseMismatchFraction(); 32 | }; 33 | 34 | } // namespace csr 35 | } // namespace octopus 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/logging/main_logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "main_logging.hpp" 5 | 6 | #include 7 | 8 | #include "config/config.hpp" 9 | #include "config/common.hpp" 10 | 11 | namespace octopus { 12 | 13 | namespace detail { 14 | 15 | std::string make_banner() 16 | { 17 | return std::string(config::CommandLineWidth, '-'); 18 | } 19 | 20 | } // namespace detail 21 | 22 | void log_program_startup() 23 | { 24 | logging::InfoLogger log {}; 25 | const auto banner = detail::make_banner(); 26 | log << banner; 27 | std::ostringstream ss {}; 28 | ss << "octopus v" << config::Version; 29 | log << ss.str(); 30 | log << config::CopyrightNotice; 31 | log << banner; 32 | } 33 | 34 | void log_command_line_options(const options::OptionMap& options) 35 | { 36 | static auto debug_log = logging::get_debug_log(); 37 | if (debug_log) { 38 | *debug_log << "Program options: "; 39 | *debug_log << options::to_string(options); 40 | } 41 | } 42 | 43 | } // namespace octopus 44 | -------------------------------------------------------------------------------- /src/core/csr/measures/is_denovo.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef is_denovo_hpp 5 | #define is_denovo_hpp 6 | 7 | #include 8 | 9 | #include "measure.hpp" 10 | 11 | namespace octopus { 12 | 13 | class VcfRecord; 14 | 15 | namespace csr { 16 | 17 | class IsDenovo : public Measure 18 | { 19 | bool report_sample_status_; 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 24 | ResultCardinality do_cardinality() const noexcept override; 25 | const std::string& do_name() const override; 26 | std::string do_describe() const override; 27 | std::vector do_requirements() const override; 28 | bool is_equal(const Measure& other) const noexcept override; 29 | public: 30 | IsDenovo(bool report_sample_status = true); 31 | }; 32 | 33 | } // namespace csr 34 | } // namespace octopus 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /lib/ranger/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(RANGER_SOURCES 2 | Data.h 3 | Data.cpp 4 | DataChar.h 5 | DataDouble.h 6 | DataFloat.h 7 | Forest.h 8 | Forest.cpp 9 | ForestClassification.h 10 | ForestClassification.cpp 11 | ForestProbability.h 12 | ForestProbability.cpp 13 | ForestRegression.h 14 | ForestRegression.cpp 15 | ForestSurvival.h 16 | ForestSurvival.cpp 17 | globals.h 18 | Tree.h 19 | Tree.cpp 20 | TreeClassification.h 21 | TreeClassification.cpp 22 | TreeProbability.h 23 | TreeProbability.cpp 24 | TreeRegression.h 25 | TreeRegression.cpp 26 | TreeSurvival.h 27 | TreeSurvival.cpp 28 | utility.h 29 | utility.cpp) 30 | 31 | set(REQUIRED_BOOST_LIBRARIES 32 | iostreams 33 | ) 34 | 35 | find_package (Boost 1.65 REQUIRED COMPONENTS ${REQUIRED_BOOST_LIBRARIES} REQUIRED) 36 | 37 | add_library(ranger STATIC ${RANGER_SOURCES}) 38 | 39 | set(WarningIgnores 40 | -Wno-unused-parameter 41 | -Wno-unused-function 42 | -Wno-missing-braces) 43 | 44 | add_compile_options(-Wall -Wextra -Werror ${WarningIgnores}) 45 | target_link_libraries (ranger ${Boost_LIBRARIES}) 46 | -------------------------------------------------------------------------------- /src/utils/kmer_mapper.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "kmer_mapper.hpp" 5 | 6 | namespace octopus { 7 | 8 | void map_query_to_target(const KmerPerfectHashes& query, const KmerHashTable& target, 9 | MappedIndexCounts& mapping_counts, std::vector& result) 10 | { 11 | map_query_to_target(query, target, mapping_counts, std::back_inserter(result)); 12 | } 13 | 14 | std::vector 15 | map_query_to_target(const KmerPerfectHashes& query, const KmerHashTable& target, 16 | MappedIndexCounts& mapping_counts) 17 | { 18 | std::vector result {}; 19 | result.reserve(1); 20 | map_query_to_target(query, target, mapping_counts, result); 21 | return result; 22 | } 23 | 24 | std::vector 25 | map_query_to_target(const KmerPerfectHashes& query, const KmerHashTable& target) 26 | { 27 | MappedIndexCounts mapping_counts(target.second, 0); 28 | return map_query_to_target(query, target, mapping_counts); 29 | } 30 | 31 | } // namespace octopus 32 | -------------------------------------------------------------------------------- /src/core/csr/measures/is_refcall.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef is_refcall_hpp 5 | #define is_refcall_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class IsRefcall : public Measure 19 | { 20 | bool report_sample_status_; 21 | const static std::string name_; 22 | std::unique_ptr do_clone() const override; 23 | ValueType get_value_type() const override; 24 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 25 | ResultCardinality do_cardinality() const noexcept override; 26 | const std::string& do_name() const override; 27 | std::string do_describe() const override; 28 | std::vector do_requirements() const override; 29 | bool is_equal(const Measure& other) const noexcept override; 30 | public: 31 | IsRefcall(bool report_sample_status = true); 32 | }; 33 | 34 | } // namespace csr 35 | } // namespace octopus 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/core/csr/measures/is_somatic.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef is_somatic_hpp 5 | #define is_somatic_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class IsSomatic : public Measure 19 | { 20 | bool report_sample_status_; 21 | const static std::string name_; 22 | std::unique_ptr do_clone() const override; 23 | ValueType get_value_type() const override; 24 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 25 | ResultCardinality do_cardinality() const noexcept override; 26 | const std::string& do_name() const override; 27 | std::string do_describe() const override; 28 | std::vector do_requirements() const override; 29 | bool is_equal(const Measure& other) const noexcept override; 30 | public: 31 | IsSomatic(bool report_sample_status = true); 32 | }; 33 | 34 | } // namespace csr 35 | } // namespace octopus 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/core/csr/facets/reference_context.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef reference_context_hpp 5 | #define reference_context_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include "basics/genomic_region.hpp" 14 | #include "core/types/haplotype.hpp" 15 | #include "io/reference/reference_genome.hpp" 16 | #include "facet.hpp" 17 | 18 | namespace octopus { namespace csr { 19 | 20 | class ReferenceContext : public Facet 21 | { 22 | public: 23 | using ResultType = std::reference_wrapper; 24 | 25 | ReferenceContext() = default; 26 | 27 | ReferenceContext(const ReferenceGenome& reference, GenomicRegion region); 28 | 29 | private: 30 | static const std::string name_; 31 | 32 | std::unique_ptr result_; 33 | 34 | const std::string& do_name() const noexcept override { return name_; } 35 | Facet::ResultType do_get() const override; 36 | }; 37 | 38 | } // namespace csr 39 | } // namespace octopus 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/core/csr/facets/repeat_context.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef repeat_context_hpp 5 | #define repeat_context_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include "basics/genomic_region.hpp" 14 | #include "io/reference/reference_genome.hpp" 15 | #include "basics/tandem_repeat.hpp" 16 | #include "facet.hpp" 17 | 18 | namespace octopus { namespace csr { 19 | 20 | class RepeatContext : public Facet 21 | { 22 | public: 23 | using ResultType = std::reference_wrapper>; 24 | 25 | RepeatContext() = default; 26 | 27 | RepeatContext(const ReferenceGenome& reference, GenomicRegion region); 28 | 29 | private: 30 | static const std::string name_; 31 | 32 | std::vector result_; 33 | 34 | const std::string& do_name() const noexcept override { return name_; } 35 | Facet::ResultType do_get() const override; 36 | }; 37 | 38 | } // namespace csr 39 | } // namespace octopus 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/core/csr/measures/mismatch_fraction.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef mismatch_fraction_hpp 5 | #define mismatch_fraction_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | #include "mismatch_count.hpp" 12 | #include "depth.hpp" 13 | 14 | namespace octopus { 15 | 16 | class VcfRecord; 17 | 18 | namespace csr { 19 | 20 | class MismatchFraction : public Measure 21 | { 22 | MismatchCount mismatch_count_; 23 | Depth depth_; 24 | const static std::string name_; 25 | std::unique_ptr do_clone() const override; 26 | ValueType get_value_type() const override; 27 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 28 | ResultCardinality do_cardinality() const noexcept override; 29 | const std::string& do_name() const override; 30 | std::string do_describe() const override; 31 | std::vector do_requirements() const override; 32 | public: 33 | MismatchFraction(); 34 | }; 35 | 36 | } // namespace csr 37 | } // namespace octopus 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/core/csr/measures/read_end_bias.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef read_end_bias_hpp 5 | #define read_end_bias_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class ReadEndBias : public Measure 19 | { 20 | const static std::string name_; 21 | double end_fraction_ = 0.03; 22 | std::unique_ptr do_clone() const override; 23 | ValueType get_value_type() const override; 24 | void do_set_parameters(std::vector params) override; 25 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 26 | ResultCardinality do_cardinality() const noexcept override; 27 | const std::string& do_name() const override; 28 | std::string do_describe() const override; 29 | std::vector do_requirements() const override; 30 | bool is_equal(const Measure& other) const noexcept override; 31 | }; 32 | 33 | } // namespace csr 34 | } // namespace octopus 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/core/csr/measures/read_tail_bias.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef read_tail_bias_hpp 5 | #define read_tail_bias_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class ReadTailBias : public Measure 19 | { 20 | const static std::string name_; 21 | double tail_fraction_ = 0.03; 22 | std::unique_ptr do_clone() const override; 23 | ValueType get_value_type() const override; 24 | void do_set_parameters(std::vector params) override; 25 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 26 | ResultCardinality do_cardinality() const noexcept override; 27 | const std::string& do_name() const override; 28 | std::string do_describe() const override; 29 | std::vector do_requirements() const override; 30 | bool is_equal(const Measure& other) const noexcept override; 31 | }; 32 | 33 | } // namespace csr 34 | } // namespace octopus 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/core/csr/measures/quality_by_depth.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef quality_by_depth_hpp 5 | #define quality_by_depth_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | #include "depth.hpp" 12 | 13 | namespace octopus { 14 | 15 | class VcfRecord; 16 | 17 | namespace csr { 18 | 19 | class QualityByDepth : public Measure 20 | { 21 | const static std::string name_; 22 | Depth depth_; 23 | std::unique_ptr do_clone() const override; 24 | ValueType get_value_type() const override; 25 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 26 | ResultCardinality do_cardinality() const noexcept override; 27 | const std::string& do_name() const override; 28 | std::string do_describe() const override; 29 | std::vector do_requirements() const override; 30 | bool is_equal(const Measure& other) const noexcept override; 31 | public: 32 | QualityByDepth(bool recalculate = false); 33 | }; 34 | 35 | } // namespace csr 36 | } // namespace octopus 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/core/csr/measures/mean_mapping_quality.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef mean_mapping_quality_hpp 5 | #define mean_mapping_quality_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class MeanMappingQuality : public Measure 19 | { 20 | const static std::string name_; 21 | bool recalculate_; 22 | std::unique_ptr do_clone() const override; 23 | ValueType get_value_type() const override; 24 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 25 | ResultCardinality do_cardinality() const noexcept override; 26 | const std::string& do_name() const override; 27 | std::string do_describe() const override; 28 | std::vector do_requirements() const override; 29 | bool is_equal(const Measure& other) const noexcept override; 30 | public: 31 | MeanMappingQuality(bool recalculate = true); 32 | }; 33 | 34 | } // namespace csr 35 | } // namespace octopus 36 | 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/core/csr/measures/quality.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "quality.hpp" 5 | 6 | #include "io/variant/vcf_record.hpp" 7 | 8 | namespace octopus { namespace csr { 9 | 10 | const std::string Quality::name_ = "QUAL"; 11 | 12 | std::unique_ptr Quality::do_clone() const 13 | { 14 | return std::make_unique(*this); 15 | } 16 | 17 | Measure::ValueType Quality::get_value_type() const 18 | { 19 | return double {}; 20 | } 21 | 22 | Measure::ResultType Quality::do_evaluate(const VcfRecord& call, const FacetMap& facets) const 23 | { 24 | Optional result {}; 25 | if (call.qual()) { 26 | result = static_cast(*call.qual()); 27 | } 28 | return result; 29 | } 30 | 31 | Measure::ResultCardinality Quality::do_cardinality() const noexcept 32 | { 33 | return ResultCardinality::one; 34 | } 35 | 36 | const std::string& Quality::do_name() const 37 | { 38 | return name_; 39 | } 40 | 41 | std::string Quality::do_describe() const 42 | { 43 | return "Call QUAL"; 44 | } 45 | 46 | } // namespace csr 47 | } // namespace octopus 48 | -------------------------------------------------------------------------------- /src/exceptions/missing_file_error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef missing_file_error_hpp 5 | #define missing_file_error_hpp 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include "user_error.hpp" 13 | 14 | namespace octopus { 15 | 16 | /** 17 | A MissingFileError should be thrown when a user-specified file does not exist. 18 | */ 19 | class MissingFileError : public UserError 20 | { 21 | public: 22 | using Path = boost::filesystem::path; 23 | 24 | MissingFileError() = delete; 25 | 26 | MissingFileError(Path file); 27 | 28 | MissingFileError(Path file, std::string type); 29 | 30 | virtual ~MissingFileError() override = default; 31 | 32 | void set_location_specified(std::string location) noexcept; 33 | 34 | private: 35 | virtual std::string do_why() const override; 36 | virtual std::string do_help() const override; 37 | 38 | Path file_; 39 | boost::optional type_, location_; 40 | }; 41 | 42 | } // namespace octopus 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/exceptions/file_open_error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef file_open_error_hpp 5 | #define file_open_error_hpp 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include "program_error.hpp" 13 | 14 | namespace octopus { 15 | 16 | class FileOpenError : public ProgramError 17 | { 18 | public: 19 | using Path = boost::filesystem::path; 20 | 21 | FileOpenError() = delete; 22 | 23 | FileOpenError(Path file); 24 | FileOpenError(Path file, std::string type); 25 | FileOpenError(Path file, std::error_code error); 26 | FileOpenError(Path file, std::string type, std::error_code error); 27 | 28 | virtual ~FileOpenError() override = default; 29 | 30 | private: 31 | virtual std::string do_why() const override; 32 | virtual std::string do_help() const override; 33 | virtual std::string do_where() const override; 34 | 35 | Path file_; 36 | boost::optional type_; 37 | boost::optional error_; 38 | }; 39 | 40 | } // namespace octopus 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/basics/trio.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "trio.hpp" 5 | 6 | #include 7 | #include 8 | 9 | namespace octopus { 10 | 11 | // public member methods 12 | 13 | Trio::Trio(Mother mother, Father father, Child child) 14 | : mother_ {std::move(mother.name)} 15 | , father_ {std::move(father.name)} 16 | , child_ {std::move(child.name)} 17 | { 18 | if (mother_ == father_ || mother_ == child_ || father_ == child_) { 19 | throw std::logic_error {"Trio: members of a trio must be unique"}; 20 | } 21 | } 22 | 23 | bool Trio::is_child(const SampleName& member) const noexcept 24 | { 25 | return member == child_; 26 | } 27 | 28 | bool Trio::is_parent(const SampleName& member) const noexcept 29 | { 30 | return member == mother_ || member == father_; 31 | } 32 | 33 | const SampleName& Trio::mother() const noexcept 34 | { 35 | return mother_; 36 | } 37 | 38 | const SampleName& Trio::father() const noexcept 39 | { 40 | return father_; 41 | } 42 | 43 | const SampleName& Trio::child() const noexcept 44 | { 45 | return child_; 46 | } 47 | 48 | } // namespace octopus 49 | -------------------------------------------------------------------------------- /src/core/csr/measures/mapping_quality_zero_count.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef mapping_quality_zero_count_hpp 5 | #define mapping_quality_zero_count_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class MappingQualityZeroCount : public Measure 19 | { 20 | const static std::string name_; 21 | bool recalculate_; 22 | std::unique_ptr do_clone() const override; 23 | ValueType get_value_type() const override; 24 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 25 | ResultCardinality do_cardinality() const noexcept override; 26 | const std::string& do_name() const override; 27 | std::string do_describe() const override; 28 | std::vector do_requirements() const override; 29 | bool is_equal(const Measure& other) const noexcept override; 30 | public: 31 | MappingQualityZeroCount(bool recalculate = true); 32 | }; 33 | 34 | } // namespace csr 35 | } // namespace octopus 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/core/csr/filters/passing_filter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "passing_filter.hpp" 5 | 6 | namespace octopus { namespace csr { 7 | 8 | PassingVariantCallFilter::PassingVariantCallFilter(FacetFactory facet_factory, 9 | std::vector measures, 10 | OutputOptions output_config, 11 | ConcurrencyPolicy threading, 12 | boost::optional progress) 13 | : SinglePassVariantCallFilter {std::move(facet_factory), std::move(measures), output_config, threading, progress} 14 | {} 15 | 16 | std::string PassingVariantCallFilter::do_name() const 17 | { 18 | return "passing"; 19 | } 20 | 21 | void PassingVariantCallFilter::annotate(VcfHeader::Builder& header) const {} 22 | 23 | VariantCallFilter::Classification PassingVariantCallFilter::classify(const MeasureVector& measures) const 24 | { 25 | return {Classification::Category::unfiltered}; 26 | } 27 | 28 | } // namespace csr 29 | } // namespace octopus 30 | -------------------------------------------------------------------------------- /src/core/csr/measures/model_posterior_by_depth.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef model_posterior_by_depth_hpp 5 | #define model_posterior_by_depth_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | #include "depth.hpp" 12 | 13 | namespace octopus { 14 | 15 | class VcfRecord; 16 | 17 | namespace csr { 18 | 19 | class ModelPosteriorByDepth : public Measure 20 | { 21 | const static std::string name_; 22 | Depth depth_; 23 | std::unique_ptr do_clone() const override; 24 | ValueType get_value_type() const override; 25 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 26 | ResultCardinality do_cardinality() const noexcept override; 27 | const std::string& do_name() const override; 28 | std::string do_describe() const override; 29 | std::vector do_requirements() const override; 30 | bool is_equal(const Measure& other) const noexcept override; 31 | public: 32 | ModelPosteriorByDepth(bool recalculate = false); 33 | }; 34 | 35 | } // namespace csr 36 | } // namespace octopus 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/basics/trio.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef trio_hpp 5 | #define trio_hpp 6 | 7 | #include "config/common.hpp" 8 | 9 | namespace octopus { 10 | 11 | class Trio 12 | { 13 | public: 14 | // Use these to make construction order explicit 15 | struct Mother { SampleName name; }; 16 | struct Father { SampleName name; }; 17 | struct Child { SampleName name; }; 18 | 19 | Trio() = default; 20 | 21 | Trio(Mother mother, Father father, Child child); 22 | 23 | Trio(const Trio&) = default; 24 | Trio& operator=(const Trio&) = default; 25 | Trio(Trio&&) = default; 26 | Trio& operator=(Trio&&) = default; 27 | 28 | ~Trio() = default; 29 | 30 | bool is_child(const SampleName& member) const noexcept; 31 | bool is_parent(const SampleName& member) const noexcept; 32 | 33 | const SampleName& mother() const noexcept; 34 | const SampleName& father() const noexcept; 35 | const SampleName& child() const noexcept; 36 | 37 | private: 38 | SampleName mother_, father_, child_; 39 | }; 40 | 41 | } // namespace octopus 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/core/csr/measures/filtered_read_fraction.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef filtered_read_fraction_hpp 5 | #define filtered_read_fraction_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | #include "depth.hpp" 12 | 13 | namespace octopus { 14 | 15 | class VcfRecord; 16 | 17 | namespace csr { 18 | 19 | class FilteredReadFraction : public Measure 20 | { 21 | const static std::string name_; 22 | Depth calling_depth_, filtering_depth_; 23 | std::unique_ptr do_clone() const override; 24 | ValueType get_value_type() const override; 25 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 26 | ResultCardinality do_cardinality() const noexcept override; 27 | const std::string& do_name() const override; 28 | std::string do_describe() const override; 29 | std::vector do_requirements() const override; 30 | bool is_equal(const Measure& other) const noexcept override; 31 | public: 32 | FilteredReadFraction(bool aggregate_samples = false); 33 | }; 34 | 35 | } // namespace csr 36 | } // namespace octopus 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/core/csr/measures/posterior_probability_by_depth.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef posterior_probability_by_depth_hpp 5 | #define posterior_probability_by_depth_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | #include "depth.hpp" 12 | 13 | namespace octopus { 14 | 15 | class VcfRecord; 16 | 17 | namespace csr { 18 | 19 | class PosteriorProbabilityByDepth : public Measure 20 | { 21 | const static std::string name_; 22 | Depth depth_; 23 | std::unique_ptr do_clone() const override; 24 | ValueType get_value_type() const override; 25 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 26 | ResultCardinality do_cardinality() const noexcept override; 27 | const std::string& do_name() const override; 28 | std::string do_describe() const override; 29 | std::vector do_requirements() const override; 30 | bool is_equal(const Measure& other) const noexcept override; 31 | public: 32 | PosteriorProbabilityByDepth(bool recalculate = false); 33 | }; 34 | 35 | } // namespace csr 36 | } // namespace octopus 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/core/csr/measures/strand_disequilibrium.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef strand_disequilibrium_hpp 5 | #define strand_disequilibrium_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class StrandDisequilibrium : public Measure 19 | { 20 | const static std::string name_; 21 | std::unique_ptr do_clone() const override; 22 | ValueType get_value_type() const override; 23 | void do_set_parameters(std::vector params) override; 24 | std::vector do_parameters() const override; 25 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 26 | ResultCardinality do_cardinality() const noexcept override; 27 | const std::string& do_name() const override; 28 | std::string do_describe() const override; 29 | std::vector do_requirements() const override; 30 | bool is_equal(const Measure& other) const noexcept override; 31 | 32 | double tail_mass_ = 0.01; 33 | }; 34 | 35 | } // namespace csr 36 | } // namespace octopus 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/exceptions/missing_index_error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "missing_index_error.hpp" 5 | 6 | #include 7 | #include 8 | 9 | namespace octopus { 10 | 11 | MissingIndexError::MissingIndexError(Path associate, std::string type) 12 | : associate_ {std::move(associate)} 13 | , type_ {std::move(type)} 14 | {} 15 | 16 | MissingIndexError::MissingIndexError(Path associate, Path given_index, std::string type) 17 | : associate_ {std::move(associate)} 18 | , given_index_ {std::move(given_index)} 19 | , type_ {std::move(type)} 20 | {} 21 | 22 | std::string MissingIndexError::do_why() const 23 | { 24 | std::ostringstream ss {}; 25 | if (given_index_) { 26 | ss << "The index file that you specified " << *given_index_ << " for the " << type_ << " file " 27 | << associate_ << " does not exist"; 28 | } else { 29 | ss << "No associated index file could be found for the " << type_ << " file " << associate_; 30 | } 31 | return ss.str(); 32 | } 33 | 34 | std::string MissingIndexError::do_help() const 35 | { 36 | return "ensure the specified path is correct and the file is readable"; 37 | } 38 | 39 | } // namespace octopus 40 | -------------------------------------------------------------------------------- /src/core/tools/vcf_header_factory.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef vcf_header_factory_hpp 5 | #define vcf_header_factory_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "io/variant/vcf_header.hpp" 13 | 14 | namespace octopus { 15 | 16 | class VcfHeaderFactory 17 | { 18 | public: 19 | VcfHeaderFactory() = default; 20 | 21 | VcfHeaderFactory(const VcfHeaderFactory&) = default; 22 | VcfHeaderFactory& operator=(const VcfHeaderFactory&) = default; 23 | VcfHeaderFactory(VcfHeaderFactory&&) = default; 24 | VcfHeaderFactory& operator=(VcfHeaderFactory&&) = default; 25 | 26 | ~VcfHeaderFactory() = default; 27 | 28 | void register_call_type(std::type_index type); 29 | 30 | void annotate(VcfHeader::Builder& hb) const; 31 | 32 | private: 33 | using Annotator = std::function; 34 | using AnnotatorMap = std::unordered_map; 35 | 36 | std::set call_types_; 37 | 38 | static AnnotatorMap annotators_; 39 | }; 40 | 41 | } // namespace octopus 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/utils/random_select.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef random_select_hpp 5 | #define random_select_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace octopus { 14 | 15 | template 16 | ForwardIt random_select(ForwardIt first, ForwardIt last, RandomGenerator& g) 17 | { 18 | if (first == last) return first; 19 | const auto max = static_cast(std::distance(first, last)); 20 | if (max == 1) return first; 21 | boost::random::uniform_int_distribution dist {0, max - 1}; 22 | std::advance(first, dist(g)); 23 | return first; 24 | } 25 | 26 | template 27 | ForwardIt random_select(ForwardIt first, ForwardIt last) 28 | { 29 | static thread_local std::mt19937 generator {42}; 30 | return random_select(first, last, generator); 31 | } 32 | 33 | template 34 | decltype(auto) random_select(const Range& values) 35 | { 36 | assert(!values.empty()); 37 | return *random_select(std::cbegin(values), std::cend(values)); 38 | } 39 | 40 | } // namespace octopus 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/core/csr/measures/depth.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef depth_hpp 5 | #define depth_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | 12 | namespace octopus { 13 | 14 | class VcfRecord; 15 | 16 | namespace csr { 17 | 18 | class Depth : public Measure 19 | { 20 | const static std::string name_; 21 | bool recalculate_ = false, aggregate_ = false; 22 | std::unique_ptr do_clone() const override; 23 | ValueType get_value_type() const override; 24 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 25 | ResultCardinality do_cardinality() const noexcept override; 26 | const std::string& do_name() const override; 27 | std::string do_describe() const override; 28 | std::vector do_requirements() const override; 29 | bool is_equal(const Measure& other) const noexcept override; 30 | void do_set_parameters(std::vector params) override; 31 | std::vector do_parameters() const override; 32 | public: 33 | Depth(); 34 | Depth(bool recalculate, bool aggregate_samples); 35 | }; 36 | 37 | } // namespace csr 38 | } // namespace octopus 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/concepts/comparable.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef comparable_hpp 5 | #define comparable_hpp 6 | 7 | namespace octopus { 8 | 9 | /** 10 | A class that is derived from Comparable must implement operator== and operator< and will 11 | then have all other comparison operators defined. 12 | */ 13 | template 14 | class Comparable {}; 15 | 16 | template 17 | inline bool operator!=(const Comparable& lhs, const Comparable& rhs) 18 | { 19 | return !operator==(static_cast(lhs), static_cast(rhs)); 20 | } 21 | 22 | template 23 | inline bool operator>(const Comparable& lhs, const Comparable& rhs) 24 | { 25 | return operator<(static_cast(rhs), static_cast(lhs)); 26 | } 27 | 28 | template 29 | inline bool operator<=(const Comparable& lhs, const Comparable& rhs) 30 | { 31 | return !operator>(static_cast(lhs), static_cast(rhs)); 32 | } 33 | 34 | template 35 | inline bool operator>=(const Comparable& lhs, const Comparable& rhs) 36 | { 37 | return !operator<(static_cast(lhs), static_cast(rhs)); 38 | } 39 | 40 | } // namespace octopus 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/core/models/error/snv_error_model.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef snv_error_model_hpp 5 | #define snv_error_model_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace octopus { 12 | 13 | class Haplotype; 14 | 15 | class SnvErrorModel 16 | { 17 | public: 18 | using MutationVector = std::vector; 19 | using PenaltyType = std::int8_t; 20 | using PenaltyVector = std::vector; 21 | 22 | virtual ~SnvErrorModel() = default; 23 | 24 | std::unique_ptr clone() const; 25 | void evaluate(const Haplotype& haplotype, 26 | MutationVector& forward_snv_mask, PenaltyVector& forward_snv_priors, 27 | MutationVector& reverse_snv_mask, PenaltyVector& reverse_snv_priors) const; 28 | 29 | private: 30 | virtual std::unique_ptr do_clone() const = 0; 31 | virtual void do_evaluate(const Haplotype& haplotype, 32 | MutationVector& forward_snv_mask, PenaltyVector& forward_snv_priors, 33 | MutationVector& reverse_snv_mask, PenaltyVector& reverse_snv_priors) const = 0; 34 | }; 35 | 36 | } // namespace octopus 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/exceptions/missing_index_error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef missing_index_error_hpp 5 | #define missing_index_error_hpp 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include "user_error.hpp" 13 | 14 | namespace octopus { 15 | 16 | /** 17 | A MissingIndexError should be thrown when an index associated with a user specified file 18 | does not exist. 19 | */ 20 | class MissingIndexError : public UserError 21 | { 22 | public: 23 | using Path = boost::filesystem::path; 24 | 25 | MissingIndexError() = delete; 26 | 27 | // When no associated index could be located 28 | MissingIndexError(Path associate, std::string type); 29 | 30 | // When an index was given, but is non-existent 31 | MissingIndexError(Path associate, Path given_index, std::string type); 32 | 33 | virtual ~MissingIndexError() override = default; 34 | 35 | private: 36 | virtual std::string do_why() const override; 37 | virtual std::string do_help() const override; 38 | 39 | Path associate_; 40 | boost::optional given_index_; 41 | std::string type_; 42 | }; 43 | 44 | } // namespace octopus 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/core/tools/haplotype_filter.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef haplotype_filter_hpp 5 | #define haplotype_filter_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "config/common.hpp" 13 | #include "core/types/haplotype.hpp" 14 | 15 | namespace octopus { 16 | 17 | class HaplotypeLikelihoodArray; 18 | 19 | std::vector 20 | filter_to_n(std::vector& haplotypes, const std::vector& samples, 21 | const HaplotypeLikelihoodArray& haplotype_likelihoods, const std::size_t n); 22 | 23 | using HaplotypeReference = std::reference_wrapper; 24 | using HaplotypeReferenceProbabilityMap = std::unordered_map; 25 | 26 | std::vector 27 | extract_removable(const std::vector& haplotypes, 28 | const HaplotypeReferenceProbabilityMap& haplotype_posteriors, 29 | const std::vector& samples, 30 | const HaplotypeLikelihoodArray& haplotype_likelihoods, 31 | std::size_t max_to_remove, 32 | double min_posterior); 33 | 34 | } // namespace octopus 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/core/types/calls/call_wrapper.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "call_wrapper.hpp" 5 | 6 | #include 7 | 8 | #include "basics/genomic_region.hpp" 9 | #include "call.hpp" 10 | 11 | namespace octopus { 12 | 13 | const GenomicRegion& CallWrapper::mapped_region() const noexcept 14 | { 15 | return call->mapped_region(); 16 | } 17 | 18 | std::vector> unwrap(std::deque&& calls) 19 | { 20 | std::vector> result {}; 21 | result.reserve(calls.size()); 22 | std::transform(std::make_move_iterator(std::begin(calls)), 23 | std::make_move_iterator(std::end(calls)), 24 | std::back_inserter(result), 25 | [] (CallWrapper&& wrapped_call) -> std::unique_ptr { 26 | return std::move(wrapped_call.call); 27 | }); 28 | calls.clear(); 29 | calls.shrink_to_fit(); 30 | return result; 31 | } 32 | 33 | bool operator==(const CallWrapper& lhs, const CallWrapper& rhs) 34 | { 35 | return lhs.call == rhs.call; 36 | } 37 | 38 | CallWrapper clone(const CallWrapper& call) 39 | { 40 | return CallWrapper {call->clone()}; 41 | } 42 | 43 | } // namespace octopus 44 | -------------------------------------------------------------------------------- /src/core/models/genotype/uniform_genotype_prior_model.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef uniform_genotype_prior_model_hpp 5 | #define uniform_genotype_prior_model_hpp 6 | 7 | #include "genotype_prior_model.hpp" 8 | 9 | namespace octopus { 10 | 11 | class UniformGenotypePriorModel : public GenotypePriorModel 12 | { 13 | public: 14 | using GenotypePriorModel::LogProbability; 15 | 16 | UniformGenotypePriorModel() = default; 17 | 18 | UniformGenotypePriorModel(const UniformGenotypePriorModel&) = default; 19 | UniformGenotypePriorModel& operator=(const UniformGenotypePriorModel&) = default; 20 | UniformGenotypePriorModel(UniformGenotypePriorModel&&) = default; 21 | UniformGenotypePriorModel& operator=(UniformGenotypePriorModel&&) = default; 22 | 23 | virtual ~UniformGenotypePriorModel() = default; 24 | 25 | private: 26 | virtual LogProbability do_evaluate(const Genotype& genotype) const override { return 1.0; } 27 | virtual LogProbability do_evaluate(const Genotype>& genotype) const override { return 1.0; } 28 | bool check_is_primed() const noexcept override { return true; } 29 | }; 30 | 31 | } // namespace octopus 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/core/models/error/indel_error_model.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef indel_error_model_hpp 5 | #define indel_error_model_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace octopus { 13 | 14 | class Haplotype; 15 | 16 | class IndelErrorModel 17 | { 18 | public: 19 | using PenaltyType = std::int8_t; 20 | using PenaltyVector = std::vector; 21 | 22 | virtual ~IndelErrorModel() = default; 23 | 24 | std::unique_ptr clone() const; 25 | void set_penalties(const Haplotype& haplotype, PenaltyVector& gap_open_penalties, PenaltyType& gap_extend_penalty) const; 26 | void set_penalties(const Haplotype& haplotype, PenaltyVector& gap_open_penalties, PenaltyVector& gap_extend_penalties) const; 27 | 28 | private: 29 | virtual std::unique_ptr do_clone() const = 0; 30 | virtual void do_set_penalties(const Haplotype& haplotype, PenaltyVector& gap_open_penalties, PenaltyType& gap_extend_penalty) const = 0; 31 | virtual void do_set_penalties(const Haplotype& haplotype, PenaltyVector& gap_open_penalties, PenaltyVector& gap_extend_penalties) const = 0; 32 | }; 33 | 34 | } // namespace octopus 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/core/callers/caller_factory.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef caller_factory_hpp 5 | #define caller_factory_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "basics/genomic_region.hpp" 11 | #include "caller.hpp" 12 | #include "caller_builder.hpp" 13 | 14 | namespace octopus { 15 | 16 | class ReferenceGenome; 17 | class ReadPipe; 18 | 19 | class CallerFactory 20 | { 21 | public: 22 | using ContigName = GenomicRegion::ContigName; 23 | 24 | CallerFactory() = delete; 25 | 26 | CallerFactory(CallerBuilder template_builder); 27 | 28 | CallerFactory(const CallerFactory&) = default; 29 | CallerFactory& operator=(const CallerFactory&) = default; 30 | CallerFactory(CallerFactory&&) = default; 31 | CallerFactory& operator=(CallerFactory&&) = default; 32 | 33 | ~CallerFactory() = default; 34 | 35 | CallerFactory& set_reference(const ReferenceGenome& reference) noexcept; 36 | CallerFactory& set_read_pipe(ReadPipe& read_pipe) noexcept; 37 | 38 | std::unique_ptr make(const ContigName& contig) const; 39 | 40 | private: 41 | mutable CallerBuilder template_builder_; 42 | }; 43 | 44 | } // namespace octopus 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/core/csr/measures/phylogeny_posterior.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "phylogeny_posterior.hpp" 5 | 6 | #include "io/variant/vcf_record.hpp" 7 | 8 | namespace octopus { namespace csr { 9 | 10 | const std::string PhylogenyPosterior::name_ = "PPP"; 11 | 12 | std::unique_ptr PhylogenyPosterior::do_clone() const 13 | { 14 | return std::make_unique(*this); 15 | } 16 | 17 | Measure::ValueType PhylogenyPosterior::get_value_type() const 18 | { 19 | return double {}; 20 | } 21 | 22 | Measure::ResultType PhylogenyPosterior::do_evaluate(const VcfRecord& call, const FacetMap& facets) const 23 | { 24 | Optional result {}; 25 | if (!is_info_missing(this->name(), call)) { 26 | result = std::stod(call.info_value(this->name()).front()); 27 | } 28 | return result; 29 | } 30 | 31 | Measure::ResultCardinality PhylogenyPosterior::do_cardinality() const noexcept 32 | { 33 | return ResultCardinality::one; 34 | } 35 | 36 | const std::string& PhylogenyPosterior::do_name() const 37 | { 38 | return name_; 39 | } 40 | 41 | std::string PhylogenyPosterior::do_describe() const 42 | { 43 | return "Phylogeny posterior probability"; 44 | } 45 | 46 | } // namespace csr 47 | } // namespace octopus 48 | -------------------------------------------------------------------------------- /src/core/csr/measures/genotype_quality_by_depth.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef genotype_quality_by_depth_hpp 5 | #define genotype_quality_by_depth_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "measure.hpp" 11 | #include "depth.hpp" 12 | 13 | namespace octopus { 14 | 15 | class VcfRecord; 16 | 17 | namespace csr { 18 | 19 | class GenotypeQualityByDepth : public Measure 20 | { 21 | const static std::string name_; 22 | Depth depth_; 23 | std::unique_ptr do_clone() const override; 24 | ValueType get_value_type() const override; 25 | ResultType do_evaluate(const VcfRecord& call, const FacetMap& facets) const override; 26 | ResultCardinality do_cardinality() const noexcept override; 27 | const std::string& do_name() const override; 28 | std::string do_describe() const override; 29 | std::vector do_requirements() const override; 30 | bool is_equal(const Measure& other) const noexcept override; 31 | void do_set_parameters(std::vector params) override; 32 | std::vector do_parameters() const override; 33 | public: 34 | GenotypeQualityByDepth(bool recalculate = false); 35 | }; 36 | 37 | } // namespace csr 38 | } // namespace octopus 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/exceptions/missing_file_error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "missing_file_error.hpp" 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | namespace octopus { 12 | 13 | MissingFileError::MissingFileError(Path file) : file_ {std::move(file)} {} 14 | 15 | MissingFileError::MissingFileError(Path file, std::string type) 16 | : file_ {std::move(file)} 17 | , type_ {std::move(type)} 18 | {} 19 | 20 | void MissingFileError::set_location_specified(std::string location) noexcept 21 | { 22 | location_ = std::move(location); 23 | } 24 | 25 | std::string MissingFileError::do_why() const 26 | { 27 | std::ostringstream ss {}; 28 | ss << "the "; 29 | if (type_) { 30 | ss << *type_ << ' '; 31 | } 32 | ss << "file that you specified " << file_ << ' '; 33 | if (boost::filesystem::is_symlink(file_)) { 34 | ss << '(' << boost::filesystem::read_symlink(file_) << ") "; 35 | } 36 | if (location_) { 37 | ss << "in " << *location_ << ' '; 38 | } 39 | ss << "does not exist"; 40 | return ss.str(); 41 | } 42 | 43 | std::string MissingFileError::do_help() const 44 | { 45 | return "ensure the specified path is correct and the file is readable"; 46 | } 47 | 48 | } // namespace octopus 49 | -------------------------------------------------------------------------------- /src/exceptions/file_open_error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "file_open_error.hpp" 5 | 6 | #include 7 | #include 8 | 9 | namespace octopus { 10 | 11 | FileOpenError::FileOpenError(Path file) : file_ {std::move(file)} {} 12 | 13 | FileOpenError::FileOpenError(Path file, std::string type) 14 | : file_ {std::move(file)} 15 | , type_ {std::move(type)} 16 | {} 17 | 18 | FileOpenError::FileOpenError(Path file, std::error_code error) 19 | : file_ {std::move(file)} 20 | , error_ {std::move(error)} 21 | {} 22 | 23 | FileOpenError::FileOpenError(Path file, std::string type, std::error_code error) 24 | : file_ {std::move(file)} 25 | , type_ {std::move(type)} 26 | , error_ {std::move(error)} 27 | {} 28 | 29 | std::string FileOpenError::do_why() const 30 | { 31 | std::ostringstream ss {}; 32 | ss << "the "; 33 | if (type_) { 34 | ss << *type_ << ' '; 35 | } 36 | ss << "file " << file_ << " could not be opened"; 37 | if (error_) { 38 | ss << ": " << error_->message(); 39 | } 40 | return ss.str(); 41 | } 42 | 43 | std::string FileOpenError::do_help() const 44 | { 45 | return "Check the output path is writable"; 46 | } 47 | 48 | std::string FileOpenError::do_where() const 49 | { 50 | return "fopen"; 51 | } 52 | 53 | } // namespace octopus 54 | -------------------------------------------------------------------------------- /src/core/models/mutation/somatic_mutation_model.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "somatic_mutation_model.hpp" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "utils/mappable_algorithms.hpp" 12 | 13 | namespace octopus { 14 | 15 | SomaticMutationModel::SomaticMutationModel(Parameters params, std::size_t num_haplotypes_hint, 16 | CachingStrategy caching) 17 | : model_ {params, num_haplotypes_hint, caching} 18 | {} 19 | 20 | void SomaticMutationModel::prime(MappableBlock haplotypes) 21 | { 22 | model_.prime(std::move(haplotypes)); 23 | } 24 | 25 | void SomaticMutationModel::unprime() noexcept 26 | { 27 | model_.unprime(); 28 | } 29 | 30 | bool SomaticMutationModel::is_primed() const noexcept 31 | { 32 | return model_.is_primed(); 33 | } 34 | 35 | SomaticMutationModel::LogProbability SomaticMutationModel::evaluate(const Haplotype& somatic, const Haplotype& germline) const 36 | { 37 | return model_.evaluate(somatic, germline); 38 | } 39 | 40 | SomaticMutationModel::LogProbability SomaticMutationModel::evaluate(const IndexedHaplotype<>& somatic, const IndexedHaplotype<>& germline) const 41 | { 42 | return model_.evaluate(somatic, germline); 43 | } 44 | 45 | } // namespace octopus 46 | -------------------------------------------------------------------------------- /website/docs/guides/errorModels.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: errorModels 3 | title: Error Models 4 | --- 5 | 6 | Octopus accounts for SNV and indel sequencing errors with a context aware error model. The parameterisation of this model is conditional on the library preparations and sequencing technology used, and can have consequences on calling accuracy, particular for indel errors in tandem repeat regions. Octopus comes packaged with parameter sets for several common library preparation and sequencing combinations, and also allows custom sequence error models to be used. 7 | 8 | Built-in error models are selected using the `--sequence-error-model` option, which accepts inputs of the form `[library preparation]<.sequencer>`. library preparation is selected from: `PCR`, `PCR-FREE`, or `10X`. sequencer is selected from: `HISEQ-2000`, `HISEQ-2500`, `HISEQ-4000`, `X10`, `NOVASEQ`, `BGISEQ-5000`. For example, `PCR.NOVASEQ` would select the sequence error model parametrised for a `PCR` library preparation and a `NOVASEQ` sequencer. If no sequencer is provided then the default is used (see `octopus --help`). 9 | 10 | Custom error models can be used by providing a path to a valid Octopus error model file. These can be produced using the [`profiler.py`](https://github.com/luntergroup/octopus/blob/develop/scripts/profiler.py) Python script in the scripts top level directory. The script creates error model files given the output of the `--data-profile` command line option. 11 | -------------------------------------------------------------------------------- /test/data/test_utils.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef Octopus_test_utils_h 5 | #define Octopus_test_utils_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | namespace octopus { 17 | 18 | class GenomicRegion; 19 | class ReferenceGenome; 20 | 21 | namespace test { 22 | 23 | template 24 | bool is_close_to_one(RealType x) 25 | { 26 | return std::abs(x - 1) < 0.0000000000001; 27 | } 28 | 29 | inline std::string get_label(const std::unordered_map& labels, const Haplotype& haplotype) 30 | { 31 | return (labels.count(haplotype) > 0) ? labels.at(haplotype) : "other"; 32 | } 33 | 34 | inline void sort(std::vector& haplotypes) 35 | { 36 | std::sort(std::begin(haplotypes), std::end(haplotypes)); 37 | } 38 | 39 | template 40 | Haplotype make_haplotype(const ReferenceGenome& reference, const GenomicRegion& region, 41 | std::initializer_list alleles) 42 | { 43 | Haplotype::Builder hb {region, reference}; 44 | 45 | for (const auto& allele : alleles) hb.push_back(allele); 46 | 47 | return hb.build(); 48 | } 49 | 50 | } // namespace test 51 | } // namespace octopus 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/exceptions/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef error_hpp 5 | #define error_hpp 6 | 7 | #include 8 | #include 9 | 10 | namespace octopus { 11 | 12 | /** 13 | Error specifies the interface for all octopus exceptions. 14 | 15 | std::string is allowed as we won't try to handle any std::bad_alloc. 16 | */ 17 | class Error : public std::exception 18 | { 19 | public: 20 | virtual ~Error() override = default; 21 | 22 | // Who is responsable for this error occurring? 23 | std::string type() const; 24 | 25 | // Where did the error occur (for debugging)? May not be a stacktrace but should give a hint. 26 | std::string where() const; 27 | 28 | // A detailed explanation of *why* the error happened. 29 | std::string why() const; 30 | 31 | // What can be done to resolve the error? 32 | std::string help() const; 33 | 34 | // Just to satisfy std::exception interface, not intended to be called. 35 | const char* what() const noexcept override; 36 | 37 | private: 38 | virtual std::string do_type() const = 0; 39 | virtual std::string do_where() const = 0; 40 | virtual std::string do_why() const = 0; 41 | virtual std::string do_help() const = 0; 42 | 43 | mutable std::string what_; // for what() 44 | }; 45 | 46 | } // namespace octopus 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/exceptions/malformed_file_error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef malformed_file_error_hpp 5 | #define malformed_file_error_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include "user_error.hpp" 14 | 15 | namespace octopus { 16 | 17 | /** 18 | A MalformedFileError should be thrown when a user-specified file is of the wrong type, 19 | or is corrupted. 20 | */ 21 | class MalformedFileError : public UserError 22 | { 23 | public: 24 | using Path = boost::filesystem::path; 25 | 26 | MalformedFileError() = delete; 27 | 28 | MalformedFileError(Path file); 29 | 30 | MalformedFileError(Path file, std::string required_type); 31 | 32 | MalformedFileError(Path file, std::vector valid_types); 33 | 34 | virtual ~MalformedFileError() override = default; 35 | 36 | void set_reason(std::string reason) noexcept; 37 | 38 | void set_location_specified(std::string location) noexcept; 39 | 40 | private: 41 | virtual std::string do_why() const override; 42 | virtual std::string do_help() const override; 43 | 44 | Path file_; 45 | std::vector valid_types_; 46 | boost::optional reason_, location_; 47 | }; 48 | 49 | } // namespace octopus 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/config/common.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef common_hpp 5 | #define common_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include "basics/genomic_region.hpp" 14 | #include "basics/aligned_read.hpp" 15 | #include "basics/aligned_template.hpp" 16 | #include "io/read/read_manager.hpp" 17 | #include "containers/mappable_flat_set.hpp" 18 | #include "containers/mappable_flat_multi_set.hpp" 19 | #include "containers/mappable_map.hpp" 20 | #include "logging/logging.hpp" 21 | 22 | namespace octopus { 23 | 24 | extern bool DEBUG_MODE; 25 | extern bool TRACE_MODE; 26 | 27 | using SampleName = std::string; 28 | 29 | using ContigName = GenomicRegion::ContigName; 30 | 31 | using InputRegionMap = MappableSetMap; 32 | 33 | using ReadContainer = MappableFlatMultiSet; 34 | using ReadMap = MappableMap; 35 | 36 | using TemplateContainer = MappableFlatMultiSet; 37 | using TemplateMap = MappableMap; 38 | 39 | enum class ExecutionPolicy { seq, par, par_vec }; // To match Parallelism TS 40 | 41 | namespace logging { 42 | boost::optional get_debug_log(); 43 | boost::optional get_trace_log(); 44 | } 45 | 46 | } // namespace octopus 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /test/unit/basics/genomic_region_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include 5 | 6 | #include "basics/genomic_region.hpp" 7 | 8 | namespace octopus { namespace test { 9 | 10 | BOOST_AUTO_TEST_SUITE(basics) 11 | BOOST_AUTO_TEST_SUITE(genomic_region) 12 | 13 | BOOST_AUTO_TEST_CASE(comparing_order_of_regions_on_different_contigs_is_an_error) 14 | { 15 | const GenomicRegion r1 {"1", 0, 1}, r2 {"2", 0, 1}; 16 | BOOST_CHECK_NO_THROW(r1 == r2); 17 | BOOST_CHECK_NO_THROW(r1 != r2); 18 | BOOST_CHECK_THROW(r1 <= r2, BadRegionCompare); 19 | BOOST_CHECK_THROW(r1 < r2, BadRegionCompare); 20 | BOOST_CHECK_THROW(r1 > r2, BadRegionCompare); 21 | BOOST_CHECK_THROW(r1 >= r2, BadRegionCompare); 22 | BOOST_CHECK_THROW(is_before(r1, r2), BadRegionCompare); 23 | BOOST_CHECK_THROW(is_after(r1, r2), BadRegionCompare); 24 | BOOST_CHECK_THROW(begins_before(r1, r2), BadRegionCompare); 25 | BOOST_CHECK_THROW(ends_before(r1, r2), BadRegionCompare); 26 | } 27 | 28 | BOOST_AUTO_TEST_CASE(some_operations_are_well_defined_on_different_contigs) 29 | { 30 | const GenomicRegion r1 {"1", 0, 1}, r2 {"2", 0, 1}; 31 | BOOST_CHECK_NO_THROW(overlaps(r1, r2)); 32 | BOOST_CHECK_NO_THROW(contains(r1, r2)); 33 | } 34 | 35 | BOOST_AUTO_TEST_SUITE_END() 36 | BOOST_AUTO_TEST_SUITE_END() 37 | 38 | } // namespace test 39 | } // namespace octopus 40 | -------------------------------------------------------------------------------- /src/io/read/read_writer.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "read_writer.hpp" 5 | 6 | #include 7 | 8 | #include "basics/aligned_read.hpp" 9 | 10 | namespace octopus { namespace io { 11 | 12 | ReadWriter::ReadWriter(Path bam_out, Path bam_template) 13 | : path_ {std::move(bam_out)} 14 | , impl_ {std::make_unique(path_, std::move(bam_template))} 15 | {} 16 | 17 | ReadWriter::ReadWriter(ReadWriter&& other) 18 | { 19 | std::lock_guard lock {other.mutex_}; 20 | path_ = std::move(other.path_); 21 | impl_ = std::move(other.impl_); 22 | } 23 | 24 | void swap(ReadWriter& lhs, ReadWriter& rhs) noexcept 25 | { 26 | if (&lhs == &rhs) return; 27 | std::lock(lhs.mutex_, rhs.mutex_); 28 | std::lock_guard lock_lhs {lhs.mutex_, std::adopt_lock}, lock_rhs {rhs.mutex_, std::adopt_lock}; 29 | using std::swap; 30 | swap(lhs.path_, rhs.path_); 31 | swap(lhs.impl_, rhs.impl_); 32 | } 33 | 34 | const ReadWriter::Path& ReadWriter::path() const noexcept 35 | { 36 | return path_; 37 | } 38 | 39 | void ReadWriter::write(const AlignedRead& read) 40 | { 41 | std::lock_guard lock {mutex_}; 42 | impl_->write(read); 43 | } 44 | 45 | ReadWriter& operator<<(ReadWriter& dst, const AlignedRead& read) 46 | { 47 | dst.write(read); 48 | return dst; 49 | } 50 | 51 | } // namespace io 52 | } // namespace octopus 53 | -------------------------------------------------------------------------------- /src/core/csr/facets/reads_summary.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "reads_summary.hpp" 5 | 6 | #include 7 | 8 | #include "utils/read_duplicates.hpp" 9 | 10 | namespace octopus { namespace csr { 11 | 12 | const std::string ReadsSummary::name_ {"ReadsSummary"}; 13 | 14 | auto copy_duplicates(const ReadContainer& reads) 15 | { 16 | const auto duplicate_itrs = find_duplicate_reads(std::cbegin(reads), std::cend(reads)); 17 | std::vector result {}; 18 | result.reserve(duplicate_itrs.size()); 19 | for (const auto& itrs : duplicate_itrs) { 20 | assert(!itrs.empty()); 21 | Facet::ReadsSummary::DuplicateReadSet dups {}; 22 | dups.reads.reserve(itrs.size()); 23 | std::transform(std::cbegin(itrs), std::cend(itrs), std::back_inserter(dups.reads), [] (auto itr) { return *itr; }); 24 | result.push_back(std::move(dups)); 25 | } 26 | std::sort(std::begin(result), std::end(result)); 27 | return result; 28 | } 29 | 30 | ReadsSummary::ReadsSummary(const ReadMap& reads) 31 | { 32 | result_.reserve(reads.size()); 33 | for (const auto& p : reads) { 34 | result_[p.first].duplicates = copy_duplicates(p.second); 35 | } 36 | } 37 | 38 | Facet::ResultType ReadsSummary::do_get() const 39 | { 40 | return std::cref(result_); 41 | } 42 | 43 | } // namespace csr 44 | } // namespace octopus 45 | -------------------------------------------------------------------------------- /src/core/csr/measures/posterior_probability.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "posterior_probability.hpp" 5 | 6 | #include "io/variant/vcf_record.hpp" 7 | #include "io/variant/vcf_spec.hpp" 8 | 9 | namespace octopus { namespace csr { 10 | 11 | const std::string PosteriorProbability::name_ = "PP"; 12 | 13 | std::unique_ptr PosteriorProbability::do_clone() const 14 | { 15 | return std::make_unique(*this); 16 | } 17 | 18 | Measure::ValueType PosteriorProbability::get_value_type() const 19 | { 20 | return double {}; 21 | } 22 | 23 | Measure::ResultType PosteriorProbability::do_evaluate(const VcfRecord& call, const FacetMap& facets) const 24 | { 25 | Optional result {}; 26 | if (call.has_info("PP")) { 27 | const auto& pp = call.info_value("PP"); 28 | if (pp.size() == 1 && pp.front() != vcfspec::missingValue) { 29 | result = std::stod(pp.front()); 30 | } 31 | } 32 | return result; 33 | } 34 | 35 | Measure::ResultCardinality PosteriorProbability::do_cardinality() const noexcept 36 | { 37 | return ResultCardinality::one; 38 | } 39 | 40 | const std::string& PosteriorProbability::do_name() const 41 | { 42 | return name_; 43 | } 44 | 45 | std::string PosteriorProbability::do_describe() const 46 | { 47 | return "Call posterior probability"; 48 | } 49 | 50 | } // namespace csr 51 | } // namespace octopus 52 | -------------------------------------------------------------------------------- /src/core/types/calls/call_wrapper.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef call_wrapper_hpp 5 | #define call_wrapper_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "concepts/equitable.hpp" 13 | #include "concepts/mappable.hpp" 14 | 15 | namespace octopus { 16 | 17 | class GenomicRegion; 18 | class Call; 19 | 20 | // Wrap the pointer so can use mappable algorithms 21 | struct CallWrapper : public Equitable, public Mappable 22 | { 23 | CallWrapper(std::unique_ptr call) : call {std::move(call) } {} 24 | operator const std::unique_ptr&() { return call; } 25 | operator std::unique_ptr&() noexcept { return call; } 26 | std::unique_ptr::pointer operator->() const noexcept { return call.get(); } 27 | const GenomicRegion& mapped_region() const noexcept; 28 | std::unique_ptr call; 29 | }; 30 | 31 | template 32 | auto wrap(std::vector>&& calls) 33 | { 34 | return std::vector {std::make_move_iterator(std::begin(calls)), std::make_move_iterator(std::end(calls))}; 35 | } 36 | 37 | std::vector> unwrap(std::deque&& calls); 38 | 39 | bool operator==(const CallWrapper& lhs, const CallWrapper& rhs); 40 | 41 | CallWrapper clone(const CallWrapper& call); 42 | 43 | } // namespace octopus 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/core/csr/facets/alleles.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef alleles_hpp 5 | #define alleles_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include "io/variant/vcf_record.hpp" 11 | #include "facet.hpp" 12 | 13 | namespace octopus { namespace csr { 14 | 15 | class Alleles : public Facet 16 | { 17 | public: 18 | using ResultType = std::reference_wrapper; 19 | 20 | Alleles() = default; 21 | Alleles(const std::vector& samples, const std::vector& calls); 22 | 23 | private: 24 | static const std::string name_; 25 | 26 | AlleleMap alleles_; 27 | 28 | const std::string& do_name() const noexcept override { return name_; } 29 | Facet::ResultType do_get() const override; 30 | }; 31 | 32 | inline const auto& get(const Facet::AlleleMap& alleles, const VcfRecord& call, const SampleName& sample) 33 | { 34 | return alleles.at(mapped_region(call)).at(sample); 35 | } 36 | 37 | std::vector get_called(const Facet::AlleleMap& alleles, const VcfRecord& call, const SampleName& sample); 38 | std::vector get_called_alt(const Facet::AlleleMap& alleles, const VcfRecord& call, const SampleName& sample); 39 | std::vector get_unique_called(const Facet::AlleleMap& alleles, const VcfRecord& call, const std::vector& samples); 40 | 41 | } // namespace csr 42 | } // namespace octopus 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/utils/compression.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "compression.hpp" 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace octopus { namespace utils { 13 | 14 | std::string compress(const std::string& data) 15 | { 16 | std::stringstream decompressed {data}; 17 | boost::iostreams::filtering_streambuf stream; 18 | stream.push(boost::iostreams::zlib_compressor()); 19 | stream.push(decompressed); 20 | std::stringstream compressed {}; 21 | boost::iostreams::copy(stream, compressed); 22 | return compressed.str(); 23 | } 24 | 25 | std::string decompress(const std::string& data) 26 | { 27 | std::stringstream compressed {data}; 28 | boost::iostreams::filtering_streambuf stream; 29 | stream.push(boost::iostreams::zlib_decompressor()); 30 | stream.push(compressed); 31 | std::stringstream decompressed; 32 | boost::iostreams::copy(stream, decompressed); 33 | return decompressed.str(); 34 | } 35 | 36 | std::string Compress::operator()(const std::string str) const 37 | { 38 | return compress(str); 39 | } 40 | 41 | std::string Decompress::operator()(const std::string str) const 42 | { 43 | return decompress(str); 44 | } 45 | 46 | } // namespace utils 47 | } // namespace octopus 48 | -------------------------------------------------------------------------------- /src/core/types/calls/denovo_call.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef denovo_call_hpp 5 | #define denovo_call_hpp 6 | 7 | #include 8 | 9 | #include "variant_call.hpp" 10 | 11 | namespace octopus { 12 | 13 | class DenovoCall : public VariantCall 14 | { 15 | public: 16 | using VariantCall::GenotypeCall; 17 | using VariantCall::PhaseCall; 18 | 19 | DenovoCall() = delete; 20 | 21 | template 22 | DenovoCall(V&& variant, T&& genotype_calls, Phred quality, Phred posterior); 23 | 24 | DenovoCall(const DenovoCall&) = default; 25 | DenovoCall& operator=(const DenovoCall&) = default; 26 | DenovoCall(DenovoCall&&) = default; 27 | DenovoCall& operator=(DenovoCall&&) = default; 28 | 29 | virtual ~DenovoCall() = default; 30 | 31 | virtual void decorate(VcfRecord::Builder& record) const override; 32 | 33 | virtual bool requires_model_evaluation() const noexcept override { return true; } 34 | 35 | private: 36 | virtual std::unique_ptr do_clone() const override; 37 | }; 38 | 39 | template 40 | DenovoCall::DenovoCall(V&& variant, T&& genotype_calls, Phred quality, Phred posterior) 41 | : VariantCall {std::forward(variant), std::forward(genotype_calls), quality, posterior} 42 | {} 43 | 44 | } // namespace octopus 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/core/csr/measures/gc_content.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "gc_content.hpp" 5 | 6 | #include 7 | 8 | #include "io/variant/vcf_record.hpp" 9 | #include "utils/sequence_utils.hpp" 10 | #include "../facets/reference_context.hpp" 11 | 12 | namespace octopus { namespace csr { 13 | 14 | const std::string GCContent::name_ = "GC"; 15 | 16 | std::unique_ptr GCContent::do_clone() const 17 | { 18 | return std::make_unique(*this); 19 | } 20 | 21 | Measure::ValueType GCContent::get_value_type() const 22 | { 23 | return double {}; 24 | } 25 | 26 | Measure::ResultType GCContent::do_evaluate(const VcfRecord& call, const FacetMap& facets) const 27 | { 28 | const auto& reference = get_value(facets.at("ReferenceContext")); 29 | return ValueType {utils::gc_content(reference.sequence(expand(mapped_region(call), 50)))}; 30 | } 31 | 32 | Measure::ResultCardinality GCContent::do_cardinality() const noexcept 33 | { 34 | return ResultCardinality::one; 35 | } 36 | 37 | const std::string& GCContent::do_name() const 38 | { 39 | return name_; 40 | } 41 | 42 | std::string GCContent::do_describe() const 43 | { 44 | return "GC bias of the reference in a window centred on the call"; 45 | } 46 | 47 | std::vector GCContent::do_requirements() const 48 | { 49 | return {"ReferenceContext"}; 50 | } 51 | 52 | } // namespace csr 53 | } // namespace octopus 54 | -------------------------------------------------------------------------------- /src/core/models/error/error_model_factory.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef error_model_factory_hpp 5 | #define error_model_factory_hpp 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include "snv_error_model.hpp" 13 | #include "indel_error_model.hpp" 14 | 15 | namespace octopus { 16 | 17 | enum class LibraryPreparation { pcr, pcr_free, tenx, mda }; 18 | enum class Sequencer { hiseq_2000, hiseq_2500, hiseq_4000, xten, novaseq, bgiseq_500, pacbio, pacbio_ccs }; 19 | 20 | struct ModelConfig 21 | { 22 | LibraryPreparation library; 23 | Sequencer sequencer; 24 | }; 25 | 26 | static constexpr LibraryPreparation default_library_preparation {LibraryPreparation::pcr_free}; 27 | static constexpr Sequencer default_sequencer {Sequencer::hiseq_2500}; 28 | static constexpr ModelConfig default_model_config {default_library_preparation, default_sequencer}; 29 | 30 | struct ErrorModel 31 | { 32 | std::unique_ptr indel; 33 | std::unique_ptr snv; 34 | }; 35 | 36 | std::unique_ptr make_snv_error_model(ModelConfig config = default_model_config); 37 | std::unique_ptr make_indel_error_model(ModelConfig config = default_model_config); 38 | 39 | ErrorModel make_error_model(const std::string& label); 40 | ErrorModel make_error_model(const boost::filesystem::path& model_filename); 41 | 42 | } // namespace octopus 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/core/tools/vargen/downloader.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef downloader_hpp 5 | #define downloader_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "core/types/variant.hpp" 12 | #include "variant_generator.hpp" 13 | 14 | namespace octopus { 15 | 16 | class GenomicRegion; 17 | class ReferenceGenome; 18 | class AlignedRead; 19 | 20 | namespace coretools { 21 | 22 | class Downloader : public VariantGenerator 23 | { 24 | public: 25 | struct Options 26 | { 27 | Variant::MappingDomain::Size max_variant_size = 100; 28 | }; 29 | 30 | Downloader() = delete; 31 | 32 | Downloader(const ReferenceGenome& reference, Options options); 33 | 34 | Downloader(const Downloader&) = default; 35 | Downloader& operator=(const Downloader&) = default; 36 | Downloader(Downloader&&) = default; 37 | Downloader& operator=(Downloader&&) = default; 38 | 39 | ~Downloader() override = default; 40 | 41 | private: 42 | std::reference_wrapper reference_; 43 | Options options_; 44 | 45 | std::unique_ptr do_clone() const override; 46 | std::vector do_generate(const RegionSet& regions, OptionalThreadPool workers) const override; 47 | std::string name() const override; 48 | }; 49 | 50 | } // namespace coretools 51 | } // namespace octopus 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /test/mock/utils.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef utils_hpp 5 | #define utils_hpp 6 | 7 | #include 8 | 9 | #include "io/reference/reference_genome.hpp" 10 | #include "core/types/allele.hpp" 11 | #include "core/types/variant.hpp" 12 | #include "core/types/haplotype.hpp" 13 | #include "core/types/genotype.hpp" 14 | 15 | namespace octopus { namespace debug { 16 | 17 | Allele make_allele(const std::string& region, std::string sequence, const ReferenceGenome& reference); 18 | 19 | Allele make_reference_allele(const std::string& region, const ReferenceGenome& reference); 20 | 21 | Variant make_variant(const std::string& region_str, Variant::NucleotideSequence alt_sequence, 22 | const ReferenceGenome& reference); 23 | 24 | Haplotype make_haplotype(const std::string& str, const GenomicRegion& region, 25 | const ReferenceGenome& reference); 26 | 27 | Haplotype make_haplotype(const std::string& str, const std::string& region, 28 | const ReferenceGenome& reference); 29 | 30 | Genotype make_genotype(const std::string& str, const GenomicRegion& region, 31 | const ReferenceGenome& reference); 32 | 33 | Genotype make_genotype(const std::string& str, const std::string& region, 34 | const ReferenceGenome& reference); 35 | 36 | } // namespace debug 37 | } // namespace octopus 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/utils/genotype_reader.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #ifndef genotype_reader_hpp 5 | #define genotype_reader_hpp 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | #include "config/common.hpp" 15 | #include "core/types/allele.hpp" 16 | #include "core/types/haplotype.hpp" 17 | #include "core/types/genotype.hpp" 18 | #include "containers/mappable_flat_set.hpp" 19 | #include "core/types/variant.hpp" 20 | #include "io/variant/vcf_record.hpp" 21 | 22 | namespace octopus { 23 | 24 | class ReferenceGenome; 25 | class GenomicRegion; 26 | 27 | using GenotypeMap = std::unordered_map>>; 28 | 29 | enum class ReferencePadPolicy { leave, trim_alt_alleles, trim_all_alleles }; 30 | 31 | std::vector> 32 | get_resolved_alleles(const std::vector& calls, 33 | std::size_t call_idx, 34 | const VcfRecord::SampleName& sample, 35 | ReferencePadPolicy ref_pad_policy = ReferencePadPolicy::trim_all_alleles); 36 | 37 | GenotypeMap 38 | extract_genotypes(const std::vector& calls, 39 | const std::vector& samples, 40 | const ReferenceGenome& reference, 41 | boost::optional call_region = boost::none); 42 | 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/core/types/calls/cnv_call.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 Daniel Cooke 2 | // Use of this source code is governed by the MIT license that can be found in the LICENSE file. 3 | 4 | #include "cnv_call.hpp" 5 | 6 | #include "utils/string_utils.hpp" 7 | #include "utils/reorder.hpp" 8 | 9 | namespace octopus { 10 | 11 | void CNVCall::decorate(VcfRecord::Builder& record) const 12 | { 13 | if (posterior_) { 14 | record.set_info("PP", utils::to_string(posterior_->score())); 15 | } 16 | if (!somatic_haplotypes_.empty()) { 17 | record.add_format({"HSS"}); 18 | for (const auto& p : somatic_haplotypes_) { 19 | const auto ploidy = this->genotype_calls_.at(p.first).genotype.ploidy(); 20 | assert(ploidy == p.second.size()); 21 | std::vector somatic_status(ploidy); 22 | std::transform(std::cbegin(p.second), std::cend(p.second), std::begin(somatic_status), 23 | [] (bool status) { return std::to_string(status); }); 24 | record.set_format(p.first, "HSS", std::move(somatic_status)); 25 | } 26 | } 27 | } 28 | 29 | std::unique_ptr CNVCall::do_clone() const 30 | { 31 | return std::make_unique(*this); 32 | } 33 | 34 | void CNVCall::reorder_genotype_fields(const SampleName& sample, const std::vector& order) 35 | { 36 | auto& somatics = somatic_haplotypes_.at(sample); 37 | assert(somatics.size() == order.size()); 38 | reorder(std::cbegin(order), std::cend(order), std::begin(somatics)); 39 | } 40 | 41 | } // namespace octopus 42 | --------------------------------------------------------------------------------