Skip to content

Commit

Permalink
Issue-259: Add simple functions with doc test examples (#261)
Browse files Browse the repository at this point in the history
* Issue-259: Add simple functions with doc test examples

Initial port

Try to debug new bindings

Ensure errors are reported

Try to work around issue

Fix swig bug

Most tests fixed

Fix all tests

Cherry pick over fixes

* Fix bug

* Fix warning and unit test

* Fix doctest again
  • Loading branch information
ezralanglois authored Apr 5, 2021
1 parent 9e9b6de commit cf7308d
Show file tree
Hide file tree
Showing 39 changed files with 1,382 additions and 27 deletions.
4 changes: 2 additions & 2 deletions docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ INPUT_ENCODING = UTF-8
# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd,
# *.vhdl, *.ucf, *.qsf, *.as and *.js.

FILE_PATTERNS = *.h *.cpp *.md *.cs
FILE_PATTERNS = *.h *.cpp *.md *.cs *.py
# TODO: *.py

# The RECURSIVE tag can be used to specify whether or not subdirectories should
Expand Down Expand Up @@ -825,7 +825,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*

EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = cmake-build-*

# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
Expand Down
7 changes: 7 additions & 0 deletions docs/src/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changes {#changes}

## v1.1.22

Date | Description
---------- | -----------
2021-03-24 | Issue-259: Add simple functions with doc test examples


## v1.1.21

Date | Description
Expand Down
8 changes: 8 additions & 0 deletions docs/src/python_binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ If you see this error:

Then upgrade numpy and try again.

## New simplified interface

from interop import *
ar = imaging("path/to/run_folder")

See new [interop.core](namespacecore.html) wrapper for the simplified interface


## Tips & Tricks

1. To see which methods/fields are available:
Expand Down
2 changes: 1 addition & 1 deletion interop/logic/plot/plot_sample_qc.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace illumina { namespace interop { namespace logic { namespace plot
void plot_sample_qc(model::metrics::run_metrics &metrics,
const size_t lane,
model::plot::plot_data <model::plot::bar_point> &data)
INTEROP_THROW_SPEC((model::index_out_of_bounds_exception));
INTEROP_THROW_SPEC((model::index_out_of_bounds_exception, std::bad_alloc));


}}}}
Expand Down
32 changes: 29 additions & 3 deletions interop/model/metrics/corrected_intensity_metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,26 +213,52 @@ namespace illumina { namespace interop { namespace model { namespace metrics
INTEROP_ASSERT(m_corrected_int_called.size() == constants::NUM_OF_BASES);
INTEROP_ASSERT(m_called_counts.size() == constants::NUM_OF_BASES_AND_NC);
}

/** Constructor
*
* @note Version 4
* @param lane lane number
* @param tile tile number
* @param cycle cycle number
* @param called_count_vec number of clusters called per base
*/
corrected_intensity_metric(const uint_t lane,
const uint_t tile,
const uint_t cycle,
const uint_array_t& called_count) :
metric_base::base_cycle_metric(lane, tile, cycle),
m_average_cycle_intensity(std::numeric_limits<ushort_t>::max()),
m_corrected_int_all(constants::NUM_OF_BASES, std::numeric_limits<ushort_t>::max()),
m_corrected_int_called(constants::NUM_OF_BASES, std::numeric_limits<float>::quiet_NaN()),
m_called_counts(called_count),
m_signal_to_noise(std::numeric_limits<float>::quiet_NaN())
{
INTEROP_ASSERT(called_count.size() == static_cast<size_t>(constants::NUM_OF_BASES_AND_NC));
}
/** Constructor
*
* @note Version 4
* @param lane lane number
* @param tile tile number
* @param cycle cycle number
* @param called_counts number of clusters called per base
* @param num_of_counts number of bases
*/
corrected_intensity_metric(const uint_t lane,
const uint_t tile,
const uint_t cycle,
const uint_array_t& called_counts) :
const ::uint32_t* called_counts,
const size_t num_of_counts,
const size_t /*dummy*/, /* dummy parameters work around swig bug */
const size_t /*dummy*/) :
metric_base::base_cycle_metric(lane, tile, cycle),
m_average_cycle_intensity(std::numeric_limits<ushort_t>::max()),
m_corrected_int_all(constants::NUM_OF_BASES, std::numeric_limits<ushort_t>::max()),
m_corrected_int_called(constants::NUM_OF_BASES, std::numeric_limits<float>::quiet_NaN()),
m_called_counts(called_counts),
m_called_counts(called_counts, called_counts + std::min(num_of_counts, static_cast<size_t>(constants::NUM_OF_BASES_AND_NC))),
m_signal_to_noise(std::numeric_limits<float>::quiet_NaN())
{
INTEROP_ASSERT(called_counts.size() == constants::NUM_OF_BASES_AND_NC);
INTEROP_ASSERT(num_of_counts== static_cast<size_t>(constants::NUM_OF_BASES_AND_NC));
}

public:
Expand Down
27 changes: 27 additions & 0 deletions interop/model/metrics/extraction_metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,33 @@ namespace illumina { namespace interop { namespace model { namespace metrics
{
}

/** Constructor
*
* @note Version 3
* @param lane lane number
* @param tile tile number
* @param cycle cycle number
* @param intensity_values 90th percentile of intensities for the given channel
* @param intensity_count number of channels
* @param focus_scores focus score for the given channel
* @param focus_count number of channels
*/
extraction_metric(const uint_t lane,
const uint_t tile,
const uint_t cycle,
const ::uint16_t* intensity_values,
const size_t intensity_count,
const float* focus_scores,
const size_t focus_count,
const size_t /*dummy*/) :
metric_base::base_cycle_metric(lane, tile, cycle),
m_date_time_csharp(0),
m_date_time(0),
m_max_intensity_values(intensity_values, intensity_values+intensity_count),
m_focus_scores(focus_scores, focus_scores+focus_count)
{
}

public:
/** Setter
*
Expand Down
30 changes: 30 additions & 0 deletions interop/model/metrics/index_metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,36 @@ namespace illumina { namespace interop { namespace model { namespace metrics
static const char *prefix()
{ return "Index"; }

/** Percentage of PF clusters on the tile that have been demultiplexed
*
* Dependent on tile_metric
*
* @return percent of demultiplexed PF clusters
*/
float percent_demultiplexed(const std::string& sample_id) const
{
uint64_t total_demultiplexed_clusters = 0;
if (sample_id.empty())
{
for (size_t index_array_counter = 0; index_array_counter < m_indices.size(); ++index_array_counter)
{
total_demultiplexed_clusters += m_indices[index_array_counter].cluster_count();
}
}
else
{
for (size_t index_array_counter = 0; index_array_counter < m_indices.size(); ++index_array_counter)
{
if(m_indices[index_array_counter].sample_id() == sample_id)
{
total_demultiplexed_clusters = m_indices[index_array_counter].cluster_count();
break;
}
}
}
return static_cast<float>(total_demultiplexed_clusters)/m_cluster_count_pf * 100;
}

private:
index_array_t m_indices;
float m_cluster_count; // Derived from tile metric
Expand Down
19 changes: 16 additions & 3 deletions src/ext/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ string(REPLACE ";" "','" PY_GEN_LIST "${py_gens}")
set(INTEROP_VERSION ${VERSION_SHORT}${VERSION_DEV})
configure_file(__init__.py.in interop/__init__.py @ONLY)
configure_file(__main__.py.in interop/__main__.py @ONLY)
file(COPY ${CMAKE_SOURCE_DIR}/src/tests/python/CoreTests.py DESTINATION interop)


add_custom_command( TARGET python_lib POST_BUILD
COMMAND ${CMAKE_COMMAND}
Expand All @@ -155,8 +155,21 @@ add_custom_command( TARGET python_lib POST_BUILD
-DCONFIG_INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in
-DCONFIG_OUTPUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/setup.py
-P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake
COMMAND ${CMAKE_COMMAND}
-DINTEROP_VERSION=${VERSION_SHORT}${VERSION_DEV}
-DINTEROP_LIB_LIST="${PY_GEN_LIST}"
-DCONFIG_INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/__main__.py.in
-DCONFIG_OUTPUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/__main__.py
-P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/core.py
${CMAKE_CURRENT_BINARY_DIR}/interop/core.py
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/src/tests/python/CoreTests.py
${CMAKE_CURRENT_BINARY_DIR}/interop/CoreTests.py
)


install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DESTINATION share/illumina/interop/src
FILES_MATCHING
Expand All @@ -173,7 +186,7 @@ set(SWIG_GEN_PYTHON_SOURCE_FILES ${py_files} CACHE INTERNAL "Python scripts gene


if(NOT PYTHONINTERP_FOUND)
message(WARNING "Cannot find Python Interpretor, cannot create wheel package")
message(WARNING "Cannot find Python Interpreter, cannot create wheel package")
return()
endif()

Expand All @@ -193,4 +206,4 @@ if(NOT SKIP_PACKAGE_ALL_WHEEL)
endif()


set(PYTHON_BUILD_AVAILABLE "Python ${PYTHON_VERSION_STRING}" CACHE INTERNAL "All dependencies are satisfied for the Java Build" FORCE)
set(PYTHON_BUILD_AVAILABLE "Python ${PYTHON_VERSION_STRING}" CACHE INTERNAL "All dependencies are satisfied for the Java Build" FORCE)
3 changes: 3 additions & 0 deletions src/ext/python/__init__.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ __doc_url__ = "http://illumina.github.io/interop/index.html"
__version__ = "@INTEROP_VERSION@"
__maintainer__ = "Illumina, inc."
__contact__ = "https://github.com/Illumina/interop/issues"

from interop.core import *

2 changes: 2 additions & 0 deletions src/ext/python/__main__.py.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import interop
import interop.core
import unittest
import argparse
from interop import @PY_MOD_NAME_LIST@
Expand All @@ -16,6 +17,7 @@ def execute_from_commandline():
if param.test:
testsuite = unittest.makeSuite(CoreTests)
unittest.TextTestRunner(verbosity=1).run(testsuite)
interop.core._run_doctests()

if __name__ == "__main__":
execute_from_commandline();
Expand Down
Loading

0 comments on commit cf7308d

Please sign in to comment.