~ubuntu-branches/ubuntu/intrepid/primer3/intrepid

« back to all changes in this revision

Viewing changes to src/oligotm_main.c

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2006-09-28 20:18:54 UTC
  • Revision ID: james.westby@ubuntu.com-20060928201854-45pwapz5e3a6d684
Tags: upstream-1.0b
ImportĀ upstreamĀ versionĀ 1.0b

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 1996,1997,1998,1999,2000,2001,2004,2006
 
3
Whitehead Institute for Biomedical Research, Steve Rozen
 
4
(http://jura.wi.mit.edu/rozen), and Helen Skaletsky
 
5
All rights reserved.
 
6
 
 
7
Redistribution and use in source and binary forms, with or without
 
8
modification, are permitted provided that the following conditions are
 
9
met:
 
10
 
 
11
   * Redistributions of source code must retain the above copyright
 
12
notice, this list of conditions and the following disclaimer.
 
13
   * Redistributions in binary form must reproduce the above
 
14
copyright notice, this list of conditions and the following disclaimer
 
15
in the documentation and/or other materials provided with the
 
16
distribution.
 
17
   * Neither the names of the copyright holders nor contributors may
 
18
be used to endorse or promote products derived from this software
 
19
without specific prior written permission.
 
20
 
 
21
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
22
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
23
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
24
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
25
OWNERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
26
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
27
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
28
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
29
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
30
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
31
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
32
*/
 
33
 
 
34
#include <stdio.h>
 
35
#include <stdlib.h>
 
36
#include <string.h>
 
37
#include "oligotm.h"
 
38
 
 
39
/* Print the melting tm of an oligo on stdout. */
 
40
int
 
41
main(argc, argv)
 
42
    int argc;
 
43
    const char **argv;
 
44
{
 
45
    double tm;
 
46
    char *msg = "Usage: %s [-k salt-conc] [-d template-conc] oligo\n\n"
 
47
                "where oligo is an oligonucleotide sequence of between 2 and 36 bases.\n"
 
48
                "(Bases in oligo must be uppercase.)\n"
 
49
                "salt-conc is mM salt (usually K) concentration; defaults to 50mM\n"
 
50
                "template-conc is nM template concentration\n; defaults to 50nM\n"
 
51
                "Prints oligo's melting temperature on stdout.\n";
 
52
    char *endptr;
 
53
    long k = 50, d = 50;
 
54
    int i;
 
55
 
 
56
    if (argc < 2 || argc > 6) {
 
57
        fprintf(stderr, msg, argv[0]);
 
58
        return -1;
 
59
    }
 
60
 
 
61
    for (i=1; i < argc; ++i) {
 
62
        if (!strncmp("-k", argv[i], 2)) {
 
63
            k = strtol(argv[i+1], &endptr, 10);
 
64
            if ('\0' != *endptr) {
 
65
                fprintf(stderr, msg, argv[0]);
 
66
                exit(-1);
 
67
            }
 
68
            i++;
 
69
        } else if (!strncmp("-d", argv[i], 2)) {
 
70
            d = strtol(argv[i+1], &endptr, 10);
 
71
            if ('\0' != *endptr) {
 
72
                fprintf(stderr, msg, argv[0]);
 
73
                exit(-1);
 
74
            }
 
75
            i++;
 
76
        } else if (!strncmp("-", argv[i], 1)) {
 
77
            /* Unknown option. */
 
78
            fprintf(stderr, msg, argv[0]);
 
79
            exit(-1);
 
80
        } else
 
81
            break;              /* all args processed. go on to sequences. */
 
82
    }
 
83
 
 
84
    tm = oligotm(argv[i], d, k);
 
85
    if (OLIGOTM_ERROR == tm) {
 
86
        fprintf(stderr,
 
87
                "%s: length of %s is less than 2 or it contains an illegal character\n",
 
88
                argv[0], argv[i]);
 
89
        return -1;
 
90
    }
 
91
    fprintf(stdout, "%f\n", tm);
 
92
    return 0;
 
93
}
 
94
 
 
95
 
 
96
 
 
97