params.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. #pragma once
  28. #include <nvBowtie/bowtie2/cuda/scoring.h>
  29. #include <string.h>
  30. #include <string>
  31. #include <map>
  32. namespace nvbio {
  33. namespace bowtie2 {
  34. namespace cuda {
  35. ///@addtogroup nvBowtie
  36. ///@{
  37. enum MappingMode {
  38. BestMappingApprox = 0,
  39. BestMappingExact = 1,
  40. AllMapping = 2
  41. };
  42. enum ScoringMode {
  43. EditDistanceMode = 0,
  44. SmithWatermanMode = 1,
  45. };
  46. static const char* s_mapping_mode[] = {
  47. "best",
  48. "best-exact",
  49. "all"
  50. };
  51. inline const char* mapping_mode(const uint32 mode)
  52. {
  53. return s_mapping_mode[ mode ];
  54. }
  55. inline uint32 mapping_mode(const char* str)
  56. {
  57. if (strcmp( str, "best" ) == 0)
  58. return BestMappingApprox;
  59. else if (strcmp( str, "best-exact" ) == 0)
  60. return BestMappingExact;
  61. else
  62. return AllMapping;
  63. }
  64. static const char* s_scoring_mode[] = {
  65. "ed",
  66. "sw"
  67. };
  68. inline const char* scoring_mode(const uint32 mode)
  69. {
  70. return s_scoring_mode[ mode ];
  71. }
  72. inline uint32 scoring_mode(const char* str)
  73. {
  74. if (strcmp( str, "ed" ) == 0)
  75. return EditDistanceMode;
  76. else if (strcmp( str, "sw" ) == 0)
  77. return SmithWatermanMode;
  78. else
  79. return EditDistanceMode;
  80. }
  81. ///
  82. /// A POD structure holding all of nvBowtie's parameters
  83. ///
  84. struct ParamsPOD
  85. {
  86. bool keep_stats;
  87. bool randomized;
  88. bool fw;
  89. bool rc;
  90. uint32 mode;
  91. uint32 scoring_mode;
  92. uint32 alignment_type;
  93. uint32 top_seed;
  94. uint32 seed_len;
  95. SimpleFunc seed_freq;
  96. uint32 max_hits;
  97. uint32 max_dist;
  98. uint32 max_effort_init;
  99. uint32 max_effort;
  100. uint32 min_ext;
  101. uint32 max_ext;
  102. uint32 max_reseed;
  103. uint32 rep_seeds;
  104. uint32 allow_sub;
  105. uint32 subseed_len;
  106. uint32 mapq_filter;
  107. uint32 min_read_len;
  108. uint32 max_batch_size;
  109. uint32 avg_read_length;
  110. bool ungapped_mates;
  111. // paired-end options
  112. uint32 pe_policy;
  113. bool pe_overlap;
  114. bool pe_dovetail;
  115. bool pe_unpaired;
  116. bool pe_discordant;
  117. uint32 min_frag_len;
  118. uint32 max_frag_len;
  119. // Scoring scheme
  120. UberScoringScheme scoring_scheme;
  121. // Internal fields
  122. uint32 scoring_window;
  123. DebugState debug;
  124. };
  125. ///
  126. /// A non-POD structure holding all of nvBowtie's parameters plus a few extra string options
  127. ///
  128. struct Params : public ParamsPOD
  129. {
  130. std::string report;
  131. std::string scoring_file;
  132. int32 persist_batch;
  133. int32 persist_seeding;
  134. int32 persist_extension;
  135. std::string persist_file;
  136. int32 no_multi_hits;
  137. };
  138. ///
  139. /// load options from a file
  140. ///
  141. std::map<std::string,std::string> load_options(const char* name);
  142. ///
  143. /// parse options
  144. ///
  145. void parse_options(Params& params, const std::map<std::string,std::string>& options, bool init);
  146. ///@} // group nvBowtie
  147. } // namespace cuda
  148. } // namespace bowtie2
  149. } // namespace nvbio