--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+<title>pairwise: pairwise.c File Reference</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.3.2 -->
+<div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>pairwise.c File Reference</h1><code>#include <stdio.h></code><br>
+<code>#include <stdlib.h></code><br>
+<code>#include <errno.h></code><br>
+<code>#include <string.h></code><br>
+<code>#include "<a class="el" href="pairwise_8h-source.html">pairwise.h</a>"</code><br>
+
+<p>
+Include dependency graph for pairwise.c:<p><center><img src="pairwise_8c__incl.png" border="0" usemap="#pairwise.c_map" alt="Include dependency graph"></center>
+<map name="pairwise.c_map">
+<area href="pairwise_8h.html" shape="rect" coords="135,86,207,105" alt="">
+</map>
+
+<p>
+<a href="pairwise_8c-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a0">ARRAY</a> 50</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a1">FILEBUF</a> 1000</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a2">MAX</a>(A, B) ((A) > (B) ? (A) : (B))</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a3">MIN</a>(A, B) ((A) < (B) ? (A) : (B))</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a4">MALLOC</a>(PTR, SIZE) do { PTR = malloc(SIZE); if (PTR == NULL) fatal_sys_error("malloc returned NULL"); } while (0)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a5">REALLOC</a>(PTR, SIZE) do { PTR = realloc(PTR, SIZE); if (PTR == NULL && SIZE != 0) fatal_sys_error("realloc returned NULL"); } while (0)</td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a6">fatal_error</a> (char *message)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a7">fatal_sys_error</a> (char *message)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>FILE * </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a8">xfopen</a> (const char *path, const char *mode)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void * </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a9">xmalloc</a> (size_t size)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void * </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a10">xrealloc</a> (void *ptr, size_t size)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a11">diff</a> (char a, char b)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>float </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a12">pairwise</a> (struct <a class="el" href="structfasta.html">fasta</a> *a, struct <a class="el" href="structfasta.html">fasta</a> *b)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a13">populate</a> (struct <a class="el" href="structfasta.html">fasta</a> *a)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a14">check_length</a> (struct <a class="el" href="structfasta.html">fasta</a> **array)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="structfasta.html">fasta</a> ** </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a15">read_fasta</a> (FILE *fh)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int </td><td class="memItemRight" valign=bottom><a class="el" href="pairwise_8c.html#a16">main</a> (int argc, char **argv)</td></tr>
+
+</table>
+<hr><h2>Define Documentation</h2>
+<a name="a0" doxytag="pairwise.c::ARRAY"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define ARRAY 50
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00029">29</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00179">read_fasta()</a>. </td>
+ </tr>
+</table>
+<a name="a1" doxytag="pairwise.c::FILEBUF"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define FILEBUF 1000
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00030">30</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00179">read_fasta()</a>. </td>
+ </tr>
+</table>
+<a name="a4" doxytag="pairwise.c::MALLOC"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define MALLOC</td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">PTR, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>SIZE </td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top"> ) </td>
+ <td class="md" nowrap> do { PTR = malloc(SIZE); if (PTR == NULL) fatal_sys_error("malloc returned NULL"); } while (0)
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00045">45</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>. </td>
+ </tr>
+</table>
+<a name="a2" doxytag="pairwise.c::MAX"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define MAX</td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">A, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>B </td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top"> ) </td>
+ <td class="md" nowrap> ((A) > (B) ? (A) : (B))
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00035">35</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00106">pairwise()</a>. </td>
+ </tr>
+</table>
+<a name="a3" doxytag="pairwise.c::MIN"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define MIN</td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">A, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>B </td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top"> ) </td>
+ <td class="md" nowrap> ((A) < (B) ? (A) : (B))
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00039">39</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00106">pairwise()</a>. </td>
+ </tr>
+</table>
+<a name="a5" doxytag="pairwise.c::REALLOC"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define REALLOC</td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">PTR, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>SIZE </td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top"> ) </td>
+ <td class="md" nowrap> do { PTR = realloc(PTR, SIZE); if (PTR == NULL && SIZE != 0) fatal_sys_error("realloc returned NULL"); } while (0)
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00049">49</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a name="a14" doxytag="pairwise.c::check_length"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void check_length </td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">struct <a class="el" href="structfasta.html">fasta</a> ** </td>
+ <td class="mdname1" valign="top" nowrap> <em>array</em> </td>
+ <td class="md" valign="top"> ) </td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00160">160</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+References <a class="el" href="pairwise_8c-source.html#l00053">fatal_error()</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00253">main()</a>.
+<p>
+<div class="fragment"><pre>00160 {
+00161 <span class="keywordtype">int</span> i, length;
+00162
+00163 <span class="keywordflow">if</span> (array[0] != NULL)
+00164 length = strlen(array[0]->seq);
+00165 <span class="keywordflow">else</span> {
+00166 fprintf(stderr, <span class="stringliteral">"check_length() not passed an array of fasta structs\n"</span>);
+00167 <span class="keywordflow">return</span>;
+00168 }
+00169
+00170 <span class="keywordflow">for</span> (i = 0; array[i] != NULL; i++) {
+00171 <span class="keywordflow">if</span> (length != strlen(array[i]->seq)) {
+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>);
+00173 }
+00174 }
+00175 }
+</pre></div> </td>
+ </tr>
+</table>
+
+<p>
+Here is the call graph for this function:<p><center><img src="pairwise_8c_a14_cgraph.png" border="0" usemap="#pairwise_8c_a14_cgraph_map" alt=""></center>
+<map name="pairwise_8c_a14_cgraph_map">
+<area href="pairwise_8h.html#a0" shape="rect" coords="160,5,235,23" alt="">
+</map>
+<a name="a11" doxytag="pairwise.c::diff"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int diff </td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">char </td>
+ <td class="mdname" nowrap> <em>a</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char </td>
+ <td class="mdname" nowrap> <em>b</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">) </td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00092">92</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00106">pairwise()</a>.
+<p>
+<div class="fragment"><pre>00092 {
+00093 <span class="keywordflow">if</span> (a == b && a == <span class="charliteral">'-'</span>)
+00094 <span class="keywordflow">return</span> 0;
+00095 <span class="keywordflow">if</span> (a == b)
+00096 <span class="keywordflow">return</span> 1;
+00097 <span class="keywordflow">return</span> 0;
+00098 }
+</pre></div> </td>
+ </tr>
+</table>
+<a name="a6" doxytag="pairwise.c::fatal_error"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void fatal_error </td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">char * </td>
+ <td class="mdname1" valign="top" nowrap> <em>message</em> </td>
+ <td class="md" valign="top"> ) </td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00053">53</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00160">check_length()</a>.
+<p>
+<div class="fragment"><pre>00053 {
+00054 printf(message);
+00055 exit(EXIT_FAILURE);
+00056 }
+</pre></div> </td>
+ </tr>
+</table>
+<a name="a7" doxytag="pairwise.c::fatal_sys_error"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void fatal_sys_error </td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">char * </td>
+ <td class="mdname1" valign="top" nowrap> <em>message</em> </td>
+ <td class="md" valign="top"> ) </td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00059">59</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00065">xfopen()</a>, <a class="el" href="pairwise_8c-source.html#l00074">xmalloc()</a>, and <a class="el" href="pairwise_8c-source.html#l00083">xrealloc()</a>.
+<p>
+<div class="fragment"><pre>00059 {
+00060 perror(message);
+00061 exit(EXIT_FAILURE);
+00062 }
+</pre></div> </td>
+ </tr>
+</table>
+<a name="a16" doxytag="pairwise.c::main"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int main </td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">int </td>
+ <td class="mdname" nowrap> <em>argc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char ** </td>
+ <td class="mdname" nowrap> <em>argv</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">) </td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00253">253</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+References <a class="el" href="pairwise_8c-source.html#l00160">check_length()</a>, <a class="el" href="pairwise_8c-source.html#l00106">pairwise()</a>, <a class="el" href="pairwise_8c-source.html#l00179">read_fasta()</a>, and <a class="el" href="pairwise_8c-source.html#l00065">xfopen()</a>.
+<p>
+<div class="fragment"><pre>00253 {
+00254 FILE *fh;
+00255 <span class="keyword">struct </span><a class="code" href="structfasta.html">fasta</a> **array;
+00256 <span class="keywordtype">int</span> i = 0, j;
+00257
+00258 <span class="comment">/* Read in the FASTA file */</span>
+00259 <span class="keywordflow">if</span> (argc == 2)
+00260 fh = <a class="code" href="pairwise_8c.html#a8">xfopen</a>(argv[1], <span class="stringliteral">"r"</span>);
+00261 <span class="keywordflow">else</span>
+00262 fh = stdin;
+00263
+00264 array = <a class="code" href="pairwise_8c.html#a15">read_fasta</a>(fh);
+00265 fclose(fh);
+00266
+00267 <a class="code" href="pairwise_8c.html#a14">check_length</a>(array);
+00268
+00269 <span class="comment">/* start the OC output */</span>
+00270 <span class="keywordflow">while</span> (array[i] != NULL)
+00271 i++;
+00272
+00273 fprintf(stdout, <span class="stringliteral">"%i\n"</span>, i);
+00274
+00275 <span class="keywordflow">for</span> (i = 0; array[i] != NULL; i++)
+00276 fprintf(stdout, <span class="stringliteral">"%s\n"</span>, array[i]->id);
+00277
+00278 <span class="comment">/* do the pairwise comparison */</span>
+00279 <span class="keywordflow">for</span> (i = 0; array[i] != NULL; i++) {
+00280 <span class="keywordflow">for</span> (j = i + 1; array[j] != NULL; j++) {
+00281 printf(<span class="stringliteral">"%f\n"</span>, <a class="code" href="pairwise_8c.html#a12">pairwise</a>(array[i], array[j]));
+00282 }
+00283 }
+00284
+00285 <span class="keywordflow">return</span> EXIT_SUCCESS;
+00286 }
+</pre></div> </td>
+ </tr>
+</table>
+
+<p>
+Here is the call graph for this function:<p><center><img src="pairwise_8c_a16_cgraph.png" border="0" usemap="#pairwise_8c_a16_cgraph_map" alt=""></center>
+<map name="pairwise_8c_a16_cgraph_map">
+<area href="pairwise_8h.html#a7" shape="rect" coords="108,5,201,24" alt="">
+<area href="pairwise_8h.html#a5" shape="rect" coords="124,48,185,67" alt="">
+<area href="pairwise_8h.html#a8" shape="rect" coords="116,209,193,228" alt="">
+<area href="pairwise_8h.html#a1" shape="rect" coords="263,92,316,111" alt="">
+<area href="pairwise_8h.html#a0" shape="rect" coords="252,5,327,24" alt="">
+<area href="pairwise_8h.html#a4" shape="rect" coords="271,48,308,67" alt="">
+<area href="pairwise_8h.html#a6" shape="rect" coords="377,153,444,172" alt="">
+<area href="pairwise_8c.html#a15" shape="rect" coords="251,209,328,228" alt="">
+<area href="pairwise_8c.html#a9" shape="rect" coords="381,252,440,271" alt="">
+<area href="pairwise_8h.html#a3" shape="rect" coords="380,209,441,228" alt="">
+<area href="pairwise_8c.html#a7" shape="rect" coords="492,209,596,228" alt="">
+</map>
+<a name="a12" doxytag="pairwise.c::pairwise"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> float pairwise </td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">struct <a class="el" href="structfasta.html">fasta</a> * </td>
+ <td class="mdname" nowrap> <em>a</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>struct <a class="el" href="structfasta.html">fasta</a> * </td>
+ <td class="mdname" nowrap> <em>b</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">) </td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00106">106</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+References <a class="el" href="pairwise_8c-source.html#l00092">diff()</a>, <a class="el" href="pairwise_8h-source.html#l00007">fasta::end</a>, <a class="el" href="pairwise_8c-source.html#l00035">MAX</a>, <a class="el" href="pairwise_8c-source.html#l00039">MIN</a>, <a class="el" href="pairwise_8h-source.html#l00008">fasta::numres</a>, <a class="el" href="pairwise_8h-source.html#l00005">fasta::seq</a>, and <a class="el" href="pairwise_8h-source.html#l00006">fasta::start</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00253">main()</a>.
+<p>
+<div class="fragment"><pre>00106 {
+00107 <span class="keywordtype">float</span> result;
+00108 <span class="keywordtype">int</span> start, end, numres, i, id = 0;
+00109
+00110 <span class="comment">/* If the sequences don't overlap then the seq ID is 0 */</span>
+00111 <span class="keywordflow">if</span> (a-><a class="code" href="structfasta.html#o3">end</a> < b-><a class="code" href="structfasta.html#o2">start</a> || a-><a class="code" href="structfasta.html#o2">start</a> > b-><a class="code" href="structfasta.html#o3">end</a>)
+00112 <span class="keywordflow">return</span> 0;
+00113
+00114 start = <a class="code" href="pairwise_8c.html#a3">MIN</a>( a-><a class="code" href="structfasta.html#o2">start</a>, b-><a class="code" href="structfasta.html#o2">start</a> );
+00115 end = <a class="code" href="pairwise_8c.html#a2">MAX</a>( a-><a class="code" href="structfasta.html#o3">end</a>, b-><a class="code" href="structfasta.html#o3">end</a> );
+00116 numres = <a class="code" href="pairwise_8c.html#a2">MAX</a>( a-><a class="code" href="structfasta.html#o4">numres</a>, b-><a class="code" href="structfasta.html#o4">numres</a> );
+00117
+00118 <span class="keywordflow">for</span> (i = start; i < end; i++)
+00119 id += <a class="code" href="pairwise_8c.html#a11">diff</a>(a-><a class="code" href="structfasta.html#o1">seq</a>[i], b-><a class="code" href="structfasta.html#o1">seq</a>[i]);
+00120
+00121 result = 100 * (<span class="keywordtype">float</span>) id / (<span class="keywordtype">float</span>) numres;
+00122
+00123 <span class="keywordflow">return</span> result;
+00124 }
+</pre></div> </td>
+ </tr>
+</table>
+
+<p>
+Here is the call graph for this function:<p><center><img src="pairwise_8c_a12_cgraph.png" border="0" usemap="#pairwise_8c_a12_cgraph_map" alt=""></center>
+<map name="pairwise_8c_a12_cgraph_map">
+<area href="pairwise_8h.html#a4" shape="rect" coords="131,5,168,23" alt="">
+</map>
+<a name="a13" doxytag="pairwise.c::populate"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void populate </td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">struct <a class="el" href="structfasta.html">fasta</a> * </td>
+ <td class="mdname1" valign="top" nowrap> <em>a</em> </td>
+ <td class="md" valign="top"> ) </td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00133">133</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+References <a class="el" href="pairwise_8h-source.html#l00007">fasta::end</a>, <a class="el" href="pairwise_8h-source.html#l00008">fasta::numres</a>, <a class="el" href="pairwise_8h-source.html#l00005">fasta::seq</a>, and <a class="el" href="pairwise_8h-source.html#l00006">fasta::start</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00179">read_fasta()</a>.
+<p>
+<div class="fragment"><pre>00133 {
+00134 <span class="keywordtype">int</span> i;
+00135 <span class="keywordtype">int</span> len = strlen(a-><a class="code" href="structfasta.html#o1">seq</a>);
+00136
+00137 a-><a class="code" href="structfasta.html#o4">numres</a> = 0;
+00138
+00139 <span class="keywordflow">for</span> (i = 0; i <= len; i++) {
+00140 <span class="keywordflow">if</span> (a-><a class="code" href="structfasta.html#o1">seq</a>[i] != <span class="charliteral">'-'</span>) {
+00141 a-><a class="code" href="structfasta.html#o2">start</a> = i;
+00142 <span class="keywordflow">break</span>;
+00143 }
+00144 }
+00145 <span class="keywordflow">for</span> (i = len; i > 0; i--) {
+00146 <span class="keywordflow">if</span> (a-><a class="code" href="structfasta.html#o1">seq</a>[i] != <span class="charliteral">'-'</span>) {
+00147 a-><a class="code" href="structfasta.html#o3">end</a> = i;
+00148 <span class="keywordflow">break</span>;
+00149 }
+00150 }
+00151 <span class="keywordflow">for</span> (i = a-><a class="code" href="structfasta.html#o2">start</a>; i < a-><a class="code" href="structfasta.html#o3">end</a>; i++) {
+00152 <span class="keywordflow">if</span> (a-><a class="code" href="structfasta.html#o1">seq</a>[i] != <span class="charliteral">'-'</span>) {
+00153 a-><a class="code" href="structfasta.html#o4">numres</a>++;
+00154 }
+00155 }
+00156 }
+</pre></div> </td>
+ </tr>
+</table>
+<a name="a15" doxytag="pairwise.c::read_fasta"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> struct <a class="el" href="structfasta.html">fasta</a>** read_fasta </td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">FILE * </td>
+ <td class="mdname1" valign="top" nowrap> <em>fh</em> </td>
+ <td class="md" valign="top"> ) </td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00179">179</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+References <a class="el" href="pairwise_8c-source.html#l00029">ARRAY</a>, <a class="el" href="pairwise_8c-source.html#l00030">FILEBUF</a>, <a class="el" href="pairwise_8h-source.html#l00004">fasta::id</a>, <a class="el" href="pairwise_8h-source.html#l00008">fasta::numres</a>, <a class="el" href="pairwise_8c-source.html#l00133">populate()</a>, <a class="el" href="pairwise_8c-source.html#l00179">read_fasta()</a>, <a class="el" href="pairwise_8h-source.html#l00005">fasta::seq</a>, <a class="el" href="pairwise_8c-source.html#l00074">xmalloc()</a>, and <a class="el" href="pairwise_8c-source.html#l00083">xrealloc()</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00253">main()</a>, and <a class="el" href="pairwise_8c-source.html#l00179">read_fasta()</a>.
+<p>
+<div class="fragment"><pre>00179 {
+00180 <span class="keywordtype">int</span> i, j, k, c, filesize = 1;
+00181 <span class="keywordtype">char</span> *file;
+00182 <span class="keyword">struct </span><a class="code" href="structfasta.html">fasta</a> **array;
+00183
+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 *));
+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>));
+00186
+00187 <span class="comment">/* Allocate initial space for the file */</span>
+00188 file = <a class="code" href="pairwise_8c.html#a10">xrealloc</a>(file, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * filesize);
+00189 file[filesize] = <span class="charliteral">'\0'</span>;
+00190
+00191 <span class="comment">/* Read in the file */</span>
+00192 <span class="keywordflow">while</span> ((c = getc(fh)) != EOF) {
+00193 <span class="keywordflow">if</span> (filesize % <a class="code" href="pairwise_8c.html#a1">FILEBUF</a>)
+00194 file = <a class="code" href="pairwise_8c.html#a10">xrealloc</a>(file, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * (FILEBUF + filesize));
+00195
+00196 file[filesize] = c;
+00197 filesize++;
+00198 }
+00199
+00200 <span class="comment">/* Parse the FASTA file into an array of structures */</span>
+00201 <span class="keywordflow">for</span> (i = 0, j = 0, k = 0; i < filesize; i++) {
+00202 <span class="keywordflow">if</span> (file[i] == <span class="charliteral">'>'</span>) {
+00203 <span class="keywordflow">if</span> (j % <a class="code" href="pairwise_8c.html#a0">ARRAY</a> == 0)
+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>));
+00205
+00206 array[j] = (<span class="keyword">struct </span>fasta *) <a class="code" href="pairwise_8c.html#a9">xmalloc</a>(sizeof(struct fasta));
+00207 array[j]-><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>));
+00208 array[j]-><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>));
+00209 array[j]-><a class="code" href="structfasta.html#o4">numres</a> = 0;
+00210
+00211 i++;
+00212 <span class="keywordflow">while</span> (file[i] != <span class="charliteral">'\0'</span> && file[i] != <span class="charliteral">'\n'</span>) {
+00213 <span class="keywordflow">if</span> (k % <a class="code" href="pairwise_8c.html#a0">ARRAY</a> == 0)
+00214 array[j]-><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]->id, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * (ARRAY + k));
+00215 array[j]-><a class="code" href="structfasta.html#o0">id</a>[k] = file[i];
+00216 k++; i++;
+00217 }
+00218 array[j]-><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]->id, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * (ARRAY + k));
+00219 array[j]-><a class="code" href="structfasta.html#o0">id</a>[k] = <span class="charliteral">'\0'</span>;
+00220 k = 0;
+00221
+00222 <span class="keywordflow">while</span> (file[i] != <span class="charliteral">'\0'</span> && file[i] != <span class="charliteral">'>'</span>) {
+00223 <span class="keywordflow">if</span> (file[i] == <span class="charliteral">'\n'</span>) {
+00224 i++;
+00225 <span class="keywordflow">continue</span>;
+00226 }
+00227 <span class="keywordflow">if</span> (k % <a class="code" href="pairwise_8c.html#a0">ARRAY</a> == 0)
+00228 array[j]-><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]->seq, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * (ARRAY + k));
+00229 array[j]-><a class="code" href="structfasta.html#o1">seq</a>[k] = file[i];
+00230 k++; i++;
+00231 }
+00232 array[j]-><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]->seq, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * (ARRAY + k));
+00233 array[j]-><a class="code" href="structfasta.html#o1">seq</a>[k] = <span class="charliteral">'\0'</span>;
+00234 k = 0;
+00235 i--;
+00236 j++;
+00237 }
+00238 }
+00239
+00240 free(file);
+00241 array = (<span class="keyword">struct </span>fasta **) <a class="code" href="pairwise_8c.html#a10">xrealloc</a>(array, sizeof(struct fasta *) * j);
+00242 array[j] = NULL;
+00243
+00244 <span class="comment">/* find the start and end points for the alignments */</span>
+00245 <span class="keywordflow">for</span> (i = 0; array[i] != NULL; i++) {
+00246 <a class="code" href="pairwise_8c.html#a13">populate</a>(array[i]);
+00247 }
+00248
+00249 <span class="keywordflow">return</span> array;
+00250 }
+</pre></div> </td>
+ </tr>
+</table>
+
+<p>
+Here is the call graph for this function:<p><center><img src="pairwise_8c_a15_cgraph.png" border="0" usemap="#pairwise_8c_a15_cgraph_map" alt=""></center>
+<map name="pairwise_8c_a15_cgraph_map">
+<area href="pairwise_8h.html#a6" shape="rect" coords="145,5,212,24" alt="">
+<area href="pairwise_8c.html#a9" shape="rect" coords="149,48,208,67" alt="">
+<area href="pairwise_8h.html#a3" shape="rect" coords="148,91,209,109" alt="">
+<area href="pairwise_8c.html#a7" shape="rect" coords="260,69,364,88" alt="">
+</map>
+<a name="a8" doxytag="pairwise.c::xfopen"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> FILE* xfopen </td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">const char * </td>
+ <td class="mdname" nowrap> <em>path</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char * </td>
+ <td class="mdname" nowrap> <em>mode</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">) </td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00065">65</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+References <a class="el" href="pairwise_8c-source.html#l00059">fatal_sys_error()</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00253">main()</a>.
+<p>
+<div class="fragment"><pre>00065 {
+00066 FILE *fh;
+00067 fh = fopen(path, mode);
+00068 <span class="keywordflow">if</span> (fh == NULL)
+00069 <a class="code" href="pairwise_8c.html#a7">fatal_sys_error</a>(<span class="stringliteral">"fopen returned NULL"</span>);
+00070 <span class="keywordflow">return</span> fh;
+00071 }
+</pre></div> </td>
+ </tr>
+</table>
+
+<p>
+Here is the call graph for this function:<p><center><img src="pairwise_8c_a8_cgraph.png" border="0" usemap="#pairwise_8c_a8_cgraph_map" alt=""></center>
+<map name="pairwise_8c_a8_cgraph_map">
+<area href="pairwise_8c.html#a7" shape="rect" coords="121,5,225,23" alt="">
+</map>
+<a name="a9" doxytag="pairwise.c::xmalloc"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void* xmalloc </td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">size_t </td>
+ <td class="mdname1" valign="top" nowrap> <em>size</em> </td>
+ <td class="md" valign="top"> ) </td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00074">74</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+References <a class="el" href="pairwise_8c-source.html#l00059">fatal_sys_error()</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00179">read_fasta()</a>.
+<p>
+<div class="fragment"><pre>00074 {
+00075 <span class="keywordtype">void</span> *ptr;
+00076 ptr = (<span class="keywordtype">void</span> *) malloc(size);
+00077 <span class="keywordflow">if</span> (ptr == NULL)
+00078 <a class="code" href="pairwise_8c.html#a7">fatal_sys_error</a>(<span class="stringliteral">"malloc returned NULL"</span>);
+00079 <span class="keywordflow">return</span> ptr;
+00080 }
+</pre></div> </td>
+ </tr>
+</table>
+
+<p>
+Here is the call graph for this function:<p><center><img src="pairwise_8c_a9_cgraph.png" border="0" usemap="#pairwise_8c_a9_cgraph_map" alt=""></center>
+<map name="pairwise_8c_a9_cgraph_map">
+<area href="pairwise_8c.html#a7" shape="rect" coords="127,5,231,23" alt="">
+</map>
+<a name="a10" doxytag="pairwise.c::xrealloc"></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void* xrealloc </td>
+ <td class="md" valign="top">( </td>
+ <td class="md" nowrap valign="top">void * </td>
+ <td class="mdname" nowrap> <em>ptr</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>size_t </td>
+ <td class="mdname" nowrap> <em>size</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">) </td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+
+<p>
+
+<p>
+Definition at line <a class="el" href="pairwise_8c-source.html#l00083">83</a> of file <a class="el" href="pairwise_8c-source.html">pairwise.c</a>.
+<p>
+References <a class="el" href="pairwise_8c-source.html#l00059">fatal_sys_error()</a>.
+<p>
+Referenced by <a class="el" href="pairwise_8c-source.html#l00179">read_fasta()</a>.
+<p>
+<div class="fragment"><pre>00083 {
+00084 ptr = (<span class="keywordtype">void</span> *) realloc(ptr, size);
+00085 <span class="keywordflow">if</span> (ptr == NULL && size != 0)
+00086 <a class="code" href="pairwise_8c.html#a7">fatal_sys_error</a>(<span class="stringliteral">"realloc returned NULL"</span>);
+00087 <span class="keywordflow">return</span> ptr;
+00088 }
+</pre></div> </td>
+ </tr>
+</table>
+
+<p>
+Here is the call graph for this function:<p><center><img src="pairwise_8c_a10_cgraph.png" border="0" usemap="#pairwise_8c_a10_cgraph_map" alt=""></center>
+<map name="pairwise_8c_a10_cgraph_map">
+<area href="pairwise_8c.html#a7" shape="rect" coords="127,5,231,23" alt="">
+</map>
+<hr size="1"><address style="align: right;"><small>Generated on Thu Jul 24 12:17:51 2003 for pairwise by
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
+</a>1.3.2 </small></address>
+</body>
+</html>