PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/primer3-2.3.4/src/oligotm_main.c

#
C | 196 lines | 145 code | 9 blank | 42 comment | 36 complexity | e1582bb13256436c07325d2df44ef0a0 MD5 | raw file
Possible License(s): GPL-2.0
  1. /*
  2. Copyright (c) 1996,1997,1998,1999,2000,2001,2004,2006,2007,2008
  3. Whitehead Institute for Biomedical Research, Steve Rozen
  4. (http://purl.com/STEVEROZEN/), Andreas Untergasser and Helen Skaletsky.
  5. All rights reserved.
  6. This file is part of the primer3 suite and libraries.
  7. The primer3 suite and libraries are free software;
  8. you can redistribute them and/or modify them under the terms
  9. of the GNU General Public License as published by the Free
  10. Software Foundation; either version 2 of the License, or (at
  11. your option) any later version.
  12. This software is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this software (file gpl-2.0.txt in the source
  18. distribution); if not, write to the Free Software
  19. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <string.h>
  35. #include <ctype.h>
  36. #include "oligotm.h"
  37. /* Print the melting temperature of an oligo on stdout. */
  38. /* This program provides a command line interface to
  39. the function oligotm() in oligtm.c
  40. */
  41. int
  42. main(int argc, char **argv)
  43. {
  44. double tm;
  45. const char *msg = "USAGE: %s OPTIONS oligo\n"
  46. "\n"
  47. "where oligo is a DNA sequence of between 2 and 36 bases\n"
  48. "\n"
  49. "and\n"
  50. "\n"
  51. "OPTIONS can include any of the the following:\n"
  52. "\n"
  53. "-mv monovalent_conc - concentration of monovalent cations in mM, by default 50mM\n"
  54. "\n"
  55. "-dv divalent_conc - concentration of divalent cations in mM, by default 0mM\n"
  56. "\n"
  57. "-n dNTP_conc - concentration of deoxynycleotide triphosphate in mM, by default 0mM\n"
  58. "\n"
  59. "-d dna_conc - concentration of DNA strands in nM, by default 50nM\n"
  60. "\n"
  61. "-tp [0|1] - Specifies the table of thermodynamic parameters and\n"
  62. " the method of melting temperature calculation:\n"
  63. " 0 Breslauer et al., 1986 and Rychlik et al., 1990\n"
  64. " (used by primer3 up to and including release 1.1.0).\n"
  65. " This is the default, but _not_ the recommended value.\n"
  66. " 1 Use nearest neighbor parameters from SantaLucia 1998\n"
  67. " *THIS IS THE RECOMMENDED VALUE*\n"
  68. "\n"
  69. "-sc [0..2] - Specifies salt correction formula for the melting \n"
  70. " temperature calculation\n"
  71. " 0 Schildkraut and Lifson 1965, used by primer3 up to \n"
  72. " and including release 1.1.0.\n"
  73. " This is the default but _not_ the recommended value.\n"
  74. " 1 SantaLucia 1998\n"
  75. " *THIS IS THE RECOMMENDED VAULE*\n"
  76. " 2 Owczarzy et al., 2004\n\n"
  77. "\n\n"
  78. "Prints oligo's melting temperature on stdout.\n";
  79. const char *copyright =
  80. "Copyright (c) 1996,1997,1998,1999,2000,2001,2004,2006\n"
  81. "Whitehead Institute for Biomedical Research, Steve Rozen\n"
  82. "(http://purl.com/STEVEROZEN/), Andreas Untergasser and Helen Skaletsky\n"
  83. "All rights reserved.\n"
  84. "\n"
  85. " This file is part of the oligotm library.\n"
  86. "\n"
  87. " The oligotm library is free software; you can redistribute it and/or modify\n"
  88. " it under the terms of the GNU General Public License as published by\n"
  89. " the Free Software Foundation; either version 2 of the License, or\n"
  90. " (at your option) any later version.\n"
  91. "\n"
  92. " The oligotm library is distributed in the hope that it will be useful,\n"
  93. " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
  94. " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
  95. " GNU General Public License for more details.\n"
  96. "\n"
  97. " You should have received a copy of the GNU General Public License\n"
  98. " along with the oligtm library (file gpl-2.0.txt in the source\n"
  99. " distribution). If not, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt;\n"
  100. " or write to the Free Software Foundation, Inc.,\n"
  101. " 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n";
  102. char *endptr, *seq;
  103. long mv = 50, d = 50;
  104. double dv = 0, n = 0;
  105. int tm_santalucia=0, salt_corrections=0;
  106. int i, j, len;
  107. if (argc < 2 || argc > 14) {
  108. fprintf(stderr, msg, argv[0]);
  109. fprintf(stderr, "%s", copyright);
  110. return -1;
  111. }
  112. for (i=1; i < argc; ++i) {
  113. if (!strncmp("-mv", argv[i], 3)) { /* conc of monovalent cations */
  114. mv = strtol(argv[i+1], &endptr, 10);
  115. if ('\0' != *endptr) {
  116. fprintf(stderr, msg, argv[0]);
  117. exit(-1);
  118. }
  119. i++;
  120. } else if (!strncmp("-dv", argv[i], 3)) { /* conc of divalent cations; added by T.Koressaar */
  121. dv = strtod(argv[i+1], &endptr);
  122. if('\0' != *endptr) {
  123. fprintf(stderr, msg, argv[0]);
  124. exit(-1);
  125. }
  126. i++;
  127. } else if (!strncmp("-n", argv[i], 2)) { /* conc of dNTP; added by T.Koressaar */
  128. n = strtod(argv[i+1], &endptr);
  129. if('\0' != *endptr) {
  130. fprintf(stderr, msg, argv[0]);
  131. exit(-1);
  132. }
  133. i++;
  134. } else if (!strncmp("-d", argv[i], 2)) {
  135. d = strtol(argv[i+1], &endptr, 10);
  136. if ('\0' != *endptr) {
  137. fprintf(stderr, msg, argv[0]);
  138. exit(-1);
  139. }
  140. i++;
  141. } else if (!strncmp("-tp", argv[i], 3)) { /* added by T.Koressaar */
  142. tm_santalucia = (int)strtol(argv[i+1], &endptr, 10);
  143. if ('\0' != *endptr || tm_santalucia<0 || tm_santalucia>1) {
  144. fprintf(stderr, msg, argv[0]);
  145. exit(-1);
  146. }
  147. i++;
  148. } else if (!strncmp("-sc", argv[i], 3)) { /* added by T.Koressaar */
  149. salt_corrections = (int)strtol(argv[i+1], &endptr, 10);
  150. if ('\0' != *endptr || salt_corrections<0 || salt_corrections>2) {
  151. fprintf(stderr, msg, argv[0]);
  152. exit(-1);
  153. }
  154. i++;
  155. } else if (!strncmp("-", argv[i], 1)) {
  156. /* Unknown option. */
  157. fprintf(stderr, msg, argv[0]);
  158. exit(-1);
  159. } else
  160. break; /* all args processed. go on to sequences. */
  161. }
  162. if(!argv[i]) { /* if no oligonucleotide sequence is specified */
  163. fprintf(stderr, msg, argv[0]);
  164. exit(-1);
  165. }
  166. /* input sequence to uppercase */
  167. seq = argv[i];
  168. len=strlen(seq);
  169. for(j=0;j<len;j++) seq[j]=toupper(seq[j]);
  170. tm = oligotm(seq, d, mv, dv, n, (tm_method_type) tm_santalucia, (salt_correction_type) salt_corrections);
  171. if (OLIGOTM_ERROR == tm) {
  172. fprintf(stderr,
  173. "%s ERROR: length of sequence %s is less than 2 or\n"
  174. " the sequence contains an illegal character or\n"
  175. " you have specified incorrect value for concentration of divalent cations or\n"
  176. " you have specified incorrect value for concentration of dNTPs\n",
  177. argv[0], argv[i]);
  178. return -1;
  179. }
  180. fprintf(stdout, "%f\n", tm);
  181. return 0;
  182. }