locate.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * nvbio
  3. * Copyright (c) 2011-2014, NVIDIA CORPORATION. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the NVIDIA CORPORATION nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  17. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. ///
  28. ///\file locate.h
  29. ///
  30. #pragma once
  31. #include <nvBowtie/bowtie2/cuda/defs.h>
  32. #include <nvBowtie/bowtie2/cuda/params.h>
  33. #include <nvbio/io/alignments.h>
  34. namespace nvbio {
  35. namespace bowtie2 {
  36. namespace cuda {
  37. template <typename ScoringScheme> struct BaseScoringPipelineState;
  38. template <typename ScoringScheme> struct BestApproxScoringPipelineState;
  39. ///@addtogroup nvBowtie
  40. ///@{
  41. /// \defgroup Locate
  42. ///
  43. /// The functions in this module implement a pipeline stage in which all the previously selected hits (\ref Select)
  44. /// locations are converted from Suffix Array coordinates to linear genome coordinates.
  45. /// In terms of inputs and outputs, this stage takes the HitQueues::seed and HitQueues::loc fields, and rewrite
  46. /// the HitQueues::loc field with the linear value.
  47. ///
  48. /// \b inputs:
  49. /// - HitQueues::seed
  50. /// - HitQueues::loc
  51. ///
  52. /// \b outputs:
  53. /// - HitQueues::loc
  54. ///
  55. ///@addtogroup Locate
  56. ///@{
  57. ///
  58. /// Locate the SA row of the the hits in the HitQueues.
  59. /// Since the input might have been sorted to gather locality, the entries
  60. /// in the HitQueues are now specified by an index (idx_queue).
  61. /// This function reads HitQueues::seed and HitQueues::loc fields and rewrites
  62. /// the HitQueues::loc field.
  63. ///
  64. template <typename BatchType, typename FMType, typename rFMType>
  65. void locate(
  66. const BatchType read_batch, const FMType fmi, const rFMType rfmi,
  67. const uint32 in_count,
  68. const uint32* idx_queue,
  69. HitQueuesDeviceView hits,
  70. const ParamsPOD params);
  71. ///
  72. /// Locate the SA row of the the hits in the HitQueues.
  73. /// Since the input might have been sorted to gather locality, the entries
  74. /// in the HitQueues are now specified by an index (idx_queue).
  75. /// This function reads HitQueues::seed and HitQueues::loc fields and writes
  76. /// the HitQueues::loc and HitQueues::ssa fields with temporary values that
  77. /// can be later consumed by locate_lookup.
  78. ///
  79. template <typename BatchType, typename FMType, typename rFMType>
  80. void locate_init(
  81. const BatchType read_batch, const FMType fmi, const rFMType rfmi,
  82. const uint32 in_count,
  83. const uint32* idx_queue,
  84. HitQueuesDeviceView hits,
  85. const ParamsPOD params);
  86. ///
  87. /// Locate the SA row of the the hits in the HitQueues.
  88. /// Since the input might have been sorted to gather locality, the entries
  89. /// in the HitQueues are now specified by an index (idx_queue).
  90. /// This function reads HitQueues::seed, HitQueues::loc and HitQueues::ssa fields
  91. /// (which must have been previously produced by a call to locate_init) and rewrites
  92. /// the HitQueues::loc field with the final linear coordinate value.
  93. ///
  94. template <typename BatchType, typename FMType, typename rFMType>
  95. void locate_lookup(
  96. const BatchType read_batch, const FMType fmi, const rFMType rfmi,
  97. const uint32 in_count,
  98. const uint32* idx_queue,
  99. HitQueuesDeviceView hits,
  100. const ParamsPOD params);
  101. ///
  102. /// Locate the SA row of the the hits in the HitQueues.
  103. /// This function reads HitQueues::seed and HitQueues::loc fields and writes
  104. /// the HitQueues::loc and HitQueues::ssa fields with temporary values that
  105. /// can be later consumed by locate_lookup.
  106. ///
  107. template <typename ScoringScheme>
  108. void locate_init(
  109. const BaseScoringPipelineState<ScoringScheme>& pipeline,
  110. const ParamsPOD params);
  111. ///
  112. /// Locate the SA row of the the hits in the HitQueues.
  113. /// This function reads HitQueues::seed, HitQueues::loc and HitQueues::ssa fields
  114. /// (which must have been previously produced by a call to locate_init) and rewrites
  115. /// the HitQueues::loc field with the final linear coordinate value.
  116. ///
  117. template <typename ScoringScheme>
  118. void locate_lookup(
  119. const BaseScoringPipelineState<ScoringScheme>& pipeline,
  120. const ParamsPOD params);
  121. ///
  122. /// mark seeds straddling the reference boundaries.
  123. ///
  124. template <typename index_iterator, typename flags_iterator>
  125. void mark_straddling(
  126. const uint32 in_count,
  127. const uint32* idx_queue,
  128. const uint32 reference_count,
  129. const index_iterator reference_index,
  130. HitQueuesDeviceView hits,
  131. flags_iterator flags,
  132. const ParamsPOD params);
  133. ///@} // group Locate
  134. ///@} // group nvBowtie
  135. } // namespace cuda
  136. } // namespace bowtie2
  137. } // namespace nvbio
  138. #include <nvBowtie/bowtie2/cuda/locate_inl.h>