Skip to content

Commit

Permalink
MANTA-1361 Create unit test utility library
Browse files Browse the repository at this point in the history
Take existing unit test support code to create an IndelBuffer,
already shared between multiple tests, and use this to seed a
new unit test utility library following the same pattern as
for manta.
  • Loading branch information
ctsa committed Apr 25, 2018
1 parent 50045b7 commit 4e996f7
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 44 deletions.
11 changes: 11 additions & 0 deletions src/c++/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ macro(buildLibraries library_dirs library_targets)
endmacro()


#
# Build libraries needed for unit testing separately
#
# This is logic required for unit-testing, but not deployed production code. This must be run before the
# primary loop below, so that PROJECT_TEST_LIBRARY_TARGETS is populated prior to configuring the unit test
# directories.
#
set (PROJECT_TEST_LIBRARY_DIRS test)
buildLibraries("${PROJECT_TEST_LIBRARY_DIRS}" PROJECT_TEST_LIBRARY_TARGETS)


#
# Build all primary libraries for the project
#
Expand Down
43 changes: 43 additions & 0 deletions src/c++/lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Libraries

- alignment
- sequence alignment utilities

- applications/X:
- code specific to command-line application X

- appstats
- shared performance tracking code between applications

- assembly
- local sequence assembly utilities

- blt\_common
- shared snv-calling logic (from old 'blt' snp-caller)

- blt\_util
- general utility functions from manta/starling/strelka/gvcftools

- calibration
- empirical variant scoring logic

- common
- general utility functions from CASAVA/Grouper/Isaac

- errorAnalysis
- shared libraries for utilities that estimate sequence artifact rates from data, used for various forms of model parameter estimation

- htsapi
- various c++ wrapper objects built on top of samtools/htslib and other utilities for standard genomic indexed file formats like bam/cram,bed,vcf, etc...

- options
- command-line options objects which are shared between applications

- starling\_common
- shared small variant calling logic

- strelka\_common
- shared comparitive small variant calling logic

- test
- Logic used only for unit testing other libraries. These are linked into the unit tests but not production binaries
26 changes: 0 additions & 26 deletions src/c++/lib/README.txt

This file was deleted.

6 changes: 5 additions & 1 deletion src/c++/lib/starling_common/test/ActiveRegionPloidyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@
/// \file
/// \author Sangtae Kim
///
#include "TestIndelBuffer.hh"

#include "boost/test/unit_test.hpp"

#include "starling_common/ActiveRegionDetector.hh"
#include "starling_common/CandidateSnvBuffer.hh"
#include "test/testIndelBuffer.hh"


/// Test whether ActiveRegionDetector correctly handles ploidy
static int ploidyTest(const unsigned ploidy)
Expand Down
5 changes: 4 additions & 1 deletion src/c++/lib/starling_common/test/ActiveRegionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
///


#include "TestIndelBuffer.hh"
#include "boost/test/unit_test.hpp"

#include "starling_common/ActiveRegionDetector.hh"
#include "starling_common/CandidateSnvBuffer.hh"
#include "test/testIndelBuffer.hh"

const unsigned maxIndelSize = 49;


Expand Down
4 changes: 2 additions & 2 deletions src/c++/lib/starling_common/test/starling_read_align_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include "starling_read_align.cpp"

// required to mock-up a read segment:
#include "starling_base_options_test.hh"
#include "htsapi/align_path_bam_util.hh"
#include "starling_read.hh"
#include "starling_common/starling_read.hh"
#include "test/starling_base_options_test.hh"



Expand Down
20 changes: 20 additions & 0 deletions src/c++/lib/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Manta - Structural Variant and Indel Caller
# Copyright (c) 2013-2018 Illumina, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#

include(${THIS_CXX_LIBRARY_CMAKE})
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

#pragma once

#include "starling_base_shared.hh"
#include "options/AlignmentFileOptions.hh"
#include "starling_common/starling_base_shared.hh"


/// \brief This version of starling_base_options provides null implementations of required virtuals
Expand Down
37 changes: 37 additions & 0 deletions src/c++/lib/test/testIndelBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Strelka - Small Variant Caller
// Copyright (c) 2009-2018 Illumina, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//

#include "testIndelBuffer.hh"



TestIndelBuffer::
TestIndelBuffer(
const reference_contig_segment& ref)
{
_opt.is_candidate_indel_signal_test = false;

const double maxDepth = 100.0;
_doptPtr.reset(new starling_base_deriv_options(_opt));

_IndelBufferPtr.reset(new IndelBuffer(_opt, *_doptPtr, ref));

_IndelBufferPtr->registerSample(depth_buffer(), depth_buffer(), maxDepth);
_IndelBufferPtr->finalizeSamples();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,20 @@
#pragma once

#include "starling_base_options_test.hh"
#include "starling_common/ActiveRegionDetector.hh"
#include "blt_util/reference_contig_segment.hh"
#include "starling_common/IndelBuffer.hh"

#include <memory>


/// Manages a mock indel buffer approriate for unit testing
///
// TODO Refactor this to a factory function returning a unique_ptr to an IndelBuffer instead
struct TestIndelBuffer
{
explicit
TestIndelBuffer(
const reference_contig_segment& ref)
{
_opt.is_candidate_indel_signal_test = false;

const double maxDepth = 100.0;
_doptPtr.reset(new starling_base_deriv_options(_opt));

_IndelBufferPtr.reset(new IndelBuffer(_opt, *_doptPtr, ref));

_IndelBufferPtr->registerSample(depth_buffer(), depth_buffer(), maxDepth);
_IndelBufferPtr->finalizeSamples();
}
const reference_contig_segment& ref);

IndelBuffer&
getIndelBuffer()
Expand Down

0 comments on commit 4e996f7

Please sign in to comment.