JPRED-2 Add sources of all binaries (except alscript) to Git
[jpred.git] / sources / pairwise / docs / html / pairwise_8c-source.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>pairwise: pairwise.c Source File</title>
4 <link href="doxygen.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.3.2 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
8 <h1>pairwise.c</h1><a href="pairwise_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* Pairwise identity program.</span>
9 00002 <span class="comment"> *</span>
10 00003 <span class="comment"> * $Id</span>
11 00004 <span class="comment"> *</span>
12 00005 <span class="comment"> * Reads in a gapped alignment sequences in a FASTA file format.</span>
13 00006 <span class="comment"> * Assume gaps are represented by '-' characters.</span>
14 00007 <span class="comment"> *</span>
15 00008 <span class="comment"> * For each pair calculates the sequence percentage identity, see comments</span>
16 00009 <span class="comment"> * for pairwise() for details.</span>
17 00010 <span class="comment"> *</span>
18 00011 <span class="comment"> * Output is in the format for OC to read in, i.e. the number of sequences,</span>
19 00012 <span class="comment"> * followed by the sequence ID's, followed by the pairwise comparisons.</span>
20 00013 <span class="comment"> *</span>
21 00014 <span class="comment"> * Thu Dec  5 14:38:43 GMT 2002 Jon</span>
22 00015 <span class="comment"> * Added checking for eqilength sequences</span>
23 00016 <span class="comment"> *</span>
24 00017 <span class="comment"> * Thu Jul 24 12:14:04 BST 2003 Jon</span>
25 00018 <span class="comment"> * Moved FASTA reading into read_fasta function</span>
26 00019 <span class="comment"> * Checked into CVS</span>
27 00020 <span class="comment"> *</span>
28 00021 <span class="comment"> * */</span>
29 00022 
30 00023 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
31 00024 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
32 00025 <span class="preprocessor">#include &lt;errno.h&gt;</span>
33 00026 <span class="preprocessor">#include &lt;string.h&gt;</span>
34 00027 <span class="preprocessor">#include "<a class="code" href="pairwise_8h.html">pairwise.h</a>"</span>
35 00028 
36 <a name="l00029"></a><a class="code" href="pairwise_8c.html#a0">00029</a> <span class="preprocessor">#define ARRAY 50</span>
37 <a name="l00030"></a><a class="code" href="pairwise_8c.html#a1">00030</a> <span class="preprocessor"></span><span class="preprocessor">#define FILEBUF 1000</span>
38 00031 <span class="preprocessor"></span>
39 00032 <span class="comment">/* Macro's added by Patrick, mucho neato, aparently ifndef aren't POSIX</span>
40 00033 <span class="comment"> * anymore */</span>
41 00034 <span class="preprocessor">#if !defined(MAX)</span>
42 <a name="l00035"></a><a class="code" href="pairwise_8c.html#a2">00035</a> <span class="preprocessor"></span><span class="preprocessor">#define MAX(A, B)       ((A) &gt; (B) ? (A) : (B))</span>
43 00036 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
44 00037 <span class="preprocessor"></span>
45 00038 <span class="preprocessor">#if !defined(MIN)</span>
46 <a name="l00039"></a><a class="code" href="pairwise_8c.html#a3">00039</a> <span class="preprocessor"></span><span class="preprocessor">#define MIN(A, B)       ((A) &lt; (B) ? (A) : (B))</span>
47 00040 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
48 00041 <span class="preprocessor"></span>
49 00042 <span class="comment">/* Macro's added by Jon, allows checking of NULL pointers from memory</span>
50 00043 <span class="comment"> * allocations without function calls, but how can you return values? */</span>
51 00044 <span class="preprocessor">#if !defined(MALLOC)</span>
52 <a name="l00045"></a><a class="code" href="pairwise_8c.html#a4">00045</a> <span class="preprocessor"></span><span class="preprocessor">#define MALLOC(PTR, SIZE) do { PTR = malloc(SIZE); if (PTR == NULL) fatal_sys_error("malloc returned NULL"); } while (0)</span>
53 00046 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
54 00047 <span class="preprocessor"></span>
55 00048 <span class="preprocessor">#if !defined(REALLOC)</span>
56 <a name="l00049"></a><a class="code" href="pairwise_8c.html#a5">00049</a> <span class="preprocessor"></span><span class="preprocessor">#define REALLOC(PTR, SIZE) do { PTR = realloc(PTR, SIZE); if (PTR == NULL &amp;&amp; SIZE != 0) fatal_sys_error("realloc returned NULL"); } while (0)</span>
57 00050 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
58 00051 <span class="preprocessor"></span>
59 00052 <span class="keywordtype">void</span>
60 <a name="l00053"></a><a class="code" href="pairwise_8c.html#a6">00053</a> <a class="code" href="pairwise_8c.html#a6">fatal_error</a> (<span class="keywordtype">char</span> *message) {
61 00054         printf(message);
62 00055         exit(EXIT_FAILURE);
63 00056 }
64 00057 
65 00058 <span class="keywordtype">void</span>
66 <a name="l00059"></a><a class="code" href="pairwise_8c.html#a7">00059</a> <a class="code" href="pairwise_8c.html#a7">fatal_sys_error</a> (<span class="keywordtype">char</span> *message) {
67 00060         perror(message);
68 00061         exit(EXIT_FAILURE);
69 00062 }
70 00063 
71 00064 FILE *
72 <a name="l00065"></a><a class="code" href="pairwise_8c.html#a8">00065</a> <a class="code" href="pairwise_8c.html#a8">xfopen</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keyword">const</span> <span class="keywordtype">char</span> *mode) {
73 00066         FILE *fh;
74 00067         fh = fopen(path, mode);
75 00068         <span class="keywordflow">if</span> (fh == NULL)
76 00069                 <a class="code" href="pairwise_8c.html#a7">fatal_sys_error</a>(<span class="stringliteral">"fopen returned NULL"</span>);
77 00070         <span class="keywordflow">return</span> fh;
78 00071 }
79 00072 
80 00073 <span class="keywordtype">void</span> *
81 <a name="l00074"></a><a class="code" href="pairwise_8c.html#a9">00074</a> <a class="code" href="pairwise_8c.html#a9">xmalloc</a> (size_t size) {
82 00075         <span class="keywordtype">void</span> *ptr;
83 00076         ptr = (<span class="keywordtype">void</span> *) malloc(size);
84 00077         <span class="keywordflow">if</span> (ptr == NULL)
85 00078                 <a class="code" href="pairwise_8c.html#a7">fatal_sys_error</a>(<span class="stringliteral">"malloc returned NULL"</span>);
86 00079         <span class="keywordflow">return</span> ptr;
87 00080 }
88 00081 
89 00082 <span class="keywordtype">void</span> *
90 <a name="l00083"></a><a class="code" href="pairwise_8c.html#a10">00083</a> <a class="code" href="pairwise_8c.html#a10">xrealloc</a> (<span class="keywordtype">void</span> *ptr, size_t size) {
91 00084         ptr = (<span class="keywordtype">void</span> *) realloc(ptr, size);
92 00085         <span class="keywordflow">if</span> (ptr == NULL &amp;&amp; size != 0)
93 00086                 <a class="code" href="pairwise_8c.html#a7">fatal_sys_error</a>(<span class="stringliteral">"realloc returned NULL"</span>);
94 00087         <span class="keywordflow">return</span> ptr;
95 00088 }
96 00089 
97 00090 <span class="comment">/* If the same resdidue return 1 else return 0 */</span>
98 00091 <span class="keywordtype">int</span> 
99 <a name="l00092"></a><a class="code" href="pairwise_8c.html#a11">00092</a> <a class="code" href="pairwise_8c.html#a11">diff</a> (<span class="keywordtype">char</span> a, <span class="keywordtype">char</span> b) {
100 00093         <span class="keywordflow">if</span> (a == b &amp;&amp; a == <span class="charliteral">'-'</span>)
101 00094                 <span class="keywordflow">return</span> 0;
102 00095         <span class="keywordflow">if</span> (a == b)
103 00096                 <span class="keywordflow">return</span> 1;
104 00097         <span class="keywordflow">return</span> 0;
105 00098 }
106 00099 
107 00100 <span class="comment">/* Does the pairwise comparison</span>
108 00101 <span class="comment"> * Compares the regions of the alignment that overlap, common gaps are</span>
109 00102 <span class="comment"> * ignored, and the number of common residues divided by the length of</span>
110 00103 <span class="comment"> * the shortest sequence is the identity.</span>
111 00104 <span class="comment"> * */</span>
112 00105 <span class="keywordtype">float</span>
113 <a name="l00106"></a><a class="code" href="pairwise_8c.html#a12">00106</a> <a class="code" href="pairwise_8c.html#a12">pairwise</a> (<span class="keyword">struct</span> <a class="code" href="structfasta.html">fasta</a> *a, <span class="keyword">struct</span> <a class="code" href="structfasta.html">fasta</a> *b) {
114 00107         <span class="keywordtype">float</span> result;
115 00108         <span class="keywordtype">int</span> start, end, numres, i, id = 0;
116 00109         
117 00110         <span class="comment">/* If the sequences don't overlap then the seq ID is 0 */</span>
118 00111         <span class="keywordflow">if</span> (a-&gt;<a class="code" href="structfasta.html#o3">end</a> &lt; b-&gt;<a class="code" href="structfasta.html#o2">start</a> || a-&gt;<a class="code" href="structfasta.html#o2">start</a> &gt; b-&gt;<a class="code" href="structfasta.html#o3">end</a>)
119 00112                 <span class="keywordflow">return</span> 0;
120 00113 
121 00114         start = <a class="code" href="pairwise_8c.html#a3">MIN</a>( a-&gt;<a class="code" href="structfasta.html#o2">start</a>, b-&gt;<a class="code" href="structfasta.html#o2">start</a> );
122 00115         end = <a class="code" href="pairwise_8c.html#a2">MAX</a>( a-&gt;<a class="code" href="structfasta.html#o3">end</a>, b-&gt;<a class="code" href="structfasta.html#o3">end</a> );
123 00116         numres = <a class="code" href="pairwise_8c.html#a2">MAX</a>( a-&gt;<a class="code" href="structfasta.html#o4">numres</a>, b-&gt;<a class="code" href="structfasta.html#o4">numres</a> );
124 00117 
125 00118         <span class="keywordflow">for</span> (i = start; i &lt; end; i++)
126 00119                 id += <a class="code" href="pairwise_8c.html#a11">diff</a>(a-&gt;<a class="code" href="structfasta.html#o1">seq</a>[i], b-&gt;<a class="code" href="structfasta.html#o1">seq</a>[i]);
127 00120 
128 00121         result = 100 * (<span class="keywordtype">float</span>) id / (<span class="keywordtype">float</span>) numres;
129 00122 
130 00123         <span class="keywordflow">return</span> result;
131 00124 }
132 00125 
133 00126 <span class="comment">/* "Populate" the rest of the fasta structure with information</span>
134 00127 <span class="comment"> * Gets the start position of the sequence (first non-gap character)</span>
135 00128 <span class="comment"> * Gets the end position (the last non-gap character)</span>
136 00129 <span class="comment"> * Gets the number of residues in the sequence (that aren't gaps)</span>
137 00130 <span class="comment"> * Gaps are represented by '-'</span>
138 00131 <span class="comment"> * */</span>
139 00132 <span class="keywordtype">void</span>
140 <a name="l00133"></a><a class="code" href="pairwise_8c.html#a13">00133</a> <a class="code" href="pairwise_8c.html#a13">populate</a> (<span class="keyword">struct</span> <a class="code" href="structfasta.html">fasta</a> *a) {
141 00134         <span class="keywordtype">int</span> i;
142 00135         <span class="keywordtype">int</span> len = strlen(a-&gt;<a class="code" href="structfasta.html#o1">seq</a>);
143 00136 
144 00137         a-&gt;<a class="code" href="structfasta.html#o4">numres</a> = 0;
145 00138         
146 00139         <span class="keywordflow">for</span> (i = 0; i &lt;= len; i++) {
147 00140                 <span class="keywordflow">if</span> (a-&gt;<a class="code" href="structfasta.html#o1">seq</a>[i] != <span class="charliteral">'-'</span>) {
148 00141                         a-&gt;<a class="code" href="structfasta.html#o2">start</a> = i;
149 00142                         <span class="keywordflow">break</span>;
150 00143                 }
151 00144         }
152 00145         <span class="keywordflow">for</span> (i = len; i &gt; 0; i--) {
153 00146                 <span class="keywordflow">if</span> (a-&gt;<a class="code" href="structfasta.html#o1">seq</a>[i] != <span class="charliteral">'-'</span>) {
154 00147                         a-&gt;<a class="code" href="structfasta.html#o3">end</a> = i;
155 00148                         <span class="keywordflow">break</span>;
156 00149                 }
157 00150         }
158 00151         <span class="keywordflow">for</span> (i = a-&gt;<a class="code" href="structfasta.html#o2">start</a>; i &lt; a-&gt;<a class="code" href="structfasta.html#o3">end</a>; i++) {
159 00152                 <span class="keywordflow">if</span> (a-&gt;<a class="code" href="structfasta.html#o1">seq</a>[i] != <span class="charliteral">'-'</span>) {
160 00153                         a-&gt;<a class="code" href="structfasta.html#o4">numres</a>++;
161 00154                 }
162 00155         }
163 00156 }
164 00157 
165 00158 <span class="comment">/* Makes sure that all of the sequences are the same length */</span>
166 00159 <span class="keywordtype">void</span>
167 <a name="l00160"></a><a class="code" href="pairwise_8c.html#a14">00160</a> <a class="code" href="pairwise_8c.html#a14">check_length</a> (<span class="keyword">struct</span> <a class="code" href="structfasta.html">fasta</a> **array) {
168 00161         <span class="keywordtype">int</span> i, length;
169 00162 
170 00163         <span class="keywordflow">if</span> (array[0] != NULL)
171 00164                 length = strlen(array[0]-&gt;seq);
172 00165         <span class="keywordflow">else</span> {
173 00166                 fprintf(stderr, <span class="stringliteral">"check_length() not passed an array of fasta structs\n"</span>);
174 00167                 <span class="keywordflow">return</span>;
175 00168         }
176 00169 
177 00170         <span class="keywordflow">for</span> (i = 0; array[i] != NULL; i++) {
178 00171                 <span class="keywordflow">if</span> (length != strlen(array[i]-&gt;seq)) {
179 00172                         <a class="code" href="pairwise_8c.html#a6">fatal_error</a>(<span class="stringliteral">"Not all of the sequences are the same length\n"</span>);
180 00173                 }
181 00174         }
182 00175 }
183 00176 
184 00177 <span class="comment">/* Reads in a FASTA file and returns an array of fasta structures */</span>
185 00178 <span class="keyword">struct </span><a class="code" href="structfasta.html">fasta</a> **
186 <a name="l00179"></a><a class="code" href="pairwise_8c.html#a15">00179</a> <a class="code" href="pairwise_8c.html#a15">read_fasta</a> (FILE *fh) {
187 00180         <span class="keywordtype">int</span> i, j, k, c, filesize = 1;
188 00181         <span class="keywordtype">char</span> *file;
189 00182         <span class="keyword">struct </span><a class="code" href="structfasta.html">fasta</a> **array;
190 00183 
191 00184         array = (<span class="keyword">struct </span><a class="code" href="structfasta.html">fasta</a> **) <a class="code" href="pairwise_8c.html#a9">xmalloc</a>(<a class="code" href="pairwise_8c.html#a0">ARRAY</a> * sizeof(struct fasta *));
192 00185         file = (<span class="keywordtype">char</span> *) <a class="code" href="pairwise_8c.html#a9">xmalloc</a>(<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));
193 00186 
194 00187         <span class="comment">/* Allocate initial space for the file */</span>
195 00188         file = <a class="code" href="pairwise_8c.html#a10">xrealloc</a>(file, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * filesize);
196 00189         file[filesize] = <span class="charliteral">'\0'</span>;
197 00190 
198 00191         <span class="comment">/* Read in the file */</span>
199 00192         <span class="keywordflow">while</span> ((c = getc(fh)) != EOF) {
200 00193                 <span class="keywordflow">if</span> (filesize % <a class="code" href="pairwise_8c.html#a1">FILEBUF</a>)
201 00194                         file = <a class="code" href="pairwise_8c.html#a10">xrealloc</a>(file, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * (<a class="code" href="pairwise_8c.html#a1">FILEBUF</a> + filesize));
202 00195 
203 00196                 file[filesize] = c;
204 00197                 filesize++;
205 00198         }
206 00199 
207 00200         <span class="comment">/* Parse the FASTA file into an array of structures */</span>
208 00201         <span class="keywordflow">for</span> (i = 0, j = 0, k = 0; i &lt; filesize; i++) {
209 00202                 <span class="keywordflow">if</span> (file[i] == <span class="charliteral">'&gt;'</span>) {
210 00203                         <span class="keywordflow">if</span> (j % <a class="code" href="pairwise_8c.html#a0">ARRAY</a> == 0)
211 00204                                 array = (<span class="keyword">struct </span>fasta **) <a class="code" href="pairwise_8c.html#a10">xrealloc</a>(array, sizeof(struct fasta *) * (j + <a class="code" href="pairwise_8c.html#a0">ARRAY</a>));
212 00205 
213 00206                         array[j] = (<span class="keyword">struct </span>fasta *) <a class="code" href="pairwise_8c.html#a9">xmalloc</a>(sizeof(struct fasta));
214 00207                         array[j]-&gt;<a class="code" href="structfasta.html#o0">id</a> = (<span class="keywordtype">char</span> *) <a class="code" href="pairwise_8c.html#a9">xmalloc</a>(<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));
215 00208                         array[j]-&gt;<a class="code" href="structfasta.html#o1">seq</a> = (<span class="keywordtype">char</span> *) <a class="code" href="pairwise_8c.html#a9">xmalloc</a>(<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));
216 00209                         array[j]-&gt;<a class="code" href="structfasta.html#o4">numres</a> = 0;
217 00210 
218 00211                         i++;
219 00212                         <span class="keywordflow">while</span> (file[i] != <span class="charliteral">'\0'</span> &amp;&amp; file[i] != <span class="charliteral">'\n'</span>) {
220 00213                                 <span class="keywordflow">if</span> (k % <a class="code" href="pairwise_8c.html#a0">ARRAY</a> == 0)
221 00214                                         array[j]-&gt;<a class="code" href="structfasta.html#o0">id</a> = (<span class="keywordtype">char</span> *) <a class="code" href="pairwise_8c.html#a10">xrealloc</a>(array[j]-&gt;<a class="code" href="structfasta.html#o0">id</a>, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * (<a class="code" href="pairwise_8c.html#a0">ARRAY</a> + k));
222 00215                                 array[j]-&gt;<a class="code" href="structfasta.html#o0">id</a>[k] = file[i];
223 00216                                 k++; i++;
224 00217                         }
225 00218                         array[j]-&gt;<a class="code" href="structfasta.html#o0">id</a> = (<span class="keywordtype">char</span> *) <a class="code" href="pairwise_8c.html#a10">xrealloc</a>(array[j]-&gt;<a class="code" href="structfasta.html#o0">id</a>, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * (<a class="code" href="pairwise_8c.html#a0">ARRAY</a> + k));
226 00219                         array[j]-&gt;<a class="code" href="structfasta.html#o0">id</a>[k] = <span class="charliteral">'\0'</span>;
227 00220                         k = 0;
228 00221 
229 00222                         <span class="keywordflow">while</span> (file[i] != <span class="charliteral">'\0'</span> &amp;&amp; file[i] != <span class="charliteral">'&gt;'</span>) {
230 00223                                 <span class="keywordflow">if</span> (file[i] == <span class="charliteral">'\n'</span>) {
231 00224                                         i++;
232 00225                                         <span class="keywordflow">continue</span>;
233 00226                                 }
234 00227                                 <span class="keywordflow">if</span> (k % <a class="code" href="pairwise_8c.html#a0">ARRAY</a> == 0)
235 00228                                         array[j]-&gt;<a class="code" href="structfasta.html#o1">seq</a> = (<span class="keywordtype">char</span> *) <a class="code" href="pairwise_8c.html#a10">xrealloc</a>(array[j]-&gt;<a class="code" href="structfasta.html#o1">seq</a>, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * (<a class="code" href="pairwise_8c.html#a0">ARRAY</a> + k));
236 00229                                 array[j]-&gt;<a class="code" href="structfasta.html#o1">seq</a>[k] = file[i];
237 00230                                 k++; i++;
238 00231                         }
239 00232                         array[j]-&gt;<a class="code" href="structfasta.html#o1">seq</a> = (<span class="keywordtype">char</span> *) <a class="code" href="pairwise_8c.html#a10">xrealloc</a>(array[j]-&gt;<a class="code" href="structfasta.html#o1">seq</a>, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * (<a class="code" href="pairwise_8c.html#a0">ARRAY</a> + k));
240 00233                         array[j]-&gt;<a class="code" href="structfasta.html#o1">seq</a>[k] = <span class="charliteral">'\0'</span>;
241 00234                         k = 0;
242 00235                         i--;
243 00236                         j++;
244 00237                 }
245 00238         }
246 00239 
247 00240         free(file);
248 00241         array = (<span class="keyword">struct </span>fasta **) <a class="code" href="pairwise_8c.html#a10">xrealloc</a>(array, sizeof(struct fasta *) * j);
249 00242         array[j] = NULL;
250 00243 
251 00244         <span class="comment">/* find the start and end points for the alignments */</span>
252 00245         <span class="keywordflow">for</span> (i = 0; array[i] != NULL; i++) {
253 00246                 <a class="code" href="pairwise_8c.html#a13">populate</a>(array[i]);
254 00247         }
255 00248 
256 00249         <span class="keywordflow">return</span> array;
257 00250 }
258 00251 
259 00252 <span class="keywordtype">int</span>
260 <a name="l00253"></a><a class="code" href="pairwise_8c.html#a16">00253</a> <a class="code" href="pairwise_8c.html#a16">main</a> (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) {
261 00254         FILE *fh;
262 00255         <span class="keyword">struct </span><a class="code" href="structfasta.html">fasta</a> **array;
263 00256         <span class="keywordtype">int</span> i = 0, j;
264 00257 
265 00258         <span class="comment">/* Read in the FASTA file */</span>
266 00259         <span class="keywordflow">if</span> (argc == 2) 
267 00260                 fh = <a class="code" href="pairwise_8c.html#a8">xfopen</a>(argv[1], <span class="stringliteral">"r"</span>);
268 00261         <span class="keywordflow">else</span>
269 00262                 fh = stdin;
270 00263 
271 00264         array = <a class="code" href="pairwise_8c.html#a15">read_fasta</a>(fh);
272 00265         fclose(fh);
273 00266 
274 00267         <a class="code" href="pairwise_8c.html#a14">check_length</a>(array);
275 00268         
276 00269         <span class="comment">/* start the OC output */</span>
277 00270         <span class="keywordflow">while</span> (array[i] != NULL)
278 00271                 i++;
279 00272 
280 00273         fprintf(stdout, <span class="stringliteral">"%i\n"</span>, i);
281 00274 
282 00275         <span class="keywordflow">for</span> (i = 0; array[i] != NULL; i++)
283 00276                 fprintf(stdout, <span class="stringliteral">"%s\n"</span>, array[i]-&gt;id);
284 00277         
285 00278         <span class="comment">/* do the pairwise comparison */</span>
286 00279         <span class="keywordflow">for</span> (i = 0; array[i] != NULL; i++) {
287 00280                 <span class="keywordflow">for</span> (j = i + 1; array[j] != NULL; j++) {
288 00281                         printf(<span class="stringliteral">"%f\n"</span>, <a class="code" href="pairwise_8c.html#a12">pairwise</a>(array[i], array[j]));
289 00282                 }
290 00283         }
291 00284 
292 00285         <span class="keywordflow">return</span> EXIT_SUCCESS;
293 00286 }
294 </pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Jul 24 12:17:49 2003 for pairwise by
295 <a href="http://www.doxygen.org/index.html">
296 <img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
297 </a>1.3.2 </small></address>
298 </body>
299 </html>