diff --git a/.gitignore b/.gitignore index d46510f23..8374a10d9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ packages.config interop/version.h .idea src/ext/csharp/src +.CMakeLists.txt.bak # Mac OSX Stuff .DS_Store diff --git a/.travis.yml b/.travis.yml index 5df66b6e4..96d5d90d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -165,7 +165,8 @@ branches: notifications: email: false before_deploy: -- tar czf interop-${BUILD_NAME}.tar.gz ${BUILD_PATH} +- cd `dirname ${BUILD_PATH}` +- tar czf interop-${BUILD_NAME}.tar.gz ${BUILD_NAME} deploy: skip_cleanup: true provider: releases diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a5058e43..c09cae1ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,12 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules) enable_testing() include(${PROJECT_SOURCE_DIR}/cmake/Modules/UseGitVersion.cmake) include(${PROJECT_SOURCE_DIR}/cmake/InternalUtils.cmake) +set(ARCHIVE_VERSION "v1.0.11-14-g824273c") + +if (NOT CMAKE_BUILD_TYPE) + message(STATUS "No build type selected, default to Release") + set(CMAKE_BUILD_TYPE "Release") +endif() interop_config_compiler_and_linker() # TODO: https://help.github.com/articles/creating-project-pages-manually/ @@ -17,16 +23,16 @@ set(INTEROP_DL_LIB interop_fpic_lib) option(ENABLE_BACKWARDS_COMPATIBILITY "Compile code for c++98" ON) option(ENABLE_DOCS "Build documentation with Doxygen" ON) option(ENABLE_SWIG "Build third-party language bindings, e.g. C#" ON) -option(ENABLE_CSHARP "Build C# language bindings" ON) option(ENABLE_TEST "Build unit tests (depends on Boost)" ON) option(ENABLE_APPS "Build command line programs" ON) option(ENABLE_EXAMPLES "Build example programs" ON) option(ENABLE_STATIC "Build static libraries instead of dynamic" ON) option(FORCE_X86 "Force 32-bit libraries instead of platform default (Does nothing for Visual Studio)" OFF) option(FORCE_SHARED_CRT "Used the shared (DLL) run time lib" ON) +option(ENABLE_CSHARP "Build C# language bindings" ON) include_directories(.) -add_version_target(version ${CMAKE_SOURCE_DIR}/interop/version.h INTEROP_VERSION) +add_version_target(version ${CMAKE_SOURCE_DIR}/interop/version.h INTEROP_VERSION ${ARCHIVE_VERSION}) if(INTEROP_VERSION) string(REGEX REPLACE "[^v]*(v.*)" "\\1" VERSION ${INTEROP_VERSION}) @@ -50,18 +56,12 @@ if(INTEROP_VERSION) set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}") set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}") set(CPACK_PACKAGE_INSTALL_DIRECTORY "interop_${VERSION_SHORT}") - set(CPACK_OUTPUT_FILE_PREFIX "interop/${VERSION_SHORT}") + set(CPACK_OUTPUT_FILE_PREFIX "interop/${VERSION}") endif() #Adds the target "package" include(CPack) -if(ENABLE_BACKWARDS_COMPATIBILITY) - message(STATUS "Using C++11: No") -else() - message(STATUS "Using C++11: Yes") -endif() - if(ENABLE_STATIC) set(LIBRARY_TYPE STATIC) else() @@ -81,9 +81,9 @@ install(FILES README.md docs/src/changes.md DESTINATION .) find_package(Git) if(GIT_FOUND) - string(REGEX REPLACE "[^v]*(v[0-9]+.[0-9]+.[0-9])-.*" "\\1" TAG ${INTEROP_VERSION}) + string(REGEX REPLACE "[^v]*(v[0-9]+.[0-9]+.[0-9]+)-.*" "\\1" TAG ${INTEROP_VERSION}) add_custom_target(history - COMMAND ${GIT_EXECUTABLE};log;${TAG}..HEAD;-m;--first-parent;--date=short;--format='%ad | %b' + COMMAND ${GIT_EXECUTABLE};--no-pager;log;${TAG}..HEAD;--date=short;--format='%ad | %B' COMMENT "List all commits from last tag - ${TAG}" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) endif() diff --git a/cmake/InternalUtils.cmake b/cmake/InternalUtils.cmake index 3531d9d1f..63c78c8a2 100644 --- a/cmake/InternalUtils.cmake +++ b/cmake/InternalUtils.cmake @@ -81,7 +81,8 @@ macro(interop_config_compiler_and_linker) set(CXX11_FLAG_ "-std=c++11") endif() - check_cxx_compiler_flag("-std=c89" COMPILER_SUPPORTS_ANSI) + set(ANSI_FLAG "-std=c++98") + check_cxx_compiler_flag("${ANSI_FLAG}" COMPILER_SUPPORTS_ANSI) #-ansi (does not work on CLang 3.4) check_cxx_compiler_flag("${CXX11_FLAG_}" COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX11) set(CXX_CX11_FLAG "${CXX11_FLAG_}") @@ -104,36 +105,60 @@ macro(interop_config_compiler_and_linker) message(FATAL_ERROR "Unsupported compiler") endif() endif() - if(COMPILER_IS_GNUCC_OR_CLANG) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wno-c++0x-compat -Wno-error=c++0x-compat -Wextra") - if(WIN32 AND MINGW) - # Add big object support to Windows Compilers - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj") + + set(ENABLE_BIG_OBJ_FLAG "") + if(MSVC) + set(ENABLE_BIG_OBJ_FLAG "/bigobj") + elseif(MINGW) + set(ENABLE_BIG_OBJ_FLAG "-Wa,-mbig-obj") + endif() + + set(flags_to_check "-Wno-eof-newline;-Wno-maybe-uninitialized;-Wno-strict-aliasing;-Wno-unused-function;-Wno-unused-parameter;-Wno-unnamed-type-template-args;-Wno-c++0x-compat;-Wno-error=c++0x-compat") + foreach(flag ${flags_to_check}) + string(TOUPPER ${flag} FLAG_NAME) + string(REPLACE "-" "_" FLAG_NAME ${FLAG_NAME}) + string(REPLACE "=" "_EQ_" FLAG_NAME ${FLAG_NAME}) + string(REPLACE "C++" "CPP" FLAG_NAME ${FLAG_NAME}) + set(${FLAG_NAME} ${flag}) + check_cxx_compiler_flag(${flag} IS_${FLAG_NAME}_SUPPORTED) + if(NOT IS_${FLAG_NAME}_SUPPORTED) + set(${FLAG_NAME} "") endif() + endforeach() + + if(COMPILER_IS_GNUCC_OR_CLANG) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror ${_WNO_CPP0X_COMPAT} ${_WNO_ERROR_EQ_CPP0X_COMPAT} ${_WNO_EOF_NEWLINE}") elseif(MSVC) # Visual Studio Complains about not being able to create an assignment operator and copy constructor # -wd4511 and -wd4512 disable these pointless warnings # Add big object support to Windows Compilers - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX -wd4511 -wd4512 /bigobj") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX -wd4511 -wd4512") + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") if(WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wno-c++0x-compat -Wno-error=c++0x-compat -Wextra") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror ${_WNO_CPP0X_COMPAT} ${_WNO_ERROR_EQ_CPP0X_COMPAT}") endif() endif() if(NOT ENABLE_BACKWARDS_COMPATIBILITY) if(COMPILER_IS_GNUCC_OR_CLANG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_CX11_FLAG}") + message(STATUS "Using C++11: Yes") + elseif(MSVC) + message(STATUS "Using C++11: Yes") + else() + message(STATUS "Using C++11: Compiler default") endif() elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") - #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedef -Wno-unnamed-type-template-args") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_CX11_FLAG}") + message(STATUS "Using C++11: Yes") elseif(MINGW) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_CX11_FLAG}") - message(WARNING "ENABLE_BACKWARDS_COMPATIBILITY=ON does not work with MinGW, ignoring") + message(STATUS "Using C++11: Yes") elseif(COMPILER_SUPPORTS_ANSI) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c89") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ANSI_FLAG}") + message(STATUS "Using C++11: No") endif() endmacro() diff --git a/cmake/Modules/UseCSharp.cmake b/cmake/Modules/UseCSharp.cmake index d4253dafd..ffc9dbbfc 100644 --- a/cmake/Modules/UseCSharp.cmake +++ b/cmake/Modules/UseCSharp.cmake @@ -34,8 +34,10 @@ endif( NOT CSHARP_COMPILER ) # Include type-based USE_FILE if( CSHARP_TYPE MATCHES ".NET" ) include( ${DotNetFrameworkSdk_USE_FILE} ) + set(CSHARP_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) elseif ( CSHARP_TYPE MATCHES "Mono" ) include( ${Mono_USE_FILE} ) + set(CSHARP_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}) endif ( CSHARP_TYPE MATCHES ".NET" ) macro( CSHARP_ADD_LIBRARY name ) @@ -91,16 +93,14 @@ macro( CSHARP_ADD_PROJECT type name ) # MESSAGE( SEND_ERROR "No C# sources were specified for ${type} ${name}" ) #endif () #list( SORT sources_dep ) - - set(CSHARP_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) - + file(MAKE_DIRECTORY ${CSHARP_OUTPUT_DIR}) string (REPLACE ";" "," source_list "${sources}") set(CSHARP_${name}_BINARY ${CSHARP_OUTPUT_DIR}/${name}.${output}) set(CSHARP_${name}_BINARY_NAME ${name}.${output}) # Add custom target and command MESSAGE( STATUS "Adding C# ${type} ${name}: '${CSHARP_COMPILER} /t:${type} /out:${name}.${output} /platform:${CSHARP_PLATFORM} ${CSHARP_SDK} ${refs} ${sources}'" ) add_custom_command( - COMMENT "Compiling C# ${type} ${name}: '${CSHARP_COMPILER} /unsafe /t:${type} /out:${CMAKE_CURRENT_BINARY_DIR}/${name}.${output} /platform:${CSHARP_PLATFORM} ${CSHARP_SDK} ${refs} ${sources}'" + COMMENT "Compiling C# ${type} ${name}: '${CSHARP_COMPILER} /unsafe /t:${type} /out:${CSHARP_OUTPUT_DIR}/${name}.${output} /platform:${CSHARP_PLATFORM} ${CSHARP_SDK} ${refs} ${sources}'" OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.${output} COMMAND ${CMAKE_COMMAND} -DFILES_TO_COPY="${source_list}" -DDESTINATION_DIR="${CMAKE_CURRENT_BINARY_DIR}" -P "${CMAKE_SOURCE_DIR}/cmake/CopyListOfFiles.cmake" COMMAND ${CSHARP_COMPILER} diff --git a/cmake/Modules/UseGitVersion.cmake b/cmake/Modules/UseGitVersion.cmake index e01c961ea..68018962b 100644 --- a/cmake/Modules/UseGitVersion.cmake +++ b/cmake/Modules/UseGitVersion.cmake @@ -8,7 +8,7 @@ # - _macro_name - name of the macro in the header file # -function(add_version_target _target _version_file _macro_name) +function(add_version_target _target _version_file _macro_name _default) if(NOT GIT_FOUND) find_package(Git REQUIRED) endif() @@ -25,15 +25,18 @@ function(add_version_target _target _version_file _macro_name) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT res EQUAL 0) - set(VERSION \"Unknown\") + set(VERSION \"\${BKUP}\") endif() configure_file(\${SRC} \${DST} @ONLY) " ) + add_custom_command(OUTPUT ${_version_file} + COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_BINARY_DIR}/${version_base}.in + -D DST=${_version_file} + -D BKUP=${_default} + -P ${CMAKE_BINARY_DIR}/version.cmake) add_custom_target(${_target} - ${CMAKE_COMMAND} -D SRC=${CMAKE_BINARY_DIR}/${version_base}.in - -D DST=${_version_file} - -P ${CMAKE_BINARY_DIR}/version.cmake + DEPENDS ${_version_file} ) execute_process( COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=-dirty @@ -45,7 +48,7 @@ function(add_version_target _target _version_file _macro_name) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT res EQUAL 0) - set(VERSION \"Unknown\") + set(VERSION "${_default}") endif() set(${_macro_name} ${VERSION} PARENT_SCOPE) endfunction() diff --git a/cmake/package.nuspec.in b/cmake/package.nuspec.in new file mode 100644 index 000000000..5f4298d50 --- /dev/null +++ b/cmake/package.nuspec.in @@ -0,0 +1,30 @@ + + + + illumina_interop_@CSHARP_TYPE@_@PLATFORM@ + @INTEROP_VERSION@ + Illumina InterOp Library for @CSHARP_TYPE@ on @PLATFORM@ + Illumina Inc. + Illumina Inc. + https://github.com/Illumina/interop/blob/master/LICENSE + https://github.com/Illumina/interop + true + false + + The Illumina InterOp libraries are a set of common routines used for reading InterOp metric files + produced by Illumina sequencers. These libraries are backwards compatible and capable of supporting prior + releases of the software, with one exception: GA systems have been excluded. + + + High-level C++ binding for Illumina C++ InterOp Library, packaged for + @CSHARP_TYPE@ @CSHARP_VERSION@ on @PLATFORM@ + + https://github.com/Illumina/interop/blob/master/README.md + GNU GPL v3 + native, Illumina, InterOp, C++, C#, @PLATFORM@, @CSHARP_TYPE@ + + + @NUGET_FILE_LIST@ + + + diff --git a/cmake/package.targets b/cmake/package.targets new file mode 100644 index 000000000..ed28b2126 --- /dev/null +++ b/cmake/package.targets @@ -0,0 +1,9 @@ + + + + + %(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + + + diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 9d47ceccf..276364851 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -159,7 +159,7 @@ STRIP_FROM_PATH = # header file to include in order to use a class. If left blank only the name of # the header file containing the class definition is used. Otherwise one should # specify the list of include paths that are normally passed to the compiler -# using the -I flag. +# using the -I test_modifier. STRIP_FROM_INC_PATH = @@ -444,7 +444,7 @@ EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. If set to YES, local methods, +# This test_modifier is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are # included in the documentation. If set to NO, only methods in the interface are # included. @@ -452,7 +452,7 @@ EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = NO -# If this flag is set to YES, the members of anonymous namespaces will be +# If this test_modifier is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base name of # the file that contains the anonymous namespace. By default anonymous namespace @@ -720,7 +720,7 @@ WARNINGS = YES #WARN_AS_ERROR = YES # If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this test_modifier # will automatically be disabled. # The default value is: YES. @@ -1269,7 +1269,7 @@ CHM_FILE = HHC_LOCATION = -# The GENERATE_CHI flag controls if a separate .chi index file is generated +# The GENERATE_CHI test_modifier controls if a separate .chi index file is generated # (YES) or that it should be included in the master .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. @@ -1282,7 +1282,7 @@ GENERATE_CHI = NO CHM_INDEX_ENCODING = -# The BINARY_TOC flag controls whether a binary table of contents is generated +# The BINARY_TOC test_modifier controls whether a binary table of contents is generated # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it # enables the Previous and Next buttons. # The default value is: NO. @@ -1290,7 +1290,7 @@ CHM_INDEX_ENCODING = BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# The TOC_EXPAND test_modifier can be set to YES to add extra items for group members to # the table of contents of the HTML help documentation and to the tree view. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. diff --git a/docs/src/changes.md b/docs/src/changes.md index 7cd9186a4..307e0c7ef 100644 --- a/docs/src/changes.md +++ b/docs/src/changes.md @@ -1,5 +1,20 @@ # Changes {#changes} +## v1.0.12 + +Date | Description +---------- | ----------- +2016-09-26 | IPA-5210: Create CSV parsable summary output +2016-09-23 | IPA-5194: Create nuspec package file +2016-09-17 | Refactor individual metric unit tests +2016-09-17 | Refactor metric stream tests +2016-09-14 | Reorganized code into own stat util file +2016-09-14 | Fixes error rate at a specific cycle when tiles are at different cycles +2016-09-14 | Add version information for zip archives +2016-09-14 | IPA-5070: Add optional flag to skip median for summary +2016-09-13 | Ensure ANSI build is being tested + + ## v1.0.11 Date | Description diff --git a/docs/src/contribute.md b/docs/src/contribute.md index 30b01b95e..d024b9462 100644 --- a/docs/src/contribute.md +++ b/docs/src/contribute.md @@ -66,3 +66,16 @@ git log v1.0.0..HEAD --oneline --decorate --no-merges In the above example, v1.0.0 was the last tag, you should replace this value with the actual last tag. +## Linking to our git hooks + +Windows: + +~~~~~~~~~{.bat} +mklink .git\hooks\pre-commit \tools\hooks\pre-commit.sh +~~~~~~~~~ + +Linux: + +~~~~~~~~~{.sh} +ln -s tools/hooks/pre-commit.sh .git/hooks/pre-commit +~~~~~~~~~ diff --git a/docs/src/example_sav_analysis.md b/docs/src/example_sav_analysis.md index 93d218ee1..acac28e96 100644 --- a/docs/src/example_sav_analysis.md +++ b/docs/src/example_sav_analysis.md @@ -18,7 +18,7 @@ Each plot command has an additional set of options that allow the user to choose a specific metric to plot or how to filter the data. For example, the user can choose to only plot data from lane 1 by specifiying the option `--filter-by-lane=1`. A full list of options for each program -can be obtained with the `--help` flag. +can be obtained with the `--help` test_modifier. ## SAV Analysis Tab diff --git a/docs/src/install.md b/docs/src/install.md index ba497d84e..ca4b43535 100644 --- a/docs/src/install.md +++ b/docs/src/install.md @@ -121,7 +121,7 @@ cmake --help ~~~~~~~~~~~~~ The default CMake generator for Windows is 32-bit. This can be changed by specifying the appropriate generator -using the `-G` flag: +using the `-G` test_modifier: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.sh} cmake ../interop -G “Visual Studio 12 2013 Win64” diff --git a/interop/constants/enums.h b/interop/constants/enums.h index 26198267f..c597ef2a6 100644 --- a/interop/constants/enums.h +++ b/interop/constants/enums.h @@ -343,3 +343,4 @@ namespace illumina { namespace interop { namespace constants #undef INTEROP_TUPLE3 #undef INTEROP_TUPLE4 + diff --git a/interop/constants/typedefs.h b/interop/constants/typedefs.h index 90fc4851f..055069ba5 100644 --- a/interop/constants/typedefs.h +++ b/interop/constants/typedefs.h @@ -23,3 +23,4 @@ namespace illumina { namespace interop { namespace constants { typedef constant_type base_lane_t; }}} + diff --git a/interop/external/rapidxml.hpp b/interop/external/rapidxml.hpp index ae91e081d..3c40d2d6b 100644 --- a/interop/external/rapidxml.hpp +++ b/interop/external/rapidxml.hpp @@ -2594,3 +2594,4 @@ namespace rapidxml #endif #endif + diff --git a/interop/external/rapidxml_iterators.hpp b/interop/external/rapidxml_iterators.hpp index 52ebc298a..8a28bc6b7 100644 --- a/interop/external/rapidxml_iterators.hpp +++ b/interop/external/rapidxml_iterators.hpp @@ -172,3 +172,4 @@ namespace rapidxml } #endif + diff --git a/interop/external/rapidxml_print.hpp b/interop/external/rapidxml_print.hpp index 0ae2b14fa..b16dc3ccf 100644 --- a/interop/external/rapidxml_print.hpp +++ b/interop/external/rapidxml_print.hpp @@ -419,3 +419,4 @@ namespace rapidxml } #endif + diff --git a/interop/external/rapidxml_utils.hpp b/interop/external/rapidxml_utils.hpp index 37c29535f..dba2c07e6 100644 --- a/interop/external/rapidxml_utils.hpp +++ b/interop/external/rapidxml_utils.hpp @@ -120,3 +120,4 @@ namespace rapidxml } #endif + diff --git a/interop/interop.h b/interop/interop.h index bf9b60e38..987efed62 100644 --- a/interop/interop.h +++ b/interop/interop.h @@ -26,3 +26,4 @@ namespace illumina { namespace interop */ inline const char* library_version(){return INTEROP_VERSION;} }} + diff --git a/interop/io/format/abstract_metric_format.h b/interop/io/format/abstract_metric_format.h index 36d9e08e8..ca4b2329d 100644 --- a/interop/io/format/abstract_metric_format.h +++ b/interop/io/format/abstract_metric_format.h @@ -81,3 +81,4 @@ namespace illumina { namespace interop { namespace io }; }}} + diff --git a/interop/io/format/default_layout.h b/interop/io/format/default_layout.h index 9c8a1bd40..d8c435b6b 100644 --- a/interop/io/format/default_layout.h +++ b/interop/io/format/default_layout.h @@ -57,3 +57,4 @@ namespace illumina { namespace interop { namespace io }; }}} + diff --git a/interop/io/format/generic_layout.h b/interop/io/format/generic_layout.h index 143ee7d67..9fcf4bd67 100644 --- a/interop/io/format/generic_layout.h +++ b/interop/io/format/generic_layout.h @@ -26,3 +26,4 @@ namespace illumina { namespace interop { namespace io }}} + diff --git a/interop/io/format/map_io.h b/interop/io/format/map_io.h index 2294b1b69..510695563 100644 --- a/interop/io/format/map_io.h +++ b/interop/io/format/map_io.h @@ -177,7 +177,7 @@ namespace illumina { namespace interop { namespace io std::streamsize stream_map(std::istream &in, std::vector&vals, const size_t n) { vals.resize(n); - INTEROP_ASSERT(!vals.empty()); + INTEROP_ASSERTMSG(!vals.empty(), "n="<::read_array_from_stream(in, &vals.front(), n); } @@ -292,7 +292,7 @@ namespace illumina { namespace interop { namespace io { for (size_t i = 0; i < n; i++) { - WriteType write_val = vals[i]; + WriteType write_val = static_cast(vals[i]); write_binary(out, write_val); } return out.tellp(); @@ -313,7 +313,7 @@ namespace illumina { namespace interop { namespace io { for (size_t i = 0; i < n; i++) { - WriteType write_val = vals[offset + i]; + WriteType write_val = static_cast(vals[offset + i]); write_binary(out, write_val); } return out.tellp(); @@ -339,3 +339,4 @@ namespace illumina { namespace interop { namespace io }}} + diff --git a/interop/io/format/metric_format.h b/interop/io/format/metric_format.h index 4cb6be452..d3036843d 100644 --- a/interop/io/format/metric_format.h +++ b/interop/io/format/metric_format.h @@ -79,12 +79,12 @@ namespace illumina { namespace interop { namespace io void read_metrics(std::istream& in, model::metric_base::metric_set& metric_set, const size_t file_size) { const std::streamsize record_size = read_header(in, metric_set); - offset_map_t metric_offset_map; + offset_map_t metric_offset_map(metric_set.offset_map()); metric_t metric(metric_set); if(file_size > 0 && !Layout::MULTI_RECORD) { const size_t record_count = static_cast((file_size-header_size(metric_set))/record_size); - metric_set.resize(record_count); + metric_set.resize(metric_set.size()+record_count); std::vector buffer(static_cast(record_size)); INTEROP_ASSERT(!buffer.empty()); while (in) @@ -92,9 +92,18 @@ namespace illumina { namespace interop { namespace io char *in_ptr = &buffer.front(); in.read(in_ptr, record_size); const std::streamsize count = in.gcount(); - if(!test_stream(in, metric_offset_map, count, record_size)) break; - read_record(in_ptr, metric_set, metric_offset_map, metric, record_size); + try + { + if (!test_stream(in, metric_offset_map, count, record_size)) break; + read_record(in_ptr, metric_set, metric_offset_map, metric, record_size); + } + catch(const incomplete_file_exception& ex) + { + metric_set.resize(metric_offset_map.size()); + throw ex; + } } + metric_set.resize(metric_offset_map.size()); } else { @@ -103,8 +112,6 @@ namespace illumina { namespace interop { namespace io read_record(in, metric_set, metric_offset_map, metric, record_size); } } - - } /** Read a metric set from the given input stream * @@ -116,7 +123,9 @@ namespace illumina { namespace interop { namespace io { // TODO: optimize header reading with block read if (in.fail()) - INTEROP_THROW(incomplete_file_exception, "Insufficient header data read from the file"); + INTEROP_THROW(incomplete_file_exception, "Insufficient header data read from the file" + << " for " + << Metric::prefix() << " " << Metric::suffix() << " v" << Layout::VERSION); //if we're not actually reading the record size from the stream // (the stream position is the same before and after), @@ -126,7 +135,9 @@ namespace illumina { namespace interop { namespace io static_cast(0)); if(in.fail()) { - INTEROP_THROW(incomplete_file_exception, "Insufficient header data read from the file"); + INTEROP_THROW(incomplete_file_exception, "Insufficient header data read from the file" + << " for " + << Metric::prefix() << " " << Metric::suffix() << " v" << Layout::VERSION); } if(record_size==0) { @@ -186,7 +197,9 @@ namespace illumina { namespace interop { namespace io { if (count == 0 && !metric_offset_map.empty()) return false; INTEROP_THROW(incomplete_file_exception, "Insufficient data read from the file, got: " << count - << " != expected: " << record_size); + << " != expected: " << record_size << " for " + << Metric::prefix() << " " << Metric::suffix() << " v" + << Layout::VERSION); } return true; } @@ -194,13 +207,12 @@ namespace illumina { namespace interop { namespace io {return true;} template static void read_record(InputStream& in, - model::metric_base::metric_set& metric_set, - offset_map_t& metric_offset_map, - metric_t& metric, - const std::streamsize record_size) + model::metric_base::metric_set& metric_set, + offset_map_t& metric_offset_map, + metric_t& metric, + const std::streamsize record_size) { metric_id_t id; - const std::streamsize read_byte_count = read_binary_with_count (in, id); if(!test_stream(in, metric_offset_map, read_byte_count, record_size)) return; std::streamsize count=read_byte_count; @@ -213,7 +225,7 @@ namespace illumina { namespace interop { namespace io if(offset>= metric_set.size()) metric_set.resize(offset+1); metric_set.at(offset).set_base(id); count += Layout::map_stream(in, metric_set.at(offset), metric_set, true); - if(metric_set.at(offset).id()==0)//Avoid adding control lanes + if(metric_set.at(offset).id()==0)//Avoid adding control lanes in tile metrics { metric_set.resize(offset); } @@ -235,9 +247,14 @@ namespace illumina { namespace interop { namespace io if(!test_stream(in, metric_offset_map, count, record_size)) return; if (count != record_size) { - INTEROP_THROW(bad_format_exception, "Record does not match expected size!"); + INTEROP_THROW(bad_format_exception, "Record does not match expected size! for " + << Metric::prefix() << " " << Metric::suffix() << " v" + << Layout::VERSION << " count=" << count << " != " + << " record_size: " << record_size + << " n= " << metric_offset_map.size()); } } }; }}} + diff --git a/interop/io/format/metric_format_factory.h b/interop/io/format/metric_format_factory.h index 25d55da9e..c32db4d78 100644 --- a/interop/io/format/metric_format_factory.h +++ b/interop/io/format/metric_format_factory.h @@ -95,3 +95,4 @@ namespace illumina { namespace interop { namespace io }}} + diff --git a/interop/io/format/stream_membuf.h b/interop/io/format/stream_membuf.h index d859fb5ed..5db2d6228 100644 --- a/interop/io/format/stream_membuf.h +++ b/interop/io/format/stream_membuf.h @@ -37,4 +37,5 @@ namespace illumina { namespace interop { namespace io } }; } -}}} \ No newline at end of file +}}} + diff --git a/interop/io/format/stream_util.h b/interop/io/format/stream_util.h index 54e8cf371..4a7de8b43 100644 --- a/interop/io/format/stream_util.h +++ b/interop/io/format/stream_util.h @@ -228,3 +228,4 @@ namespace illumina { namespace interop { namespace io }}} + diff --git a/interop/io/layout/base_metric.h b/interop/io/layout/base_metric.h index e22ee4f8b..e49f5f861 100644 --- a/interop/io/layout/base_metric.h +++ b/interop/io/layout/base_metric.h @@ -169,3 +169,4 @@ namespace illumina { namespace interop { namespace io { namespace layout #pragma pack() }}}} + diff --git a/interop/io/metric_file_stream.h b/interop/io/metric_file_stream.h index 8c120a40d..e24dbdbcc 100644 --- a/interop/io/metric_file_stream.h +++ b/interop/io/metric_file_stream.h @@ -127,13 +127,18 @@ namespace illumina { namespace interop { namespace io */ template void read_interop(const std::string& run_directory, MetricSet& metrics, const bool use_out=true) throw - (interop::io::file_not_found_exception, - interop::io::bad_format_exception, - interop::io::incomplete_file_exception, + (file_not_found_exception, + bad_format_exception, + incomplete_file_exception, model::index_out_of_bounds_exception) { - const std::string file_name = interop_filename(run_directory, use_out); + std::string file_name = interop_filename(run_directory, use_out); std::ifstream fin(file_name.c_str(), std::ios::binary); + if(!fin.good()) + { + file_name = interop_filename(run_directory, !use_out); + fin.open(file_name.c_str(), std::ios::binary); + } if(!fin.good()) INTEROP_THROW(file_not_found_exception, "File not found: " << file_name); read_metrics(fin, metrics, static_cast(file_size(file_name))); } @@ -147,9 +152,9 @@ namespace illumina { namespace interop { namespace io */ template bool interop_exists(const std::string& run_directory, MetricSet&, const bool use_out=true) - throw(interop::io::file_not_found_exception, - interop::io::bad_format_exception, - interop::io::incomplete_file_exception, + throw(file_not_found_exception, + bad_format_exception, + incomplete_file_exception, model::index_out_of_bounds_exception) { const std::string file_name = interop_filename(run_directory, use_out); @@ -212,3 +217,4 @@ namespace illumina { namespace interop { namespace io }}} + diff --git a/interop/io/metric_stream.h b/interop/io/metric_stream.h index 59848f3da..7d036dcf5 100644 --- a/interop/io/metric_stream.h +++ b/interop/io/metric_stream.h @@ -121,7 +121,15 @@ namespace illumina { namespace interop { namespace io interop_basename() << " with version: " << version << " of " << format_map.size() ); INTEROP_ASSERT(format_map[version]); metrics.set_version(static_cast< ::int16_t>(version)); - format_map[version]->read_metrics(in, metrics, file_size); + try + { + format_map[version]->read_metrics(in, metrics, file_size); + } + catch(const incomplete_file_exception& ex) + { + metrics.rebuild_index(); + throw ex; + } metrics.rebuild_index(); } @@ -245,3 +253,4 @@ namespace illumina { namespace interop { namespace io } }}} + diff --git a/interop/io/plot/gnuplot.h b/interop/io/plot/gnuplot.h index 27d32bd92..f7b0e9de6 100644 --- a/interop/io/plot/gnuplot.h +++ b/interop/io/plot/gnuplot.h @@ -408,3 +408,4 @@ namespace illumina { namespace interop { namespace io { namespace plot }}}} + diff --git a/interop/io/stream_exceptions.h b/interop/io/stream_exceptions.h index c7168e03a..ba9bd1cb3 100644 --- a/interop/io/stream_exceptions.h +++ b/interop/io/stream_exceptions.h @@ -96,3 +96,4 @@ namespace illumina { namespace interop { namespace io /** @} */ }}} + diff --git a/interop/io/table/csv_format.h b/interop/io/table/csv_format.h index f36ba167b..fc8001746 100644 --- a/interop/io/table/csv_format.h +++ b/interop/io/table/csv_format.h @@ -54,3 +54,4 @@ namespace illumina { namespace interop { namespace io { namespace table } }}}} + diff --git a/interop/io/table/imaging_table_csv.h b/interop/io/table/imaging_table_csv.h index 510dfaefa..8bd00e63a 100644 --- a/interop/io/table/imaging_table_csv.h +++ b/interop/io/table/imaging_table_csv.h @@ -110,3 +110,4 @@ namespace illumina { namespace interop { namespace model { namespace table return out; } }}}} + diff --git a/interop/logic/logic.h b/interop/logic/logic.h index ea3709e55..386628bd9 100644 --- a/interop/logic/logic.h +++ b/interop/logic/logic.h @@ -40,3 +40,4 @@ * * @ingroup logic */ + diff --git a/interop/logic/metric/extraction_metric.h b/interop/logic/metric/extraction_metric.h index 97d02301c..e8b77919d 100644 --- a/interop/logic/metric/extraction_metric.h +++ b/interop/logic/metric/extraction_metric.h @@ -33,3 +33,4 @@ namespace illumina { namespace interop { namespace logic { namespace metric }}}} + diff --git a/interop/logic/metric/metric_value.h b/interop/logic/metric/metric_value.h index c49ebc284..e0f84b94c 100644 --- a/interop/logic/metric/metric_value.h +++ b/interop/logic/metric/metric_value.h @@ -309,3 +309,4 @@ namespace illumina { namespace interop { namespace logic { namespace metric }}}} + diff --git a/interop/logic/metric/q_metric.h b/interop/logic/metric/q_metric.h index 71fcf9afc..6b68df5a4 100644 --- a/interop/logic/metric/q_metric.h +++ b/interop/logic/metric/q_metric.h @@ -282,3 +282,4 @@ namespace illumina { namespace interop { namespace logic { namespace metric model::metric_base::metric_set& bylane) throw(model::index_out_of_bounds_exception); }}}} + diff --git a/interop/logic/metric/tile_metric.h b/interop/logic/metric/tile_metric.h index 78ab76ddf..a14e595b9 100644 --- a/interop/logic/metric/tile_metric.h +++ b/interop/logic/metric/tile_metric.h @@ -184,3 +184,4 @@ namespace illumina { namespace interop { namespace logic { namespace metric }}}} + diff --git a/interop/logic/plot/plot_by_cycle.h b/interop/logic/plot/plot_by_cycle.h index 171a155bd..d32a54b2c 100644 --- a/interop/logic/plot/plot_by_cycle.h +++ b/interop/logic/plot/plot_by_cycle.h @@ -60,3 +60,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot const bool ignore_accumulated=false); }}}} + diff --git a/interop/logic/plot/plot_by_lane.h b/interop/logic/plot/plot_by_lane.h index 0f216589b..854975e44 100644 --- a/interop/logic/plot/plot_by_lane.h +++ b/interop/logic/plot/plot_by_lane.h @@ -59,3 +59,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot }}}} + diff --git a/interop/logic/plot/plot_data.h b/interop/logic/plot/plot_data.h index 13b02b925..387ec02ff 100644 --- a/interop/logic/plot/plot_data.h +++ b/interop/logic/plot/plot_data.h @@ -105,3 +105,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot data.set_yrange(ymin, ymax); } }}}} + diff --git a/interop/logic/plot/plot_flowcell_map.h b/interop/logic/plot/plot_flowcell_map.h index 24740adb4..f3ab9920d 100644 --- a/interop/logic/plot/plot_flowcell_map.h +++ b/interop/logic/plot/plot_flowcell_map.h @@ -75,3 +75,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot }}}} + diff --git a/interop/logic/plot/plot_point.h b/interop/logic/plot/plot_point.h index e57dda7a1..1ee29578c 100644 --- a/interop/logic/plot/plot_point.h +++ b/interop/logic/plot/plot_point.h @@ -63,3 +63,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot { }}}} + diff --git a/interop/logic/plot/plot_qscore_heatmap.h b/interop/logic/plot/plot_qscore_heatmap.h index debad8e94..63706a27b 100644 --- a/interop/logic/plot/plot_qscore_heatmap.h +++ b/interop/logic/plot/plot_qscore_heatmap.h @@ -43,3 +43,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot }}}} + diff --git a/interop/logic/plot/plot_qscore_histogram.h b/interop/logic/plot/plot_qscore_histogram.h index 12d1c1430..ba2e49583 100644 --- a/interop/logic/plot/plot_qscore_histogram.h +++ b/interop/logic/plot/plot_qscore_histogram.h @@ -32,3 +32,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot { model::invalid_filter_option); }}}} + diff --git a/interop/logic/plot/plot_sample_qc.h b/interop/logic/plot/plot_sample_qc.h index 592ea6048..e616303d5 100644 --- a/interop/logic/plot/plot_sample_qc.h +++ b/interop/logic/plot/plot_sample_qc.h @@ -30,3 +30,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot }}}} + diff --git a/interop/logic/summary/cycle_state_summary.h b/interop/logic/summary/cycle_state_summary.h index 75f896966..9ff855aeb 100644 --- a/interop/logic/summary/cycle_state_summary.h +++ b/interop/logic/summary/cycle_state_summary.h @@ -119,3 +119,4 @@ namespace illumina { namespace interop { namespace logic { namespace summary } }}}} + diff --git a/interop/logic/summary/error_summary.h b/interop/logic/summary/error_summary.h index 6b06c8d77..4c360ef3a 100644 --- a/interop/logic/summary/error_summary.h +++ b/interop/logic/summary/error_summary.h @@ -74,9 +74,8 @@ namespace illumina { namespace interop { namespace logic { namespace summary const size_t lane = ebeg->first.first - 1; if (lane >= summary_by_lane_read.lane_count()) INTEROP_THROW(model::index_out_of_bounds_exception, "Lane exceeds number of lanes in RunInfo.xml"); - if (max_cycle < std::numeric_limits::max() && max_error_cycle[read] < max_cycle) - summary_by_lane_read(read, lane).push_back(0); - else summary_by_lane_read(read, lane).push_back(divide(ebeg->second.first, ebeg->second.second)); + if(max_cycle < std::numeric_limits::max() && ebeg->second.second < max_cycle) continue; + summary_by_lane_read(read, lane).push_back(divide(ebeg->second.first, ebeg->second.second)); } } } @@ -86,10 +85,12 @@ namespace illumina { namespace interop { namespace logic { namespace summary * @param summary_by_lane_read source cache by read then by lane a collection of errors * @param run destination run summary * @param func member function pointer to metric + * @param skip_median skip the median calculation */ inline void error_summary_from_cache(summary_by_lane_read &summary_by_lane_read, model::summary::run_summary &run, - void (model::summary::lane_summary::*func )(const model::summary::metric_stat&)) + void (model::summary::lane_summary::*func )(const model::summary::metric_stat&), + const bool skip_median=false) { for (size_t read = 0; read < run.size(); ++read) { @@ -102,7 +103,8 @@ namespace illumina { namespace interop { namespace logic { namespace summary model::summary::metric_stat stat; summarize(summary_by_lane_read(read, lane).begin(), summary_by_lane_read(read, lane).end(), - stat); + stat, + skip_median); (run[read][lane].*func)(stat); } } @@ -126,12 +128,14 @@ namespace illumina { namespace interop { namespace logic { namespace summary * @param end iterator to end of a collection of error metrics * @param cycle_to_read map cycle to the read number and cycle within read number * @param run destination run summary + * @param skip_median skip the median calculation */ template void summarize_error_metrics(I beg, I end, const read_cycle_vector_t &cycle_to_read, - model::summary::run_summary &run) throw(model::index_out_of_bounds_exception) + model::summary::run_summary &run, + const bool skip_median=false) throw(model::index_out_of_bounds_exception) { typedef summary_by_lane_read summary_by_lane_read_t; typedef void (model::summary::lane_summary::*error_functor_t )(const model::summary::metric_stat&); @@ -150,7 +154,7 @@ namespace illumina { namespace interop { namespace logic { namespace summary for (size_t i = 0; i < util::length_of(cycle_functor_pairs); ++i) { cache_error_by_lane_read(beg, end, cycle_functor_pairs[i].first, cycle_to_read, temp); - error_summary_from_cache(temp, run, cycle_functor_pairs[i].second); + error_summary_from_cache(temp, run, cycle_functor_pairs[i].second, skip_median); temp.clear(); } @@ -172,7 +176,8 @@ namespace illumina { namespace interop { namespace logic { namespace summary model::summary::metric_stat stat; summarize(temp(read, lane).begin(), temp(read, lane).end(), - stat); + stat, + skip_median); run[read][lane].error_rate(stat); error_rate_by_read += std::accumulate(temp(read, lane).begin(), temp(read, lane).end(), @@ -196,3 +201,4 @@ namespace illumina { namespace interop { namespace logic { namespace summary } }}}} + diff --git a/interop/logic/summary/extraction_summary.h b/interop/logic/summary/extraction_summary.h index ffd477cbc..6e9e413e8 100644 --- a/interop/logic/summary/extraction_summary.h +++ b/interop/logic/summary/extraction_summary.h @@ -30,13 +30,15 @@ namespace illumina { namespace interop { namespace logic { namespace summary * @param cycle_to_read map cycle to the read number and cycle within read number * @param channel channel to use for intensity reporting * @param run destination run summary + * @param skip_median skip the median calculation */ template void summarize_extraction_metrics(I beg, I end, const read_cycle_vector_t &cycle_to_read, const size_t channel, - model::summary::run_summary &run) throw(model::index_out_of_bounds_exception) + model::summary::run_summary &run, + const bool skip_median=false) throw(model::index_out_of_bounds_exception) { typedef typename model::metrics::extraction_metric::ushort_t ushort_t; typedef summary_by_lane_read summary_by_lane_read_t; @@ -73,7 +75,7 @@ namespace illumina { namespace interop { namespace logic { namespace summary { INTEROP_ASSERT(lane < temp.lane_count()); INTEROP_ASSERT(lane < run[read].size()); - summarize(temp(read, lane).begin(), temp(read, lane).end(), first_cycle_intensity_stat); + summarize(temp(read, lane).begin(), temp(read, lane).end(), first_cycle_intensity_stat, skip_median); run[read][lane].first_cycle_intensity(first_cycle_intensity_stat); first_cycle_intensity_by_read += std::accumulate(temp(read, lane).begin(), temp(read, lane).end(), @@ -98,3 +100,4 @@ namespace illumina { namespace interop { namespace logic { namespace summary } }}}} + diff --git a/interop/logic/summary/index_summary.h b/interop/logic/summary/index_summary.h index 05fbddba5..53b3d4f12 100644 --- a/interop/logic/summary/index_summary.h +++ b/interop/logic/summary/index_summary.h @@ -49,3 +49,4 @@ namespace illumina { namespace interop { namespace logic { namespace summary model::summary::index_flowcell_summary &summary) throw(model::index_out_of_bounds_exception); }}}} + diff --git a/interop/logic/summary/map_cycle_to_read.h b/interop/logic/summary/map_cycle_to_read.h index 9753a2de1..399020f7d 100644 --- a/interop/logic/summary/map_cycle_to_read.h +++ b/interop/logic/summary/map_cycle_to_read.h @@ -77,3 +77,4 @@ namespace illumina { namespace interop { namespace logic { namespace summary }}}} + diff --git a/interop/logic/summary/quality_summary.h b/interop/logic/summary/quality_summary.h index 2467d46b9..daa206ff0 100644 --- a/interop/logic/summary/quality_summary.h +++ b/interop/logic/summary/quality_summary.h @@ -182,3 +182,4 @@ namespace illumina { namespace interop { namespace logic { namespace summary run.total_summary().percent_gt_q30(100 * divide(float(useable_calls_gt_q30), float(total_useable_calls))); } }}}} + diff --git a/interop/logic/summary/run_summary.h b/interop/logic/summary/run_summary.h index ce59f6d0e..8ae37b271 100644 --- a/interop/logic/summary/run_summary.h +++ b/interop/logic/summary/run_summary.h @@ -22,9 +22,13 @@ namespace illumina { namespace interop { namespace logic { namespace summary * @ingroup summary_logic * @param metrics source collection of all metrics * @param summary destination run summary + * @param skip_median skip the median calculation */ - void summarize_run_metrics(model::metrics::run_metrics& metrics, model::summary::run_summary& summary) + void summarize_run_metrics(model::metrics::run_metrics& metrics, + model::summary::run_summary& summary, + const bool skip_median=false) throw( model::index_out_of_bounds_exception, model::invalid_channel_exception ); }}}} + diff --git a/interop/logic/summary/summary_statistics.h b/interop/logic/summary/summary_statistics.h index 67342f222..7571d9215 100644 --- a/interop/logic/summary/summary_statistics.h +++ b/interop/logic/summary/summary_statistics.h @@ -128,14 +128,15 @@ namespace illumina { namespace interop { namespace logic { namespace summary * @param beg iterator to start of collection * @param end iterator to end of collection * @param stat object to store mean, stddev, and median + * @param skip_median skip the median calculation */ template - void summarize(I beg, I end, S &stat) + void summarize(I beg, I end, S &stat, const bool skip_median) { if (beg == end) return; stat.mean(util::mean(beg, end)); stat.stddev(std::sqrt(util::variance_with_mean(beg, end, stat.mean()))); - stat.median(util::median_interpolated(beg, end)); + if(!skip_median) stat.median(util::median_interpolated(beg, end)); } /** Calculate the mean, standard deviation (stddev) and median over a collection of values @@ -145,14 +146,15 @@ namespace illumina { namespace interop { namespace logic { namespace summary * @param stat object to store mean, stddev, and median * @param op unary/binary operator for getting a value in a complex object * @param comp comparison operator to compare a single value in a complex object + * @param skip_median skip the median calculation */ template - void summarize(I beg, I end, S &stat, BinaryOp op, Compare comp) + void summarize(I beg, I end, S &stat, BinaryOp op, Compare comp, const bool skip_median) { if (beg == end) return; stat.mean(util::mean(beg, end, op)); stat.stddev(std::sqrt(util::variance_with_mean(beg, end, stat.mean(), op))); - stat.median(util::median_interpolated(beg, end, comp, op)); + if(!skip_median) stat.median(util::median_interpolated(beg, end, comp, op)); } /** Calculate the mean, standard deviation (stddev) and median over a collection of values, ignoring NaNs @@ -162,10 +164,11 @@ namespace illumina { namespace interop { namespace logic { namespace summary * @param stat object to store mean, stddev, and median * @param op unary/binary operator for getting a value in a complex object * @param comp comparison operator to compare a single value in a complex object + * @param skip_median skip the median calculation * @return number of non-NaN elements */ template - size_t nan_summarize(I beg, I end, S &stat, BinaryOp op, Compare comp) + size_t nan_summarize(I beg, I end, S &stat, BinaryOp op, Compare comp, const bool skip_median) { stat.clear(); if (beg == end) return 0; @@ -174,7 +177,7 @@ namespace illumina { namespace interop { namespace logic { namespace summary stat.mean(util::mean(beg, end, op)); INTEROP_ASSERT(!std::isnan(stat.mean())); stat.stddev(std::sqrt(util::variance_with_mean(beg, end, stat.mean(), op))); - stat.median(util::median_interpolated(beg, end, comp, op)); + if(!skip_median) stat.median(util::median_interpolated(beg, end, comp, op)); return size_t(std::distance(beg, end)); } @@ -269,3 +272,4 @@ namespace illumina { namespace interop { namespace logic { namespace summary } }}}} + diff --git a/interop/logic/summary/tile_summary.h b/interop/logic/summary/tile_summary.h index b393f1dd7..7bbbbb7e0 100644 --- a/interop/logic/summary/tile_summary.h +++ b/interop/logic/summary/tile_summary.h @@ -35,9 +35,13 @@ namespace illumina { namespace interop { namespace logic { namespace summary * @param beg iterator to start of a collection of tile metrics * @param end iterator to end of a collection of tile metrics * @param run destination run summary + * @param skip_median skip the median calculation */ template - void summarize_tile_metrics(I beg, I end, model::summary::run_summary &run) + void summarize_tile_metrics(I beg, + I end, + model::summary::run_summary &run, + const bool skip_median=false) throw(model::index_out_of_bounds_exception) { typedef typename model::metrics::tile_metric::read_metric_vector read_metric_vector_t; @@ -83,31 +87,36 @@ namespace illumina { namespace interop { namespace logic { namespace summary tile_data_by_lane[lane].end(), stat, util::op::const_member_function(&model::metrics::tile_metric::cluster_density), - util::op::const_member_function_less(&model::metrics::tile_metric::cluster_density)); + util::op::const_member_function_less(&model::metrics::tile_metric::cluster_density), + skip_median); run[0][lane].density(stat); summarize(tile_data_by_lane[lane].begin(), tile_data_by_lane[lane].end(), stat, util::op::const_member_function(&model::metrics::tile_metric::cluster_density_pf), - util::op::const_member_function_less(&model::metrics::tile_metric::cluster_density_pf)); + util::op::const_member_function_less(&model::metrics::tile_metric::cluster_density_pf), + skip_median); run[0][lane].density_pf(stat); summarize(tile_data_by_lane[lane].begin(), tile_data_by_lane[lane].end(), stat, util::op::const_member_function(&model::metrics::tile_metric::cluster_count), - util::op::const_member_function_less(&model::metrics::tile_metric::cluster_count)); + util::op::const_member_function_less(&model::metrics::tile_metric::cluster_count), + skip_median); run[0][lane].cluster_count(stat); summarize(tile_data_by_lane[lane].begin(), tile_data_by_lane[lane].end(), stat, util::op::const_member_function(&model::metrics::tile_metric::cluster_count_pf), - util::op::const_member_function_less(&model::metrics::tile_metric::cluster_count_pf)); + util::op::const_member_function_less(&model::metrics::tile_metric::cluster_count_pf), + skip_median); run[0][lane].cluster_count_pf(stat); summarize(tile_data_by_lane[lane].begin(), tile_data_by_lane[lane].end(), stat, util::op::const_member_function(&model::metrics::tile_metric::percent_pf), - util::op::const_member_function_less(&model::metrics::tile_metric::percent_pf)); + util::op::const_member_function_less(&model::metrics::tile_metric::percent_pf), + skip_median); run[0][lane].percent_pf(stat); run[0][lane].reads(std::accumulate(tile_data_by_lane[lane].begin(), tile_data_by_lane[lane].end(), @@ -151,19 +160,22 @@ namespace illumina { namespace interop { namespace logic { namespace summary util::op::const_member_function( &model::metrics::read_metric::percent_aligned), util::op::const_member_function_less( - &model::metrics::read_metric::percent_aligned)); + &model::metrics::read_metric::percent_aligned), + skip_median); run[read][lane].percent_aligned(stat); nan_summarize(read_data_by_lane_read(read, lane).begin(), read_data_by_lane_read(read, lane).end(), stat, util::op::const_member_function(&model::metrics::read_metric::percent_prephasing), - util::op::const_member_function_less(&model::metrics::read_metric::percent_prephasing)); + util::op::const_member_function_less(&model::metrics::read_metric::percent_prephasing), + skip_median); run[read][lane].prephasing(stat); nan_summarize(read_data_by_lane_read(read, lane).begin(), read_data_by_lane_read(read, lane).end(), stat, util::op::const_member_function(&model::metrics::read_metric::percent_phasing), - util::op::const_member_function_less(&model::metrics::read_metric::percent_phasing)); + util::op::const_member_function_less(&model::metrics::read_metric::percent_phasing), + skip_median); run[read][lane].phasing(stat); INTEROP_ASSERT(!std::isnan(run[read][lane].percent_aligned().mean())); percent_aligned_by_read += run[read][lane].percent_aligned().mean() * non_nan; @@ -184,3 +196,4 @@ namespace illumina { namespace interop { namespace logic { namespace summary } }}}} + diff --git a/interop/logic/table/check_imaging_table_column.h b/interop/logic/table/check_imaging_table_column.h index 2a95eee86..1c3b395d7 100644 --- a/interop/logic/table/check_imaging_table_column.h +++ b/interop/logic/table/check_imaging_table_column.h @@ -196,3 +196,4 @@ namespace illumina { namespace interop { namespace logic { namespace table } }; }}}} + diff --git a/interop/logic/table/create_imaging_table.h b/interop/logic/table/create_imaging_table.h index 4cd3fef42..ed255a501 100644 --- a/interop/logic/table/create_imaging_table.h +++ b/interop/logic/table/create_imaging_table.h @@ -53,3 +53,4 @@ namespace illumina { namespace interop { namespace logic { namespace table void list_imaging_table_metrics_to_load(std::vector& valid_to_load); }}}} + diff --git a/interop/logic/table/create_imaging_table_columns.h b/interop/logic/table/create_imaging_table_columns.h index ce54f34cc..34c5cc6a6 100644 --- a/interop/logic/table/create_imaging_table_columns.h +++ b/interop/logic/table/create_imaging_table_columns.h @@ -47,3 +47,4 @@ namespace illumina { namespace interop { namespace logic { namespace table }}}} + diff --git a/interop/logic/table/table_populator.h b/interop/logic/table/table_populator.h index 404880d3e..d37f55e9d 100644 --- a/interop/logic/table/table_populator.h +++ b/interop/logic/table/table_populator.h @@ -246,3 +246,4 @@ namespace illumina { namespace interop { namespace logic { namespace table } }; }}}} + diff --git a/interop/logic/table/table_util.h b/interop/logic/table/table_util.h index a244256f9..8ad4c0ec3 100644 --- a/interop/logic/table/table_util.h +++ b/interop/logic/table/table_util.h @@ -69,3 +69,4 @@ namespace illumina { namespace interop { namespace constants { }; }}} #undef INTEROP_TUPLE7 // Reuse this for another conversion + diff --git a/interop/logic/utils/channel.h b/interop/logic/utils/channel.h index f0f7f7ba0..42192848c 100644 --- a/interop/logic/utils/channel.h +++ b/interop/logic/utils/channel.h @@ -198,3 +198,4 @@ namespace illumina { namespace interop { namespace logic { namespace utils #ifdef _MSC_VER #pragma warning(pop) #endif + diff --git a/interop/logic/utils/enums.h b/interop/logic/utils/enums.h index d5b651c3e..814ff5dbd 100644 --- a/interop/logic/utils/enums.h +++ b/interop/logic/utils/enums.h @@ -318,3 +318,4 @@ namespace illumina { namespace interop { namespace constants #undef INTEROP_TUPLE2 #undef INTEROP_TUPLE3 #undef INTEROP_TUPLE4 + diff --git a/interop/logic/utils/metric_type_ext.h b/interop/logic/utils/metric_type_ext.h index 6b473889e..5b74307ec 100644 --- a/interop/logic/utils/metric_type_ext.h +++ b/interop/logic/utils/metric_type_ext.h @@ -123,3 +123,4 @@ namespace illumina { namespace interop { namespace logic { namespace utils } }}}} + diff --git a/interop/logic/utils/metrics_to_load.h b/interop/logic/utils/metrics_to_load.h index bc3c0921c..e88f78389 100644 --- a/interop/logic/utils/metrics_to_load.h +++ b/interop/logic/utils/metrics_to_load.h @@ -81,3 +81,4 @@ namespace illumina { namespace interop { namespace logic { namespace utils }}}} + diff --git a/interop/model/metric_base/base_cycle_metric.h b/interop/model/metric_base/base_cycle_metric.h index 709272d7c..3ee887e8f 100644 --- a/interop/model/metric_base/base_cycle_metric.h +++ b/interop/model/metric_base/base_cycle_metric.h @@ -161,3 +161,4 @@ namespace illumina { namespace interop { namespace model { namespace metric_base }; }}}} + diff --git a/interop/model/metric_base/base_metric.h b/interop/model/metric_base/base_metric.h index a3882cd35..052f1b0bf 100644 --- a/interop/model/metric_base/base_metric.h +++ b/interop/model/metric_base/base_metric.h @@ -429,3 +429,4 @@ namespace illumina { namespace interop { namespace model { namespace metric_base }}}} + diff --git a/interop/model/metric_base/base_read_metric.h b/interop/model/metric_base/base_read_metric.h index fb530e0d7..bb9019af0 100644 --- a/interop/model/metric_base/base_read_metric.h +++ b/interop/model/metric_base/base_read_metric.h @@ -146,3 +146,4 @@ namespace illumina { namespace interop { namespace model { namespace metric_base }; }}}} + diff --git a/interop/model/metric_base/metric_set.h b/interop/model/metric_base/metric_set.h index 40c2da243..d5e215f5a 100644 --- a/interop/model/metric_base/metric_set.h +++ b/interop/model/metric_base/metric_set.h @@ -163,7 +163,6 @@ namespace illumina { namespace interop { namespace model { namespace metric_base size_t offset = 0; for (const_iterator b = m_data.begin(), e = m_data.end(); b != e; ++b) { - INTEROP_ASSERT(b->id()>0); m_id_map[b->id()] = offset; ++offset; T::header_type::update_max_cycle(*b); @@ -469,6 +468,8 @@ namespace illumina { namespace interop { namespace model { namespace metric_base header_type::clear(); m_id_map.clear(); m_data.clear(); + m_version=0; + m_data_source_exists=false; } /** Get the metrics in a vector @@ -542,6 +543,15 @@ namespace illumina { namespace interop { namespace model { namespace metric_base return m_data[it->second]; } + /** Get the current id offset map + * + * @return id offset map + */ + const id_map_t& offset_map()const + { + return m_id_map; + } + private: metric_array_t metrics_for_cycle(const uint_t cycle, const constants::base_cycle_t*) const { @@ -650,3 +660,4 @@ namespace illumina { namespace interop { namespace model { namespace metric_base #pragma warning(pop) #endif + diff --git a/interop/model/metrics/corrected_intensity_metric.h b/interop/model/metrics/corrected_intensity_metric.h index 87651c137..7ded9c499 100644 --- a/interop/model/metrics/corrected_intensity_metric.h +++ b/interop/model/metrics/corrected_intensity_metric.h @@ -590,3 +590,4 @@ namespace illumina { namespace interop { namespace model { namespace metrics + diff --git a/interop/model/metrics/error_metric.h b/interop/model/metrics/error_metric.h index 3be891820..174a4439c 100644 --- a/interop/model/metrics/error_metric.h +++ b/interop/model/metrics/error_metric.h @@ -168,3 +168,4 @@ namespace illumina { namespace interop { namespace model { namespace metrics struct io::generic_layout; }; }}}} + diff --git a/interop/model/metrics/extraction_metric.h b/interop/model/metrics/extraction_metric.h index 63a7e0ae8..19c89d645 100644 --- a/interop/model/metrics/extraction_metric.h +++ b/interop/model/metrics/extraction_metric.h @@ -343,3 +343,4 @@ namespace illumina { namespace interop { namespace model { namespace metrics }; }}}} + diff --git a/interop/model/metrics/image_metric.h b/interop/model/metrics/image_metric.h index fafe20e3a..2fbdd17cf 100644 --- a/interop/model/metrics/image_metric.h +++ b/interop/model/metrics/image_metric.h @@ -303,3 +303,4 @@ namespace illumina { namespace interop { namespace model { namespace metrics }; }}}} + diff --git a/interop/model/metrics/index_metric.h b/interop/model/metrics/index_metric.h index 82858a588..6e1829c1a 100644 --- a/interop/model/metrics/index_metric.h +++ b/interop/model/metrics/index_metric.h @@ -256,3 +256,4 @@ namespace illumina { namespace interop { namespace model { namespace metrics struct io::generic_layout; }; }}}} + diff --git a/interop/model/metrics/q_by_lane_metric.h b/interop/model/metrics/q_by_lane_metric.h index 4a40109bb..03a3ec61f 100644 --- a/interop/model/metrics/q_by_lane_metric.h +++ b/interop/model/metrics/q_by_lane_metric.h @@ -88,3 +88,4 @@ namespace illumina { namespace interop { namespace model { namespace metrics }}}} + diff --git a/interop/model/metrics/q_collapsed_metric.h b/interop/model/metrics/q_collapsed_metric.h index 48f17b856..947987b00 100644 --- a/interop/model/metrics/q_collapsed_metric.h +++ b/interop/model/metrics/q_collapsed_metric.h @@ -266,3 +266,4 @@ namespace illumina { namespace interop { namespace model { namespace metrics { }}}} + diff --git a/interop/model/metrics/q_metric.h b/interop/model/metrics/q_metric.h index 1a14de569..5180eb106 100644 --- a/interop/model/metrics/q_metric.h +++ b/interop/model/metrics/q_metric.h @@ -1,10 +1,13 @@ /** Q-score metric - * * * The InterOp files parsed by this class include: * - InterOp/QMetrics.bin * - InterOp/QMetricsOut.bin * + * The QMetricsOut.bin InterOp file contains a histogram of the counts of PF clusters at each quality value ranging + * from 1 to 50 for each lane, tile, and cycle. % >= Q30 is calculated as the sum of the populations in bins with a + * quality value of 30 or greater divided by the total non-N basecalls (sum of the population over all bins) times 100. + * * @file * @date 8/21/2015 * @version 1.0 @@ -228,6 +231,11 @@ namespace illumina { namespace interop { namespace model { namespace metrics }; /** Q-score metric + * + * The QMetricsOut.bin InterOp file contains a histogram of the counts of PF clusters at each quality value + * ranging from 1 to 50 for each lane, tile, and cycle. % >= Q30 is calculated as the sum of the populations in + * bins with a quality value of 30 or greater divided by the total non-N basecalls (sum of the population over + * all bins times) 100. * * @note Supported versions: 4, 5 and 6 */ @@ -614,3 +622,4 @@ namespace illumina { namespace interop { namespace model { namespace metrics }; }}}} + diff --git a/interop/model/metrics/tile_metric.h b/interop/model/metrics/tile_metric.h index fef949a20..4cd486fd9 100644 --- a/interop/model/metrics/tile_metric.h +++ b/interop/model/metrics/tile_metric.h @@ -441,3 +441,4 @@ namespace illumina { namespace interop { namespace model { namespace metrics struct io::generic_layout; }; }}}} + diff --git a/interop/model/model_exceptions.h b/interop/model/model_exceptions.h index a1ba25411..ba144739e 100644 --- a/interop/model/model_exceptions.h +++ b/interop/model/model_exceptions.h @@ -6,6 +6,7 @@ * @copyright GNU Public License. */ #pragma once + #include #ifdef _MSC_VER @@ -133,3 +134,4 @@ namespace illumina { namespace interop { namespace model /** @} */ }}} + diff --git a/interop/model/plot/axes.h b/interop/model/plot/axes.h index f6c9091af..8f8d52201 100644 --- a/interop/model/plot/axes.h +++ b/interop/model/plot/axes.h @@ -174,3 +174,4 @@ namespace illumina { namespace interop { namespace model { namespace plot { }; }}}} + diff --git a/interop/model/plot/bar_point.h b/interop/model/plot/bar_point.h index bfbe286b7..2c0418cb0 100644 --- a/interop/model/plot/bar_point.h +++ b/interop/model/plot/bar_point.h @@ -67,3 +67,4 @@ namespace illumina { namespace interop { namespace model { namespace plot }}}} + diff --git a/interop/model/plot/candle_stick_point.h b/interop/model/plot/candle_stick_point.h index 3aea65a03..7cca621f9 100644 --- a/interop/model/plot/candle_stick_point.h +++ b/interop/model/plot/candle_stick_point.h @@ -142,3 +142,4 @@ namespace illumina { namespace interop { namespace model { namespace plot }}}} + diff --git a/interop/model/plot/chart_data.h b/interop/model/plot/chart_data.h index 04f4ba5ff..6dd8286d4 100644 --- a/interop/model/plot/chart_data.h +++ b/interop/model/plot/chart_data.h @@ -149,3 +149,4 @@ namespace illumina { namespace interop { namespace model { namespace plot }}}} + diff --git a/interop/model/plot/data_point.h b/interop/model/plot/data_point.h index eec65b8e2..96f38a57f 100644 --- a/interop/model/plot/data_point.h +++ b/interop/model/plot/data_point.h @@ -94,3 +94,4 @@ namespace illumina { namespace interop { namespace model { namespace plot { }}}} + diff --git a/interop/model/plot/data_point_collection.h b/interop/model/plot/data_point_collection.h index 076a22ce7..4cb2ac3dd 100644 --- a/interop/model/plot/data_point_collection.h +++ b/interop/model/plot/data_point_collection.h @@ -128,3 +128,4 @@ namespace illumina { namespace interop { namespace model { namespace plot }}}} + diff --git a/interop/model/plot/filter_options.h b/interop/model/plot/filter_options.h index 1b011ef42..c48c35941 100644 --- a/interop/model/plot/filter_options.h +++ b/interop/model/plot/filter_options.h @@ -6,6 +6,7 @@ * @copyright GNU Public License. */ #pragma once + #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4290)// MSVC warns that it ignores the exception specification. @@ -597,4 +598,4 @@ namespace illumina { namespace interop { namespace model { namespace plot }}}} #ifdef _MSC_VER #pragma warning(pop) -#endif \ No newline at end of file +#endif diff --git a/interop/model/plot/flowcell_data.h b/interop/model/plot/flowcell_data.h index dd9b93680..197d5ccd6 100644 --- a/interop/model/plot/flowcell_data.h +++ b/interop/model/plot/flowcell_data.h @@ -269,3 +269,4 @@ namespace illumina { namespace interop { namespace model { namespace plot }; }}}} + diff --git a/interop/model/plot/heatmap_data.h b/interop/model/plot/heatmap_data.h index 0d0a30177..966cd44fa 100644 --- a/interop/model/plot/heatmap_data.h +++ b/interop/model/plot/heatmap_data.h @@ -37,13 +37,11 @@ namespace illumina { namespace interop { namespace model { namespace plot * @param data use the given buffer to back the heat map * @param default_val value to fill heatmap */ - void set_buffer(float* data, - const float default_val=std::numeric_limits::quiet_NaN()) throw(invalid_parameter) + void set_buffer(float* data) throw(invalid_parameter) { if(m_free) INTEROP_THROW( invalid_parameter, "Cannot use internal buffer map with external buffer"); if(empty()) INTEROP_THROW( invalid_parameter, "Cannot set external buffer to empty map"); m_data = data; - std::fill(m_data, m_data+length(), default_val); } /** Resize the heat map to the given number of rows and columns * @@ -192,8 +190,6 @@ namespace illumina { namespace interop { namespace model { namespace plot m_num_columns = 0; m_num_rows = 0; } - - protected: /** Get the index of the row and column in the array * * @param row row index @@ -213,3 +209,4 @@ namespace illumina { namespace interop { namespace model { namespace plot }; }}}} + diff --git a/interop/model/plot/plot_data.h b/interop/model/plot/plot_data.h index 79ecedae4..cd4eaad66 100644 --- a/interop/model/plot/plot_data.h +++ b/interop/model/plot/plot_data.h @@ -130,3 +130,4 @@ namespace illumina { namespace interop { namespace model { namespace plot { }}}} + diff --git a/interop/model/plot/series.h b/interop/model/plot/series.h index 267ec7109..4e58b5722 100644 --- a/interop/model/plot/series.h +++ b/interop/model/plot/series.h @@ -107,3 +107,4 @@ namespace illumina { namespace interop { namespace model { namespace plot { }}}} + diff --git a/interop/model/run/cycle_range.h b/interop/model/run/cycle_range.h index 57c6614b6..b5709f783 100644 --- a/interop/model/run/cycle_range.h +++ b/interop/model/run/cycle_range.h @@ -140,3 +140,4 @@ namespace illumina { namespace interop { namespace model { namespace run }; }}}} + diff --git a/interop/model/run/flowcell_layout.h b/interop/model/run/flowcell_layout.h index e11a12ebd..22d14656f 100644 --- a/interop/model/run/flowcell_layout.h +++ b/interop/model/run/flowcell_layout.h @@ -171,3 +171,4 @@ namespace illumina { namespace interop { namespace model { namespace run }; }}}} + diff --git a/interop/model/run/image_dimensions.h b/interop/model/run/image_dimensions.h index aabe6dafd..174d2352f 100644 --- a/interop/model/run/image_dimensions.h +++ b/interop/model/run/image_dimensions.h @@ -59,3 +59,4 @@ namespace illumina { namespace interop { namespace model { namespace run }}}} + diff --git a/interop/model/run/info.h b/interop/model/run/info.h index c2bc56adb..71f12be48 100644 --- a/interop/model/run/info.h +++ b/interop/model/run/info.h @@ -294,3 +294,4 @@ namespace illumina { namespace interop { namespace model { namespace run #pragma warning(pop) #endif + diff --git a/interop/model/run/parameters.h b/interop/model/run/parameters.h index 1f7a33b61..5c7c3a8b5 100644 --- a/interop/model/run/parameters.h +++ b/interop/model/run/parameters.h @@ -115,3 +115,4 @@ namespace illumina { namespace interop { namespace model { namespace run #ifdef _MSC_VER #pragma warning(pop) #endif + diff --git a/interop/model/run/read_info.h b/interop/model/run/read_info.h index 4928befee..f40785d6e 100644 --- a/interop/model/run/read_info.h +++ b/interop/model/run/read_info.h @@ -98,3 +98,4 @@ namespace illumina { namespace interop { namespace model { namespace run }; }}}} + diff --git a/interop/model/run_metrics.h b/interop/model/run_metrics.h index eecbf101a..b3d4acdec 100644 --- a/interop/model/run_metrics.h +++ b/interop/model/run_metrics.h @@ -563,3 +563,4 @@ namespace illumina { namespace interop { namespace model { namespace metrics }}}} + diff --git a/interop/model/summary/cycle_state_summary.h b/interop/model/summary/cycle_state_summary.h index 6e77eab22..8c11cbbd5 100644 --- a/interop/model/summary/cycle_state_summary.h +++ b/interop/model/summary/cycle_state_summary.h @@ -130,3 +130,4 @@ namespace illumina { namespace interop { namespace model { namespace summary }; }}}} + diff --git a/interop/model/summary/index_count_summary.h b/interop/model/summary/index_count_summary.h index f9d711771..8c7b04211 100644 --- a/interop/model/summary/index_count_summary.h +++ b/interop/model/summary/index_count_summary.h @@ -148,3 +148,4 @@ namespace illumina { namespace interop { namespace model { namespace summary { }; }}}} + diff --git a/interop/model/summary/index_flowcell_summary.h b/interop/model/summary/index_flowcell_summary.h index a26a36bbc..c131e69fe 100644 --- a/interop/model/summary/index_flowcell_summary.h +++ b/interop/model/summary/index_flowcell_summary.h @@ -12,7 +12,8 @@ #include "interop/model/model_exceptions.h" #include "interop/model/summary/index_lane_summary.h" -namespace illumina { namespace interop { namespace model { namespace summary { +namespace illumina { namespace interop { namespace model { namespace summary +{ /** Summary of metrics for index reads for the entire flowcell */ @@ -147,3 +148,4 @@ namespace illumina { namespace interop { namespace model { namespace summary { }; }}}} + diff --git a/interop/model/summary/index_lane_summary.h b/interop/model/summary/index_lane_summary.h index 9c070d871..be2761e40 100644 --- a/interop/model/summary/index_lane_summary.h +++ b/interop/model/summary/index_lane_summary.h @@ -257,3 +257,4 @@ namespace illumina { namespace interop { namespace model { namespace summary { }; }}}} + diff --git a/interop/model/summary/lane_summary.h b/interop/model/summary/lane_summary.h index 90f535a7e..63523f5fb 100644 --- a/interop/model/summary/lane_summary.h +++ b/interop/model/summary/lane_summary.h @@ -475,3 +475,4 @@ namespace illumina { namespace interop { namespace model { namespace summary }; }}}} + diff --git a/interop/model/summary/metric_stat.h b/interop/model/summary/metric_stat.h index ae85440c0..799595b3f 100644 --- a/interop/model/summary/metric_stat.h +++ b/interop/model/summary/metric_stat.h @@ -25,7 +25,7 @@ namespace illumina { namespace interop { namespace model { namespace summary */ metric_stat(const float mean = 0, const float stddev = 0, - const float median = 0) : + const float median = std::numeric_limits::quiet_NaN()) : m_mean(mean), m_stddev(stddev), m_median(median) @@ -39,7 +39,7 @@ namespace illumina { namespace interop { namespace model { namespace summary { m_mean = 0; m_stddev = 0; - m_median = 0; + m_median = std::numeric_limits::quiet_NaN(); } public: @@ -116,3 +116,4 @@ namespace illumina { namespace interop { namespace model { namespace summary }; }}}} + diff --git a/interop/model/summary/metric_summary.h b/interop/model/summary/metric_summary.h index 2e28e3afc..a58ef0bb0 100644 --- a/interop/model/summary/metric_summary.h +++ b/interop/model/summary/metric_summary.h @@ -8,8 +8,6 @@ #pragma once #include "interop/io/format/generic_layout.h" - - namespace illumina { namespace interop { namespace model { namespace summary { /** Summary statistics by read, total and non-indexed @@ -152,3 +150,4 @@ namespace illumina { namespace interop { namespace model { namespace summary { }}}} + diff --git a/interop/model/summary/read_summary.h b/interop/model/summary/read_summary.h index 0c92fa4b3..8ece68171 100644 --- a/interop/model/summary/read_summary.h +++ b/interop/model/summary/read_summary.h @@ -227,3 +227,4 @@ namespace illumina { namespace interop { namespace model { namespace summary }; }}}} + diff --git a/interop/model/summary/run_summary.h b/interop/model/summary/run_summary.h index 25f8e1f9f..e33c074a7 100644 --- a/interop/model/summary/run_summary.h +++ b/interop/model/summary/run_summary.h @@ -349,3 +349,4 @@ namespace illumina { namespace interop { namespace model { namespace summary }; }}}} + diff --git a/interop/model/table/imaging_column.h b/interop/model/table/imaging_column.h index 448b11178..6d55c6bb0 100644 --- a/interop/model/table/imaging_column.h +++ b/interop/model/table/imaging_column.h @@ -67,7 +67,7 @@ INTEROP_TUPLE7(Fwhm, metrics::extraction_metric, focus_scores, Void, Float, ChannelArray, 2) \ INTEROP_TUPLE7(Corrected, metrics::corrected_intensity_metric,corrected_int_all_array, Void, UShort, BaseArray, 0)\ INTEROP_TUPLE7(Called, metrics::corrected_intensity_metric,corrected_int_called_array, Void, UShort, BaseArray, 0)\ - INTEROP_TUPLE7(SignalToNoise, metrics::corrected_intensity_metric,signal_to_noise, Void, Float, ValueType, 0)\ + INTEROP_TUPLE7(SignalToNoise, metrics::corrected_intensity_metric,signal_to_noise, Void, Float, ValueType, 2)\ INTEROP_TUPLE7(MinimumContrast, metrics::image_metric, min_contrast_array, Void, UShort, ChannelArray, 0)\ INTEROP_TUPLE7(MaximumContrast, metrics::image_metric, max_contrast_array, Void, UShort, ChannelArray, 0)\ INTEROP_TUPLE7(Time, metrics::extraction_metric, date_time_csharp, Void, DateTime, StructType, 0)\ @@ -284,3 +284,4 @@ namespace illumina { namespace interop { namespace model { namespace table }}}} + diff --git a/interop/model/table/imaging_table.h b/interop/model/table/imaging_table.h index 2005243fb..19b18e5d7 100644 --- a/interop/model/table/imaging_table.h +++ b/interop/model/table/imaging_table.h @@ -208,3 +208,4 @@ namespace illumina { namespace interop { namespace model { namespace table }; }}}} + diff --git a/interop/util/assert.h b/interop/util/assert.h index 75bf17dfd..8bbd9b854 100644 --- a/interop/util/assert.h +++ b/interop/util/assert.h @@ -52,3 +52,4 @@ #define INTEROP_ASSERTMSG(TST,MSG) (void)0; #endif + diff --git a/interop/util/constant_mapping.h b/interop/util/constant_mapping.h index 4c9a2804f..6125a82db 100644 --- a/interop/util/constant_mapping.h +++ b/interop/util/constant_mapping.h @@ -88,3 +88,4 @@ namespace illumina { namespace interop { namespace util } }}} + diff --git a/interop/util/cstdint.h b/interop/util/cstdint.h index 101223340..312eccc10 100644 --- a/interop/util/cstdint.h +++ b/interop/util/cstdint.h @@ -113,3 +113,4 @@ namespace std } #endif + diff --git a/interop/util/exception.h b/interop/util/exception.h index 9f2522ed9..dc73e7578 100644 --- a/interop/util/exception.h +++ b/interop/util/exception.h @@ -17,3 +17,4 @@ #define INTEROP_THROW(EXCEPTION, MESSAGE) \ throw EXCEPTION ( static_cast(std::ostringstream().flush() << MESSAGE << "\n" << __FILE__<< "::" \ << __FUNCTION__<< " (" << __LINE__ << ")" ).str()) + diff --git a/interop/util/filesystem.h b/interop/util/filesystem.h index 64c33ef2b..2515286a2 100644 --- a/interop/util/filesystem.h +++ b/interop/util/filesystem.h @@ -45,10 +45,11 @@ namespace illumina { namespace interop { namespace io /** Create a directory * * @param path path to new directory - * @param mode linux permissions + * @param mode permissions on directory * @return true if directory was created */ bool mkdir(const std::string& path, const int mode=0733); + /** Get the size of a file * * This should be more efficient than opening a file and seeking the end. @@ -59,3 +60,4 @@ namespace illumina { namespace interop { namespace io ::int64_t file_size(const std::string& path); }}} + diff --git a/interop/util/length_of.h b/interop/util/length_of.h index 10e091ec7..f93188369 100644 --- a/interop/util/length_of.h +++ b/interop/util/length_of.h @@ -66,3 +66,4 @@ namespace illumina { namespace interop { namespace util }}} + diff --git a/interop/util/lexical_cast.h b/interop/util/lexical_cast.h index 68c22a30f..70c43eae9 100644 --- a/interop/util/lexical_cast.h +++ b/interop/util/lexical_cast.h @@ -252,3 +252,4 @@ namespace illumina { namespace interop { namespace util }}} + diff --git a/interop/util/linear_hierarchy.h b/interop/util/linear_hierarchy.h index 68cd389b7..2c70cd076 100644 --- a/interop/util/linear_hierarchy.h +++ b/interop/util/linear_hierarchy.h @@ -125,3 +125,4 @@ namespace illumina { namespace interop { namespace hierarchy }}} + diff --git a/interop/util/math.h b/interop/util/math.h index ba4078d3e..45c731023 100644 --- a/interop/util/math.h +++ b/interop/util/math.h @@ -41,3 +41,4 @@ } } #endif + diff --git a/interop/util/object_list.h b/interop/util/object_list.h index 0a7df3c8e..02d0ced05 100644 --- a/interop/util/object_list.h +++ b/interop/util/object_list.h @@ -174,3 +174,4 @@ namespace interop { } } + diff --git a/interop/util/option_parser.h b/interop/util/option_parser.h index d4408c2fe..f1361689c 100644 --- a/interop/util/option_parser.h +++ b/interop/util/option_parser.h @@ -261,7 +261,6 @@ namespace illumina { namespace interop { namespace util template option_parser &operator()(T &value, const std::string &flag, const std::string &help) { - //m_options.push_back(option_pointer(new option(value_container(&value), flag, help))); m_options.push_back(option_pointer(new option(&value, flag, help))); return *this; } @@ -376,3 +375,4 @@ namespace illumina { namespace interop { namespace util }}} + diff --git a/interop/util/pstdint.h b/interop/util/pstdint.h index 6218ce89e..718088268 100644 --- a/interop/util/pstdint.h +++ b/interop/util/pstdint.h @@ -811,3 +811,4 @@ int main () { } #endif + diff --git a/interop/util/static_assert.h b/interop/util/static_assert.h index da2d21fef..aaccf108c 100644 --- a/interop/util/static_assert.h +++ b/interop/util/static_assert.h @@ -25,3 +25,4 @@ #endif #endif + diff --git a/interop/util/statistics.h b/interop/util/statistics.h index 46bd5421a..20f172de6 100644 --- a/interop/util/statistics.h +++ b/interop/util/statistics.h @@ -12,6 +12,7 @@ #pragma once +#include #include #include #include @@ -691,3 +692,4 @@ namespace illumina { namespace interop { namespace util }}} + diff --git a/interop/util/string.h b/interop/util/string.h index a30f04fe1..455324f7d 100644 --- a/interop/util/string.h +++ b/interop/util/string.h @@ -72,3 +72,4 @@ namespace illumina { namespace interop { namespace util }}} + diff --git a/interop/util/time.h b/interop/util/time.h index e76c89d6b..aa3ab6deb 100644 --- a/interop/util/time.h +++ b/interop/util/time.h @@ -99,3 +99,4 @@ namespace illumina { namespace interop { namespace util }; #pragma pack() }}} + diff --git a/interop/util/type_traits.h b/interop/util/type_traits.h index fc2d3efac..54e674091 100644 --- a/interop/util/type_traits.h +++ b/interop/util/type_traits.h @@ -149,3 +149,4 @@ namespace illumina { namespace interop template struct int_constant_type : public constant_type{}; }} + diff --git a/interop/util/unique_ptr.h b/interop/util/unique_ptr.h index 70756b5c3..b81bdbe3b 100644 --- a/interop/util/unique_ptr.h +++ b/interop/util/unique_ptr.h @@ -96,3 +96,4 @@ namespace stdbp } #endif + diff --git a/interop/util/xml_exceptions.h b/interop/util/xml_exceptions.h index 4dfa5d642..74b28cd1c 100644 --- a/interop/util/xml_exceptions.h +++ b/interop/util/xml_exceptions.h @@ -98,3 +98,4 @@ namespace illumina { namespace interop { namespace xml /** @} */ }}} + diff --git a/interop/util/xml_parser.h b/interop/util/xml_parser.h index 4dd82fc2d..18881ab74 100644 --- a/interop/util/xml_parser.h +++ b/interop/util/xml_parser.h @@ -172,3 +172,4 @@ namespace illumina { namespace interop { namespace xml }}} + diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index c27f5cca7..43b1c2482 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -3,7 +3,7 @@ function(add_application _target _source_files) add_executable(${_target} ${_source_files} inc/application.h inc/plot_options.h) target_link_libraries(${_target} ${INTEROP_LIB}) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR CMAKE_COMPILER_IS_GNUCC) + if(COMPILER_IS_GNUCC_OR_CLANG) set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "${CXX_PEDANTIC_FLAG}" ) endif() @@ -21,10 +21,6 @@ function(add_application _target _source_files) endif() endfunction() -if(MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS) -endif() - add_application(interop2csv interop2csv.cpp) add_application(cyclesim cyclesim.cpp) add_application(summary summary.cpp) diff --git a/src/apps/cyclesim.cpp b/src/apps/cyclesim.cpp index 25948ef5b..16d1a3500 100644 --- a/src/apps/cyclesim.cpp +++ b/src/apps/cyclesim.cpp @@ -347,3 +347,4 @@ void print_help(std::ostream& out) } + diff --git a/src/apps/dumpbin.cpp b/src/apps/dumpbin.cpp index 011638c8f..189450898 100644 --- a/src/apps/dumpbin.cpp +++ b/src/apps/dumpbin.cpp @@ -160,3 +160,4 @@ int main(int argc, char** argv) } + diff --git a/src/apps/imaging_table.cpp b/src/apps/imaging_table.cpp index 1d52b8800..6af20e9b0 100644 --- a/src/apps/imaging_table.cpp +++ b/src/apps/imaging_table.cpp @@ -63,3 +63,4 @@ int main(int argc, char** argv) } return SUCCESS; } + diff --git a/src/apps/inc/application.h b/src/apps/inc/application.h index 473f7d14a..20e4ff352 100644 --- a/src/apps/inc/application.h +++ b/src/apps/inc/application.h @@ -119,4 +119,4 @@ inline int read_run_metrics(const char* filename, return EMPTY_INTEROP; } return SUCCESS; -} \ No newline at end of file +} diff --git a/src/apps/inc/plot_options.h b/src/apps/inc/plot_options.h index c316eb973..d8ad22c95 100644 --- a/src/apps/inc/plot_options.h +++ b/src/apps/inc/plot_options.h @@ -99,3 +99,4 @@ std::string plot_image_name(const std::string& plot_name, if(extra != "") name += "_"+extra; return name+".png"; } + diff --git a/src/apps/index_summary.cpp b/src/apps/index_summary.cpp index 7cfa3b227..e341cec87 100644 --- a/src/apps/index_summary.cpp +++ b/src/apps/index_summary.cpp @@ -241,3 +241,4 @@ void print_summary(std::ostream& out, const index_flowcell_summary& summary) } } + diff --git a/src/apps/interop2csv.cpp b/src/apps/interop2csv.cpp index 02a8e7e05..afad3b7ad 100644 --- a/src/apps/interop2csv.cpp +++ b/src/apps/interop2csv.cpp @@ -779,3 +779,4 @@ void print_help(std::ostream& out) out << "Usage: interop2csv run-folder" << std::endl; } + diff --git a/src/apps/plot_by_cycle.cpp b/src/apps/plot_by_cycle.cpp index d043b88c8..d7d1ed22b 100644 --- a/src/apps/plot_by_cycle.cpp +++ b/src/apps/plot_by_cycle.cpp @@ -249,3 +249,4 @@ int test_all_filter_options(run_metrics& run) std::cout << "I just created " << plot_count << " plots" << std::endl; return SUCCESS; } + diff --git a/src/apps/plot_by_lane.cpp b/src/apps/plot_by_lane.cpp index 48c24a383..df4f084e1 100644 --- a/src/apps/plot_by_lane.cpp +++ b/src/apps/plot_by_lane.cpp @@ -141,3 +141,4 @@ int main(int argc, const char** argv) } + diff --git a/src/apps/plot_flowcell.cpp b/src/apps/plot_flowcell.cpp index a359b9666..172f20e8e 100644 --- a/src/apps/plot_flowcell.cpp +++ b/src/apps/plot_flowcell.cpp @@ -225,3 +225,4 @@ int test_all_filter_options(run_metrics& run) std::cout << "I just created " << plot_count << " plots" << std::endl; return SUCCESS; } + diff --git a/src/apps/plot_qscore_heatmap.cpp b/src/apps/plot_qscore_heatmap.cpp index 516b77c0a..01c1539a6 100644 --- a/src/apps/plot_qscore_heatmap.cpp +++ b/src/apps/plot_qscore_heatmap.cpp @@ -129,3 +129,4 @@ int main(int argc, const char** argv) } + diff --git a/src/apps/plot_qscore_histogram.cpp b/src/apps/plot_qscore_histogram.cpp index edc45340a..d7f607715 100644 --- a/src/apps/plot_qscore_histogram.cpp +++ b/src/apps/plot_qscore_histogram.cpp @@ -134,3 +134,4 @@ int main(int argc, const char** argv) } + diff --git a/src/apps/plot_sample_qc.cpp b/src/apps/plot_sample_qc.cpp index 4d18766b2..854f03a67 100644 --- a/src/apps/plot_sample_qc.cpp +++ b/src/apps/plot_sample_qc.cpp @@ -92,3 +92,4 @@ int main(int argc, char** argv) } + diff --git a/src/apps/summary.cpp b/src/apps/summary.cpp index 31948f9b6..088fe0750 100644 --- a/src/apps/summary.cpp +++ b/src/apps/summary.cpp @@ -35,6 +35,7 @@ #include #include +#include "interop/util/math.h" #include "interop/io/metric_file_stream.h" #include "interop/logic/summary/run_summary.h" #include "interop/version.h" @@ -76,7 +77,7 @@ int main(int argc, char** argv) run_summary summary; try { - summarize_run_metrics(run, summary); + summarize_run_metrics(run, summary, true); } catch(const std::exception& ex) { @@ -108,9 +109,16 @@ template void print_array(std::ostream& out, I beg, I end, const size_t width, const char fillch=' ') { std::ios::fmtflags f( out.flags() ); + if(beg != end) + { + out.width(width); + out.fill(fillch); + out << std::left << *beg; + ++beg; + } for(;beg != end;++beg) { - out << " "; + out << ","; out.width(width); out.fill(fillch); out << std::left << *beg; @@ -274,3 +282,4 @@ void print_summary(std::ostream& out, const run_summary& summary) out << "Called: " << format(summary.cycle_state().called_cycle_range()) << "\n"; out << "Scored: " << format(summary.cycle_state().qscored_cycle_range()) << "\n"; } + diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 839db7880..abcc6ad3e 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -2,10 +2,8 @@ function(add_example _target _source_files) add_executable(${_target} ${_source_files}) target_link_libraries(${_target} ${INTEROP_LIB}) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR CMAKE_COMPILER_IS_GNUCC) + if(COMPILER_IS_GNUCC_OR_CLANG) set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "${CXX_PEDANTIC_FLAG}" ) - elseif(MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS) endif() if(NOT ENABLE_EXAMPLES) diff --git a/src/examples/example1.cpp b/src/examples/example1.cpp index 9d31dd322..509652276 100644 --- a/src/examples/example1.cpp +++ b/src/examples/example1.cpp @@ -58,3 +58,4 @@ int check_args(int argc) return 0; } + diff --git a/src/examples/example2.cpp b/src/examples/example2.cpp index d4a348067..fea19c17c 100644 --- a/src/examples/example2.cpp +++ b/src/examples/example2.cpp @@ -91,3 +91,4 @@ int read_interop_file(const char* filename, metric_set& tile_metric return 0; } + diff --git a/src/examples/example3.cpp b/src/examples/example3.cpp index 22a9480b4..672f3a03d 100644 --- a/src/examples/example3.cpp +++ b/src/examples/example3.cpp @@ -79,3 +79,4 @@ int read_interop_file(const char* filename, extraction_metric_set_t& extraction_ + diff --git a/src/examples/example4.cpp b/src/examples/example4.cpp index 78cb84449..1981af067 100644 --- a/src/examples/example4.cpp +++ b/src/examples/example4.cpp @@ -76,3 +76,4 @@ int check_args(int argc) return 0; } + diff --git a/src/examples/example_q_metric.cpp b/src/examples/example_q_metric.cpp index ed8840bc3..9d4efff4e 100644 --- a/src/examples/example_q_metric.cpp +++ b/src/examples/example_q_metric.cpp @@ -90,3 +90,4 @@ int check_args(int argc) return 0; } + diff --git a/src/ext/csharp/CMakeLists.txt b/src/ext/csharp/CMakeLists.txt index 304bdc848..fe8cc99cf 100644 --- a/src/ext/csharp/CMakeLists.txt +++ b/src/ext/csharp/CMakeLists.txt @@ -3,7 +3,6 @@ set(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR}) - add_custom_target(csharp_lib) set_target_properties(csharp_lib PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) @@ -27,11 +26,15 @@ foreach(SRC ${SWIG_SRCS}) set_target_properties(${SWIG_MODULE} PROPERTIES LINK_FLAGS "${EXTRA_LINKER_FLAGS}") endif() if(MSVC) - set_target_properties(${SWIG_MODULE} PROPERTIES COMPILE_FLAGS "/bigobj /wd4100 -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS") + set_target_properties(${SWIG_MODULE} PROPERTIES COMPILE_FLAGS "${ENABLE_BIG_OBJ_FLAG} /wd4100") elseif(MINGW) - set_target_properties(${SWIG_MODULE} PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj -Wno-unused-function -Wno-unused-parameter") - elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCC) - set_target_properties(${SWIG_MODULE} PROPERTIES COMPILE_FLAGS "-Wno-unused-function -Wno-unused-parameter") + set_target_properties(${SWIG_MODULE} PROPERTIES COMPILE_FLAGS "${ENABLE_BIG_OBJ_FLAG} ${_WNO_UNUSED_FUNCTION} ${_WNO_UNUSED_PARAMETER}") + elseif(COMPILER_IS_GNUCC_OR_CLANG) + set_target_properties(${SWIG_MODULE} PROPERTIES COMPILE_FLAGS "${_WNO_UNUSED_FUNCTION} ${_WNO_UNUSED_PARAMETER}") + endif() + if(NOT MSVC) + set_target_properties(${SWIG_MODULE} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_BINARY_DIR}/Release") + set_target_properties(${SWIG_MODULE} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_BINARY_DIR}/Debug") endif() swig_link_libraries(${SWIG_MODULE} ${INTEROP_DL_LIB}) @@ -48,8 +51,6 @@ foreach(SRC ${SWIG_SRCS}) add_dependencies(csharp_lib ${SWIG_MODULE}) endforeach() - - find_package(CSharp) if(NOT CSHARP_FOUND) @@ -96,3 +97,60 @@ add_custom_target(clean_csharp COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}) set_target_properties(clean_csharp PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) + +######################################################################################################################## +# Create NuGet nuspec package file +######################################################################################################################## +if(MSVC) + set(CONFIG_DIR "$") +else() + if(CMAKE_BUILD_TYPE) + set(CONFIG_DIR "${CMAKE_BUILD_TYPE}") + else() + set(CONFIG_DIR "Debug") + endif() +endif() + +function(create_nuspec_files _output _config _framework _source_files) + # C# Dlls should be packaged in a directory lib\\ + # C++ Shared Libraries should be packaged in a directory called build\ + # The following code generates this file list from the SWIG generated C++ shared libraries and the C# Dll + get_filename_component(DLL_NAME ${CSHARP_csharp_interop_BINARY} NAME) + set(_files ${${_output}}) + if(NOT "${_files}" STREQUAL "") + set(_files "${_files};") + endif() + set(_files "${_files}") + list(APPEND _files "") + foreach(SRC ${_source_files}) + get_filename_component(MODULE ${SRC} NAME_WE) + set(NUGET_FILE "\\\";target=\\\"build\\\\${_config}\\\";/>") + list(APPEND _files ${NUGET_FILE}) + endforeach() + set(${_output} ${_files} PARENT_SCOPE) +endfunction() + +set(DOT_NET_FRAMEWORK "net40") +create_nuspec_files(NUGET_FILE_LIST "Debug" ${DOT_NET_FRAMEWORK} "${SWIG_SRCS}") +create_nuspec_files(NUGET_FILE_LIST "Release" ${DOT_NET_FRAMEWORK} "${SWIG_SRCS}") +# This creates the nuspec file in the proper directory +add_custom_target(nuspec + COMMENT "Creating package.nuspec" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_SOURCE_DIR}/cmake/package.targets + $/../interop_${CSHARP_TYPE}_${CMAKE_SYSTEM_NAME}.targets + + COMMAND ${CMAKE_COMMAND} + -DCMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} + -DCSHARP_TYPE=${CSHARP_TYPE} + -DCSHARP_VERSION=${CSHARP_VERSION} + -DINTEROP_VERSION=${VERSION_SHORT} + -DPLATFORM=${CMAKE_SYSTEM_NAME} + -DNUGET_FILE_LIST="${NUGET_FILE_LIST}" + -DCONFIG_INPUT_FILE=${CMAKE_SOURCE_DIR}/cmake/package.nuspec.in + -DCONFIG_OUTPUT_FILE=$/../package.nuspec + -P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake + ) +add_dependencies(nuspec csharp_interop) +set_target_properties(nuspec PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) + diff --git a/src/ext/swig/arrays/numpy.i b/src/ext/swig/arrays/numpy.i index 2ddc11de7..58ad9e39b 100644 --- a/src/ext/swig/arrays/numpy.i +++ b/src/ext/swig/arrays/numpy.i @@ -249,9 +249,9 @@ } /* Given a PyArrayObject, check to see if it is contiguous. If so, - * return the input pointer and flag it as not a new object. If it is + * return the input pointer and test_modifier it as not a new object. If it is * not contiguous, create a new PyArrayObject using the original data, - * flag it as a new object and return the pointer. + * test_modifier it as a new object and return the pointer. */ PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object, @@ -276,9 +276,9 @@ } /* Given a PyArrayObject, check to see if it is Fortran-contiguous. - * If so, return the input pointer, but do not flag it as not a new + * If so, return the input pointer, but do not test_modifier it as not a new * object. If it is not Fortran-contiguous, create a new - * PyArrayObject using the original data, flag it as a new object + * PyArrayObject using the original data, test_modifier it as a new object * and return the pointer. */ PyArrayObject* make_fortran(PyArrayObject* ary, @@ -303,7 +303,7 @@ /* Convert a given PyObject to a contiguous PyArrayObject of the * specified type. If the input object is not a contiguous - * PyArrayObject, a new one will be created and the new object flag + * PyArrayObject, a new one will be created and the new object test_modifier * will be set. */ PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input, @@ -331,7 +331,7 @@ /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the * specified type. If the input object is not a Fortran-ordered - * PyArrayObject, a new one will be created and the new object flag + * PyArrayObject, a new one will be created and the new object test_modifier * will be set. */ PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input, @@ -524,7 +524,7 @@ /* Require the given PyArrayObject to to be Fortran ordered. If the * the PyArrayObject is already Fortran ordered, do nothing. Else, - * set the Fortran ordering flag and recompute the strides. + * set the Fortran ordering test_modifier and recompute the strides. */ int require_fortran(PyArrayObject* ary) { @@ -533,7 +533,7 @@ int i; npy_intp * strides = array_strides(ary); if (array_is_fortran(ary)) return success; - /* Set the Fortran ordered flag */ + /* Set the Fortran ordered test_modifier */ array_enableflags(ary,NPY_ARRAY_FARRAY); /* Recompute the strides */ strides[0] = strides[nd-1]; diff --git a/src/ext/swig/metrics.i b/src/ext/swig/metrics.i index 88c3d0cda..8dda81e7a 100644 --- a/src/ext/swig/metrics.i +++ b/src/ext/swig/metrics.i @@ -64,6 +64,8 @@ EXCEPTION_WRAPPER(WRAP_EXCEPTION_IMPORT) using namespace illumina::interop::model::metrics; namespace metric_base = illumina::interop::model::metric_base; + %ignore illumina::interop::model::metric_base::metric_set::offset_map; + %apply size_t { std::map< std::size_t, metric_t >::size_type }; %apply uint64_t { metric_base::metric_set::id_t }; WRAP_VECTOR(illumina::interop::model::metric_base::metric_set); @@ -138,7 +140,6 @@ WRAP_METRICS(IMPORT_METRIC_WRAPPER) %template(metric_group_vector) std::vector< illumina::interop::constants::metric_group>; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Wrap metrics //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/interop/CMakeLists.txt b/src/interop/CMakeLists.txt index 2aa32e4d5..cd1bcf106 100644 --- a/src/interop/CMakeLists.txt +++ b/src/interop/CMakeLists.txt @@ -25,7 +25,8 @@ set(SRCS logic/table/create_imaging_table_columns.cpp logic/table/create_imaging_table.cpp util/time.cpp - util/filesystem.cpp logic/utils/metrics_to_load.cpp) + util/filesystem.cpp + logic/utils/metrics_to_load.cpp) set(HEADERS ../../interop/model/summary/cycle_state_summary.h @@ -143,7 +144,7 @@ set(HEADERS ) set(INTEROP_HEADERS ${HEADERS} PARENT_SCOPE) -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR CMAKE_COMPILER_IS_GNUCC) +if(COMPILER_IS_GNUCC_OR_CLANG) foreach(SRC ${SRCS}) set_source_files_properties(${SRC} PROPERTIES COMPILE_FLAGS "${CXX_PEDANTIC_FLAG}" ) endforeach() diff --git a/src/interop/logic/metric/extraction_metric.cpp b/src/interop/logic/metric/extraction_metric.cpp index 4e894e131..4837ff6bf 100644 --- a/src/interop/logic/metric/extraction_metric.cpp +++ b/src/interop/logic/metric/extraction_metric.cpp @@ -26,3 +26,4 @@ namespace illumina { namespace interop { namespace logic { namespace metric }}}} + diff --git a/src/interop/logic/metric/q_metric.cpp b/src/interop/logic/metric/q_metric.cpp index afe9633ae..d6ae06a6f 100644 --- a/src/interop/logic/metric/q_metric.cpp +++ b/src/interop/logic/metric/q_metric.cpp @@ -266,3 +266,4 @@ namespace illumina { namespace interop { namespace logic { namespace metric } }}}} + diff --git a/src/interop/logic/plot/plot_by_cycle.cpp b/src/interop/logic/plot/plot_by_cycle.cpp index 272a85172..05a6e3f67 100644 --- a/src/interop/logic/plot/plot_by_cycle.cpp +++ b/src/interop/logic/plot/plot_by_cycle.cpp @@ -371,3 +371,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot } }}}} + diff --git a/src/interop/logic/plot/plot_by_lane.cpp b/src/interop/logic/plot/plot_by_lane.cpp index 7866a8f84..905834ab6 100644 --- a/src/interop/logic/plot/plot_by_lane.cpp +++ b/src/interop/logic/plot/plot_by_lane.cpp @@ -185,3 +185,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot }}}} + diff --git a/src/interop/logic/plot/plot_flowcell_map.cpp b/src/interop/logic/plot/plot_flowcell_map.cpp index a84d7b31f..f86065175 100644 --- a/src/interop/logic/plot/plot_flowcell_map.cpp +++ b/src/interop/logic/plot/plot_flowcell_map.cpp @@ -264,3 +264,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot }}}} + diff --git a/src/interop/logic/plot/plot_qscore_heatmap.cpp b/src/interop/logic/plot/plot_qscore_heatmap.cpp index 02feaad72..92198fe45 100644 --- a/src/interop/logic/plot/plot_qscore_heatmap.cpp +++ b/src/interop/logic/plot/plot_qscore_heatmap.cpp @@ -200,3 +200,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot }}}} + diff --git a/src/interop/logic/plot/plot_qscore_histogram.cpp b/src/interop/logic/plot/plot_qscore_histogram.cpp index 641ed2d78..42d0b6df8 100644 --- a/src/interop/logic/plot/plot_qscore_histogram.cpp +++ b/src/interop/logic/plot/plot_qscore_histogram.cpp @@ -272,3 +272,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot }}}} + diff --git a/src/interop/logic/plot/plot_sample_qc.cpp b/src/interop/logic/plot/plot_sample_qc.cpp index 9fb1a1a9f..ed7a5ff57 100644 --- a/src/interop/logic/plot/plot_sample_qc.cpp +++ b/src/interop/logic/plot/plot_sample_qc.cpp @@ -113,3 +113,4 @@ namespace illumina { namespace interop { namespace logic { namespace plot { }}}} + diff --git a/src/interop/logic/summary/index_summary.cpp b/src/interop/logic/summary/index_summary.cpp index fe7f0af17..b91d594b6 100644 --- a/src/interop/logic/summary/index_summary.cpp +++ b/src/interop/logic/summary/index_summary.cpp @@ -161,3 +161,4 @@ namespace illumina { namespace interop { namespace logic { namespace summary { } }}}} + diff --git a/src/interop/logic/summary/run_summary.cpp b/src/interop/logic/summary/run_summary.cpp index d9488847d..b03a6aef1 100644 --- a/src/interop/logic/summary/run_summary.cpp +++ b/src/interop/logic/summary/run_summary.cpp @@ -6,7 +6,6 @@ * @copyright GNU Public License. */ #include "interop/logic/summary/run_summary.h" - #include "interop/logic/summary/error_summary.h" #include "interop/logic/summary/tile_summary.h" #include "interop/logic/summary/extraction_summary.h" @@ -68,32 +67,34 @@ namespace illumina { namespace interop { namespace logic { namespace summary * @ingroup summary_logic * @param metrics source collection of all metrics * @param summary destination run summary + * @param skip_median skip the median calculation */ - void summarize_run_metrics(model::metrics::run_metrics& metrics, model::summary::run_summary& summary) + void summarize_run_metrics(model::metrics::run_metrics& metrics, + model::summary::run_summary& summary, + const bool skip_median) throw( model::index_out_of_bounds_exception, model::invalid_channel_exception ) { using namespace model::metrics; if(metrics.empty()) return; - - summary.initialize(metrics.run_info().reads(), metrics.run_info().flowcell().lane_count()); - read_cycle_vector_t cycle_to_read; map_read_to_cycle_number(summary.begin(), summary.end(), cycle_to_read); summarize_tile_metrics(metrics.get_set().begin(), metrics.get_set().end(), summary); summarize_error_metrics(metrics.get_set().begin(), metrics.get_set().end(), cycle_to_read, - summary); + summary, + skip_median); INTEROP_ASSERT(metrics.run_info().channels().size()>0); const size_t intensity_channel = utils::expected2actual_map(metrics.run_info().channels())[0]; summarize_extraction_metrics(metrics.get_set().begin(), metrics.get_set().end(), cycle_to_read, intensity_channel, - summary); + summary, + skip_median); if(0 == metrics.get_set().size()) logic::metric::create_collapse_q_metrics(metrics.get_set(), @@ -140,3 +141,4 @@ namespace illumina { namespace interop { namespace logic { namespace summary } }}}} + diff --git a/src/interop/logic/table/create_imaging_table.cpp b/src/interop/logic/table/create_imaging_table.cpp index 529b18d32..4ddad7ba1 100644 --- a/src/interop/logic/table/create_imaging_table.cpp +++ b/src/interop/logic/table/create_imaging_table.cpp @@ -339,3 +339,4 @@ namespace illumina { namespace interop { namespace logic { namespace table } }}}} + diff --git a/src/interop/logic/table/create_imaging_table_columns.cpp b/src/interop/logic/table/create_imaging_table_columns.cpp index 9d985c58d..119bb4777 100644 --- a/src/interop/logic/table/create_imaging_table_columns.cpp +++ b/src/interop/logic/table/create_imaging_table_columns.cpp @@ -171,3 +171,4 @@ namespace illumina { namespace interop { namespace logic { namespace table }}}} + diff --git a/src/interop/logic/utils/metrics_to_load.cpp b/src/interop/logic/utils/metrics_to_load.cpp index 4b5bd705c..eec9f5750 100644 --- a/src/interop/logic/utils/metrics_to_load.cpp +++ b/src/interop/logic/utils/metrics_to_load.cpp @@ -140,4 +140,4 @@ namespace illumina { namespace interop { namespace logic { namespace utils } -}}}} \ No newline at end of file +}}}} diff --git a/src/interop/model/metrics/corrected_intensity_metric.cpp b/src/interop/model/metrics/corrected_intensity_metric.cpp index 65f297e68..191e7a20d 100644 --- a/src/interop/model/metrics/corrected_intensity_metric.cpp +++ b/src/interop/model/metrics/corrected_intensity_metric.cpp @@ -223,3 +223,4 @@ INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(corrected_intensity_metric, 2 ) INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(corrected_intensity_metric, 3 ) INTEROP_FORCE_LINK_DEF(corrected_intensity_metric) + diff --git a/src/interop/model/metrics/error_metric.cpp b/src/interop/model/metrics/error_metric.cpp index 835e68c8a..b41effc5e 100644 --- a/src/interop/model/metrics/error_metric.cpp +++ b/src/interop/model/metrics/error_metric.cpp @@ -113,3 +113,4 @@ namespace illumina{ namespace interop{ namespace io { INTEROP_FORCE_LINK_DEF(error_metric) INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(error_metric, 3 ) + diff --git a/src/interop/model/metrics/extraction_metric.cpp b/src/interop/model/metrics/extraction_metric.cpp index db73a5429..bd557e036 100644 --- a/src/interop/model/metrics/extraction_metric.cpp +++ b/src/interop/model/metrics/extraction_metric.cpp @@ -153,3 +153,4 @@ namespace illumina { namespace interop { namespace io INTEROP_FORCE_LINK_DEF(extraction_metric) INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(extraction_metric, 2 ) + diff --git a/src/interop/model/metrics/image_metric.cpp b/src/interop/model/metrics/image_metric.cpp index b8ed29c3b..423c3fedc 100644 --- a/src/interop/model/metrics/image_metric.cpp +++ b/src/interop/model/metrics/image_metric.cpp @@ -208,6 +208,8 @@ namespace illumina { namespace interop { namespace io static std::streamsize map_stream(Stream& stream, Metric& metric, Header& header, const bool) { std::streamsize count = 0; + if(header.m_channel_count==0) + INTEROP_THROW(bad_format_exception, "Cannot write data where channel count is 0"); copy_from(stream, metric.m_channel_count, header.m_channel_count); count += stream_map< contrast_t >(stream, metric.m_min_contrast, header.m_channel_count); count += stream_map< contrast_t >(stream, metric.m_max_contrast, header.m_channel_count); @@ -232,7 +234,11 @@ namespace illumina { namespace interop { namespace io template static std::streamsize map_stream_for_header(Stream& stream, Header& header) { - return stream_map< channel_count_t >(stream, header.m_channel_count); + std::streamsize count = stream_map< channel_count_t >(stream, header.m_channel_count); + if(stream.fail()) return count; + if(header.m_channel_count==0) + INTEROP_THROW(bad_format_exception, "Cannot write data where channel count is 0"); + return count; } /** Compute header size * @@ -249,3 +255,4 @@ namespace illumina { namespace interop { namespace io INTEROP_FORCE_LINK_DEF(image_metric) INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(image_metric, 1 ) INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(image_metric, 2 ) + diff --git a/src/interop/model/metrics/index_metric.cpp b/src/interop/model/metrics/index_metric.cpp index e05288fc7..20c2c89a7 100644 --- a/src/interop/model/metrics/index_metric.cpp +++ b/src/interop/model/metrics/index_metric.cpp @@ -176,3 +176,4 @@ namespace illumina { namespace interop { namespace io INTEROP_FORCE_LINK_DEF(index_metric) INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(index_metric, 1) + diff --git a/src/interop/model/metrics/q_collapsed_metric.cpp b/src/interop/model/metrics/q_collapsed_metric.cpp index 3bba236ac..713736598 100644 --- a/src/interop/model/metrics/q_collapsed_metric.cpp +++ b/src/interop/model/metrics/q_collapsed_metric.cpp @@ -567,3 +567,4 @@ INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(q_collapsed_metric, 3 ) INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(q_collapsed_metric, 4 ) INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(q_collapsed_metric, 5 ) INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(q_collapsed_metric, 6 ) + diff --git a/src/interop/model/metrics/q_metric.cpp b/src/interop/model/metrics/q_metric.cpp index fac94e955..db6ef5644 100644 --- a/src/interop/model/metrics/q_metric.cpp +++ b/src/interop/model/metrics/q_metric.cpp @@ -256,6 +256,8 @@ namespace illumina { namespace interop { namespace io bin_count_t bin_count = static_cast(header.bin_count()); count+=stream_map< bin_count_t>(stream, bin_count); if(stream.fail()) return count; + if(bin_count==0) + INTEROP_THROW(bad_format_exception, "Zero bins is not supported"); INTEROP_ASSERT(bin_count>0); bin_t tmp[q_metric::MAX_Q_BINS]; map_resize(header.m_qscore_bins, bin_count); @@ -425,6 +427,8 @@ namespace illumina { namespace interop { namespace io static std::streamsize map_stream(Stream& stream, Metric& metric, Header& header, const bool) { const size_t bin_count = (header.bin_count() == 0) ? static_cast(q_metric::MAX_Q_BINS) : header.bin_count(); + if(bin_count==0) + INTEROP_THROW(bad_format_exception, "Zero bins is not supported"); const std::streamsize count = stream_map< count_t >(stream, metric.m_qscore_hist, bin_count); resize_accumulated(stream, metric); return count; @@ -457,6 +461,8 @@ namespace illumina { namespace interop { namespace io bin_count_t bin_count = static_cast(header.bin_count()); count+=stream_map< bin_count_t >(stream, bin_count); if(stream.fail()) return count; + if(bin_count==0) + INTEROP_THROW(bad_format_exception, "Zero bins is not supported"); INTEROP_ASSERT(bin_count>0); bin_t tmp[q_metric::MAX_Q_BINS]; map_resize(header.m_qscore_bins, bin_count); @@ -560,3 +566,4 @@ INTEROP_FORCE_LINK_DEF(q_by_lane_metric) INTEROP_REGISTER_METRIC_ANOTHER_GENERIC_LAYOUT(q_metric, q_by_lane_metric, 4) INTEROP_REGISTER_METRIC_ANOTHER_GENERIC_LAYOUT(q_metric, q_by_lane_metric, 5) INTEROP_REGISTER_METRIC_ANOTHER_GENERIC_LAYOUT(q_metric, q_by_lane_metric, 6) + diff --git a/src/interop/model/metrics/tile_metric.cpp b/src/interop/model/metrics/tile_metric.cpp index 7f04ad425..5295ca821 100644 --- a/src/interop/model/metrics/tile_metric.cpp +++ b/src/interop/model/metrics/tile_metric.cpp @@ -247,3 +247,4 @@ namespace illumina { namespace interop { namespace io INTEROP_FORCE_LINK_DEF(tile_metric) INTEROP_REGISTER_METRIC_GENERIC_LAYOUT(tile_metric, 2 ) + diff --git a/src/interop/model/run/info.cpp b/src/interop/model/run/info.cpp index 533380553..6ed908844 100644 --- a/src/interop/model/run/info.cpp +++ b/src/interop/model/run/info.cpp @@ -265,3 +265,4 @@ namespace illumina { namespace interop { namespace model { namespace run #pragma warning(pop) #endif + diff --git a/src/interop/model/run/parameters.cpp b/src/interop/model/run/parameters.cpp index 24e631df7..47c7d1220 100644 --- a/src/interop/model/run/parameters.cpp +++ b/src/interop/model/run/parameters.cpp @@ -141,3 +141,4 @@ namespace illumina { namespace interop { namespace model { namespace run #pragma warning(pop) #endif + diff --git a/src/interop/model/run_metrics.cpp b/src/interop/model/run_metrics.cpp index 2b00b191b..0ae204811 100644 --- a/src/interop/model/run_metrics.cpp +++ b/src/interop/model/run_metrics.cpp @@ -600,3 +600,4 @@ namespace illumina { namespace interop { namespace model { namespace metrics }}}} + diff --git a/src/interop/model/summary/run_summary.cpp b/src/interop/model/summary/run_summary.cpp index ab6330a9c..c1df987ae 100644 --- a/src/interop/model/summary/run_summary.cpp +++ b/src/interop/model/summary/run_summary.cpp @@ -204,3 +204,4 @@ namespace illumina { namespace interop { namespace model { namespace summary return in; } }}}} + diff --git a/src/interop/util/filesystem.cpp b/src/interop/util/filesystem.cpp index 3472578cb..67f795c70 100644 --- a/src/interop/util/filesystem.cpp +++ b/src/interop/util/filesystem.cpp @@ -154,3 +154,4 @@ namespace illumina { namespace interop { namespace io } }}} + diff --git a/src/interop/util/time.cpp b/src/interop/util/time.cpp index 31f892c3d..163696857 100644 --- a/src/interop/util/time.cpp +++ b/src/interop/util/time.cpp @@ -161,3 +161,4 @@ namespace illumina { namespace interop { namespace util return INTEROP_UTIL_TICKS_1970; } }}} + diff --git a/src/tests/interop/CMakeLists.txt b/src/tests/interop/CMakeLists.txt index 38c96bd05..208bb589e 100644 --- a/src/tests/interop/CMakeLists.txt +++ b/src/tests/interop/CMakeLists.txt @@ -4,12 +4,11 @@ include(${GTEST_USE_FILE}) include(${GMOCK_USE_FILE}) find_package(Threads) -add_executable(interop_gtests +set(SRCS run/info_test.cpp run/parameters_test.cpp metrics/corrected_intensity_metrics_test.cpp metrics/error_metrics_test.cpp - metrics/error_metrics_test2.cpp metrics/extraction_metrics_test.cpp metrics/index_metrics_test.cpp metrics/image_metrics_test.cpp @@ -17,34 +16,40 @@ add_executable(interop_gtests metrics/tile_metrics_test.cpp metrics/q_by_lane_metric_test.cpp metrics/q_collapsed_metrics_test.cpp + logic/summary_metrics_test.cpp + metrics/base_metric_tests.cpp + logic/enum_parsing_test.cpp + logic/metric_type_ext_test.cpp + logic/plot_logic_test.cpp + util/option_parser_test.cpp + logic/imaging_table_logic_test.cpp + logic/imaging_table_regression_test.cpp + metrics/metric_streams_test.cpp + util/stat_test.cpp + unit_tests.cpp + metrics/run_metric_test.cpp) + +set(HEADERS metrics/inc/corrected_intensity_metrics_test.h metrics/inc/error_metrics_test.h metrics/inc/metric_test.h - metrics/inc/stream_tests.hpp - logic/summary_metrics_test.cpp - metrics/inc/summary_fixture.h metrics/inc/extraction_metrics_test.h metrics/inc/image_metrics_test.h metrics/inc/index_metrics_test.h metrics/inc/q_metrics_test.h metrics/inc/tile_metrics_test.h metrics/inc/q_collapsed_metrics_test.h - metrics/base_metric_tests.cpp - logic/enum_parsing_test.cpp - logic/metric_type_ext_test.cpp - logic/plot_logic_test.cpp - util/option_parser_test.cpp - inc/regression_fixture.h - unit_tests.cpp inc/failure_listener.h inc/persistent_parameter_generator.h - logic/imaging_table_logic_test.cpp - logic/imaging_table_regression_test.cpp inc/generic_fixture.h metrics/inc/metric_generator.h - metrics/inc/metric_stream_tests.hpp inc/regression_test_data.h - inc/proxy_parameter_generator.h inc/abstract_regression_test_generator.h) + inc/proxy_parameter_generator.h + inc/abstract_regression_test_generator.h + metrics/inc/metric_format_fixtures.h) + + +add_executable(interop_gtests ${SRCS} ${HEADERS}) target_link_libraries(interop_gtests ${INTEROP_LIB} ${GTEST_LIBRARY} ${GMOCK_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) add_test(NAME interop_gtests WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/testBin @@ -60,10 +65,10 @@ add_custom_command(TARGET interop_gtests POST_BUILD endif() if(MSVC) - set_target_properties(interop_gtests PROPERTIES COMPILE_FLAGS "/bigobj") + set_target_properties(interop_gtests PROPERTIES COMPILE_FLAGS "${ENABLE_BIG_OBJ_FLAG}") elseif(MINGW) - set_target_properties(interop_gtests PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj -Wno-unused-function") -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCC) - set_target_properties(interop_gtests PROPERTIES COMPILE_FLAGS "-Wno-unused-function -Wno-unnamed-type-template-args") + set_target_properties(interop_gtests PROPERTIES COMPILE_FLAGS "${ENABLE_BIG_OBJ_FLAG} ${_WNO_UNUSED_FUNCTION} ${_WNO_UNUSED_PARAMETER}") +elseif(COMPILER_IS_GNUCC_OR_CLANG) + set_target_properties(interop_gtests PROPERTIES COMPILE_FLAGS "${_WNO_UNUSED_FUNCTION} ${_WNO_UNUSED_PARAMETER} ${_WNO_UNNAMED_TYPE_TEMPLATE_ARGS}") endif() diff --git a/src/tests/interop/inc/abstract_regression_test_generator.h b/src/tests/interop/inc/abstract_regression_test_generator.h index 055c2d38a..e2e8867f4 100644 --- a/src/tests/interop/inc/abstract_regression_test_generator.h +++ b/src/tests/interop/inc/abstract_regression_test_generator.h @@ -26,8 +26,10 @@ namespace illumina{ namespace interop { namespace unittest /** Constructor * * @param test_dir test subdir + * @param test_modifier flag to modify a test */ - abstract_regression_test_generator(const std::string& test_dir) : m_test_dir(test_dir) + abstract_regression_test_generator(const std::string& test_dir, const int test_modifier=0) : + abstract_generator< Model >(test_modifier), m_test_dir(test_dir) { regression_test_data::instance().add_subdir(test_dir); } @@ -35,8 +37,12 @@ namespace illumina{ namespace interop { namespace unittest * * @param run_folder run folder * @param test_dir test subdir + * @param test_modifier flag to modify a test */ - abstract_regression_test_generator(const std::string& run_folder, const std::string& test_dir) : m_run_folder(run_folder), m_test_dir(test_dir) + abstract_regression_test_generator(const std::string& run_folder, + const std::string& test_dir, + const int test_modifier=0) : + abstract_generator< Model >(test_modifier), m_run_folder(run_folder), m_test_dir(test_dir) { } /** Clone the concret implementation @@ -71,7 +77,7 @@ namespace illumina{ namespace interop { namespace unittest } else { - std::cout << "[ ] Rebaseline: " << io::basename(m_run_folder) << std::endl; + std::cout << "[ ] Rebaseline: " << *this << std::endl; try { generate_actual(m_run_folder, actual); @@ -128,3 +134,4 @@ namespace illumina{ namespace interop { namespace unittest }}} + diff --git a/src/tests/interop/inc/failure_listener.h b/src/tests/interop/inc/failure_listener.h index deec4a16a..f26991383 100644 --- a/src/tests/interop/inc/failure_listener.h +++ b/src/tests/interop/inc/failure_listener.h @@ -126,3 +126,4 @@ namespace illumina{ namespace interop { namespace unittest }; }}} + diff --git a/src/tests/interop/inc/generic_fixture.h b/src/tests/interop/inc/generic_fixture.h index a2cbfd2c8..3c20a0dfa 100644 --- a/src/tests/interop/inc/generic_fixture.h +++ b/src/tests/interop/inc/generic_fixture.h @@ -24,6 +24,11 @@ namespace illumina{ namespace interop { namespace unittest { public: typedef abstract_generator* base_type; typedef generator_ptr parent_type; + /** Constructor + * + * @param test_modifier flag that modifies the test + */ + abstract_generator(const int test_modifier=0) : m_test_modifier(test_modifier){} /** Generate the expected and actual metric sets * * @param expected expected object @@ -38,6 +43,30 @@ namespace illumina{ namespace interop { namespace unittest { virtual base_type clone()const=0; /** Destructor */ virtual ~abstract_generator(){} + /** Flag that modifies the test + * + * @return flag that modifies the test + */ + int test_modifier()const{return m_test_modifier;} + /** Write generator info to output stream + * + * @param out output stream + */ + virtual void write(std::ostream& out)const=0; + /** Write name of generator to output stream + * + * @param out output stream + * @param gen generator + * @return output stream + */ + friend std::ostream& operator<<(std::ostream& out, const abstract_generator& gen) + { + gen.write(out); + return out; + } + + private: + int m_test_modifier; }; /** Smart pointer wrapper @@ -57,7 +86,7 @@ namespace illumina{ namespace interop { namespace unittest { * * @param other source object to copy */ - generator_ptr(const generator_ptr& other) : m_ptr(other.m_ptr->clone()){} + generator_ptr(const generator_ptr& other) : m_ptr(other.m_ptr==0?0:other.m_ptr->clone()){} /** Copy operator * * @param other source object to copy @@ -66,20 +95,61 @@ namespace illumina{ namespace interop { namespace unittest { generator_ptr& operator=(const generator_ptr& other) { delete m_ptr; - m_ptr= other.m_ptr->clone(); + INTEROP_ASSERT(other.m_ptr != 0); + if(other.m_ptr != 0) m_ptr= other.m_ptr->clone(); return *this; } /** Destructor */ virtual ~generator_ptr(){delete m_ptr;} - /** Generate the expected and actual metric sets + + /** Get access to underlying object * - * @param expected expected object - * @param actual actual object + * @return reference to abstract generator */ - bool generate(T& expected, T& actual)const + const abstract_generator& operator*()const { INTEROP_ASSERT(m_ptr != 0); - return m_ptr->generate(expected, actual); + return *m_ptr; + } + /** Get access to underlying object + * + * @return reference to abstract generator + */ + abstract_generator& operator*() + { + INTEROP_ASSERT(m_ptr != 0); + return *m_ptr; + } + /** Get access to underlying pointer + * + * @return pointer to abstract generator + */ + const abstract_generator* operator->()const + { + INTEROP_ASSERT(m_ptr != 0); + return m_ptr; + } + /** Get access to underlying pointer + * + * @return pointer to abstract generator + */ + abstract_generator* operator->() + { + INTEROP_ASSERT(m_ptr != 0); + return m_ptr; + } + /** Write name of generator to output stream + * + * @param out output stream + * @param ptr generator pointer + * @return output stream + */ + friend std::ostream& operator<<(std::ostream& out, const generator_ptr& ptr) + { + INTEROP_ASSERT(ptr.m_ptr != 0); + if(ptr.m_ptr == 0) return out; + ptr.m_ptr->write(out); + return out; } private: abstract_generator* m_ptr; @@ -105,7 +175,6 @@ namespace illumina{ namespace interop { namespace unittest { struct generic_test_fixture : public ::testing::TestWithParam< generator_ptr > { private: - //typedef ::testing::TestWithParam< abstract_generator* > parent_type; typedef ::testing::TestWithParam< generator_ptr > parent_type; public: //typedef abstract_generator* generator_type; @@ -113,10 +182,12 @@ namespace illumina{ namespace interop { namespace unittest { /** Value type of the object to test */ typedef T value_type; - /** Constructor */ - generic_test_fixture()//const char* test_dir) + /** Constructor + */ + generic_test_fixture() { - test = parent_type::GetParam().generate(expected, actual); + test = parent_type::GetParam()->generate(expected, actual); + test_modifier = parent_type::GetParam()->test_modifier(); } /** Expected object to test */ T expected; @@ -124,7 +195,10 @@ namespace illumina{ namespace interop { namespace unittest { T actual; /** Run test */ bool test; + /** Flag for type of test*/ + int test_modifier; }; }}} + diff --git a/src/tests/interop/inc/persistent_parameter_generator.h b/src/tests/interop/inc/persistent_parameter_generator.h index 139ad480d..4e969fc82 100644 --- a/src/tests/interop/inc/persistent_parameter_generator.h +++ b/src/tests/interop/inc/persistent_parameter_generator.h @@ -146,3 +146,4 @@ namespace illumina{ namespace interop { namespace unittest { return ::testing::internal::ParamGenerator(new argument_generator(values)); } }}} + diff --git a/src/tests/interop/inc/proxy_parameter_generator.h b/src/tests/interop/inc/proxy_parameter_generator.h index e162a555a..93eecb8f5 100644 --- a/src/tests/interop/inc/proxy_parameter_generator.h +++ b/src/tests/interop/inc/proxy_parameter_generator.h @@ -163,3 +163,4 @@ namespace illumina{ namespace interop { namespace unittest { return ::testing::internal::ParamGenerator< typename T::parent_type >(new proxy_argument_generator(object, values)); } }}} + diff --git a/src/tests/interop/inc/regression_fixture.h b/src/tests/interop/inc/regression_fixture.h deleted file mode 100644 index d5d16200b..000000000 --- a/src/tests/interop/inc/regression_fixture.h +++ /dev/null @@ -1,98 +0,0 @@ -/** Fixture to reuse unit tests for regression testing - * - * - * @file - * @date 6/23/16 - * @version 1.0 - * @copyright GNU Public License. - */ -#pragma once -#include -#include -#include -#include "src/tests/interop/inc/persistent_parameter_generator.h" -#include "src/tests/interop/inc/regression_test_data.h" -#include "interop/util/filesystem.h" -#include "interop/model/run_metrics.h" - - -namespace illumina{ namespace interop { namespace unittest -{ - - /** Convert an array to a vector - * - * Determines the length of the stack array automatically. - * - * @param vals array pointer - * @return vector of values - */ - template - inline std::vector to_vector(const T (&vals)[N]) - { - return std::vector(vals, vals + N); - } - - /** Regression test fixture - * - * This parameter based fixture takes a set of run folders and populates the baseline for later testing. - * Rebaseling the test is also supported through a command line argument. - */ - template - struct regression_test_fixture : public ::testing::TestWithParam< std::string > - { - /** Constructor */ - regression_test_fixture(const char* test_dir) : test(false) - { - regression_test_data::instance().add_subdir(test_dir); - run_folder = GetParam(); - const regression_test_data& data = regression_test_data::instance(); - const std::string baseline_file = io::combine(io::combine(data.baseline(), test_dir), io::basename(run_folder)); - - model::metrics::run_metrics actual_metrics; - EXPECT_NO_THROW(actual_metrics.read(run_folder)) << "Failed to find run folder: " << run_folder; - actual.clear(); - Fixture::populate_actual(actual_metrics, actual); - - if(!data.rebaseline()) - { - if(io::is_file_readable(baseline_file)) - { - expected.clear(); - std::ifstream fin(baseline_file.c_str()); - try - { - fin >> expected; - } - catch (const std::exception &) - { } - test = true; - } - else EXPECT_TRUE(false) << "Failed to find baseline: " << baseline_file; - } - else - { - std::cout << "[ ] Rebaseline: " << io::basename(run_folder) << std::endl; - std::ofstream fout(baseline_file.c_str()); - try - { - fout << actual; - } - catch(const std::exception& ex) - { - EXPECT_TRUE(false)<< "Failed to write baseline: " << baseline_file << " " << ex.what(); - } - EXPECT_TRUE(fout.good()) << "Failed to write baseline: " << baseline_file; - } - } - - /** Run folder file path */ - std::string run_folder; - /** Expected object to test */ - T expected; - /** Actual object to test */ - T actual; - /** True if in test mode, otherwise rebaseline mode */ - bool test; - }; - -}}} diff --git a/src/tests/interop/inc/regression_test_data.h b/src/tests/interop/inc/regression_test_data.h index d21a2b7e0..ae8e837d0 100644 --- a/src/tests/interop/inc/regression_test_data.h +++ b/src/tests/interop/inc/regression_test_data.h @@ -120,3 +120,4 @@ namespace illumina{ namespace interop { namespace unittest bool m_rebaseline; }; }}} + diff --git a/src/tests/interop/logic/enum_parsing_test.cpp b/src/tests/interop/logic/enum_parsing_test.cpp index 22d7d9066..50086d81a 100644 --- a/src/tests/interop/logic/enum_parsing_test.cpp +++ b/src/tests/interop/logic/enum_parsing_test.cpp @@ -36,3 +36,4 @@ TEST(enum_parsing_test, metric_type_to_group) { EXPECT_EQ(logic::utils::to_group(constants::Intensity), constants::Extraction); } + diff --git a/src/tests/interop/logic/imaging_table_logic_test.cpp b/src/tests/interop/logic/imaging_table_logic_test.cpp index 93ebb46ca..22b578ed6 100644 --- a/src/tests/interop/logic/imaging_table_logic_test.cpp +++ b/src/tests/interop/logic/imaging_table_logic_test.cpp @@ -11,12 +11,25 @@ #include "interop/util/length_of.h" #include "interop/logic/table/create_imaging_table.h" #include "src/tests/interop/metrics/inc/error_metrics_test.h" -#include "src/tests/interop/inc/regression_fixture.h" #include "interop/io/table/imaging_table_csv.h" using namespace illumina::interop; using namespace illumina::interop::unittest; + +/** Convert an array to a vector + * + * Determines the length of the stack array automatically. + * + * @param vals array pointer + * @return vector of values + */ +template +inline std::vector to_vector(const T (&vals)[N]) +{ + return std::vector(vals, vals + N); +} + namespace illumina{ namespace interop {namespace model {namespace table { /** Compare whether two imaging columns are equal @@ -57,7 +70,7 @@ void simulate_read_error_metrics(model::metrics::run_metrics& metrics) metrics.legacy_channel_update(constants::HiSeq); metrics.set_naming_method(constants::FourDigit); - io::read_interop_from_string(unittest::error_v3::binary_data(), metrics.get_set()); + unittest::error_metric_v3::create_metric_set(metrics.get_set()); } /** * @class illumina::interop::model::table::imaging_table @@ -216,3 +229,4 @@ TEST(imaging_table, create_imaging_table_error_metrics_tile_test) EXPECT_EQ(table(1, model::table::SwathColumn), 1.0f); } + diff --git a/src/tests/interop/logic/imaging_table_regression_test.cpp b/src/tests/interop/logic/imaging_table_regression_test.cpp index e93bbaafb..b4a3bb0af 100644 --- a/src/tests/interop/logic/imaging_table_regression_test.cpp +++ b/src/tests/interop/logic/imaging_table_regression_test.cpp @@ -11,7 +11,6 @@ #include "interop/util/length_of.h" #include "interop/logic/table/create_imaging_table.h" #include "src/tests/interop/metrics/inc/error_metrics_test.h" -#include "src/tests/interop/inc/regression_fixture.h" #include "interop/io/table/imaging_table_csv.h" #include "src/tests/interop/inc/abstract_regression_test_generator.h" @@ -90,6 +89,14 @@ class imaging_table_regression_test : public abstract_regression_test_generator< { return new imaging_table_regression_test(m_run_folder, m_test_dir); } + /** Write generator info to output stream + * + * @param out output stream + */ + void write(std::ostream& out)const + { + out << "imaging_table_regression_test - " << io::basename(m_run_folder); + } }; /** Setup for tests that compare two run summaries */ struct imaging_table_tests : public generic_test_fixture< model::table::imaging_table > {}; @@ -136,7 +143,8 @@ TEST_P(imaging_table_tests, compare_to_baseline) << "@" << expected(expected_idx[row_index], model::table::CycleColumn) << " == " << actual(actual_idx[row_index], model::table::LaneColumn) << "_" << actual(actual_idx[row_index], model::table::TileColumn) - << "@" << actual(actual_idx[row_index], model::table::CycleColumn); + << "@" << actual(actual_idx[row_index], model::table::CycleColumn) + << " digit_count: " << digit_count; } } } @@ -149,3 +157,4 @@ INSTANTIATE_TEST_CASE_P(imaging_table_regression_test, imaging_table_tests, ProxyValuesIn(imaging_table_regression_gen, regression_test_data::instance().files())); + diff --git a/src/tests/interop/logic/metric_type_ext_test.cpp b/src/tests/interop/logic/metric_type_ext_test.cpp index 009b0658c..eb58c17fe 100644 --- a/src/tests/interop/logic/metric_type_ext_test.cpp +++ b/src/tests/interop/logic/metric_type_ext_test.cpp @@ -35,3 +35,4 @@ TEST(metric_type_ext, is_cycle_metric) EXPECT_TRUE(logic::utils::is_cycle_metric(constants::Intensity)); EXPECT_FALSE(logic::utils::is_cycle_metric(constants::PercentAligned)); } + diff --git a/src/tests/interop/logic/plot_logic_test.cpp b/src/tests/interop/logic/plot_logic_test.cpp index 184cdfff4..2f286997a 100644 --- a/src/tests/interop/logic/plot_logic_test.cpp +++ b/src/tests/interop/logic/plot_logic_test.cpp @@ -84,8 +84,7 @@ TEST(plot_logic, intensity_by_cycle) metrics.set_naming_method(constants::FourDigit); metrics.legacy_channel_update(constants::HiSeq); - io::read_interop_from_string(unittest::extraction_v2::binary_data(), - metrics.get_set()); + unittest::extraction_metric_v2::create_metric_set(metrics.get_set()); model::plot::plot_data data; logic::plot::plot_by_cycle(metrics, constants::Intensity, options, data); @@ -128,7 +127,7 @@ TEST(plot_logic, pf_clusters_by_lane) metrics.set_naming_method(constants::FourDigit); metrics.legacy_channel_update(constants::HiSeq); - io::read_interop_from_string(unittest::tile_v2::binary_data(), metrics.get_set()); + unittest::tile_metric_v2::create_metric_set(metrics.get_set()); model::plot::plot_data data; logic::plot::plot_by_lane(metrics, constants::ClusterCountPF, options, data); @@ -163,7 +162,7 @@ TEST(plot_logic, q_score_histogram) metrics.legacy_channel_update(constants::HiSeq); metrics.set_naming_method(constants::FourDigit); - io::read_interop_from_string(unittest::q_v6::binary_data(), metrics.get_set()); + unittest::q_metric_v6::create_metric_set(metrics.get_set()); metrics.finalize_after_load(); model::plot::plot_data data; @@ -198,7 +197,7 @@ TEST(plot_logic, q_score_heatmap) metrics.legacy_channel_update(constants::HiSeq); metrics.set_naming_method(constants::FourDigit); - io::read_interop_from_string(unittest::q_v6::binary_data(), metrics.get_set()); + unittest::q_metric_v6::create_metric_set(metrics.get_set()); metrics.finalize_after_load(); model::plot::heatmap_data data; @@ -230,6 +229,35 @@ TEST(plot_logic, q_score_heatmap) } } +//Checks that q-score heatmap works as intended +TEST(plot_logic, q_score_heatmap_empty_interop) +{ + const float tol = 1e-3f; + model::metrics::run_metrics metrics; + model::plot::filter_options options(constants::FourDigit); + std::vector reads(2); + reads[0] = model::run::read_info(1, 1, 26); + reads[1] = model::run::read_info(2, 27, 76); + metrics.run_info(model::run::info("", "", 1, model::run::flowcell_layout(8, 2, 2, 16), + std::vector(), model::run::image_dimensions(), reads)); + metrics.legacy_channel_update(constants::HiSeq); + metrics.set_naming_method(constants::FourDigit); + + metrics.finalize_after_load(); + + model::plot::heatmap_data data; + logic::plot::plot_qscore_heatmap(metrics, options, data); + ASSERT_EQ(data.row_count(), 0u); + ASSERT_EQ(data.column_count(), 0u); + EXPECT_EQ(data.title(), ""); + EXPECT_EQ(data.x_axis().label(), ""); + EXPECT_EQ(data.y_axis().label(), ""); + EXPECT_NEAR(data.x_axis().min(), 0.0f, tol); + EXPECT_NEAR(data.y_axis().min(), 0.0f, tol); + EXPECT_NEAR(data.x_axis().max(), 0.0f, tol); + EXPECT_NEAR(data.y_axis().max(), 0.0f, tol); +} + TEST(plot_logic, q_score_heatmap_buffer) { const float tol = 1e-5f; @@ -250,7 +278,7 @@ TEST(plot_logic, q_score_heatmap_buffer) metrics.legacy_channel_update(constants::HiSeq); metrics.set_naming_method(constants::FourDigit); - io::read_interop_from_string(unittest::q_v6::binary_data(), metrics.get_set()); + unittest::q_metric_v6::create_metric_set(metrics.get_set()); metrics.finalize_after_load(); model::plot::heatmap_data data1; @@ -292,7 +320,7 @@ TEST(plot_logic, flowcell_map) model::plot::filter_options options(constants::FourDigit, ALL_IDS, 0, constants::A, ALL_IDS, 1, 1); metrics.legacy_channel_update(constants::HiSeq); - io::read_interop_from_string(unittest::extraction_v2::binary_data(), metrics.get_set()); + unittest::extraction_metric_v2::create_metric_set(metrics.get_set()); ASSERT_GT(metrics.extraction_metric_set().size(), 0u); model::plot::flowcell_data data; @@ -324,8 +352,8 @@ TEST(plot_logic, sample_qc) model::plot::filter_options options(constants::FourDigit, ALL_IDS, 0, constants::A, ALL_IDS, 1, 1); metrics.legacy_channel_update(constants::HiSeq); - io::read_interop_from_string(unittest::index_v1::binary_data(), metrics.get_set()); - io::read_interop_from_string(unittest::tile_v2::binary_data(), metrics.get_set()); + unittest::index_metric_v1::create_metric_set(metrics.get_set()); + unittest::tile_metric_v2::create_metric_set(metrics.get_set()); ASSERT_GT(metrics.index_metric_set().size(), 0u); model::plot::plot_data data; @@ -339,3 +367,4 @@ TEST(plot_logic, sample_qc) EXPECT_NEAR(data.x_axis().max(), 1, tol); EXPECT_NEAR(data.y_axis().max(), 5, tol); } + diff --git a/src/tests/interop/logic/summary_metrics_test.cpp b/src/tests/interop/logic/summary_metrics_test.cpp index 5e1292bd1..4c24f8c94 100644 --- a/src/tests/interop/logic/summary_metrics_test.cpp +++ b/src/tests/interop/logic/summary_metrics_test.cpp @@ -17,7 +17,6 @@ #include "src/tests/interop/metrics/inc/tile_metrics_test.h" #include "src/tests/interop/metrics/inc/q_metrics_test.h" #include "src/tests/interop/metrics/inc/index_metrics_test.h" -#include "src/tests/interop/inc/regression_fixture.h" #include "src/tests/interop/inc/abstract_regression_test_generator.h" using namespace illumina::interop::model::metrics; using namespace illumina::interop::io; @@ -41,7 +40,13 @@ class run_summary_generator : public abstract_generator< model::summary::run_sum */ bool generate(model::summary::run_summary& expected, model::summary::run_summary& actual)const { - expected = Gen::summary(); + const size_t lane_count = 8; + const size_t surface_count = 2; + const size_t swath_count = 4; + const size_t tile_count = 99; + const size_t sections_per_lane = 6; + const size_t lanes_per_section = 6; + Gen::create_summary(expected); std::vector reads; expected.copy_reads(reads); actual = model::summary::run_summary(reads.begin(), reads.end(), 8); @@ -51,38 +56,51 @@ class run_summary_generator : public abstract_generator< model::summary::run_sum model::run::info run_info("XX", "", 1, - model::run::flowcell_layout(8, 2, 4, 99, 6, 6), + model::run::flowcell_layout(lane_count, + surface_count, + swath_count, + tile_count, + sections_per_lane, + lanes_per_section), channels, model::run::image_dimensions(), reads); run_info.set_naming_method(constants::FourDigit); model::metrics::run_metrics metrics(run_info); - try - { - io::read_interop_from_string(Gen::binary_data(), - metrics.get_set()); - } - catch (const std::exception &) { } + Gen::create_metric_set(metrics.get_set()); metrics.finalize_after_load(); logic::summary::summarize_run_metrics(metrics, actual); return true; } + /** Create a copy of this object + * + * @return pointer to an abstract_generator + */ abstract_generator< model::summary::run_summary >* clone()const { return new run_summary_generator; } + /** Write generator info to output stream + * + * @param out output stream + */ + void write(std::ostream& out)const + { + out << "run_summary_generator<"<< metric_set_t::prefix() + << " " << metric_set_t::suffix() << ">"; + } }; /** Setup for tests that compare two run summaries */ struct run_summary_tests : public generic_test_fixture< model::summary::run_summary > {}; run_summary_tests::generator_type run_summary_unit_test_generators[] = { - new run_summary_generator< error_v3 >(), - new run_summary_generator< extraction_v2 >(), - new run_summary_generator< q_v4 >(), - new run_summary_generator< q_v5 >(), - new run_summary_generator< q_v6 >(), - new run_summary_generator< tile_v2 >() + new run_summary_generator< error_metric_v3 >(), + new run_summary_generator< extraction_metric_v2 >(), + new run_summary_generator< q_metric_v4 >(), + new run_summary_generator< q_metric_v5 >(), + new run_summary_generator< q_metric_v6 >(), + new run_summary_generator< tile_metric_v2 >() }; @@ -92,9 +110,12 @@ INSTANTIATE_TEST_CASE_P(run_summary_unit_test, ::testing::ValuesIn(run_summary_unit_test_generators)); #define EXPECT_STAT_NEAR(ACTUAL, EXPECTED, TOL) \ - EXPECT_NEAR(ACTUAL.mean(), EXPECTED.mean(), TOL); \ - EXPECT_NEAR(ACTUAL.stddev(), EXPECTED.stddev(), TOL); \ - EXPECT_NEAR(ACTUAL.median(), EXPECTED.median(), TOL) + if(!std::isnan(ACTUAL.mean()) && !std::isnan(EXPECTED.mean())) \ + EXPECT_NEAR(ACTUAL.mean(), EXPECTED.mean(), TOL); \ + if(!std::isnan(ACTUAL.stddev()) && !std::isnan(EXPECTED.stddev())) \ + EXPECT_NEAR(ACTUAL.stddev(), EXPECTED.stddev(), TOL); \ + if(!std::isnan(ACTUAL.median()) && !std::isnan(EXPECTED.median())) \ + EXPECT_NEAR(ACTUAL.median(), EXPECTED.median(), TOL) #define EXPECT_CYCLE_EQ(ACTUAL, EXPECTED) \ EXPECT_EQ(ACTUAL.first_cycle(), EXPECTED.first_cycle()); \ @@ -217,6 +238,71 @@ TEST_P(run_summary_tests, lane_summary) } } +TEST(summary_metrics_test, cycle_35_cycle_34_tile) +{ + const size_t lane_count = 8; + const size_t surface_count = 2; + const size_t swath_count = 4; + const size_t tile_count = 99; + const size_t sections_per_lane = 6; + const size_t lanes_per_section = 6; + std::vector channels; + channels.push_back("Red"); + channels.push_back("Green"); + std::vector reads; + reads.push_back(model::run::read_info(1, 1, 36)); + model::run::info run_info("XX", + "", + 1, + model::run::flowcell_layout(lane_count, + surface_count, + swath_count, + tile_count, + sections_per_lane, + lanes_per_section), + channels, + model::run::image_dimensions(), + reads); + run_info.set_naming_method(constants::FourDigit); + + model::metrics::run_metrics expected_run_metrics(run_info); + model::metric_base::metric_set& expected_error_metrics= + expected_run_metrics.get_set(); + model::metrics::run_metrics actual_run_metrics(run_info); + model::metric_base::metric_set& actual_error_metrics= + actual_run_metrics.get_set(); + typedef model::metrics::error_metric::uint_t uint_t; + for(uint_t cycle_number=0;cycle_number<36;++cycle_number) + { + expected_error_metrics.insert(error_metric(1, 1101, 1 + cycle_number, 3.0f)); + actual_error_metrics.insert(error_metric(1, 1101, 1 + cycle_number, 3.0f)); + } + for(uint_t cycle_number=0;cycle_number<34;++cycle_number) + { + actual_error_metrics.insert(error_metric(1, 1102, 1 + cycle_number, 1.0f)); + } + + model::summary::run_summary expected; + logic::summary::summarize_run_metrics(expected_run_metrics, expected); + model::summary::run_summary actual; + logic::summary::summarize_run_metrics(actual_run_metrics, actual); + ASSERT_EQ(actual.size(), expected.size()); + ASSERT_EQ(actual[0].size(), expected[0].size()); + ASSERT_EQ(actual.size(), 1u); + ASSERT_EQ(actual[0].size(), 1u); + + const float tol = 1e-7f; + const model::summary::lane_summary& actual_lane_summary = actual[0][0]; + const model::summary::lane_summary& expected_lane_summary = expected[0][0]; + model::summary::metric_stat expected_stat(3.0f, 0.0f, 3.0f); + EXPECT_STAT_NEAR(expected_lane_summary.error_rate_35(), expected_stat, tol); + EXPECT_NEAR(actual_lane_summary.error_rate_35().mean(), expected_lane_summary.error_rate_35().mean(), tol); + expected_stat=model::summary::metric_stat(0.0f, 0.0f, 0.0f); + EXPECT_STAT_NEAR(expected_lane_summary.error_rate_50(), expected_stat, tol); + EXPECT_NEAR(actual_lane_summary.error_rate_50().mean(), expected_lane_summary.error_rate_50().mean(), tol); + +} + TEST(summary_metrics_test, empty_run_metrics) { model::metrics::run_metrics metrics; @@ -227,14 +313,31 @@ TEST(summary_metrics_test, empty_run_metrics) /** TODO take tile metrics and index metrics from the same run */ TEST(index_summary_test, lane_summary) { - model::summary::index_flowcell_summary expected(index_v1::summary()); + const size_t lane_count = 8; + std::vector reads(1, model::run::read_info(1, 1, 3, false)); + std::vector channels; + channels.push_back("Red"); + channels.push_back("Green"); + model::run::info run_info("XX", + "", + 1, + model::run::flowcell_layout(lane_count), + channels, + model::run::image_dimensions(), + reads); + + model::summary::index_flowcell_summary expected; + index_metric_v1::create_summary(expected); model::summary::index_flowcell_summary actual; - model::metrics::run_metrics metrics(index_v1::run_info()); + model::metrics::run_metrics metrics(run_info); try { - io::read_interop_from_string(index_v1::binary_data(), + std::string data; + index_metric_v1::create_binary_data(data); + io::read_interop_from_string(data, metrics.get_set()); - io::read_interop_from_string(tile_v2::binary_data(), + tile_metric_v2::create_binary_data(data); + io::read_interop_from_string(data, metrics.get_set()); } catch (const std::exception &) { } @@ -322,6 +425,14 @@ class regression_test_summary_generator : public abstract_regression_test_genera { return new regression_test_summary_generator(m_run_folder, m_test_dir); } + /** Write generator info to output stream + * + * @param out output stream + */ + void write(std::ostream& out)const + { + out << "regression_test_summary_generator - " << io::basename(m_run_folder); + } }; regression_test_summary_generator run_summary_regression_gen("summary"); @@ -329,3 +440,4 @@ INSTANTIATE_TEST_CASE_P(run_summary_regression_test, run_summary_tests, ProxyValuesIn(run_summary_regression_gen, regression_test_data::instance().files())); + diff --git a/src/tests/interop/metrics/base_metric_tests.cpp b/src/tests/interop/metrics/base_metric_tests.cpp index 0693d39b9..792b0f8e7 100644 --- a/src/tests/interop/metrics/base_metric_tests.cpp +++ b/src/tests/interop/metrics/base_metric_tests.cpp @@ -82,3 +82,4 @@ TEST(base_read_metric_test, tile_hash_from_id) } + diff --git a/src/tests/interop/metrics/corrected_intensity_metrics_test.cpp b/src/tests/interop/metrics/corrected_intensity_metrics_test.cpp index caa29bcb3..3224f4144 100644 --- a/src/tests/interop/metrics/corrected_intensity_metrics_test.cpp +++ b/src/tests/interop/metrics/corrected_intensity_metrics_test.cpp @@ -1,6 +1,6 @@ /** Unit tests for the corrected intensity metrics * - * + * @see https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#how-to-write-value-parameterized-tests * @file * @date 8/7/2015 * @version 1.0 @@ -8,42 +8,73 @@ */ #ifdef _MSC_VER - #pragma warning(push) #pragma warning(disable:4127) // MSVC warns about using constants in conditional statements, for template constants #endif -#include +#include #include "interop/util/math.h" -#include "inc/corrected_intensity_metrics_test.h" #include "interop/model/run_metrics.h" +#include "src/tests/interop/metrics/inc/corrected_intensity_metrics_test.h" +#include "src/tests/interop/inc/generic_fixture.h" +#include "src/tests/interop/inc/proxy_parameter_generator.h" +#include "src/tests/interop/metrics/inc/metric_generator.h" using namespace illumina::interop::model::metrics; +using namespace illumina::interop::model::metric_base; using namespace illumina::interop; using namespace illumina::interop::io; using namespace illumina::interop::unittest; -typedef ::testing::Types< - hardcoded_fixture, - hardcoded_fixture, - write_read_fixture, - write_read_fixture -> Formats; -TYPED_TEST_CASE(corrected_intensity_metrics_test, Formats); +typedef metric_set< corrected_intensity_metric > corrected_intensity_metric_set; +/** Fixture for tests that compare two corrected intensity metric sets + * + * @see https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#how-to-write-value-parameterized-tests + */ +struct corrected_intensity_metrics_tests : public generic_test_fixture< corrected_intensity_metric_set > {}; -/** Compare two corrected intensity metric sets +/** + * This array contains a set of fixtures used to generate data for all TEST_P tests labeled + * corrected_intensity_metrics_tests. * - * @param actual metric set read from stream - * @param expected metric set setup from known data + * This used the parameter based method in GTest. The genertic_test_fixture will call GetParam to use each fixture + * to populate the expected and actual metric_set. */ -template -void compare_metrics(const T& actual, const T& expected) +corrected_intensity_metrics_tests::generator_type corrected_intensity_unit_test_generators[] = { + wrap(new hardcoded_metric_generator< corrected_intensity_metric_v2 >) , + wrap(new write_read_metric_generator< corrected_intensity_metric_v2 >), + wrap(new hardcoded_metric_generator< corrected_intensity_metric_v3 >), + wrap(new write_read_metric_generator< corrected_intensity_metric_v3 >) +}; + +// Specificy the fixtures used for corrected_intensity_metrics_tests TEST_P functions +INSTANTIATE_TEST_CASE_P(corrected_intensity_metric_unit_test, + corrected_intensity_metrics_tests, + ::testing::ValuesIn(corrected_intensity_unit_test_generators)); + + +/** + * @class illumina::interop::model::metrics::corrected_intensity_metric + * @test Confirm version 2 of the metric matches known binary file + * @test Confirm version 3 of the metric matches known binary file + * @test Confirm version 2 of the metric can be written to and read from a stream + * @test Confirm version 3 of the metric can be written to and read from a stream + * + * The test, actual and expected variables are metric sets that are contained in the fixture + * `corrected_intensity_metrics_tests`. + * + * The `test` variable is only set to false when the regression test is being rebaselined. + */ +TEST_P(corrected_intensity_metrics_tests, test_metric_io_fidelity) { + typedef corrected_intensity_metric_set::const_iterator const_iterator; + if(!test) return;// Disable test for rebaseline const float tol = 1e-3f; EXPECT_EQ(actual.version(), expected.version()); - EXPECT_EQ(actual.size(), expected.size()); + ASSERT_EQ(actual.size(), expected.size()); EXPECT_EQ(actual.max_cycle(), expected.max_cycle()); - for(typename T::const_iterator it_expected=expected.begin(), it_actual = actual.begin(); + for(const_iterator it_expected=expected.begin(), + it_actual = actual.begin(); it_expected != expected.end() && it_actual != actual.end(); it_expected++,it_actual++) { @@ -60,30 +91,21 @@ void compare_metrics(const T& actual, const T& expected) EXPECT_NEAR(it_expected->signal_to_noise(), it_actual->signal_to_noise(), tol); } for(ptrdiff_t i=-1;icalled_counts(static_cast(i)), it_actual->called_counts(static_cast(i))); + EXPECT_EQ(it_expected->called_counts(static_cast(i)), + it_actual->called_counts(static_cast(i))); for(size_t i=0;icorrected_int_called(static_cast(i)), it_actual->corrected_int_called(static_cast(i))); + EXPECT_EQ(it_expected->corrected_int_called(static_cast(i)), + it_actual->corrected_int_called(static_cast(i))); if(expected.version() < 3) { - EXPECT_EQ(it_expected->corrected_int_all(static_cast(i)), it_actual->corrected_int_all(static_cast(i))); + EXPECT_EQ(it_expected->corrected_int_all(static_cast(i)), + it_actual->corrected_int_all(static_cast(i))); } } } } -/** - * @class illumina::interop::model::metrics::corrected_intensity_metric - * @test Confirm version 2 of the metric matches known binary file - * @test Confirm version 3 of the metric matches known binary file - * @test Confirm version 2 of the metric can be written to and read from a stream - * @test Confirm version 3 of the metric can be written to and read from a stream - */ -TYPED_TEST(corrected_intensity_metrics_test, test_metric_io_fidelity) -{ - compare_metrics(TypeParam::actual_metric_set, TypeParam::expected_metric_set); -} - TEST(corrected_intensity_metrics_test, test_percent_base_nan) { typedef corrected_intensity_metric::ushort_array_t ushort_array_t; @@ -93,27 +115,25 @@ TEST(corrected_intensity_metrics_test, test_percent_base_nan) } -TEST(run_metrics_corrected_intensity_test, test_is_group_empty) -{ - run_metrics metrics; - EXPECT_TRUE(metrics.is_group_empty(constants::CorrectedInt)); - io::read_interop_from_string(corrected_intensity_v2::binary_data(), - metrics.get_set()); - EXPECT_FALSE(metrics.is_group_empty(constants::CorrectedInt)); -} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Setup regression test +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +// Use the sub folder `metrics` in the baseline folder to contain all the baseline data +regression_test_metric_generator corrected_intensity_regression_gen("metrics"); -#define FIXTURE corrected_intensity_metrics_test /** - * @class illumina::interop::model::metrics::corrected_intensity_metric - * @test Confirm binary write matches expected binary data - * @test Confirm bad_format_exception is thrown when version is unsupported - * @test Confirm incomplete_file_exception is thrown for a small partial record - * @test Confirm incomplete_file_exception is thrown for a mostly complete file - * @test Confirm bad_format_exception is thrown when record size is incorrect - * @test Confirm file_not_found_exception is thrown when a file is not found - * @test Confirm reading from good data does not throw an exception + * This method populates the regression test with run folders specified on the command line. The run folders + * are contained in the method `files` within a singleton class called `regression_test_data`. This is populated + * in the `unit_tests.cpp` file. + * + * The `ProxyValuesIn` function is a hack in GTest that allows the population of the files to be deferred. */ -#include "inc/stream_tests.hpp" +INSTANTIATE_TEST_CASE_P(corrected_intensity_metric_regression_test, + corrected_intensity_metrics_tests, + ProxyValuesIn(corrected_intensity_regression_gen, regression_test_data::instance().files())); + + diff --git a/src/tests/interop/metrics/error_metrics_test.cpp b/src/tests/interop/metrics/error_metrics_test.cpp index 84f1543e2..067cde7ca 100644 --- a/src/tests/interop/metrics/error_metrics_test.cpp +++ b/src/tests/interop/metrics/error_metrics_test.cpp @@ -7,77 +7,84 @@ * @copyright GNU Public License. */ -#include +#ifdef _MSC_VER +#pragma warning(disable:4127) // MSVC warns about using constants in conditional statements, for template constants +#endif + #include -#include "inc/error_metrics_test.h" #include "interop/model/run_metrics.h" +#include "src/tests/interop/metrics/inc/error_metrics_test.h" +#include "src/tests/interop/inc/generic_fixture.h" +#include "src/tests/interop/inc/proxy_parameter_generator.h" +#include "src/tests/interop/metrics/inc/metric_generator.h" using namespace illumina::interop::model::metrics; using namespace illumina::interop::model::metric_base; using namespace illumina::interop::io; using namespace illumina::interop; using namespace illumina::interop::unittest; +typedef metric_set< error_metric > error_metric_set; +/** Setup for tests that compare two error metric sets */ +struct error_metrics_tests : public generic_test_fixture< error_metric_set > {}; + +error_metrics_tests::generator_type error_unit_test_generators[] = { + wrap(new hardcoded_metric_generator< error_metric_v3 >) , + wrap(new write_read_metric_generator< error_metric_v3 >) +}; -typedef ::testing::Types< - hardcoded_fixture, - write_read_fixture -> Formats; -TYPED_TEST_CASE(error_metrics_test, Formats); +// Setup unit tests for error_metrics_tests +INSTANTIATE_TEST_CASE_P(error_metric_unit_test, + error_metrics_tests, + ::testing::ValuesIn(error_unit_test_generators)); /** * @class illumina::interop::model::metrics::error_metric * @test Confirm version 3 of the metric can be written to and read from a stream * @test Confirm version 3 of the metric matches known binary file */ -TYPED_TEST(error_metrics_test, test_read_write) +TEST_P(error_metrics_tests, compare_expected_actual) { - const float tol = 1e-4f; - EXPECT_EQ(TypeParam::actual_metric_set.version(), TypeParam::VERSION); - EXPECT_EQ(TypeParam::actual_metric_set.size(), TypeParam::expected_metric_set.size()); - EXPECT_EQ(TypeParam::actual_metric_set.max_cycle(), TypeParam::expected_metric_set.max_cycle()); + if(!test) return;// Disable test for rebaseline + ASSERT_EQ(actual.version(), expected.version()); + ASSERT_EQ(actual.size(), expected.size()); + EXPECT_EQ(actual.max_cycle(), expected.max_cycle()) << actual.offset_map().size() + << " == " + << expected.offset_map().size(); - for(typename TypeParam::const_iterator it_expected=TypeParam::expected_metric_set.begin(), it_actual = TypeParam::actual_metric_set.begin(); - it_expected != TypeParam::expected_metric_set.end() && it_actual != TypeParam::actual_metric_set.end(); + for(value_type::const_iterator it_expected=expected.begin(), it_actual = actual.begin(); + it_expected != expected.end(); it_expected++,it_actual++) { EXPECT_EQ(it_expected->lane(), it_actual->lane()); EXPECT_EQ(it_expected->tile(), it_actual->tile()); EXPECT_EQ(it_expected->cycle(), it_actual->cycle()); EXPECT_EQ(it_expected->mismatch_count(), it_actual->mismatch_count()); - EXPECT_NEAR(it_expected->error_rate(), it_actual->error_rate(), tol); + EXPECT_NEAR(it_expected->error_rate(), it_actual->error_rate(), 1e-5f); for(ptrdiff_t i=0;i(it_expected->mismatch_count());i++) EXPECT_EQ(it_expected->mismatch_cluster_count(i), it_actual->mismatch_cluster_count(i)); } } - -TYPED_TEST(error_metrics_test, test_tile_metric_count_for_lane) +/** + * @test Ensure tile_numbers_for_lane returns the proper number + */ +TEST(error_metrics_single_test, test_tile_metric_count_for_lane) { - ASSERT_GT(TypeParam::expected_metric_set.size(), 1u); - const error_metric::uint_t lane = TypeParam::expected_metric_set.metrics()[0].lane(); - EXPECT_EQ(TypeParam::expected_metric_set.tile_numbers_for_lane(lane).size(), 1u); + error_metric_set metrics; + error_metric_v3::create_metric_set(metrics); + EXPECT_EQ(metrics.tile_numbers_for_lane(7).size(), 1u); } -TEST(run_metrics_error_test, test_is_group_empty) -{ - run_metrics metrics; - EXPECT_TRUE(metrics.is_group_empty(constants::Error)); - io::read_interop_from_string(error_v3::binary_data(), - metrics.get_set()); - EXPECT_FALSE(metrics.is_group_empty(constants::Error)); -} -#define FIXTURE error_metrics_test -/** - * @class illumina::interop::model::metrics::error_metric - * @test Confirm binary write matches expected binary data - * @test Confirm bad_format_exception is thrown when version is unsupported - * @test Confirm incomplete_file_exception is thrown for a small partial record - * @test Confirm incomplete_file_exception is thrown for a mostly complete file - * @test Confirm bad_format_exception is thrown when record size is incorrect - * @test Confirm file_not_found_exception is thrown when a file is not found - * @test Confirm reading from good data does not throw an exception - */ -#include "inc/stream_tests.hpp" +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Setup regression test +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +regression_test_metric_generator error_regression_gen("metrics"); +INSTANTIATE_TEST_CASE_P(error_metric_regression_test, + error_metrics_tests, + ProxyValuesIn(error_regression_gen, regression_test_data::instance().files())); + + + diff --git a/src/tests/interop/metrics/error_metrics_test2.cpp b/src/tests/interop/metrics/error_metrics_test2.cpp deleted file mode 100644 index 5956554fb..000000000 --- a/src/tests/interop/metrics/error_metrics_test2.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/** Unit tests for the error metrics - * - * - * @file - * @date 8/23/2015 - * @version 1.0 - * @copyright GNU Public License. - */ - -#include -#include -#include "src/tests/interop/inc/generic_fixture.h" -#include "src/tests/interop/inc/proxy_parameter_generator.h" -#include "src/tests/interop/metrics/inc/metric_generator.h" -#include "src/tests/interop/metrics/inc/error_metrics_test.h" -#include "interop/model/run_metrics.h" -using namespace illumina::interop::model::metrics; -using namespace illumina::interop::model::metric_base; -using namespace illumina::interop::io; -using namespace illumina::interop; -using namespace illumina::interop::unittest; - -typedef metric_set< error_metric > error_metric_set; -/** Setup for tests that compare two error metric sets */ -struct error_metrics_tests : public generic_test_fixture< error_metric_set > {}; - -error_metrics_tests::generator_type unit_test_generators[] = { - wrap(new hardcoded_metric_generator< error_metric_v3 >) , - wrap(new write_read_metric_generator< error_metric_v3 >) -}; - -// Setup unit tests for error_metrics_tests -INSTANTIATE_TEST_CASE_P(error_metric_unit_test, - error_metrics_tests, - ::testing::ValuesIn(unit_test_generators)); - -/** - * @class illumina::interop::model::metrics::error_metric - * @test Confirm version 3 of the metric can be written to and read from a stream - * @test Confirm version 3 of the metric matches known binary file - */ -TEST_P(error_metrics_tests, compare_expected_actual) -{ - if(!test) return;// Disable test for rebaseline - EXPECT_EQ(actual.version(), expected.version()); - EXPECT_EQ(actual.size(), expected.size()); - EXPECT_EQ(actual.max_cycle(), expected.max_cycle()); - - for(value_type::const_iterator it_expected=expected.begin(), it_actual = actual.begin(); - it_expected != expected.end() && it_actual != actual.end(); - it_expected++,it_actual++) - { - EXPECT_EQ(it_expected->lane(), it_actual->lane()); - EXPECT_EQ(it_expected->tile(), it_actual->tile()); - EXPECT_EQ(it_expected->cycle(), it_actual->cycle()); - EXPECT_EQ(it_expected->mismatch_count(), it_actual->mismatch_count()); - EXPECT_NEAR(it_expected->error_rate(), it_actual->error_rate(), 1e-7f); - for(ptrdiff_t i=0;i(it_expected->mismatch_count());i++) - EXPECT_EQ(it_expected->mismatch_cluster_count(i), it_actual->mismatch_cluster_count(i)); - } -} - -/** - * @test Ensure tile_numbers_for_lane returns the proper number - */ -TEST(error_metrics_single_test, test_tile_metric_count_for_lane) -{ - error_metric_set metrics; - error_metric_v3::create_expected(metrics); - EXPECT_EQ(metrics.tile_numbers_for_lane(7).size(), 1u); -} - -/** - * @test Ensure the keys function returns the proper metric - */ -TEST(error_metrics_single_test, test_expected_get_metric) -{ - error_metric_set metrics; - error_metric_v3::create_expected(metrics); - error_metric_set::key_vector keys = metrics.keys(); - for(size_t i=0;i()); - EXPECT_FALSE(metrics.is_group_empty(constants::Error)); -} - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Setup regression test -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -regression_test_metric_generator regression_gen("metrics"); -INSTANTIATE_TEST_CASE_P(error_metric_regression_test, - error_metrics_tests, - ProxyValuesIn(regression_gen, regression_test_data::instance().files())); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Shared stream tests -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** Setup for tests that compare two binary buffers created by writing error metrics */ -struct error_metric_write_tests : public generic_test_fixture< std::string > -{ - /** Define a metric set type */ - typedef error_metric_set metric_set_t; -}; - -error_metric_write_tests::generator_type write_generators[] = { - new write_metric_generator< error_metric_v3 >() -}; -INSTANTIATE_TEST_CASE_P(error_metric_write_test_params, - error_metric_write_tests, - ::testing::ValuesIn(write_generators)); - - -#define FIXTURE error_metric_write_tests -#include "src/tests/interop/metrics/inc/metric_stream_tests.hpp" - diff --git a/src/tests/interop/metrics/extraction_metrics_test.cpp b/src/tests/interop/metrics/extraction_metrics_test.cpp index 8abdee9c2..6df4dee0f 100644 --- a/src/tests/interop/metrics/extraction_metrics_test.cpp +++ b/src/tests/interop/metrics/extraction_metrics_test.cpp @@ -8,38 +8,52 @@ */ #include -#include #include -#include "inc/extraction_metrics_test.h" #include "interop/model/run_metrics.h" +#include "src/tests/interop/metrics/inc/extraction_metrics_test.h" +#include "src/tests/interop/inc/generic_fixture.h" +#include "src/tests/interop/inc/proxy_parameter_generator.h" +#include "src/tests/interop/metrics/inc/metric_generator.h" + using namespace illumina::interop::model::metrics; +using namespace illumina::interop::model::metric_base; using namespace illumina::interop::io; using namespace illumina::interop; using namespace illumina::interop::unittest; -typedef ::testing::Types< - hardcoded_fixture, - write_read_fixture -> Formats; -TYPED_TEST_CASE(extraction_metrics_test, Formats); +typedef metric_set< extraction_metric > extraction_metric_set; +/** Setup for tests that compare two extraction metric sets */ +struct extraction_metrics_tests : public generic_test_fixture< extraction_metric_set > {}; + +extraction_metrics_tests::generator_type extraction_unit_test_generators[] = { + wrap(new hardcoded_metric_generator< extraction_metric_v2 >) , + wrap(new write_read_metric_generator< extraction_metric_v2 >) +}; + +// Setup unit tests for extraction_metrics_tests +INSTANTIATE_TEST_CASE_P(extraction_metric_unit_test, + extraction_metrics_tests, + ::testing::ValuesIn(extraction_unit_test_generators)); /** * @class illumina::interop::model::metrics::extraction_metric * @test Confirm version 2 of the metric can be written to and read from a stream * @test Confirm version 2 of the metric matches known binary file */ -TYPED_TEST(extraction_metrics_test, test_read_write) +TEST_P(extraction_metrics_tests, test_read_write) { + typedef extraction_metric_set::const_iterator const_iterator; + if(!test) return;// Disable test for rebaseline const float tol = 1e-7f; - EXPECT_EQ(TypeParam::actual_metric_set.version(), TypeParam::VERSION); - EXPECT_EQ(TypeParam::actual_metric_set.size(), TypeParam::expected_metric_set.size()); - EXPECT_EQ(TypeParam::actual_metric_set.max_cycle(), TypeParam::expected_metric_set.max_cycle()); + EXPECT_EQ(actual.version(), expected.version()); + ASSERT_EQ(actual.size(), expected.size()); + EXPECT_EQ(actual.max_cycle(), expected.max_cycle()); - for(typename TypeParam::const_iterator it_expected=TypeParam::expected_metric_set.begin(), it_actual = TypeParam::actual_metric_set.begin(); - it_expected != TypeParam::expected_metric_set.end() && it_actual != TypeParam::actual_metric_set.end(); + for(const_iterator it_expected=expected.begin(), it_actual = actual.begin(); + it_expected != expected.end() && it_actual != actual.end(); it_expected++,it_actual++) { EXPECT_EQ(it_expected->lane(), it_actual->lane()); @@ -59,24 +73,16 @@ TYPED_TEST(extraction_metrics_test, test_read_write) } } } -TEST(run_metrics_extraction_test, test_is_group_empty) -{ - run_metrics metrics; - EXPECT_TRUE(metrics.is_group_empty(constants::Extraction)); - io::read_interop_from_string(extraction_v2::binary_data(), - metrics.get_set()); - EXPECT_FALSE(metrics.is_group_empty(constants::Extraction)); -} -#define FIXTURE extraction_metrics_test -/** - * @class illumina::interop::model::metrics::extraction_metric - * @test Confirm binary write matches expected binary data - * @test Confirm bad_format_exception is thrown when version is unsupported - * @test Confirm incomplete_file_exception is thrown for a small partial record - * @test Confirm incomplete_file_exception is thrown for a mostly complete file - * @test Confirm bad_format_exception is thrown when record size is incorrect - * @test Confirm file_not_found_exception is thrown when a file is not found - * @test Confirm reading from good data does not throw an exception - */ -#include "inc/stream_tests.hpp" + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Setup regression test +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +regression_test_metric_generator extraction_regression_gen("metrics"); +INSTANTIATE_TEST_CASE_P(extraction_metric_regression_test, + extraction_metrics_tests, + ProxyValuesIn(extraction_regression_gen, regression_test_data::instance().files())); + + + + diff --git a/src/tests/interop/metrics/image_metrics_test.cpp b/src/tests/interop/metrics/image_metrics_test.cpp index 48fba789a..41eca5cae 100644 --- a/src/tests/interop/metrics/image_metrics_test.cpp +++ b/src/tests/interop/metrics/image_metrics_test.cpp @@ -8,25 +8,36 @@ */ #include -#include #include -#include "inc/image_metrics_test.h" +#include "src/tests/interop/metrics/inc/image_metrics_test.h" +#include "src/tests/interop/inc/generic_fixture.h" +#include "src/tests/interop/inc/proxy_parameter_generator.h" +#include "src/tests/interop/metrics/inc/metric_generator.h" #include "interop/model/run_metrics.h" using namespace illumina::interop::model::metrics; +using namespace illumina::interop::model::metric_base; using namespace illumina::interop::io; using namespace illumina::interop; using namespace illumina::interop::unittest; -typedef ::testing::Types< - hardcoded_fixture, - write_read_fixture, - hardcoded_fixture, - write_read_fixture -> Formats; -TYPED_TEST_CASE(image_metrics_test, Formats); +typedef metric_set< image_metric > image_metric_set; +/** Setup for tests that compare two image metric sets */ +struct image_metrics_tests : public generic_test_fixture< image_metric_set > {}; +image_metrics_tests::generator_type image_unit_test_generators[] = { + wrap(new hardcoded_metric_generator< image_metric_v1 >) , + wrap(new write_read_metric_generator< image_metric_v1 >), + wrap(new hardcoded_metric_generator< image_metric_v2 >) , + wrap(new write_read_metric_generator< image_metric_v2 >) +}; + +// Setup unit tests for image_metrics_tests +INSTANTIATE_TEST_CASE_P(image_metric_unit_test, + image_metrics_tests, + ::testing::ValuesIn(image_unit_test_generators)); + /** * @class illumina::interop::model::metrics::image_metric * @test Confirm version 1 of the metric can be written to and read from a stream @@ -34,47 +45,39 @@ TYPED_TEST_CASE(image_metrics_test, Formats); * @test Confirm version 2 of the metric can be written to and read from a stream * @test Confirm version 2 of the metric matches known binary file */ -TYPED_TEST(image_metrics_test, test_read_write) +TEST_P(image_metrics_tests, test_read_write) { - EXPECT_EQ(TypeParam::actual_metric_set.version(), TypeParam::VERSION); - EXPECT_EQ(TypeParam::actual_metric_set.size(), TypeParam::expected_metric_set.size()); - EXPECT_EQ(TypeParam::actual_metric_set.channel_count(), TypeParam::expected_metric_set.channel_count()); - EXPECT_EQ(TypeParam::actual_metric_set.max_cycle(), TypeParam::expected_metric_set.max_cycle()); + typedef image_metric_set::const_iterator const_iterator; + if(!test) return;// Disable test for rebaseline + EXPECT_EQ(actual.version(), expected.version()); + ASSERT_EQ(actual.size(), expected.size()); + ASSERT_EQ(actual.channel_count(), expected.channel_count()); + EXPECT_EQ(actual.max_cycle(), expected.max_cycle()); - for(typename TypeParam::const_iterator it_expected=TypeParam::expected_metric_set.begin(), it_actual = TypeParam::actual_metric_set.begin(); - it_expected != TypeParam::expected_metric_set.end() && it_actual != TypeParam::actual_metric_set.end(); + for(const_iterator it_expected=expected.begin(), it_actual = actual.begin(); + it_expected != expected.end() && it_actual != actual.end(); it_expected++,it_actual++) { EXPECT_EQ(it_expected->lane(), it_actual->lane()); EXPECT_EQ(it_expected->tile(), it_actual->tile()); EXPECT_EQ(it_expected->cycle(), it_actual->cycle()); - EXPECT_EQ(it_expected->channel_count(), it_actual->channel_count()); - for(size_t i=0;ichannel_count(), it_actual->channel_count());i++) + ASSERT_EQ(it_expected->channel_count(), it_actual->channel_count()); + for(size_t i=0;ichannel_count();i++) { EXPECT_EQ(it_expected->min_contrast(i), it_actual->min_contrast(i)); EXPECT_EQ(it_expected->max_contrast(i), it_actual->max_contrast(i)); } } } -TEST(run_metrics_image_test, test_is_group_empty) -{ - run_metrics metrics; - EXPECT_TRUE(metrics.is_group_empty(constants::Image)); - io::read_interop_from_string(image_v1::binary_data(), - metrics.get_set()); - EXPECT_FALSE(metrics.is_group_empty(constants::Image)); -} -#define FIXTURE image_metrics_test -/** - * @class illumina::interop::model::metrics::image_metric - * @test Confirm binary write matches expected binary data - * @test Confirm bad_format_exception is thrown when version is unsupported - * @test Confirm incomplete_file_exception is thrown for a small partial record - * @test Confirm incomplete_file_exception is thrown for a mostly complete file - * @test Confirm bad_format_exception is thrown when record size is incorrect - * @test Confirm file_not_found_exception is thrown when a file is not found - * @test Confirm reading from good data does not throw an exception - */ -#include "inc/stream_tests.hpp" + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Setup regression test +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +regression_test_metric_generator image_regression_gen("metrics"); +INSTANTIATE_TEST_CASE_P(image_metric_regression_test, + image_metrics_tests, + ProxyValuesIn(image_regression_gen, regression_test_data::instance().files())); + diff --git a/src/tests/interop/metrics/inc/corrected_intensity_metrics_test.h b/src/tests/interop/metrics/inc/corrected_intensity_metrics_test.h index 3efe632c3..62084430c 100644 --- a/src/tests/interop/metrics/inc/corrected_intensity_metrics_test.h +++ b/src/tests/interop/metrics/inc/corrected_intensity_metrics_test.h @@ -7,174 +7,139 @@ * @copyright GNU Public License. */ #pragma once -#include -#include "metric_test.h" +#include "src/tests/interop/metrics/inc/metric_test.h" #include "interop/model/metrics/corrected_intensity_metric.h" #include "interop/model/summary/run_summary.h" +#include "interop/util/length_of.h" - -namespace illumina{ namespace interop { namespace unittest { - - /** This test compares byte values taken from an InterOp file for three records produced by RTA 2.7.x - * to the values displayed in SAV. - * - * Regression Test: 1947950_117213Bin2R0I +namespace illumina{ namespace interop { namespace unittest +{ + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::corrected_intensity_metric * @note Version 2 */ - struct corrected_intensity_v2 : metric_test + struct corrected_intensity_metric_v2 : metric_test { - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() + static void create_metric_set(metric_set_t& metrics) { typedef metric_t::uint_t uint_t; typedef metric_t::ushort_t ushort_t; - std::vector metrics; - ushort_t corrected_int_all1[] = {1213, 966, 960, 1095}; - ushort_t corrected_int_called1[] = {4070, 4074, 4029, 3972}; - uint_t called_counts1[] = {0, 698433, 548189, 548712, 646638}; - metrics.push_back( + metrics = metric_set_t(VERSION); + const ushort_t corrected_int_all1[] = {1213, 966, 960, 1095}; + const ushort_t corrected_int_called1[] = {4070, 4074, 4029, 3972}; + const uint_t called_counts1[] = {0, 698433, 548189, 548712, 646638}; + metrics.insert( metric_t(1, 1104, 25, 1063, 11.9458876f, to_vector(corrected_int_called1), to_vector(corrected_int_all1), to_vector(called_counts1))); - ushort_t corrected_int_all2[] = {1558, 1151, 1158, 1293}; - uint_t called_counts2[] = {10938, 733661, 537957, 543912, 615504}; - ushort_t corrected_int_called2[] = {5013, 4983, 4915, 4932}; - metrics.push_back( + const ushort_t corrected_int_all2[] = {1558, 1151, 1158, 1293}; + const uint_t called_counts2[] = {10938, 733661, 537957, 543912, 615504}; + const ushort_t corrected_int_called2[] = {5013, 4983, 4915, 4932}; + metrics.insert( metric_t(1, 1104, 1, 1295, 13.3051805f, to_vector(corrected_int_called2), to_vector(corrected_int_all2), to_vector(called_counts2))); - ushort_t corrected_int_all3[] = {1171, 932, 912, 1069}; - uint_t called_counts3[] = {0, 706987, 556441, 556067, 653959}; - ushort_t corrected_int_called3[] = {3931, 3931, 3923, 3878}; - metrics.push_back( + const ushort_t corrected_int_all3[] = {1171, 932, 912, 1069}; + const uint_t called_counts3[] = {0, 706987, 556441, 556067, 653959}; + const ushort_t corrected_int_called3[] = {3931, 3931, 3923, 3878}; + metrics.insert( metric_t(1, 1105, 25, 1025, 11.7396259f, to_vector(corrected_int_called3), to_vector(corrected_int_all3), to_vector(called_counts3))); - return metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() - { - return header_t(); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - int tmp[] = {2, 48, 1, 0, 80, 4, 25, 0, 39, 4, 189, 4, 198, 3, 192, 3, 71, 4, 230, 15, 234, 15, 189, 15, 132, - 15, 0, 0, 0, 0, 65, 168, 10, 0, 93, 93, 8, 0, 104, 95, 8, 0, 238, 221, 9, 0, 91, 34, 63, 65, 1, 0, - 80, 4, 1, 0, 15, 5, 22, 6, 127, 4, 134, 4, 13, 5, 149, 19, 119, 19, 51, 19, 68, 19, 186, 42, 0, 0, - 221, 49, 11, 0, 101, 53, 8, 0, 168, 76, 8, 0, 80, 100, 9, 0, 5, 226, 84, 65, 1, 0, 81, 4, 25, 0, 1, - 4, 147, 4, 164, 3, 144, 3, 45, 4, 91, 15, 91, 15, 83, 15, 38, 15, 0, 0, 0, 0, 171, 201, 10, 0, 153, - 125, 8, 0, 35, 124, 8, 0, 135, 250, 9, 0, 130, 213, 59, 65 + const int tmp[] = + { + 2, 48, 1, 0, 80, 4, 25, 0, 39, 4, 189, 4, 198, 3, 192, 3, 71, 4, 230, 15, 234, 15, 189, 15, 132, + 15, 0, 0, 0, 0, 65, 168, 10, 0, 93, 93, 8, 0, 104, 95, 8, 0, 238, 221, 9, 0, 91, 34, 63, 65, 1, 0, + 80, 4, 1, 0, 15, 5, 22, 6, 127, 4, 134, 4, 13, 5, 149, 19, 119, 19, 51, 19, 68, 19, 186, 42, 0, 0, + 221, 49, 11, 0, 101, 53, 8, 0, 168, 76, 8, 0, 80, 100, 9, 0, 5, 226, 84, 65, 1, 0, 81, 4, 25, 0, 1, + 4, 147, 4, 164, 3, 144, 3, 45, 4, 91, 15, 91, 15, 83, 15, 38, 15, 0, 0, 0, 0, 171, 201, 10, 0, 153, + 125, 8, 0, 35, 124, 8, 0, 135, 250, 9, 0, 130, 213, 59, 65 }; - return to_string(tmp); - } - /** Get reads describing data - * - * @return reads vector - */ - static std::vector reads() - { - std::vector reads(1, model::run::read_info(1, 1, 27, false)); - return reads; - } - /** Get the summary for these metrics + buffer.assign(tmp, tmp+util::length_of(tmp)); + }/** Get the summary for these metrics * * @return run summary */ - static model::summary::run_summary summary() + static void create_summary(model::summary::run_summary& summary) { const size_t lane_count = 1; - std::vector read_infos = reads(); - model::summary::run_summary summary(read_infos.begin(), read_infos.end(), lane_count); + const model::run::read_info reads[]={ + model::run::read_info(1, 1, 27, false) + }; + summary.initialize(to_vector(reads), lane_count); summary[0][0].cycle_state().called_cycle_range(model::run::cycle_range(1, 25)); summary.cycle_state().called_cycle_range(model::run::cycle_range(1, 25)); - return summary; } }; - /** This test compares byte values taken from an InterOp file for three records produced by RTA 2.7.x - * to the values displayed in SAV. + + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::corrected_intensity_metric * @note Version 3 */ - struct corrected_intensity_v3 : metric_test + struct corrected_intensity_metric_v3 : metric_test { - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() + static void create_metric_set(metric_set_t& metrics) { typedef metric_t::uint_t uint_t; typedef metric_t::ushort_t ushort_t; - std::vector metrics; - uint_t called_counts1[] = {52, 1049523, 654071, 500476, 982989}; - ushort_t corrected_int_called1[] = {245, 252, 61, 235}; - //expected_metrics.push_back(metric_type(7, 1114, 1, to_vector(corrected_int_called1), to_vector(called_counts1))); - metrics.push_back(metric_t(7, 1114, 1, (corrected_int_called1), (called_counts1))); - uint_t called_counts2[] = {0, 1063708, 582243, 588028, 953132}; - ushort_t corrected_int_called2[] = {232, 257, 68, 228}; - //expected_metrics.push_back(metric_type(7, 1114, 2, to_vector(corrected_int_called2), to_vector(called_counts2))); - metrics.push_back(metric_t(7, 1114, 2, (corrected_int_called2), (called_counts2))); - uint_t called_counts3[] = {0, 1022928, 617523, 594836, 951825}; - ushort_t corrected_int_called3[] = {227, 268, 68, 229}; - metrics.push_back(metric_t(7, 1114, 3, (corrected_int_called3), (called_counts3))); - //expected_metrics.push_back(metric_type(7, 1114, 3, to_vector(corrected_int_called3), to_vector(called_counts3))); - return metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() - { - return header_t(); + metrics = metric_set_t(VERSION); + const uint_t called_counts1[] = {52, 1049523, 654071, 500476, 982989}; + const ushort_t corrected_int_called1[] = {245, 252, 61, 235}; + metrics.insert(metric_t(7, 1114, 1, to_vector(corrected_int_called1), to_vector(called_counts1))); + const uint_t called_counts2[] = {0, 1063708, 582243, 588028, 953132}; + const ushort_t corrected_int_called2[] = {232, 257, 68, 228}; + metrics.insert(metric_t(7, 1114, 2, to_vector(corrected_int_called2), to_vector(called_counts2))); + const uint_t called_counts3[] = {0, 1022928, 617523, 594836, 951825}; + const ushort_t corrected_int_called3[] = {227, 268, 68, 229}; + metrics.insert(metric_t(7, 1114, 3, to_vector(corrected_int_called3), to_vector(called_counts3))); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - const int tmp[] = {3, 34, 7, 0, 90, 4, 1, 0, -11, 0, -4, 0, 61, 0, -21, 0, 52, 0, 0, 0, -77, 3, 16, 0, -9, -6, 9, 0, - -4, -94, 7, 0, -51, -1, 14, 0, 7, 0, 90, 4, 2, 0, -24, 0, 1, 1, 68, 0, -28, 0, 0, 0, 0, 0, 28, 59, - 16, 0, 99, -30, 8, 0, -4, -8, 8, 0, 44, -117, 14, 0, 7, 0, 90, 4, 3, 0, -29, 0, 12, 1, 68, 0, -27, - 0, 0, 0, 0, 0, -48, -101, 15, 0, 51, 108, 9, 0, -108, 19, 9, 0, 17, -122, 14, 0 + const int tmp[] = + { + 3, 34, 7, 0, 90, 4, 1, 0, -11, 0, -4, 0, 61, 0, -21, 0, 52, 0, 0, 0, -77, 3, 16, 0, -9, -6, 9, 0, + -4, -94, 7, 0, -51, -1, 14, 0, 7, 0, 90, 4, 2, 0, -24, 0, 1, 1, 68, 0, -28, 0, 0, 0, 0, 0, 28, 59, + 16, 0, 99, -30, 8, 0, -4, -8, 8, 0, 44, -117, 14, 0, 7, 0, 90, 4, 3, 0, -29, 0, 12, 1, 68, 0, -27, + 0, 0, 0, 0, 0, -48, -101, 15, 0, 51, 108, 9, 0, -108, 19, 9, 0, 17, -122, 14, 0 }; - return to_string(tmp); - } - /** Get reads describing data - * - * @return reads vector - */ - static std::vector reads() - { - std::vector reads(1, model::run::read_info(1, 1, 27, false)); - return reads; + buffer.assign(tmp, tmp+util::length_of(tmp)); } /** Get the summary for these metrics * * @return run summary */ - static model::summary::run_summary summary() + static void create_summary(model::summary::run_summary& summary) { const size_t lane_count = 1; - std::vector read_infos = reads(); - model::summary::run_summary summary(read_infos.begin(), read_infos.end(), lane_count); + const model::run::read_info reads[]={ + model::run::read_info(1, 1, 27, false) + }; + summary.initialize(to_vector(reads), lane_count); summary[0][0].cycle_state().called_cycle_range(model::run::cycle_range(3, 3)); summary.cycle_state().called_cycle_range(model::run::cycle_range(3, 3)); - return summary; } }; - /** Interface between fixtures and Google Test */ - template - struct corrected_intensity_metrics_test : public ::testing::Test, public TestSetup{}; + }}} + diff --git a/src/tests/interop/metrics/inc/error_metrics_test.h b/src/tests/interop/metrics/inc/error_metrics_test.h index fb99158c7..1858d49c9 100644 --- a/src/tests/interop/metrics/inc/error_metrics_test.h +++ b/src/tests/interop/metrics/inc/error_metrics_test.h @@ -8,8 +8,7 @@ */ #pragma once -#include -#include "metric_test.h" +#include "src/tests/interop/metrics/inc/metric_test.h" #include "interop/model/metrics/error_metric.h" #include "interop/model/summary/run_summary.h" #include "interop/util/length_of.h" @@ -20,129 +19,55 @@ namespace illumina { namespace interop { namespace unittest /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::error_metric * @note Version 3 */ struct error_metric_v3 : metric_test { - //typedef model::metrics::error_metric metric_t; - //typedef model::metric_base::metric_set< metric_t > metric_set_t; /** Create the expected metric set * * @param metrics destination metric set */ - static void create_expected(metric_set_t& metrics) + static void create_metric_set(metric_set_t &metrics) { - metrics = metric_set_t(3); + metrics = metric_set_t(VERSION); metrics.insert(metric_t(7, 1114, 1, 0.450100899f)); metrics.insert(metric_t(7, 1114, 2, 0.900201797f)); metrics.insert(metric_t(7, 1114, 3, 0.465621591f)); } - /** Get the expected binary data - * - * @param buffer binary data vector - */ - static void create_binary_data(std::vector< ::uint8_t >& buffer) - { - create_binary_data_t(buffer); - } - /** Get the expected binary data - * - * @param buffer binary data string - */ - static void create_binary_data(std::string& buffer) - { - create_binary_data_t(buffer); - } - private: /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - template - static void create_binary_data_t(T& buffer) + template + static void create_binary_data(Collection &buffer) { - static const int tmp[] = {3, 30, - 7, 0, 90, 4, 1, 0, -96, 115, -26, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 7, 0, 90, 4, 2, 0, -96, 115, 102, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 7, 0, 90, 4, 3, 0, -12, 101, -18, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + const int tmp[] = + { + 3, 30, 7, 0, 90, 4, 1, 0, -96, 115, -26, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 7, 0, 90, 4, 2, 0, -96, 115, 102, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 90, 4, 3, 0, -12, 101, -18, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; buffer.assign(tmp, tmp+util::length_of(tmp)); } - }; - - /** This test writes three records of an InterOp files, then reads them back in and compares - * each value to ensure they did not change. - * - * @note Version 3 - */ - struct error_v3 : metric_test - { - /** Build the expected metric set - * - * @return vector of metrics - */ - static std::vector metrics() - { - std::vector expected_metrics; - - - expected_metrics.push_back(metric_t(7, 1114, 1, 0.450100899f)); - expected_metrics.push_back(metric_t(7, 1114, 2, 0.900201797f)); - expected_metrics.push_back(metric_t(7, 1114, 3, 0.465621591f)); - - return expected_metrics; - } - - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() - { - return header_t(); - } - - /** Get the expected binary data - * - * @return binary data string - */ - static std::string binary_data() - { - const int tmp[] = {3, 30, 7, 0, 90, 4, 1, 0, -96, 115, -26, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 7, 0, 90, 4, 2, 0, -96, 115, 102, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 90, 4, 3, 0, -12, 101, -18, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - return to_string(tmp); - } - - /** Get reads describing data - * - * @return reads vector - */ - static std::vector reads() - { - std::vector reads(1, model::run::read_info(1, 1, 3, false)); - return reads; - } /** Get the summary for these metrics * * @return run summary */ - static model::summary::run_summary summary() + static void create_summary(model::summary::run_summary &summary) { const size_t lane_count = 1; - std::vector read_infos = reads(); - model::summary::run_summary summary(read_infos.begin(), read_infos.end(), lane_count); + const model::run::read_info reads[] = { + model::run::read_info(1, 1, 3, false) + }; + summary.initialize(to_vector(reads), lane_count); summary[0][0].lane(7); summary[0][0].error_rate(model::summary::metric_stat(0.67515134811401367f, 0, 0.67515134811401367f)); summary[0][0].error_rate_35(model::summary::metric_stat(0.0f, 0, 0.0f)); - summary[0][0].error_rate_50(model::summary::metric_stat(00.0f, 0, 0.0f)); + summary[0][0].error_rate_50(model::summary::metric_stat(0.0f, 0, 0.0f)); summary[0][0].error_rate_75(model::summary::metric_stat(0.0f, 0, 0.0f)); summary[0][0].error_rate_100(model::summary::metric_stat(0.0f, 0, 0.0f)); summary[0][0].cycle_state().error_cycle_range(model::run::cycle_range(3, 3)); @@ -151,13 +76,9 @@ namespace illumina { namespace interop { namespace unittest summary.nonindex_summary().error_rate(0.67515134811401367f); summary[0][0].tile_count(1); summary.cycle_state().error_cycle_range(model::run::cycle_range(3, 3)); - return summary; } }; -/** Interface between fixtures and Google Test */ - template - struct error_metrics_test : public ::testing::Test, public TestSetup - { - }; + }}} + diff --git a/src/tests/interop/metrics/inc/extraction_metrics_test.h b/src/tests/interop/metrics/inc/extraction_metrics_test.h index a32390fa2..1510d23eb 100644 --- a/src/tests/interop/metrics/inc/extraction_metrics_test.h +++ b/src/tests/interop/metrics/inc/extraction_metrics_test.h @@ -7,81 +7,67 @@ * @copyright GNU Public License. */ #pragma once -#include -#include "metric_test.h" +#include "src/tests/interop/metrics/inc/metric_test.h" #include "interop/model/metrics/extraction_metric.h" #include "interop/model/summary/run_summary.h" +#include "interop/util/length_of.h" -namespace illumina{ namespace interop { namespace unittest { +namespace illumina{ namespace interop { namespace unittest +{ - /** This test compares byte values taken from an InterOp file for three records produced by RTA 2.7.x - * to the values displayed in SAV. + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::extraction_metric * @note Version 2 */ - struct extraction_v2 : metric_test + struct extraction_metric_v2 : metric_test { - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() + static void create_metric_set(metric_set_t& metrics) { - std::vector expected_metrics; - + metrics = metric_set_t(VERSION); typedef metric_t::ushort_t ushort_t; const float focus1[] = {2.24664021f, 2.1896739f, 0, 0}; const ushort_t p90_1[] = {302, 273, 0, 0}; - expected_metrics.push_back(metric_t(7, 1114, 1, interop::util::csharp_date_time(9859129975844165472ul), to_vector(p90_1), to_vector(focus1))); + metrics.insert(metric_t(7, 1114, 1, interop::util::csharp_date_time(9859129975844165472ul), to_vector(p90_1), to_vector(focus1))); const float focus2[] = {2.23177338f, 2.20616174f, 0, 0}; const ushort_t p90_2[] = {312, 273, 0, 0}; - expected_metrics.push_back(metric_t(7, 1214, 1, interop::util::csharp_date_time(9859129975872781680ul), to_vector(p90_2), to_vector(focus2))); + metrics.insert(metric_t(7, 1214, 1, interop::util::csharp_date_time(9859129975872781680ul), to_vector(p90_2), to_vector(focus2))); const float focus3[] = {2.10524225f, 2.14023066f, 0, 0}; const ushort_t p90_3[] = {349, 302, 0, 0}; - expected_metrics.push_back(metric_t(7, 2114, 1, interop::util::csharp_date_time(9859129975901427921ul), to_vector(p90_3), to_vector(focus3))); + metrics.insert(metric_t(7, 2114, 1, interop::util::csharp_date_time(9859129975901427921ul), to_vector(p90_3), to_vector(focus3))); - return expected_metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() - { - return header_t(); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - const int tmp[] = {2,38,7,0,90,4,1,0,-12,-56,15,64,-98,35,12,64,0,0,0,0,0,0,0,0,46,1,17,1,0,0,0,0,96,-41,-104,36,122,-86,-46,-120 - ,7,0,-66,4,1,0,96,-43,14,64,-63,49,13,64,0,0,0,0,0,0,0,0,56,1,17,1,0,0,0,0,112,125,77,38,122,-86,-46,-120 - ,7,0,66,8,1,0,74,-68,6,64,-118,-7,8,64,0,0,0,0,0,0,0,0,93,1,46,1,0,0,0,0,-47,-104,2,40,122,-86,-46,-120 + const int tmp[] = + { + 2,38,7,0,90,4,1,0,-12,-56,15,64,-98,35,12,64,0,0,0,0,0,0,0,0,46,1,17,1,0,0,0,0,96,-41,-104,36,122,-86,-46,-120 + ,7,0,-66,4,1,0,96,-43,14,64,-63,49,13,64,0,0,0,0,0,0,0,0,56,1,17,1,0,0,0,0,112,125,77,38,122,-86,-46,-120 + ,7,0,66,8,1,0,74,-68,6,64,-118,-7,8,64,0,0,0,0,0,0,0,0,93,1,46,1,0,0,0,0,-47,-104,2,40,122,-86,-46,-120 }; - return to_string(tmp); - } - /** Get reads describing data - * - * @return reads vector - */ - static std::vector reads() - { - std::vector reads(1, model::run::read_info(1, 1, 2, false)); - return reads; - } - /** Get the summary for these metrics + buffer.assign(tmp, tmp+util::length_of(tmp)); + }/** Get the summary for these metrics * * @return run summary */ - static model::summary::run_summary summary() + static void create_summary(model::summary::run_summary& summary) { - const size_t lane_count=1; - std::vector read_infos = reads(); - model::summary::run_summary summary(read_infos.begin(), read_infos.end(), lane_count); + const size_t lane_count = 1; + const model::run::read_info reads[]={ + model::run::read_info(1, 1, 2, false) + }; + summary.initialize(to_vector(reads), lane_count); summary[0][0].lane(7); summary[0][0].first_cycle_intensity(model::summary::metric_stat(321, 24.75883674621582f, 312)); summary[0][0].cycle_state().extracted_cycle_range(model::run::cycle_range(1, 1)); @@ -90,11 +76,9 @@ namespace illumina{ namespace interop { namespace unittest { summary.nonindex_summary().first_cycle_intensity(321); summary[0][0].tile_count(3); summary.cycle_state().extracted_cycle_range(model::run::cycle_range(1, 1)); - return summary; } }; + - /** Interface between fixtures and Google Test */ - template - struct extraction_metrics_test : public ::testing::Test, public TestSetup { }; }}} + diff --git a/src/tests/interop/metrics/inc/image_metrics_test.h b/src/tests/interop/metrics/inc/image_metrics_test.h index bffd43f92..2ff3aa9c6 100644 --- a/src/tests/interop/metrics/inc/image_metrics_test.h +++ b/src/tests/interop/metrics/inc/image_metrics_test.h @@ -7,35 +7,32 @@ * @copyright GNU Public License. */ #pragma once -#include -#include "metric_test.h" +#include "src/tests/interop/metrics/inc/metric_test.h" #include "interop/model/metrics/image_metric.h" +#include "interop/util/length_of.h" -namespace illumina{ namespace interop { namespace unittest { +namespace illumina{ namespace interop { namespace unittest +{ - /** This test compares byte values taken from an InterOp file for three records produced by RTA 2.7.x - * to the values displayed in SAV. - * - * Regression Test: 1947950_117213Bin2R0I + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::image_metric * @note Version 1 */ - struct image_v1 : metric_test + struct image_metric_v1 : metric_test { enum{ /** Do not check the expected binary data */ disable_binary_data=true // The order here could change }; - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() + static void create_metric_set(metric_set_t& metrics) { - std::vector expected_metrics; - - + metrics = metric_set_t(VERSION); typedef metric_t::ushort_t ushort_t; const ushort_t channel_count = metric_t::MAX_CHANNELS; const ushort_t min_contrast1[] = {896, 1725,738,812}; @@ -45,61 +42,52 @@ namespace illumina{ namespace interop { namespace unittest { const ushort_t max_contrast1[] = {4840, 8144,3308,4974}; const ushort_t max_contrast2[] = {4829, 8159,3302,4985}; const ushort_t max_contrast3[] = {4829, 8236,3304,4947}; - expected_metrics.push_back(metric_t(1, 1101, 1, channel_count, to_vector(min_contrast1), to_vector(max_contrast1))); - expected_metrics.push_back(metric_t(1, 1102, 1, channel_count, to_vector(min_contrast2), to_vector(max_contrast2))); - expected_metrics.push_back(metric_t(1, 1103, 1, channel_count, to_vector(min_contrast3), to_vector(max_contrast3))); - - return expected_metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() - { - return header_t(metric_t::MAX_CHANNELS); + metrics.insert(metric_t(1, 1101, 1, channel_count, to_vector(min_contrast1), to_vector(max_contrast1))); + metrics.insert(metric_t(1, 1102, 1, channel_count, to_vector(min_contrast2), to_vector(max_contrast2))); + metrics.insert(metric_t(1, 1103, 1, channel_count, to_vector(min_contrast3), to_vector(max_contrast3))); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - const int tmp[] = {1,12, - 1,0,77,4,1,0,0,0,128,3,232,18, - 1,0,77,4,1,0,1,0,189,6,208,31, - 1,0,77,4,1,0,2,0,226,2,236,12, - 1,0,77,4,1,0,3,0,44,3,110,19, - 1,0,78,4,1,0,0,0,140,3,221,18, - 1,0,78,4,1,0,1,0,234,6,223,31, - 1,0,78,4,1,0,2,0,227,2,230,12, - 1,0,78,4,1,0,3,0,38,3,121,19, - 1,0,79,4,1,0,0,0,155,3,221,18, - 1,0,79,4,1,0,1,0,37,7,44,32, - 1,0,79,4,1,0,2,0,222,2,232,12, - 1,0,79,4,1,0,3,0,34,3,83,19 + const int tmp[] = + {1,12, + 1,0,77,4,1,0,0,0,128,3,232,18, + 1,0,77,4,1,0,1,0,189,6,208,31, + 1,0,77,4,1,0,2,0,226,2,236,12, + 1,0,77,4,1,0,3,0,44,3,110,19, + 1,0,78,4,1,0,0,0,140,3,221,18, + 1,0,78,4,1,0,1,0,234,6,223,31, + 1,0,78,4,1,0,2,0,227,2,230,12, + 1,0,78,4,1,0,3,0,38,3,121,19, + 1,0,79,4,1,0,0,0,155,3,221,18, + 1,0,79,4,1,0,1,0,37,7,44,32, + 1,0,79,4,1,0,2,0,222,2,232,12, + 1,0,79,4,1,0,3,0,34,3,83,19 }; - return to_string(tmp); + buffer.assign(tmp, tmp+util::length_of(tmp)); } }; - /** This test compares byte values taken from an InterOp file for three records produced by RTA 2.7.x - * to the values displayed in SAV. + + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::image_metric * @note Version 2 */ - struct image_v2 : metric_test + struct image_metric_v2 : metric_test { - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() + static void create_metric_set(metric_set_t& metrics) { - std::vector expected_metrics; - - + metrics = metric_set_t(header_t(2), VERSION); typedef metric_t::ushort_t ushort_t; - const ushort_t channel_count = header().channel_count(); + const ushort_t channel_count = metrics.channel_count(); const ushort_t min_contrast1[] = {231, 207}; const ushort_t min_contrast2[] = {229, 205}; const ushort_t min_contrast3[] = {231, 222}; @@ -107,37 +95,27 @@ namespace illumina{ namespace interop { namespace unittest { const ushort_t max_contrast1[] = {462, 387}; const ushort_t max_contrast2[] = {457, 387}; const ushort_t max_contrast3[] = {473, 416}; - expected_metrics.push_back(metric_t(7, 1114, 1, channel_count, to_vector(min_contrast1), to_vector(max_contrast1))); - expected_metrics.push_back(metric_t(7, 1214, 1, channel_count, to_vector(min_contrast2), to_vector(max_contrast2))); - expected_metrics.push_back(metric_t(7, 2114, 1, channel_count, to_vector(min_contrast3), to_vector(max_contrast3))); - - - return expected_metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() - { - return header_t(2); + metrics.insert(metric_t(7, 1114, 1, channel_count, to_vector(min_contrast1), to_vector(max_contrast1))); + metrics.insert(metric_t(7, 1214, 1, channel_count, to_vector(min_contrast2), to_vector(max_contrast2))); + metrics.insert(metric_t(7, 2114, 1, channel_count, to_vector(min_contrast3), to_vector(max_contrast3))); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - const int tmp[] = {2,14,2 - ,7,0,90,4,1,0,-25,0,-49,0,-50,1,-125,1 - ,7,0,-66,4,1,0,-27,0,-51,0,-55,1,-125,1 - ,7,0,66,8,1,0,-25,0,-34,0,-39,1,-96,1 + const int tmp[] = + { + 2,14,2 + ,7,0,90,4,1,0,-25,0,-49,0,-50,1,-125,1 + ,7,0,-66,4,1,0,-27,0,-51,0,-55,1,-125,1 + ,7,0,66,8,1,0,-25,0,-34,0,-39,1,-96,1 }; - return to_string(tmp); + buffer.assign(tmp, tmp+util::length_of(tmp)); } }; - /** Interface between fixtures and Google Test */ - template - struct image_metrics_test : public ::testing::Test, public TestSetup { }; }}} + diff --git a/src/tests/interop/metrics/inc/index_metrics_test.h b/src/tests/interop/metrics/inc/index_metrics_test.h index 7284f6979..8d87abf6e 100644 --- a/src/tests/interop/metrics/inc/index_metrics_test.h +++ b/src/tests/interop/metrics/inc/index_metrics_test.h @@ -7,24 +7,22 @@ * @copyright GNU Public License. */ #pragma once -#include -#include "metric_test.h" +#include "src/tests/interop/metrics/inc/metric_test.h" #include "interop/model/metrics/index_metric.h" #include "interop/model/run/info.h" #include "interop/model/summary/index_flowcell_summary.h" +#include "interop/util/length_of.h" -namespace illumina{ namespace interop { namespace unittest { +namespace illumina{ namespace interop { namespace unittest +{ - /** This test compares byte values taken from an InterOp file for three records produced by RTA 2.7.x - * to the values displayed in SAV. - * - * This metric was artificially changed to give it three unique records. The lane was changed from 1 to 2 and 3 - * for the second and third records. + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::index_metric * @note Version 1 */ - struct index_v1 : metric_test + struct index_metric_v1 : metric_test { enum{ /** Do not check record size (does not have it)*/ @@ -32,90 +30,71 @@ namespace illumina{ namespace interop { namespace unittest { /** Do not check the expected binary data size */ disable_binary_data_size=true }; - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() + static void create_metric_set(metric_set_t& metrics) { - std::vector expected_metrics; typedef metric_t::index_info_t index_info_t; - - + metrics = metric_set_t(VERSION); metric_t::index_array_t indices1; indices1.push_back(index_info_t("ATCACGAC-AAGGTTCA", "1", "TSCAIndexes", 4570)); - expected_metrics.push_back(metric_t(1, 12106, 3, indices1)); + metrics.insert(metric_t(7, 1114, 3, indices1)); metric_t::index_array_t indices2; indices2.push_back(index_info_t("ACAGTGGT-AAGGTTCA", "2", "TSCAIndexes", 4477)); - expected_metrics.push_back(metric_t(2, 12106, 3, indices2)); + metrics.insert(metric_t(7, 1214, 3, indices2)); metric_t::index_array_t indices3; indices3.push_back(index_info_t("CAGATCCA-AAGGTTCA", "3", "TSCAIndexes", 4578)); - expected_metrics.push_back(metric_t(3, 12106, 3, indices3)); - - return expected_metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() - { - return header_t(); + metrics.insert(metric_t(7, 2114, 3, indices3)); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - const int tmp[] = {1 - ,1,0,74,47,3,0 - ,17,0,65,84,67,65,67,71,65,67,45,65,65,71,71,84,84,67,65,218,17,0,0,1,0,49,11,0,84,83,67,65,73,110 - ,100,101,120,101,115 - ,2,0,74,47,3,0 // changed to lane 2 - ,17,0,65,67,65,71,84,71,71,84,45,65,65,71,71,84,84,67,65,125,17,0,0,1,0,50,11,0,84,83,67,65,73,110 - ,100,101,120,101,115 - ,3,0,74,47,3,0 // changed to lane 3 - ,17,0,67,65,71,65,84,67,67,65,45,65,65,71,71,84,84,67,65,226,17,0,0,1,0,51,11,0,84,83,67,65,73,110 - ,100,101,120,101,115 + const int tmp[] = + { + 1 + ,7,0,90,4,3,0 + ,17,0,65,84,67,65,67,71,65,67,45,65,65,71,71,84,84,67,65,218,17,0,0,1,0,49,11,0,84,83,67,65,73,110 + ,100,101,120,101,115 + ,7,0,-66,4,3,0 + ,17,0,65,67,65,71,84,71,71,84,45,65,65,71,71,84,84,67,65,125,17,0,0,1,0,50,11,0,84,83,67,65,73,110 + ,100,101,120,101,115 + ,7,0,66,8,3,0 + ,17,0,67,65,71,65,84,67,67,65,45,65,65,71,71,84,84,67,65,226,17,0,0,1,0,51,11,0,84,83,67,65,73,110 + ,100,101,120,101,115 }; - return to_string(tmp); + buffer.assign(tmp, tmp+util::length_of(tmp)); } - /** Get the expected run info + /** Get the summary for these metrics * - * @return expected run info + * @return index_summary index summary */ - static model::run::info run_info() - { - std::vector reads(1, model::run::read_info(1, 1, 3, false)); - std::vector channels; - channels.push_back("Red"); - channels.push_back("Green"); - model::run::info run_info("XX", - "", - 1, - model::run::flowcell_layout(8), - channels, - model::run::image_dimensions(), - reads); - return run_info; - } - /** Get the expected index summary - * - * @return expected index summary - */ - static model::summary::index_flowcell_summary summary() + static void create_summary(model::summary::index_flowcell_summary& index_summary) { const float NaN = std::numeric_limits::quiet_NaN(); - model::summary::index_flowcell_summary index_summary(8); + index_summary.resize(8); for(size_t lane = 0;lane - struct index_metrics_test : public ::testing::Test, public TestSetup { }; + }}} + diff --git a/src/tests/interop/metrics/inc/metric_format_fixtures.h b/src/tests/interop/metrics/inc/metric_format_fixtures.h new file mode 100644 index 000000000..6ea80549e --- /dev/null +++ b/src/tests/interop/metrics/inc/metric_format_fixtures.h @@ -0,0 +1,45 @@ +/** Fixtures for all the metric formats + * + * + * @file + * @date 9/21/16 + * @version 1.0 + * @copyright GNU Public License. + */ +#pragma once + +#include "interop/model/run_metrics.h" +#include "src/tests/interop/metrics/inc/corrected_intensity_metrics_test.h" +#include "src/tests/interop/metrics/inc/error_metrics_test.h" +#include "src/tests/interop/metrics/inc/extraction_metrics_test.h" +#include "src/tests/interop/metrics/inc/image_metrics_test.h" +#include "src/tests/interop/metrics/inc/index_metrics_test.h" +#include "src/tests/interop/metrics/inc/q_collapsed_metrics_test.h" +#include "src/tests/interop/metrics/inc/q_metrics_test.h" +#include "src/tests/interop/metrics/inc/tile_metrics_test.h" + +namespace illumina{ namespace interop { namespace unittest +{ + + + typedef ::testing::Types + < + corrected_intensity_metric_v2, + corrected_intensity_metric_v3, + error_metric_v3, + extraction_metric_v2, + image_metric_v1, + image_metric_v2, + index_metric_v1, + q_collapsed_metric_v2, + q_collapsed_metric_v6, + q_metric_v4, + q_metric_v5, + q_metric_v6, + q_metric_v6_unbinned, + tile_metric_v2 + > PublicFormats; + + +}}} + diff --git a/src/tests/interop/metrics/inc/metric_generator.h b/src/tests/interop/metrics/inc/metric_generator.h index ab08fd5a5..afd9440ff 100644 --- a/src/tests/interop/metrics/inc/metric_generator.h +++ b/src/tests/interop/metrics/inc/metric_generator.h @@ -10,7 +10,8 @@ #include "src/tests/interop/inc/regression_test_data.h" #include "src/tests/interop/inc/abstract_regression_test_generator.h" -namespace illumina{ namespace interop { namespace unittest { +namespace illumina{ namespace interop { namespace unittest +{ /** Generate the actual metric set by reading in from hardcoded binary buffer * @@ -30,15 +31,10 @@ namespace illumina{ namespace interop { namespace unittest { bool generate(metric_set_t& expected, metric_set_t& actual)const { actual.clear(); - Gen::create_expected(expected); + Gen::create_metric_set(expected); std::vector< ::uint8_t > binary_data; Gen::create_binary_data(binary_data); - try - { - io::read_interop_from_string(binary_data, - actual); - } - catch (const std::exception &) { } + io::read_interop_from_string(binary_data, actual); return true; } /** Create a copy of this object @@ -46,6 +42,14 @@ namespace illumina{ namespace interop { namespace unittest { * @return pointer to copy */ parent_t clone()const{return new hardcoded_metric_generator;} + /** Write generator info to output stream + * + * @param out output stream + */ + void write(std::ostream& out)const + { + out << "hardcoded_metric_generator<" << Gen::name() << ">"; + } }; /** Generate the actual metric set writing out the expected and reading it back in again @@ -58,6 +62,8 @@ namespace illumina{ namespace interop { namespace unittest { typedef typename Gen::metric_set_t metric_set_t; typedef typename abstract_generator::base_type parent_t; public: + /** Constructor */ + write_read_metric_generator() : abstract_generator< typename Gen::metric_set_t >(1){} /** Generate the expected and actual metric sets * * @param expected expected metric set @@ -66,19 +72,10 @@ namespace illumina{ namespace interop { namespace unittest { bool generate(metric_set_t& expected, metric_set_t& actual)const { actual.clear(); - Gen::create_expected(expected); + Gen::create_metric_set(expected); std::ostringstream fout; - try - { - illumina::interop::io::write_metrics(fout, expected); - } - catch (const std::exception &) { } - try - { - io::read_interop_from_string(fout.str(), - actual); - } - catch (const std::exception &) { } + illumina::interop::io::write_metrics(fout, expected); + io::read_interop_from_string(fout.str(), actual); return true; } /** Create a copy of this object @@ -86,6 +83,14 @@ namespace illumina{ namespace interop { namespace unittest { * @return pointer to copy */ parent_t clone()const{return new write_read_metric_generator;} + /** Write generator info to output stream + * + * @param out output stream + */ + void write(std::ostream& out)const + { + out << "write_read_metric_generator<" << Gen::name() << ">"; + } }; /** Generate the actual metric set writing out the expected and reading it back in again * @@ -100,10 +105,20 @@ namespace illumina{ namespace interop { namespace unittest { public: typedef typename abstract_regression_test_generator< MetricSet >::parent_type parent_type; public: - regression_test_metric_generator(const std::string& test_dir) : parent_t(test_dir) + /** Constructor + * + * @param test_dir subdirectory for baseline data + */ + regression_test_metric_generator(const std::string& test_dir) : parent_t(test_dir, 2) { } - regression_test_metric_generator(const std::string& run_folder, const std::string& test_dir) : parent_t(run_folder, test_dir) + /** Constructor + * + * @param run_folder run folder + * @param test_dir subdirectory for baseline data + */ + regression_test_metric_generator(const std::string& run_folder, const std::string& test_dir) : + parent_t(run_folder, test_dir, 2) { } @@ -120,8 +135,10 @@ namespace illumina{ namespace interop { namespace unittest { { illumina::interop::io::read_interop(baseline_file, expected); } - catch(const io::incomplete_file_exception&){} - catch(const io::file_not_found_exception&){} + // Should never have an incomplete file in baseline, set sentinel to detect + catch(const io::incomplete_file_exception&){expected.set_version(250);} + // Ensure missing file is expected + catch(const io::file_not_found_exception&){expected.set_version(251);} } /** Read the actual data from the run folder * @@ -135,7 +152,10 @@ namespace illumina{ namespace interop { namespace unittest { { illumina::interop::io::read_interop(run_folder, actual); } - catch(const io::incomplete_file_exception&){} + // Ensure missing file is expected + catch(const io::incomplete_file_exception&){if(actual.empty()) actual.set_version(251);} + // Ensure file is missing + catch(const io::file_not_found_exception&){actual.set_version(251);} } /** Write the actual data to the run folder * @@ -156,42 +176,17 @@ namespace illumina{ namespace interop { namespace unittest { { return new regression_test_metric_generator(parent_t::m_run_folder, parent_t::m_test_dir); } - }; - - /** Generate the actual binary data by writing out the expected metric set - * - * The expected binary data is provided by the generator. - */ - template - class write_metric_generator : public abstract_generator< std::string > - { - typedef typename Gen::metric_set_t metric_set_t; - typedef typename abstract_generator::base_type parent_t; - public: - /** Generate the expected and actual metric sets + /** Write generator info to output stream * - * @param expected expected binary buffer - * @param actual actual binary buffer + * @param out output stream */ - bool generate(std::string& expected, std::string& actual)const + void write(std::ostream& out)const { - Gen::create_binary_data(expected); - metric_set_t metrics; - Gen::create_expected(metrics); - std::ostringstream fout; - try - { - illumina::interop::io::write_metrics(fout, metrics); - } - catch (const std::exception &) { } - actual = fout.str(); - return true; + out << "regression_test_metric_generator< "<< metric_set_t::prefix() << metric_set_t::suffix() << "> - " + << io::basename(parent_t::m_run_folder); } - /** Create a copy of this object - * - * @return pointer to copy - */ - parent_t clone()const{return new write_metric_generator;} }; + }}} + diff --git a/src/tests/interop/metrics/inc/metric_stream_tests.hpp b/src/tests/interop/metrics/inc/metric_stream_tests.hpp deleted file mode 100644 index 0cf950861..000000000 --- a/src/tests/interop/metrics/inc/metric_stream_tests.hpp +++ /dev/null @@ -1,115 +0,0 @@ -/** Unit tests for various failure conditions handled by exceptions. - * - * - * @file - * @date 10/6/2015 - * @version 1.0 - * @copyright GNU Public License. - */ - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4127) // MSVC warns about using constants in conditional statements, for template constants -#endif - -/** Wrapper for X-Macro FIXTURE - * - */ -#define WRAPPED_TEST(FIXTURE, FUNC) TEST_P(FIXTURE, FUNC) - - -/** - * Confirm binary write matches expected binary data - */ -WRAPPED_TEST(FIXTURE, test_write_read_binary_data) -{ -# ifdef INTEROP_BINARY_DATA_SIZE_CHECK - return; -# endif - EXPECT_EQ(expected.size(), actual.size()); -# ifdef INTEROP_BINARY_DATA_CHECK - return; -# endif - for(::uint32_t i=0;i10); -} -/** Confirm incomplete_file_exception is thrown for a mostly complete file - */ -WRAPPED_TEST(FIXTURE, test_hardcoded_incomplete_file_exception_last_metric) -{ - metric_set_t metrics; - EXPECT_THROW(illumina::interop::io::read_interop_from_string(expected.substr(0,expected.length()-4), metrics), incomplete_file_exception); -} -/** Confirm bad_format_exception is thrown when record size is incorrect - */ -WRAPPED_TEST(FIXTURE, test_hardcoded_incorrect_record_size) -{ -# ifdef INTEROP_SKIP_RECORD_SIZE_CHECK - return; -# endif - std::string tmp = std::string(expected); - tmp[1] = 0; - metric_set_t metrics; - EXPECT_THROW(illumina::interop::io::read_interop_from_string(tmp, metrics), bad_format_exception); -} -/** Confirm file_not_found_exception is thrown when a file is not found - */ -WRAPPED_TEST(FIXTURE, test_hardcoded_file_not_found) -{ - metric_set_t metrics; - EXPECT_THROW(illumina::interop::io::read_interop("/NO/FILE/EXISTS", metrics), file_not_found_exception); -} -/** Confirm reading from good data does not throw an exception - */ -WRAPPED_TEST(FIXTURE, test_hardcoded_read) -{ - std::string tmp = std::string(expected); - metric_set_t metrics; - EXPECT_NO_THROW(illumina::interop::io::read_interop_from_string(tmp, metrics)); -} -/** Confirm the clear function works - */ -WRAPPED_TEST(FIXTURE, test_clear) -{ - std::string tmp = std::string(expected); - metric_set_t metrics; - EXPECT_NO_THROW(illumina::interop::io::read_interop_from_string(tmp, metrics)); - size_t cnt = metrics.size(); - metrics.clear(); - EXPECT_NO_THROW(illumina::interop::io::read_interop_from_string(tmp, metrics)); - EXPECT_EQ(cnt, metrics.size()); - -} - -#ifdef _MSC_VER -#pragma warning(pop) -#endif diff --git a/src/tests/interop/metrics/inc/metric_test.h b/src/tests/interop/metrics/inc/metric_test.h index f51941e01..a715581fe 100644 --- a/src/tests/interop/metrics/inc/metric_test.h +++ b/src/tests/interop/metrics/inc/metric_test.h @@ -11,6 +11,7 @@ #include #include "interop/model/metric_base/metric_set.h" #include "interop/io/metric_file_stream.h" +#include "interop/util/length_of.h" namespace illumina{ namespace interop { namespace unittest { @@ -61,6 +62,14 @@ namespace illumina{ namespace interop { namespace unittest { typedef typename metric_set_t::const_iterator const_iterator; public: + /** Get name of the test generator + * + * @return name of metric plus version of format + */ + static std::string name() + { + return std::string() + Metric::prefix()+Metric::suffix()+util::lexical_cast(VERSION); + } /** Convert an array to a vector * * Determines the length of the stack array automatically. @@ -73,17 +82,6 @@ namespace illumina{ namespace interop { namespace unittest { { return std::vector(vals, vals + N); } - /** Get size of stack array - * - * Determines the length of the stack array automatically. - * - * @return size of stack array - */ - template - static size_t size_of(const T (&)[N]) - { - return N; - } /** Convert an array to a vector * * Determines the length of the stack array automatically. @@ -99,98 +97,7 @@ namespace illumina{ namespace interop { namespace unittest { vec[vals[i].offset] = vals[i].value; return vec; } - /** Set expected binary data - * - * @param tmp int array of byte values - * @return string of byte values - */ - template - static std::string to_string(const int (&tmp)[N]) - { - std::string binary_data=""; - for (size_t i = 0; i < N; ++i) binary_data += char(tmp[i]); - return binary_data; - } }; - /** Generic fixture base class */ - template - struct metric_test_fixture : public Gen - { - /** Metric type */ - typedef typename Gen::metric_t metric_t; - /** Metric set type */ - typedef typename Gen::metric_set_t metric_set_t; - /** Constructor - * - */ - metric_test_fixture() : expected_metric_set(Gen::metrics(), Gen::VERSION, Gen::header()), - expected_binary_data(Gen::binary_data()) - { - } - /** Read metrics from a binary buffer - * - * @param data binary buffer - * @param metrics metric set - */ - static void read_metrics(const std::string& data, metric_set_t& metrics) - { - try - { - illumina::interop::io::read_interop_from_string(data, metrics); - } - catch (const std::exception &) { } - } - - public: - /** Expected metric set */ - metric_set_t expected_metric_set; - /** Expected buffer of binary metric data */ - std::string expected_binary_data; - /** Actual metric set */ - metric_set_t actual_metric_set; - /** Actual buffer of binary metric data */ - std::string actual_binary_data; - }; - - /** Setup up a hardcoded metric test */ - template - class hardcoded_fixture : public metric_test_fixture - { - typedef metric_test_fixture fixture_t; - public: - /** Construct hard coded test */ - hardcoded_fixture() - { - fixture_t::read_metrics(fixture_t::expected_binary_data,fixture_t::actual_metric_set); - std::ostringstream fout; - illumina::interop::io::write_metrics(fout, fixture_t::actual_metric_set, T::VERSION); - fixture_t::actual_binary_data = fout.str(); - } - }; - - /** Sets up a write read test */ - template - class write_read_fixture : public metric_test_fixture - { - typedef metric_test_fixture fixture_t; - public: - /** Construct write read test */ - write_read_fixture() - { - { - std::ostringstream fout; - illumina::interop::io::write_metrics(fout, fixture_t::expected_metric_set, T::VERSION); - fixture_t::expected_binary_data = fout.str(); - } - fixture_t::read_metrics(fixture_t::expected_binary_data,fixture_t::actual_metric_set); - { - std::ostringstream fout; - illumina::interop::io::write_metrics(fout, fixture_t::actual_metric_set, T::VERSION); - fixture_t::actual_binary_data = fout.str(); - } - } - }; - - }}} + diff --git a/src/tests/interop/metrics/inc/q_collapsed_metrics_test.h b/src/tests/interop/metrics/inc/q_collapsed_metrics_test.h index 006cb2d4d..741c268c6 100644 --- a/src/tests/interop/metrics/inc/q_collapsed_metrics_test.h +++ b/src/tests/interop/metrics/inc/q_collapsed_metrics_test.h @@ -7,66 +7,56 @@ * @copyright GNU Public License. */ #pragma once -#include -#include "metric_test.h" +#include "src/tests/interop/metrics/inc/metric_test.h" #include "interop/model/metrics/q_collapsed_metric.h" +#include "interop/util/length_of.h" -namespace illumina{ namespace interop { namespace unittest { - /** This test compares byte values taken from an InterOp file for three records produced by RTA 2.7.x - * to the values displayed in SAV. - * - * Regression set: 1947950_117213Bin2R0I +namespace illumina{ namespace interop { namespace unittest +{ + + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::q_collapsed_metric * @note Version 2 */ - struct q_collapsed_v2 : metric_test + struct q_collapsed_metric_v2 : metric_test { - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() + static void create_metric_set(metric_set_t& metrics) { - std::vector expected_metrics; - expected_metrics.push_back(metric_t(1,1105,1,2447414,2334829,2566750,33)); - expected_metrics.push_back(metric_t(1,1103,1,2436317,2327796,2543605,33)); - expected_metrics.push_back(metric_t(1,1106,1,2474217,2366046,2583629,33)); - - return expected_metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() - { - typedef header_t::qscore_bin_vector_type qscore_bin_vector_type; - qscore_bin_vector_type headervec; - return header_t(headervec); + metrics = metric_set_t(VERSION); + metrics.insert(metric_t(1,1105,1,2447414,2334829,2566750,33)); + metrics.insert(metric_t(1,1103,1,2436317,2327796,2543605,33)); + metrics.insert(metric_t(1,1106,1,2474217,2366046,2583629,33)); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - const int tmp[] = { + const int tmp[] = + { 2,22 ,1,0,81,4,1,0,54,88,37,0,109,-96,35,0,94,42,39,0,0,0,4,66 ,1,0,79,4,1,0,-35,44,37,0,-12,-124,35,0,-11,-49,38,0,0,0,4,66 ,1,0,82,4,1,0,-23,-64,37,0,94,26,36,0,77,108,39,0,0,0,4,66 }; - return to_string(tmp); + buffer.assign(tmp, tmp+util::length_of(tmp)); } }; - /** This test writes three records of an InterOp files, then reads them back in and compares - * each value to ensure they did not change. + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::q_collapsed_metric * @note Version 6 */ - struct q_collapsed_v6 : metric_test + struct q_collapsed_metric_v6 : metric_test { enum{ /** Do not check the expected binary data */ @@ -74,23 +64,11 @@ namespace illumina{ namespace interop { namespace unittest { /** Do not check the expected binary data size */ disable_binary_data_size=true }; - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() - { - std::vector expected_metrics; - expected_metrics.push_back(metric_t(1,1105,1,2447414,2334829,2566750,33)); - expected_metrics.push_back(metric_t(1,1103,1,2436317,2327796,2543605,33)); - expected_metrics.push_back(metric_t(1,1106,1,2474217,2366046,2583629,33)); - return expected_metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() + static void create_metric_set(metric_set_t& metrics) { typedef header_t::qscore_bin_vector_type qscore_bin_vector_type; typedef header_t::bin_t bin_t; @@ -104,25 +82,30 @@ namespace illumina{ namespace interop { namespace unittest { qscore_bin_vector_type headervec; for(uint_t i=0;i + static void create_binary_data(Collection& buffer) { - const int tmp[] = { + const int tmp[] = + { 6,22,1,7,2,10,20,25,30,35,40,9,19,24,29,34,39,40,2,14,21,27,32,36,40 ,1,0,81,4,1,0,54,88,37,0,109,-96,35,0,94,42,39,0,0,0,4,66 ,1,0,79,4,1,0,-35,44,37,0,-12,-124,35,0,-11,-49,38,0,0,0,4,66 ,1,0,82,4,1,0,-23,-64,37,0,94,26,36,0,77,108,39,0,0,0,4,66 }; - return to_string(tmp); + buffer.assign(tmp, tmp+util::length_of(tmp)); } }; + - /** Interface between fixtures and Google Test */ - template - struct q_collapsed_metrics_test : public ::testing::Test, public TestSetup { }; }}} + diff --git a/src/tests/interop/metrics/inc/q_metrics_test.h b/src/tests/interop/metrics/inc/q_metrics_test.h index 31528858f..ff125269e 100644 --- a/src/tests/interop/metrics/inc/q_metrics_test.h +++ b/src/tests/interop/metrics/inc/q_metrics_test.h @@ -7,30 +7,29 @@ * @copyright GNU Public License. */ #pragma once -#include -#include "metric_test.h" +#include "src/tests/interop/metrics/inc/metric_test.h" #include "interop/model/metrics/q_metric.h" #include "interop/model/summary/run_summary.h" +#include "interop/util/length_of.h" -namespace illumina{ namespace interop { namespace unittest { - /** This test compares byte values taken from an InterOp file for three records produced by RTA 2.7.x - * to the values displayed in SAV. - * - * Regression set: 1947950_117213Bin2R0I +namespace illumina{ namespace interop { namespace unittest +{ + + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::q_metric * @note Version 4 */ - struct q_v4 : metric_test + struct q_metric_v4 : metric_test { - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() + static void create_metric_set(metric_set_t& metrics) { - std::vector expected_metrics; - + metrics = metric_set_t(VERSION); typedef metric_t::uint_t uint_t; typedef sparse_value q_val; @@ -39,65 +38,47 @@ namespace illumina{ namespace interop { namespace unittest { const q_val hist2[] = {q_val(14,22647), q_val(21,9570), q_val(26,81839), q_val(32,2413227)}; const q_val hist3[] = {q_val(14,18878), q_val(21,8168), q_val(26,72634), q_val(32,2342292)}; - expected_metrics.push_back(metric_t(1, 1104, 1, to_vector(hist1))); - expected_metrics.push_back(metric_t(1, 1106, 1, to_vector(hist2))); - expected_metrics.push_back(metric_t(1, 1104, 2, to_vector(hist3))); - - - return expected_metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() - { - typedef header_t::qscore_bin_vector_type qscore_bin_vector_type; - qscore_bin_vector_type headervec; - return header_t(headervec); + metrics.insert(metric_t(1, 1104, 1, to_vector(hist1))); + metrics.insert(metric_t(1, 1106, 1, to_vector(hist2))); + metrics.insert(metric_t(1, 1104, 2, to_vector(hist3))); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - const int tmp[] = { - 4,206, - 1,0,80,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,216,82,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,91 - ,29,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,158,178,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,0,82,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,119,88,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,98,37,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,175,63,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,171,210,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,0,80,4,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,190,73,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,232,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,186,27,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,148,189,35,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0 + const int tmp[] = + { + 4,206, + 1,0,80,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,216,82,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,91 + ,29,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,158,178,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,0,82,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,119,88,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,98,37,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,175,63,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,171,210,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,0,80,4,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,190,73,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,232,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,186,27,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,148,189,35,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0 }; - return to_string(tmp); - } - /** Get reads describing data - * - * @return reads vector - */ - static std::vector reads() - { - std::vector reads(1, model::run::read_info(1, 1, 3, false)); - return reads; - } - /** Get the summary for these metrics + buffer.assign(tmp, tmp+util::length_of(tmp)); + }/** Get the summary for these metrics * * @return run summary */ - static model::summary::run_summary summary() + static void create_summary(model::summary::run_summary& summary) { - std::vector read_infos = reads(); - model::summary::run_summary summary(read_infos.begin(), read_infos.end(), 1); + const size_t lane_count = 1; + const model::run::read_info reads[]={ + model::run::read_info(1, 1, 3, false) + }; + summary.initialize(to_vector(reads), lane_count); summary[0][0].tile_count(2); summary[0][0].projected_yield_g(0.0098816361278295517); summary[0][0].yield_g(0.0074112270958721638f); @@ -113,43 +94,21 @@ namespace illumina{ namespace interop { namespace unittest { summary.nonindex_summary().projected_yield_g(0.0098816361278295517); summary.nonindex_summary().yield_g(0.0074112270958721638f); summary.cycle_state().qscored_cycle_range(model::run::cycle_range(1, 2)); - return summary; } }; - /** This test writes three records of an InterOp files, then reads them back in and compares - * each value to ensure they did not change. + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::q_metric * @note Version 5 */ - struct q_v5 : metric_test // TODO: Add binned + struct q_metric_v5 : metric_test { - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() - { - std::vector expected_metrics; - - typedef metric_t::uint_t uint_t; - typedef sparse_value q_val; - - const q_val hist1[] = {q_val(1,45272), q_val(3,33369), q_val(4,1784241)}; - const q_val hist2[] = {q_val(1,45229), q_val(3,34304), q_val(4,1792186)}; - const q_val hist3[] = {q_val(1,49152), q_val(3,37440), q_val(4,1806479)}; - - expected_metrics.push_back(metric_t(1, 1103, 1, to_vector(hist1))); - expected_metrics.push_back(metric_t(1, 1104, 1, to_vector(hist2))); - expected_metrics.push_back(metric_t(1, 1108, 1, to_vector(hist3))); - - return expected_metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() + static void create_metric_set(metric_set_t& metrics) { typedef header_t::qscore_bin_vector_type qscore_bin_vector_type; typedef header_t::bin_t bin_t; @@ -162,53 +121,58 @@ namespace illumina{ namespace interop { namespace unittest { qscore_bin_vector_type headervec; for(uint_t i=0;i q_val; + + const q_val hist1[] = {q_val(1,45272), q_val(3,33369), q_val(4,1784241)}; + const q_val hist2[] = {q_val(1,45229), q_val(3,34304), q_val(4,1792186)}; + const q_val hist3[] = {q_val(1,49152), q_val(3,37440), q_val(4,1806479)}; + + metrics.insert(metric_t(1, 1103, 1, to_vector(hist1))); + metrics.insert(metric_t(1, 1104, 1, to_vector(hist2))); + metrics.insert(metric_t(1, 1108, 1, to_vector(hist3))); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - const int tmp[] = { - 5,206, - 1,7, - 1,10,20,25,30,35,40,9,19,24,29,34,39,41,1,14,22,27,33,37,40, - 1,0,79,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,216,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,89,130,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,177,57,27,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0, - 1,0,80,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,173,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,0,134,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,186,88,27,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0, - 1,0,84,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,0,64,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,143,144,27,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + const int tmp[] = + { + 5,206, + 1,7, + 1,10,20,25,30,35,40,9,19,24,29,34,39,41,1,14,22,27,33,37,40, + 1,0,79,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,216,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,89,130,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,177,57,27,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0, + 1,0,80,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,173,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,0,134,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,186,88,27,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0, + 1,0,84,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,0,64,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,143,144,27,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; - return to_string(tmp); - } - /** Get reads describing data - * - * @return reads vector - */ - static std::vector reads() - { - std::vector reads(1, model::run::read_info(1, 1, 2, false)); - return reads; - } - /** Get the summary for these metrics + buffer.assign(tmp, tmp+util::length_of(tmp)); + }/** Get the summary for these metrics * * @return run summary */ - static model::summary::run_summary summary() + static void create_summary(model::summary::run_summary& summary) { - std::vector read_infos = reads(); - model::summary::run_summary summary(read_infos.begin(), read_infos.end(), 1); + const size_t lane_count = 1; + const model::run::read_info reads[]={ + model::run::read_info(1, 1, 2, false) + }; + summary.initialize(to_vector(reads), lane_count); summary[0][0].tile_count(3); summary[0][0].projected_yield_g(0.0056276721879839897f); summary[0][0].yield_g(0.0056276721879839897f); @@ -224,42 +188,21 @@ namespace illumina{ namespace interop { namespace unittest { summary.nonindex_summary().projected_yield_g(0.0056276721879839897f); summary.nonindex_summary().yield_g(0.0056276721879839897); summary.cycle_state().qscored_cycle_range(model::run::cycle_range(1, 1)); - return summary; } }; - /** This test writes three records of an InterOp files, then reads them back in and compares - * each value to ensure they did not change. + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::q_metric * @note Version 6 */ - struct q_v6 : metric_test + struct q_metric_v6 : metric_test { - /** Build the expected metric set - * - * @return vector of metrics - */ - static std::vector metrics() - { - std::vector expected_metrics; - typedef metric_t::uint_t uint_t; - - const uint_t hist_all1[] = {0, 267962, 118703, 4284, 2796110, 0, 0}; - const uint_t hist_all2[] = {0,241483, 44960, 1100, 2899568, 0 ,0}; - const uint_t hist_all3[] = {0,212144, 53942, 427, 2920598, 0, 0}; - std::vector hist_tmp(50, 0); - - expected_metrics.push_back(metric_t(7, 1114, 1, to_vector(hist_all1))); - expected_metrics.push_back(metric_t(7, 1114, 2, to_vector(hist_all2))); - expected_metrics.push_back(metric_t(7, 1114, 3,to_vector(hist_all3))); - - return expected_metrics; - } - /** Get the expected metric set header + /** Create the expected metric set * - * @return expected metric set header + * @param metrics destination metric set */ - static header_t header() + static void create_metric_set(metric_set_t& metrics) { typedef header_t::qscore_bin_vector_type qscore_bin_vector_type; typedef header_t::bin_t bin_t; @@ -273,39 +216,44 @@ namespace illumina{ namespace interop { namespace unittest { qscore_bin_vector_type headervec; for(uint_t i=0;i hist_tmp(50, 0); + + metrics.insert(metric_t(7, 1114, 1, to_vector(hist_all1))); + metrics.insert(metric_t(7, 1114, 2, to_vector(hist_all2))); + metrics.insert(metric_t(7, 1114, 3,to_vector(hist_all3))); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - const int tmp[] = { - 6,34,1,7,2,10,20,25,30,35,40,9,19,24,29,34,39,40,2,14,21,27,32,36,40 - ,7,0,90,4,1,0,0,0,0,0,-70,22,4,0,-81,-49,1,0,-68,16,0,0,78,-86,42,0,0,0,0,0,0,0,0,0 - ,7,0,90,4,2,0,0,0,0,0,75,-81,3,0,-96,-81,0,0,76,4,0,0,112,62,44,0,0,0,0,0,0,0,0,0 - ,7,0,90,4,3,0,0,0,0,0,-80,60,3,0,-74,-46,0,0,-85,1,0,0,-106,-112,44,0,0,0,0,0,0,0,0,0 + const int tmp[] = + { + 6,34,1,7,2,10,20,25,30,35,40,9,19,24,29,34,39,40,2,14,21,27,32,36,40 + ,7,0,90,4,1,0,0,0,0,0,-70,22,4,0,-81,-49,1,0,-68,16,0,0,78,-86,42,0,0,0,0,0,0,0,0,0 + ,7,0,90,4,2,0,0,0,0,0,75,-81,3,0,-96,-81,0,0,76,4,0,0,112,62,44,0,0,0,0,0,0,0,0,0 + ,7,0,90,4,3,0,0,0,0,0,-80,60,3,0,-74,-46,0,0,-85,1,0,0,-106,-112,44,0,0,0,0,0,0,0,0,0 }; - return to_string(tmp); - } - /** Get reads describing data - * - * @return reads vector - */ - static std::vector reads() - { - std::vector reads(1, model::run::read_info(1, 1, 4, false)); - return reads; - } - /** Get the summary for these metrics + buffer.assign(tmp, tmp+util::length_of(tmp)); + }/** Get the summary for these metrics * * @return run summary */ - static model::summary::run_summary summary() + static void create_summary(model::summary::run_summary& summary) { - std::vector read_infos = reads(); - model::summary::run_summary summary(read_infos.begin(), read_infos.end(), 1); + const size_t lane_count = 1; + const model::run::read_info reads[]={ + model::run::read_info(1, 1, 4, false) + }; + summary.initialize(to_vector(reads), lane_count); summary[0][0].lane(7); summary[0][0].tile_count(1); summary[0][0].projected_yield_g(0.0095612816512584686f); @@ -322,51 +270,39 @@ namespace illumina{ namespace interop { namespace unittest { summary.nonindex_summary().projected_yield_g(0.0095612816512584686f); summary.nonindex_summary().yield_g(0.0095612816512584686f); summary.cycle_state().qscored_cycle_range(model::run::cycle_range(3, 3)); - return summary; } }; - - /** This test writes three records of an InterOp files, then reads them back in and compares - * each value to ensure they did not change. + /** This generator creates an expected metric set and the corresponding binary data * - * @note Version 6 + * @see model::metrics::q_metric + * @note Version 6 (unbinned) */ - struct q_v6_unbinned : metric_test + struct q_metric_v6_unbinned : metric_test { - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() + static void create_metric_set(metric_set_t& metrics) { - std::vector expected_metrics; + metrics = metric_set_t(VERSION); typedef metric_t::uint_t uint_t; std::vector hist_tmp(50, 0); - expected_metrics.push_back(metric_t(1, 1110, 1, hist_tmp)); - expected_metrics.push_back(metric_t(1, 1110, 2, hist_tmp)); - expected_metrics.push_back(metric_t(1, 1110, 3, hist_tmp)); - - return expected_metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() - { - typedef header_t::qscore_bin_vector_type qscore_bin_vector_type; - qscore_bin_vector_type headervec; - return header_t(headervec); + metrics.insert(metric_t(1, 1110, 1, hist_tmp)); + metrics.insert(metric_t(1, 1110, 2, hist_tmp)); + metrics.insert(metric_t(1, 1110, 3, hist_tmp)); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - const int tmp[] = { + const int tmp[] = + { 6,-50,0,1,0,86,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 @@ -392,11 +328,9 @@ namespace illumina{ namespace interop { namespace unittest { ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0 }; - return to_string(tmp); + buffer.assign(tmp, tmp+util::length_of(tmp)); } }; - /** Interface between fixtures and Google Test */ - template - struct q_metrics_test : public ::testing::Test, public TestSetup { }; }}} + diff --git a/src/tests/interop/metrics/inc/stream_tests.hpp b/src/tests/interop/metrics/inc/stream_tests.hpp deleted file mode 100644 index ce223b43e..000000000 --- a/src/tests/interop/metrics/inc/stream_tests.hpp +++ /dev/null @@ -1,126 +0,0 @@ -/** Unit tests for various failure conditions handled by exceptions. - * - * - * @file - * - * @date 10/6/2015 - * @version 1.0 - * @copyright GNU Public License. - */ - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4127) // MSVC warns about using constants in conditional statements, for template constants -#endif - -/** Wrapper for X-Macro FIXTURE - * - */ -#define WRAPPED_TEST(FIXTURE, FUNC) TYPED_TEST(FIXTURE, FUNC) - -/** - * Confirm binary write matches expected binary data - */ -WRAPPED_TEST(FIXTURE, test_expected_get_metric) -{ - typename TypeParam::metric_set_t::key_vector keys = TypeParam::actual_metric_set.keys(); - for(size_t i=0;i10) << "incomplete: " << incomplete; -} -/** Confirm incomplete_file_exception is thrown for a mostly complete file - */ -WRAPPED_TEST(FIXTURE, test_hardcoded_incomplete_file_exception_last_metric) -{ - typename TypeParam::metric_set_t metrics; - EXPECT_THROW(illumina::interop::io::read_interop_from_string( - TypeParam::expected_binary_data.substr(0,TypeParam::expected_binary_data.length()-4), metrics), - incomplete_file_exception); -} -/** Confirm bad_format_exception is thrown when record size is incorrect - */ -WRAPPED_TEST(FIXTURE, test_hardcoded_incorrect_record_size) -{ - if(TypeParam::disable_check_record_size) return; - std::string tmp = std::string(TypeParam::expected_binary_data); - tmp[1] = 0; - typename TypeParam::metric_set_t metrics; - EXPECT_THROW(illumina::interop::io::read_interop_from_string(tmp, metrics), bad_format_exception); -} -/** Confirm file_not_found_exception is thrown when a file is not found - */ -WRAPPED_TEST(FIXTURE, test_hardcoded_file_not_found) -{ - typename TypeParam::metric_set_t metrics; - EXPECT_THROW(illumina::interop::io::read_interop("/NO/FILE/EXISTS", metrics), file_not_found_exception); -} -/** Confirm reading from good data does not throw an exception - */ -WRAPPED_TEST(FIXTURE, test_hardcoded_read) -{ - std::string tmp = std::string(TypeParam::expected_binary_data); - typename TypeParam::metric_set_t metrics; - EXPECT_NO_THROW(illumina::interop::io::read_interop_from_string(tmp, metrics)); -} -/** Confirm the clear function works - */ -WRAPPED_TEST(FIXTURE, test_clear) -{ - std::string tmp = std::string(TypeParam::expected_binary_data); - typename TypeParam::metric_set_t metrics; - EXPECT_NO_THROW(illumina::interop::io::read_interop_from_string(tmp, metrics)); - size_t cnt = metrics.size(); - metrics.clear(); - EXPECT_NO_THROW(illumina::interop::io::read_interop_from_string(tmp, metrics)); - EXPECT_EQ(cnt, metrics.size()); - -} - -#ifdef _MSC_VER -#pragma warning(pop) -#endif diff --git a/src/tests/interop/metrics/inc/summary_fixture.h b/src/tests/interop/metrics/inc/summary_fixture.h deleted file mode 100644 index ca5aeb298..000000000 --- a/src/tests/interop/metrics/inc/summary_fixture.h +++ /dev/null @@ -1,54 +0,0 @@ -/** Run summary test fixture - * - * @file - * @date 3/11/16 - * @version 1.0 - * @copyright GNU Public License. - */ - -#pragma once -#include -#include "interop/model/summary/index_flowcell_summary.h" -#include "interop/logic/summary/run_summary.h" -#include "interop/logic/summary/index_summary.h" - -namespace illumina{ namespace interop { namespace unittest { - /** Fixture for the run summary*/ - template - struct summary_fixture - { - /** Constructor - * - * @param reads list of reads - */ - summary_fixture(std::vector reads = Gen::reads()) : - expected(Gen::summary()), - actual(reads.begin(), reads.end(), Gen::lane_count()) - { - std::vector channels; - channels.push_back("Red"); - channels.push_back("Green"); - model::run::info run_info("XX", - "", - 1, - model::run::flowcell_layout(Gen::lane_count(), 2, 4, 99, 6, 6), - channels, - model::run::image_dimensions(), - reads); - run_info.set_naming_method(constants::FourDigit); - model::metrics::run_metrics metrics(run_info); - try - { - io::read_interop_from_string(Gen::binary_data(), - metrics.get_set()); - } - catch (const std::exception &) { } - metrics.finalize_after_load(); - logic::summary::summarize_run_metrics(metrics, actual); - } - /** Expected run summary */ - model::summary::run_summary expected; - /** Actual run summary derived from hardcoded binary data */ - model::summary::run_summary actual; - }; -}}} diff --git a/src/tests/interop/metrics/inc/tile_metrics_test.h b/src/tests/interop/metrics/inc/tile_metrics_test.h index d0c547e0e..95d14302f 100644 --- a/src/tests/interop/metrics/inc/tile_metrics_test.h +++ b/src/tests/interop/metrics/inc/tile_metrics_test.h @@ -7,20 +7,21 @@ * @copyright GNU Public License. */ #pragma once -#include -#include "metric_test.h" +#include "src/tests/interop/metrics/inc/metric_test.h" #include "interop/model/metrics/tile_metric.h" #include "interop/model/summary/run_summary.h" +#include "interop/util/length_of.h" -namespace illumina{ namespace interop { namespace unittest { +namespace illumina{ namespace interop { namespace unittest +{ - /** This test compares byte values taken from an InterOp file for three records produced by RTA 2.7.x - * to the values displayed in SAV. + /** This generator creates an expected metric set and the corresponding binary data * + * @see model::metrics::tile_metric * @note Version 2 */ - struct tile_v2 : metric_test + struct tile_metric_v2 : metric_test { enum{ /** Do not check the expected binary data */ @@ -28,97 +29,78 @@ namespace illumina{ namespace interop { namespace unittest { /** Do not check the expected binary data size */ disable_binary_data_size=true }; - /** Build the expected metric set + /** Create the expected metric set * - * @return vector of metrics + * @param metrics destination metric set */ - static std::vector metrics() + static void create_metric_set(metric_set_t& metrics) { - std::vector expected_metrics; - + metrics = metric_set_t(VERSION); metric_t::read_metric_vector reads1; reads1.push_back(metric_t::read_metric_type(1, 2.61630869f, 0.0797112584f, 0.119908921f)); reads1.push_back(metric_t::read_metric_type(2, 2.61630869f, 0.0797112584f, 0.119908921f)); - expected_metrics.push_back(metric_t(7, 1114, 2355119.25f,1158081.50f,6470949,3181956,reads1)); - expected_metrics.push_back(metric_t(7, 1214, 2355119.25f,1174757.75f,6470949,3227776, - metric_t::read_metric_vector(1, metric_t::read_metric_type(1, 2.62243795f, 0.129267812f, 0.135128692f)))); - expected_metrics.push_back(metric_t(7, 2114, 2355119.25f,1211592.38f,6470949,3328983, - metric_t::read_metric_vector(1, metric_t::read_metric_type(1, 2.490309f, 0.11908555f, 0.092706576f)))); - - return expected_metrics; - } - /** Get the expected metric set header - * - * @return expected metric set header - */ - static header_t header() - { - return header_t(); + metrics.insert(metric_t(7, 1114, 2355119.25f,1158081.50f,6470949,3181956,reads1)); + metrics.insert(metric_t(7, 1214, 2355119.25f,1174757.75f,6470949,3227776, + metric_t::read_metric_vector(1, metric_t::read_metric_type(1, 2.62243795f, 0.129267812f, 0.135128692f)))); + metrics.insert(metric_t(7, 2114, 2355119.25f,1211592.38f,6470949,3328983, + metric_t::read_metric_vector(1, metric_t::read_metric_type(1, 2.490309f, 0.11908555f, 0.092706576f)))); } /** Get the expected binary data * - * @return binary data string + * @param buffer binary data string */ - static std::string binary_data() + template + static void create_binary_data(Collection& buffer) { - const int tmp[] = { - 2,10 - ,7,0,90,4,100,0,-67,-66,15,74 - ,7,0,90,4,102,0,74,122,-59,74 - ,7,0,90,4,101,0,12,94,-115,73 - ,7,0,90,4,103,0,16,54,66,74 - ,7,0,90,4,-56,0,82,-11,80,58 - ,7,0,90,4,-55,0,-62,42,-99,58 - ,7,0,90,4,44,1,-102,113,39,64 - ,7,0,90,4,-54,0,82,-11,80,58 - ,7,0,90,4,-53,0,-62,42,-99,58 - ,7,0,90,4,45,1,-102,113,39,64 - ,7,0,90,4,-56,0,82,-11,80,58 - ,7,0,90,4,-55,0,-62,42,-99,58 - ,7,0,90,4,44,1,-102,113,39,64 - ,7,0,-66,4,100,0,-67,-66,15,74 - ,7,0,-66,4,102,0,74,122,-59,74 - ,7,0,-66,4,101,0,46,103,-113,73 - ,7,0,-66,4,103,0,0,2,69,74 - ,7,0,-66,4,-56,0,21,111,-87,58 - ,7,0,-66,4,-55,0,-86,29,-79,58 - ,7,0,-66,4,44,1,6,-42,39,64 - ,7,0,66,8,100,0,-67,-66,15,74 - ,7,0,66,8,102,0,74,122,-59,74 - ,7,0,66,8,101,0,67,-26,-109,73 - ,7,0,66,8,103,0,92,47,75,74 - ,7,0,66,8,-56,0,123,22,-100,58 - ,7,0,66,8,-55,0,85,6,115,58 - ,7,0,66,8,44,1,57,97,31,64 - ,7,0,66,8,144,1,0,0,0,0 // Test whether control lane accidentally clears data - ,6,0,66,8,144,1,0,0,0,0 // Test whether control lane for empty tile shows up + const int tmp[] = + { + 2,10 + ,7,0,90,4,100,0,-67,-66,15,74 + ,7,0,90,4,102,0,74,122,-59,74 + ,7,0,90,4,101,0,12,94,-115,73 + ,7,0,90,4,103,0,16,54,66,74 + ,7,0,90,4,-56,0,82,-11,80,58 + ,7,0,90,4,-55,0,-62,42,-99,58 + ,7,0,90,4,44,1,-102,113,39,64 + ,7,0,90,4,-54,0,82,-11,80,58 + ,7,0,90,4,-53,0,-62,42,-99,58 + ,7,0,90,4,45,1,-102,113,39,64 + ,7,0,90,4,-56,0,82,-11,80,58 + ,7,0,90,4,-55,0,-62,42,-99,58 + ,7,0,90,4,44,1,-102,113,39,64 + ,7,0,-66,4,100,0,-67,-66,15,74 + ,7,0,-66,4,102,0,74,122,-59,74 + ,7,0,-66,4,101,0,46,103,-113,73 + ,7,0,-66,4,103,0,0,2,69,74 + ,7,0,-66,4,-56,0,21,111,-87,58 + ,7,0,-66,4,-55,0,-86,29,-79,58 + ,7,0,-66,4,44,1,6,-42,39,64 + ,7,0,66,8,100,0,-67,-66,15,74 + ,7,0,66,8,102,0,74,122,-59,74 + ,7,0,66,8,101,0,67,-26,-109,73 + ,7,0,66,8,103,0,92,47,75,74 + ,7,0,66,8,-56,0,123,22,-100,58 + ,7,0,66,8,-55,0,85,6,115,58 + ,7,0,66,8,44,1,57,97,31,64 + ,7,0,66,8,144,1,0,0,0,0 // Test whether control lane accidentally clears data + ,6,0,66,8,144,1,0,0,0,0 // Test whether control lane for empty tile shows up }; - return to_string(tmp); - } - /** Get reads describing data - * - * @return reads vector - */ - static std::vector reads() - { - std::vector reads; - reads.reserve(2); - reads.push_back(model::run::read_info(1, 1, 3, false)); - reads.push_back(model::run::read_info(2, 1, 3, false)); - return reads; - } - /** Get the summary for these metrics + buffer.assign(tmp, tmp+util::length_of(tmp)); + }/** Get the summary for these metrics * * @return run summary */ - static model::summary::run_summary summary() + static void create_summary(model::summary::run_summary& summary) { - const size_t lane_count=1; - std::vector read_infos = reads(); - model::summary::run_summary summary(read_infos.begin(), read_infos.end(), lane_count); - for(size_t read=0;read - struct tile_metrics_test : public ::testing::Test, public TestSetup { }; + }}} + diff --git a/src/tests/interop/metrics/index_metrics_test.cpp b/src/tests/interop/metrics/index_metrics_test.cpp index 2cb81e58f..e36ed88f1 100644 --- a/src/tests/interop/metrics/index_metrics_test.cpp +++ b/src/tests/interop/metrics/index_metrics_test.cpp @@ -7,33 +7,47 @@ * @copyright GNU Public License. */ -#include #include -#include "inc/index_metrics_test.h" #include "interop/model/run_metrics.h" +#include "src/tests/interop/metrics/inc/index_metrics_test.h" +#include "src/tests/interop/inc/generic_fixture.h" +#include "src/tests/interop/inc/proxy_parameter_generator.h" +#include "src/tests/interop/metrics/inc/metric_generator.h" using namespace illumina::interop::model::metrics; +using namespace illumina::interop::model::metric_base; using namespace illumina::interop::io; using namespace illumina::interop; using namespace illumina::interop::unittest; -typedef ::testing::Types< - hardcoded_fixture, - write_read_fixture -> Formats; -TYPED_TEST_CASE(index_metrics_test, Formats); + +typedef metric_set< index_metric > index_metric_set; +/** Setup for tests that compare two index metric sets */ +struct index_metrics_tests : public generic_test_fixture< index_metric_set > {}; + +index_metrics_tests::generator_type index_unit_test_generators[] = { + wrap(new hardcoded_metric_generator< index_metric_v1 >) , + wrap(new write_read_metric_generator< index_metric_v1 >) +}; + +// Setup unit tests for index_metrics_tests +INSTANTIATE_TEST_CASE_P(index_metric_unit_test, + index_metrics_tests, + ::testing::ValuesIn(index_unit_test_generators)); /** * @class illumina::interop::model::metrics::index_metric * @test Confirm version 1 of the metric can be written to and read from a stream * @test Confirm version 1 of the metric matches known binary file */ -TYPED_TEST(index_metrics_test, test_read_write) +TEST_P(index_metrics_tests, test_read_write) { - EXPECT_EQ(TypeParam::actual_metric_set.version(), TypeParam::VERSION); - EXPECT_EQ(TypeParam::actual_metric_set.size(), TypeParam::expected_metric_set.size()); + typedef index_metric_set::const_iterator const_iterator; + if(!test) return;// Disable test for rebaseline + EXPECT_EQ(actual.version(), expected.version()); + ASSERT_EQ(actual.size(), expected.size()); - for(typename TypeParam::const_iterator it_expected=TypeParam::expected_metric_set.begin(), it_actual = TypeParam::actual_metric_set.begin(); - it_expected != TypeParam::expected_metric_set.end() && it_actual != TypeParam::actual_metric_set.end(); + for(const_iterator it_expected=expected.begin(), it_actual = actual.begin(); + it_expected != expected.end() && it_actual != actual.end(); it_expected++,it_actual++) { EXPECT_EQ(it_expected->lane(), it_actual->lane()); @@ -50,24 +64,16 @@ TYPED_TEST(index_metrics_test, test_read_write) } } -TEST(run_metrics_index_test, test_is_group_empty) -{ - run_metrics metrics; - EXPECT_TRUE(metrics.is_group_empty(constants::Index)); - io::read_interop_from_string(index_v1::binary_data(), - metrics.get_set()); - EXPECT_FALSE(metrics.is_group_empty(constants::Index)); -} -#define FIXTURE index_metrics_test -/** - * @class illumina::interop::model::metrics::index_metric - * @test Confirm bad_format_exception is thrown when version is unsupported - * @test Confirm incomplete_file_exception is thrown for a small partial record - * @test Confirm incomplete_file_exception is thrown for a mostly complete file - * @test Confirm bad_format_exception is thrown when record size is incorrect - * @test Confirm file_not_found_exception is thrown when a file is not found - * @test Confirm reading from good data does not throw an exception - */ -#include "inc/stream_tests.hpp" + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Setup regression test +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +regression_test_metric_generator index_regression_gen("metrics"); +INSTANTIATE_TEST_CASE_P(index_metric_regression_test, + index_metrics_tests, + ProxyValuesIn(index_regression_gen, regression_test_data::instance().files())); + + + diff --git a/src/tests/interop/metrics/metric_streams_test.cpp b/src/tests/interop/metrics/metric_streams_test.cpp new file mode 100644 index 000000000..b6f4865d1 --- /dev/null +++ b/src/tests/interop/metrics/metric_streams_test.cpp @@ -0,0 +1,138 @@ +/** Unit tests for the metric streams + * + * + * @file + * @date 9/17/2016 + * @version 1.0 + * @copyright GNU Public License. + */ + +#ifdef _MSC_VER +#pragma warning(disable:4127) // MSVC warns about using constants in conditional statements, for template constants +#endif + +#include +#include "src/tests/interop/metrics/inc/metric_format_fixtures.h" + +using namespace illumina::interop; +using namespace illumina::interop::unittest; + + +/** Fixture for expected vs actual binary data */ +template +struct metric_stream_test : public ::testing::Test, public TestSetup +{ + /** Type of metric set */ + typedef typename TestSetup::metric_set_t metric_set_t; + /** Constructor */ + metric_stream_test() + { + TestSetup::create_binary_data(expected); + metric_set_t metrics; + TestSetup::create_metric_set(metrics); + std::ostringstream fout; + io::write_metrics(fout, metrics); + actual = fout.str(); + } + /** Expected binary data */ + std::string expected; + /** Actual binary data */ + std::string actual; +}; +TYPED_TEST_CASE_P(metric_stream_test); + +/** + * Confirm binary write matches expected binary data + */ +TYPED_TEST_P(metric_stream_test, test_write_read_binary_data) +{ + if (TypeParam::disable_binary_data_size) return; + ASSERT_EQ(TestFixture::expected.size(), TestFixture::actual.size()); + if (TypeParam::disable_binary_data) return; + for (::uint32_t i = 0;i 10) << "incomplete: " << incomplete; +} +/** Confirm incomplete_file_exception is thrown for a mostly complete file + */ +TYPED_TEST_P(metric_stream_test, test_hardcoded_incomplete_file_exception_last_metric) +{ + typename TypeParam::metric_set_t metrics; + EXPECT_THROW(io::read_interop_from_string( + TestFixture::expected.substr(0, TestFixture::expected.length() - 4), metrics), + io::incomplete_file_exception); +} +/** Confirm bad_format_exception is thrown when record size is incorrect + */ +TYPED_TEST_P(metric_stream_test, test_hardcoded_incorrect_record_size) +{ + if (TypeParam::disable_check_record_size) return; + std::string tmp = std::string(TestFixture::expected); + tmp[1] = 0; + tmp[2] = 0; + typename TypeParam::metric_set_t metrics; + EXPECT_THROW(io::read_interop_from_string(tmp, metrics), io::bad_format_exception); +} +/** Confirm file_not_found_exception is thrown when a file is not found + */ +TYPED_TEST_P(metric_stream_test, test_hardcoded_file_not_found) +{ + typename TypeParam::metric_set_t metrics; + EXPECT_THROW(io::read_interop("/NO/FILE/EXISTS", metrics), io::file_not_found_exception); +} +/** Confirm reading from good data does not throw an exception + */ +TYPED_TEST_P(metric_stream_test, test_hardcoded_read) +{ + std::string tmp = std::string(TestFixture::expected); + typename TypeParam::metric_set_t metrics; + EXPECT_NO_THROW(io::read_interop_from_string(tmp, metrics)); +} + +REGISTER_TYPED_TEST_CASE_P(metric_stream_test, test_write_read_binary_data, + test_hardcoded_bad_format_exception, + test_hardcoded_incomplete_file_exception, + test_hardcoded_incomplete_file_exception_last_metric, + test_hardcoded_incorrect_record_size, + test_hardcoded_file_not_found, + test_hardcoded_read +); + + +INSTANTIATE_TYPED_TEST_CASE_P(Public, metric_stream_test, PublicFormats); + diff --git a/src/tests/interop/metrics/q_by_lane_metric_test.cpp b/src/tests/interop/metrics/q_by_lane_metric_test.cpp index a1864bee7..c08eca21c 100644 --- a/src/tests/interop/metrics/q_by_lane_metric_test.cpp +++ b/src/tests/interop/metrics/q_by_lane_metric_test.cpp @@ -8,28 +8,25 @@ */ #include -#include "interop/model/metrics/q_by_lane_metric.h" -#include "inc/q_metrics_test.h" #include "interop/logic/metric/q_metric.h" #include "interop/model/run_metrics.h" +#include "interop/model/metrics/q_by_lane_metric.h" +#include "src/tests/interop/inc/generic_fixture.h" +#include "src/tests/interop/inc/proxy_parameter_generator.h" +#include "src/tests/interop/metrics/inc/metric_generator.h" +#include "src/tests/interop/metrics/inc/q_metrics_test.h" using namespace illumina::interop; using namespace illumina::interop::model::metrics; using namespace illumina::interop::model::metric_base; using namespace illumina::interop::unittest; -// Test that q_by_lane_metric can use q_metric parsers/writers -TEST(q_by_lane_metrics_test, test_read_v4) -{ - metric_set metrics; - io::read_interop_from_string(q_v4::binary_data(), - metrics); -} - // Test if we can parse by lane q-metrics TEST(q_by_lane_metrics_test, test_convert_write_read) { metric_set metrics; - io::read_interop_from_string(q_v4::binary_data(), + std::string data; + q_metric_v4::create_binary_data(data); + io::read_interop_from_string(data, metrics); @@ -63,12 +60,24 @@ TEST(q_by_lane_metrics_test, test_convert_write_read) } } +// Test that q_by_lane_metric can use q_metric parsers/writers +TEST(q_by_lane_metrics_test, test_read_v4) +{ + metric_set metrics; + std::string data; + q_metric_v4::create_binary_data(data); + io::read_interop_from_string(data, + metrics); +} + TEST(run_metrics_q_by_lane_test, test_is_group_empty) { run_metrics metrics; EXPECT_TRUE(metrics.is_group_empty(constants::QByLane)); - io::read_interop_from_string(q_v4::binary_data(), + std::string data; + q_metric_v4::create_binary_data(data); + io::read_interop_from_string(data, metrics.get_set()); logic::metric::create_q_metrics_by_lane(metrics.get_set(), metrics.get_set()); EXPECT_FALSE(metrics.is_group_empty(constants::QByLane)); -} \ No newline at end of file +} diff --git a/src/tests/interop/metrics/q_collapsed_metrics_test.cpp b/src/tests/interop/metrics/q_collapsed_metrics_test.cpp index 7be55ee2b..a3780b84a 100644 --- a/src/tests/interop/metrics/q_collapsed_metrics_test.cpp +++ b/src/tests/interop/metrics/q_collapsed_metrics_test.cpp @@ -8,10 +8,13 @@ */ #include -#include "interop/logic/metric/q_metric.h" -#include "inc/q_collapsed_metrics_test.h" -#include "inc/q_metrics_test.h" #include "interop/model/run_metrics.h" +#include "src/tests/interop/metrics/inc/q_collapsed_metrics_test.h" +#include "src/tests/interop/inc/generic_fixture.h" +#include "src/tests/interop/inc/proxy_parameter_generator.h" +#include "src/tests/interop/metrics/inc/metric_generator.h" +#include "interop/logic/metric/q_metric.h" +#include "src/tests/interop/metrics/inc/q_metrics_test.h" using namespace illumina::interop::model::metrics; using namespace illumina::interop::model::metric_base; @@ -20,13 +23,22 @@ using namespace illumina::interop; using namespace illumina::interop::unittest; -typedef ::testing::Types< - hardcoded_fixture, - write_read_fixture, - hardcoded_fixture, - write_read_fixture -> Formats; -TYPED_TEST_CASE(q_collapsed_metrics_test, Formats); +typedef metric_set< q_collapsed_metric > q_collapsed_metric_set; +/** Setup for tests that compare two Q-collapsed metric sets */ +struct q_collapsed_metrics_tests : public generic_test_fixture< q_collapsed_metric_set > {}; + + +q_collapsed_metrics_tests::generator_type q_collapsed_unit_test_generators[] = { + wrap(new hardcoded_metric_generator< q_collapsed_metric_v2 >) , + wrap(new write_read_metric_generator< q_collapsed_metric_v2 >), + wrap(new hardcoded_metric_generator< q_collapsed_metric_v6 >) , + wrap(new write_read_metric_generator< q_collapsed_metric_v6 >) +}; + +// Setup unit tests for q_collapsed_metrics_tests +INSTANTIATE_TEST_CASE_P(q_collapsed_metric_unit_test, + q_collapsed_metrics_tests, + ::testing::ValuesIn(q_collapsed_unit_test_generators)); /** * @class illumina::interop::model::metrics::q_collapsed_metric @@ -35,14 +47,16 @@ TYPED_TEST_CASE(q_collapsed_metrics_test, Formats); * @test Confirm version 6 of the metric can be written to and read from a stream * @test Confirm version 6 of the metric matches known binary file */ -TYPED_TEST(q_collapsed_metrics_test, test_read_write) +TEST_P(q_collapsed_metrics_tests, test_read_write) { - EXPECT_EQ(TypeParam::actual_metric_set.version(), TypeParam::expected_metric_set.version()); - EXPECT_EQ(TypeParam::actual_metric_set.size(), TypeParam::expected_metric_set.size()); - EXPECT_EQ(TypeParam::actual_metric_set.max_cycle(), TypeParam::expected_metric_set.max_cycle()); - - for(typename TypeParam::const_iterator it_expected=TypeParam::expected_metric_set.begin(), it_actual = TypeParam::actual_metric_set.begin(); - it_expected != TypeParam::expected_metric_set.end() && it_actual != TypeParam::actual_metric_set.end(); + typedef q_collapsed_metric_set::const_iterator const_iterator; + if(!test) return;// Disable test for rebaseline + EXPECT_EQ(actual.version(), expected.version()); + ASSERT_EQ(actual.size(), expected.size()); + EXPECT_EQ(actual.max_cycle(), expected.max_cycle()); + + for(const_iterator it_expected=expected.begin(), it_actual = actual.begin(); + it_expected != expected.end() && it_actual != actual.end(); it_expected++,it_actual++) { EXPECT_EQ(it_expected->lane(), it_actual->lane()); @@ -56,8 +70,9 @@ TYPED_TEST(q_collapsed_metrics_test, test_read_write) TEST(q_collapsed_metrics_test, test_convert_write_read) { metric_set metrics; - std::istringstream fin(q_v4::binary_data()); - io::read_interop_from_string(q_v4::binary_data(), + std::string data; + q_metric_v4::create_binary_data(data); + io::read_interop_from_string(data, metrics); @@ -89,27 +104,15 @@ TEST(q_collapsed_metrics_test, test_convert_write_read) } } -TEST(run_metrics_q_collapsed_test, test_is_group_empty) -{ - run_metrics metrics; - EXPECT_TRUE(metrics.is_group_empty(constants::QCollapsed)); - io::read_interop_from_string(q_v4::binary_data(), - metrics.get_set()); - logic::metric::create_collapse_q_metrics(metrics.get_set(), metrics.get_set()); - EXPECT_FALSE(metrics.is_group_empty(constants::QCollapsed)); -} -#define FIXTURE q_collapsed_metrics_test -/** - * @class illumina::interop::model::metrics::q_collapsed_metric - * @test Confirm binary write matches expected binary data - * @test Confirm bad_format_exception is thrown when version is unsupported - * @test Confirm incomplete_file_exception is thrown for a small partial record - * @test Confirm incomplete_file_exception is thrown for a mostly complete file - * @test Confirm bad_format_exception is thrown when record size is incorrect - * @test Confirm file_not_found_exception is thrown when a file is not found - * @test Confirm reading from good data does not throw an exception - */ -#include "inc/stream_tests.hpp" + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Setup regression test +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +regression_test_metric_generator q_collapsed_regression_gen("metrics"); +INSTANTIATE_TEST_CASE_P(q_collapsed_metric_regression_test, + q_collapsed_metrics_tests, + ProxyValuesIn(q_collapsed_regression_gen, regression_test_data::instance().files())); + diff --git a/src/tests/interop/metrics/q_metrics_test.cpp b/src/tests/interop/metrics/q_metrics_test.cpp index 30f1f8856..7abf4cecc 100644 --- a/src/tests/interop/metrics/q_metrics_test.cpp +++ b/src/tests/interop/metrics/q_metrics_test.cpp @@ -8,11 +8,13 @@ */ #include -#include #include -#include "interop/logic/metric/q_metric.h" -#include "inc/q_metrics_test.h" #include "interop/model/run_metrics.h" +#include "src/tests/interop/metrics/inc/q_metrics_test.h" +#include "src/tests/interop/inc/generic_fixture.h" +#include "src/tests/interop/inc/proxy_parameter_generator.h" +#include "src/tests/interop/metrics/inc/metric_generator.h" +#include "interop/logic/metric/q_metric.h" using namespace illumina::interop::model::metrics; using namespace illumina::interop::model::metric_base; using namespace illumina::interop::io; @@ -20,17 +22,25 @@ using namespace illumina::interop; using namespace illumina::interop::unittest; -typedef ::testing::Types< - hardcoded_fixture, - write_read_fixture, - hardcoded_fixture, - write_read_fixture, - hardcoded_fixture, - write_read_fixture, - hardcoded_fixture, - write_read_fixture -> Formats; -TYPED_TEST_CASE(q_metrics_test, Formats); +typedef metric_set< q_metric > q_metric_set; +/** Setup for tests that compare two Q metric sets */ +struct q_metrics_tests : public generic_test_fixture< q_metric_set > {}; + +q_metrics_tests::generator_type q_unit_test_generators[] = { + wrap(new hardcoded_metric_generator< q_metric_v4 >), + wrap(new write_read_metric_generator< q_metric_v4 >), + wrap(new hardcoded_metric_generator< q_metric_v5 >), + wrap(new write_read_metric_generator< q_metric_v5 >), + wrap(new hardcoded_metric_generator< q_metric_v6 >), + wrap(new write_read_metric_generator< q_metric_v6 >), + wrap(new hardcoded_metric_generator< q_metric_v6_unbinned>), + wrap(new write_read_metric_generator< q_metric_v6_unbinned>) +}; + +// Setup unit tests for q_metrics_tests +INSTANTIATE_TEST_CASE_P(q_metric_unit_test, + q_metrics_tests, + ::testing::ValuesIn(q_unit_test_generators)); /** * @class illumina::interop::model::metrics::q_metric @@ -41,14 +51,16 @@ TYPED_TEST_CASE(q_metrics_test, Formats); * @test Confirm version 6 of the metric can be written to and read from a stream * @test Confirm version 6 of the metric matches known binary file */ -TYPED_TEST(q_metrics_test, test_read_write) +TEST_P(q_metrics_tests, test_read_write) { - EXPECT_EQ(TypeParam::actual_metric_set.version(), TypeParam::VERSION); - EXPECT_EQ(TypeParam::actual_metric_set.size(), TypeParam::expected_metric_set.size()); - EXPECT_EQ(TypeParam::actual_metric_set.max_cycle(), TypeParam::expected_metric_set.max_cycle()); - - for(typename TypeParam::const_iterator it_expected=TypeParam::expected_metric_set.begin(), it_actual = TypeParam::actual_metric_set.begin(); - it_expected != TypeParam::expected_metric_set.end() && it_actual != TypeParam::actual_metric_set.end(); + typedef q_metric_set::const_iterator const_iterator; + if(!test) return;// Disable test for rebaseline + EXPECT_EQ(actual.version(), expected.version()); + ASSERT_EQ(actual.size(), expected.size()); + EXPECT_EQ(actual.max_cycle(), expected.max_cycle()); + + for(const_iterator it_expected=expected.begin(), it_actual = actual.begin(); + it_expected != expected.end() && it_actual != actual.end(); it_expected++,it_actual++) { EXPECT_EQ(it_expected->lane(), it_actual->lane()); @@ -60,13 +72,13 @@ TYPED_TEST(q_metrics_test, test_read_write) EXPECT_EQ(it_expected->qscore_hist(i), it_actual->qscore_hist(i)); } } - EXPECT_EQ(logic::metric::count_q_metric_bins(TypeParam::actual_metric_set),logic::metric::count_q_metric_bins(TypeParam::expected_metric_set)); - EXPECT_EQ(TypeParam::actual_metric_set.bin_count(), TypeParam::expected_metric_set.bin_count()); - for(size_t i=0;iis_cumulative_empty()); metric_set empty_metrics; logic::metric::populate_cumulative_distribution(empty_metrics); @@ -103,7 +118,7 @@ TEST(q_metrics_test, test_cumulative) metric_set q_metric_set(q_metric_vec, 6, q_metric::header_type()); logic::metric::populate_cumulative_distribution(q_metric_set); - for(uint_t i=0;i q_regression_gen("metrics"); +INSTANTIATE_TEST_CASE_P(q_metric_regression_test, + q_metrics_tests, + ProxyValuesIn(q_regression_gen, regression_test_data::instance().files())); + + + -TEST(run_metrics_q_test, test_is_group_empty) -{ - run_metrics metrics; - EXPECT_TRUE(metrics.is_group_empty(constants::Q)); - io::read_interop_from_string(q_v4::binary_data(), - metrics.get_set()); - EXPECT_FALSE(metrics.is_group_empty(constants::Q)); -} -#define FIXTURE q_metrics_test -/** - * @class illumina::interop::model::metrics::q_metric - * @test Confirm binary write matches expected binary data - * @test Confirm bad_format_exception is thrown when version is unsupported - * @test Confirm incomplete_file_exception is thrown for a small partial record - * @test Confirm incomplete_file_exception is thrown for a mostly complete file - * @test Confirm bad_format_exception is thrown when record size is incorrect - * @test Confirm file_not_found_exception is thrown when a file is not found - * @test Confirm reading from good data does not throw an exception - */ -#include "inc/stream_tests.hpp" diff --git a/src/tests/interop/metrics/run_metric_test.cpp b/src/tests/interop/metrics/run_metric_test.cpp new file mode 100644 index 000000000..356e9eadb --- /dev/null +++ b/src/tests/interop/metrics/run_metric_test.cpp @@ -0,0 +1,86 @@ +/** Unit tests for the run metrics class + * + * + * @file + * @date 9/21/16 + * @version 1.0 + * @copyright GNU Public License. + */ + + +#include +#include "src/tests/interop/metrics/inc/metric_format_fixtures.h" + + +using namespace illumina::interop; +using namespace illumina::interop::unittest; + +/** Fixture for a metric set */ +template +struct run_metric_test : public ::testing::Test, public TestSetup +{ + /** Type of metric set */ + typedef typename TestSetup::metric_set_t metric_set_t; + /** Constructor */ + run_metric_test() + { + TestSetup::create_metric_set(expected.template get()); + } + /** Expected metric set */ + model::metrics::run_metrics expected; +}; +TYPED_TEST_CASE_P(run_metric_test); + +/** Confirm the clear function works + */ +TYPED_TEST_P(run_metric_test, test_clear) +{ + typedef typename TestFixture::metric_set_t metric_set_t; + metric_set_t& metric_set = TestFixture::expected.template get(); + size_t cnt = metric_set.size(); + TestFixture::expected.clear(); + TypeParam::create_metric_set(metric_set); + EXPECT_EQ(cnt, metric_set.size()); +} + +/** Confirm that is_group_empty reports True */ +TYPED_TEST_P(run_metric_test, is_group_empty_true) +{ + typedef typename TestFixture::metric_set_t metric_set_t; + typedef typename metric_set_t::metric_type metric_t; + TestFixture::expected.clear(); + EXPECT_TRUE(TestFixture::expected.is_group_empty(static_cast(metric_t::TYPE))); +} + +/** Confirm that is_group_empty reports True */ +TYPED_TEST_P(run_metric_test, is_group_empty_false) +{ + typedef typename TestFixture::metric_set_t metric_set_t; + typedef typename metric_set_t::metric_type metric_t; + EXPECT_FALSE(TestFixture::expected.is_group_empty(static_cast(metric_t::TYPE))); +} + +/** + * Confirm binary write matches expected binary data + */ +TYPED_TEST_P(run_metric_test, test_expected_get_metric) +{ + typedef typename TestFixture::metric_set_t metric_set_t; + metric_set_t& metric_set = TestFixture::expected. template get(); + const typename metric_set_t::key_vector keys = metric_set.keys(); + for (size_t i = 0; i < keys.size(); i++) + { + ASSERT_EQ(keys[i], metric_set.get_metric(keys[i]).id()); + } +} + +REGISTER_TYPED_TEST_CASE_P(run_metric_test, + test_clear, + is_group_empty_true, + is_group_empty_false, + test_expected_get_metric +); + + +INSTANTIATE_TYPED_TEST_CASE_P(Public, run_metric_test, PublicFormats); + diff --git a/src/tests/interop/metrics/tile_metrics_test.cpp b/src/tests/interop/metrics/tile_metrics_test.cpp index 8dca9c601..53bbfc75b 100644 --- a/src/tests/interop/metrics/tile_metrics_test.cpp +++ b/src/tests/interop/metrics/tile_metrics_test.cpp @@ -7,13 +7,17 @@ * @copyright GNU Public License. */ #include -#include #include #include -#include "inc/tile_metrics_test.h" #include "interop/util/math.h" #include "interop/util/statistics.h" +#include "interop/util/type_traits.h" #include "interop/model/run_metrics.h" +#include "src/tests/interop/metrics/inc/tile_metrics_test.h" +#include "src/tests/interop/inc/generic_fixture.h" +#include "src/tests/interop/inc/proxy_parameter_generator.h" +#include "src/tests/interop/metrics/inc/metric_generator.h" + using namespace illumina::interop::model::metrics; using namespace illumina::interop::model::metric_base; using namespace illumina::interop::io; @@ -22,27 +26,38 @@ using namespace illumina::interop::unittest; using namespace illumina; +typedef metric_set< tile_metric > tile_metric_set; +/** Setup for tests that compare two tile metric sets */ +struct tile_metrics_tests : public generic_test_fixture< tile_metric_set > {}; + + +tile_metrics_tests::generator_type tile_unit_test_generators[] = { + wrap(new hardcoded_metric_generator< tile_metric_v2 >) , + wrap(new write_read_metric_generator< tile_metric_v2 >) +}; -typedef ::testing::Types< - hardcoded_fixture, - write_read_fixture -> Formats; -TYPED_TEST_CASE(tile_metrics_test, Formats); +// Setup unit tests for tile_metrics_tests +INSTANTIATE_TEST_CASE_P(tile_metric_unit_test, + tile_metrics_tests, + ::testing::ValuesIn(tile_unit_test_generators)); /** * @class illumina::interop::model::metrics::tile_metric * @test Confirm version 2 of the metric can be written to and read from a stream * @test Confirm version 2 of the metric matches known binary file */ -TYPED_TEST(tile_metrics_test, test_read_write) +TEST_P(tile_metrics_tests, test_read_write) { - const float scale = is_same< TypeParam, write_read_fixture >::value ? 100 : 1; - EXPECT_EQ(TypeParam::actual_metric_set.version(), TypeParam::VERSION); - EXPECT_EQ(TypeParam::actual_metric_set.size(), TypeParam::expected_metric_set.size()); + typedef tile_metric_set::const_iterator const_iterator; + typedef tile_metric_set::metric_type metric_t; + if(!test) return;// Disable test for rebaseline + const float scale = (test_modifier==2) ? 0.01f : ( (test_modifier==1) ? 100.0f : 1.0f); + ASSERT_EQ(actual.version(), expected.version()); + ASSERT_EQ(actual.size(), expected.size()); const float tol = 1e-7f / 0.01f; - for(typename TypeParam::const_iterator it_expected=TypeParam::expected_metric_set.begin(), it_actual = TypeParam::actual_metric_set.begin(); - it_expected != TypeParam::expected_metric_set.end() && it_actual != TypeParam::actual_metric_set.end(); + for(const_iterator it_expected=expected.begin(), it_actual = actual.begin(); + it_expected != expected.end() && it_actual != actual.end(); it_expected++,it_actual++) { EXPECT_EQ(it_expected->lane(), it_actual->lane()); @@ -53,13 +68,14 @@ TYPED_TEST(tile_metrics_test, test_read_write) EXPECT_NEAR(it_expected->cluster_count(), it_actual->cluster_count(), tol); EXPECT_NEAR(it_expected->cluster_count_pf(), it_actual->cluster_count_pf(), tol); EXPECT_EQ(it_expected->read_metrics().size(), it_actual->read_metrics().size()); - for(typename TypeParam::metric_t::read_metric_vector::const_iterator it_read_expected = it_expected->read_metrics().begin(), + for(metric_t::read_metric_vector::const_iterator it_read_expected = it_expected->read_metrics().begin(), it_read_actual = it_actual->read_metrics().begin(); it_read_expected != it_expected->read_metrics().end() && it_read_actual != it_actual->read_metrics().end(); it_read_expected++, it_read_actual++) { EXPECT_EQ(it_read_expected->read(), it_read_actual->read()); - EXPECT_NEAR(it_read_expected->percent_aligned(), it_read_actual->percent_aligned(), tol); + if(!std::isnan(it_read_expected->percent_aligned()) && !std::isnan(it_read_actual->percent_aligned())) + EXPECT_NEAR(it_read_expected->percent_aligned(), it_read_actual->percent_aligned(), tol); if(!std::isnan(it_read_expected->percent_phasing()) && !std::isnan(it_read_actual->percent_phasing())) EXPECT_NEAR(it_read_expected->percent_phasing()*scale, it_read_actual->percent_phasing(), tol); if(!std::isnan(it_read_expected->percent_prephasing()) && !std::isnan(it_read_actual->percent_prephasing())) @@ -68,68 +84,6 @@ TYPED_TEST(tile_metrics_test, test_read_write) } } -TYPED_TEST(tile_metrics_test, median) -{ - const float tol = 1e-7f / 0.01f; - const size_t read = 0; - float expected_percent_aligned_avg = interop::util::median(TypeParam::expected_metric_set.begin(), - TypeParam::expected_metric_set.end(), - interop::util::op::const_member_function_less(read, &tile_metric::percent_aligned))->percent_aligned(read); - EXPECT_NEAR(expected_percent_aligned_avg, 2.6163086891174316, tol); -} - -TYPED_TEST(tile_metrics_test, mean) -{ - const float tol = 1e-7f / 0.01f; - const size_t read = 0; - float expected_percent_aligned_avg = interop::util::mean(TypeParam::expected_metric_set.begin(), - TypeParam::expected_metric_set.end(), - interop::util::op::const_member_function(read, &tile_metric::percent_aligned)); - EXPECT_NEAR(expected_percent_aligned_avg, 2.5763518810272217, tol); -} - -TYPED_TEST(tile_metrics_test, nan_mean) -{ - const float tol = 1e-7f / 0.01f; - const size_t read = 0; - float expected_percent_aligned_avg = interop::util::nan_mean(TypeParam::expected_metric_set.begin(), - TypeParam::expected_metric_set.end(), - interop::util::op::const_member_function(read, &tile_metric::percent_aligned)); - EXPECT_NEAR(expected_percent_aligned_avg, 2.5763518810272217, tol); -} - - -TYPED_TEST(tile_metrics_test, standard_deviation) -{ - const float tol = 1e-7f / 0.01f; - const size_t read = 0; - float expected_percent_aligned_std = std::sqrt(interop::util::variance(TypeParam::expected_metric_set.begin(), - TypeParam::expected_metric_set.end(), - interop::util::op::const_member_function(read, &tile_metric::percent_aligned))); - EXPECT_NEAR(expected_percent_aligned_std, 0.074578315019607544, tol); -} - -TYPED_TEST(tile_metrics_test, nan_standard_deviation) -{ - const float tol = 1e-7f / 0.01f; - const size_t read = 0; - float expected_percent_aligned_std = std::sqrt(interop::util::nan_variance(TypeParam::expected_metric_set.begin(), - TypeParam::expected_metric_set.end(), - interop::util::op::const_member_function(read, &tile_metric::percent_aligned))); - EXPECT_NEAR(expected_percent_aligned_std, 0.074578315019607544, tol); -} - -TYPED_TEST(tile_metrics_test, standard_deviation_vec) -{ - const float tol = 1e-7f / 0.01f; - const size_t read = 0; - std::vector percent_aligned_vec(TypeParam::expected_metric_set.size()); - for(size_t i=0;i(percent_aligned_vec.begin(), - percent_aligned_vec.end())); - EXPECT_NEAR(expected_percent_aligned_std, 0.074578315019607544, tol); -} - TEST(tile_metrics_test, test_unique_id_four_digit) { typedef metric_set::uint_t uint_t; @@ -184,7 +138,8 @@ TEST(tile_metrics_test, test_tile_metric_for_lane) { metric_set metrics; tile_metric expected_metric(7, 1114, 2355119.25f,1158081.50f,6470949,3181956, - tile_metric::read_metric_vector(1, tile_metric::read_metric_type(3, 2.61630869f, 0.0797112584f/100, 0.119908921f/100))); + tile_metric::read_metric_vector(1, + tile_metric::read_metric_type(3, 2.61630869f, 0.0797112584f/100, 0.119908921f/100))); metrics.insert(expected_metric.id(), expected_metric); metric_set::metric_array_t tile_lane_metrics = metrics.metrics_for_lane(7); tile_metric& actual_metric = tile_lane_metrics[0]; @@ -198,28 +153,15 @@ TEST(tile_metrics_test, test_tile_metric_for_lane) EXPECT_NEAR(expected_metric.cluster_count(), actual_metric.cluster_count(), tol); EXPECT_NEAR(expected_metric.cluster_count_pf(), actual_metric.cluster_count_pf(), tol); EXPECT_EQ(expected_metric.read_metrics().size(), actual_metric.read_metrics().size()); +} -} -TEST(run_metrics_tile_test, test_is_group_empty) -{ - run_metrics metrics; - EXPECT_TRUE(metrics.is_group_empty(constants::Tile)); - io::read_interop_from_string(tile_v2::binary_data(), - metrics.get_set()); - EXPECT_FALSE(metrics.is_group_empty(constants::Tile)); -} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Setup regression test +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +regression_test_metric_generator tile_regression_gen("metrics"); +INSTANTIATE_TEST_CASE_P(tile_metric_regression_test, + tile_metrics_tests, + ProxyValuesIn(tile_regression_gen, regression_test_data::instance().files())); -#define FIXTURE tile_metrics_test -/** - * @class illumina::interop::model::metrics::tile_metric - * @test Confirm binary write matches expected binary data - * @test Confirm bad_format_exception is thrown when version is unsupported - * @test Confirm incomplete_file_exception is thrown for a small partial record - * @test Confirm incomplete_file_exception is thrown for a mostly complete file - * @test Confirm bad_format_exception is thrown when record size is incorrect - * @test Confirm file_not_found_exception is thrown when a file is not found - * @test Confirm reading from good data does not throw an exception - */ -#include "inc/stream_tests.hpp" diff --git a/src/tests/interop/run/info_test.cpp b/src/tests/interop/run/info_test.cpp index ba29da0ac..536c353c6 100644 --- a/src/tests/interop/run/info_test.cpp +++ b/src/tests/interop/run/info_test.cpp @@ -270,3 +270,4 @@ TEST(RunInfo, ParseXML_NextSeq) test_helper_run_info_parse_xml(expected_run_info, xml_file); } + diff --git a/src/tests/interop/run/parameters_test.cpp b/src/tests/interop/run/parameters_test.cpp index bf79c3a94..27818112c 100644 --- a/src/tests/interop/run/parameters_test.cpp +++ b/src/tests/interop/run/parameters_test.cpp @@ -422,3 +422,4 @@ TEST(RunParameters, ParseXML_NextSeq) test_helper_run_parameter_parse_xml(expected_param, xml_file); } + diff --git a/src/tests/interop/unit_tests.cpp b/src/tests/interop/unit_tests.cpp index d150c341e..39ded10a1 100644 --- a/src/tests/interop/unit_tests.cpp +++ b/src/tests/interop/unit_tests.cpp @@ -9,7 +9,7 @@ #include #include #include "src/tests/interop/inc/failure_listener.h" -#include "src/tests/interop/inc/regression_fixture.h" +#include "src/tests/interop/inc/regression_test_data.h" using namespace illumina::interop::unittest; int main(int argc, char **argv) @@ -60,7 +60,6 @@ int main(int argc, char **argv) failure_listener *listener = new failure_listener(default_printer); listeners.Append(listener); - // run try { @@ -73,3 +72,4 @@ int main(int argc, char **argv) } } + diff --git a/src/tests/interop/util/option_parser_test.cpp b/src/tests/interop/util/option_parser_test.cpp index e88b72db8..ae324cb4d 100644 --- a/src/tests/interop/util/option_parser_test.cpp +++ b/src/tests/interop/util/option_parser_test.cpp @@ -73,4 +73,4 @@ TEST(option_parser_test, no_invalid_option_value_exception) util::option_parser description; description(actual_value, "actual", "Help description"); EXPECT_NO_THROW(description.parse(argc, argv)); -} \ No newline at end of file +} diff --git a/src/tests/interop/util/stat_test.cpp b/src/tests/interop/util/stat_test.cpp new file mode 100644 index 000000000..e8210e967 --- /dev/null +++ b/src/tests/interop/util/stat_test.cpp @@ -0,0 +1,107 @@ +/** Unit tests for the stat utility +* +* +* @file +* @date 9/18/2016 +* @version 1.0 +* @copyright GNU Public License. +*/ +#include +#include +#include +#include +#include "interop/util/math.h" +#include "interop/util/statistics.h" +#include "interop/model/run_metrics.h" +#include "src/tests/interop/metrics/inc/tile_metrics_test.h" + +using namespace illumina::interop::model::metrics; +using namespace illumina::interop::model::metric_base; +using namespace illumina::interop::io; +using namespace illumina::interop; +using namespace illumina::interop::unittest; +using namespace illumina; +typedef metric_set< tile_metric > tile_metric_set; + +TEST(stat_test, median) +{ + tile_metric_set expected; + tile_metric_v2::create_metric_set(expected); + const float tol = 1e-7f / 0.01f; + const size_t read = 0; + float expected_percent_aligned_avg = interop::util::median(expected.begin(), + expected.end(), + interop::util::op::const_member_function_less(read, + &tile_metric::percent_aligned))->percent_aligned( + read); + EXPECT_NEAR(expected_percent_aligned_avg, 2.6163086891174316, tol); +} + +TEST(stat_test, mean) +{ + tile_metric_set expected; + tile_metric_v2::create_metric_set(expected); + const float tol = 1e-7f / 0.01f; + const size_t read = 0; + float expected_percent_aligned_avg = interop::util::mean(expected.begin(), + expected.end(), + interop::util::op::const_member_function(read, + &tile_metric::percent_aligned)); + EXPECT_NEAR(expected_percent_aligned_avg, 2.5763518810272217, tol); +} + +TEST(stat_test, nan_mean) +{ + tile_metric_set expected; + tile_metric_v2::create_metric_set(expected); + const float tol = 1e-7f / 0.01f; + const size_t read = 0; + float expected_percent_aligned_avg = interop::util::nan_mean(expected.begin(), + expected.end(), + interop::util::op::const_member_function(read, + &tile_metric::percent_aligned)); + EXPECT_NEAR(expected_percent_aligned_avg, 2.5763518810272217, tol); +} + + +TEST(stat_test, standard_deviation) +{ + tile_metric_set expected; + tile_metric_v2::create_metric_set(expected); + const float tol = 1e-7f / 0.01f; + const size_t read = 0; + float expected_percent_aligned_std = std::sqrt(interop::util::variance(expected.begin(), + expected.end(), + interop::util::op::const_member_function( + read, + &tile_metric::percent_aligned))); + EXPECT_NEAR(expected_percent_aligned_std, 0.074578315019607544, tol); +} + +TEST(stat_test, nan_standard_deviation) +{ + tile_metric_set expected; + tile_metric_v2::create_metric_set(expected); + const float tol = 1e-7f / 0.01f; + const size_t read = 0; + float expected_percent_aligned_std = std::sqrt(interop::util::nan_variance(expected.begin(), + expected.end(), + interop::util::op::const_member_function( + read, + &tile_metric::percent_aligned))); + EXPECT_NEAR(expected_percent_aligned_std, 0.074578315019607544, tol); +} + +TEST(stat_test, standard_deviation_vec) +{ + tile_metric_set expected; + tile_metric_v2::create_metric_set(expected); + const float tol = 1e-7f / 0.01f; + const size_t read = 0; + std::vector percent_aligned_vec(expected.size()); + for (size_t i = 0; i < expected.size(); ++i) percent_aligned_vec[i] = expected.at(i).percent_aligned(read); + float expected_percent_aligned_std = std::sqrt(interop::util::variance(percent_aligned_vec.begin(), + percent_aligned_vec.end())); + EXPECT_NEAR(expected_percent_aligned_std, 0.074578315019607544, tol); +} + diff --git a/tools/hooks/pre-commit.sh b/tools/hooks/pre-commit.sh new file mode 100755 index 000000000..71ab17ba4 --- /dev/null +++ b/tools/hooks/pre-commit.sh @@ -0,0 +1,17 @@ +#!/bin/bash + + +BRANCH=`git rev-parse --abbrev-ref HEAD` + +if [[ "$BRANCH" == "master" ]]; then + echo "You are on branch $BRANCH. Are you sure you want to commit to this branch?" + echo "If so, commit with -n to bypass this pre-commit hook." + exit 1 +fi + +#git diff --cached --exit-code --quiet +#status1=$? +#git diff --exit-code --quiet +#status2=$? +#if [ "$status1" == "1" ] || ["$status2" == "1"] ; then +#fi diff --git a/tools/hooks/pre-push.sh b/tools/hooks/pre-push.sh new file mode 100755 index 000000000..465432f6b --- /dev/null +++ b/tools/hooks/pre-push.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + + +version=`git describe --tags --dirty=-src` +cp CMakeLists.txt .CMakeLists.txt.bak +sed "s/set(ARCHIVE_VERSION .*)/set(ARCHIVE_VERSION \"${version}\")/g" .CMakeLists.txt.bak > CMakeLists.txt +rm -f .CMakeLists.txt.bak +git add CMakeLists.txt +git commit --amend -C HEAD --no-verify +