JPRED-2 Add sources of all binaries (except alscript) to Git
[jpred.git] / sources / pairwise / pairwise.c
diff --git a/sources/pairwise/pairwise.c b/sources/pairwise/pairwise.c
new file mode 100644 (file)
index 0000000..e5f9363
--- /dev/null
@@ -0,0 +1,57 @@
+/* Pairwise identity program.
+ *
+ * $Id
+ *
+ * Reads in a gapped alignment sequences in a FASTA file format.
+ * Assume gaps are represented by '-' characters.
+ *
+ * For each pair calculates the sequence percentage identity, see comments
+ * for pairwise() for details.
+ *
+ * Output is in the format for OC to read in, i.e. the number of sequences,
+ * followed by the sequence ID's, followed by the pairwise comparisons.
+ *
+ * Thu Dec  5 14:38:43 GMT 2002 Jon
+ * Added checking for eqilength sequences
+ *
+ * Thu Jul 24 12:14:04 BST 2003 Jon
+ * Moved FASTA reading into read_fasta function
+ * Checked into CVS
+ *
+ * */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "pairwise.h"
+
+int
+main (int argc, char **argv) {
+       FILE *fh;
+       struct fasta **seqs;
+       char **output;
+       int i = 0;
+
+       /* Read in the FASTA file */
+       if (argc == 2) 
+               fh = xfopen(argv[1], "r");
+       else
+               fh = stdin;
+
+       seqs = read_fasta(fh);
+       fclose(fh);
+
+       check_length(seqs);
+       output = do_pairwise(seqs);
+
+       for (i = 0; seqs[i] != NULL; i++)
+               free_fasta(seqs[i]);
+       free(seqs);
+
+       for (i = 0; output[i] != NULL; i++) {
+               printf("%s\n", output[i]);
+               /*free(output[i]);*/
+       }
+       /*free(output);*/
+
+       return EXIT_SUCCESS;
+}