JPRED-2 Add sources of all binaries (except alscript) to Git
[jpred.git] / sources / pairwise / Pairwise / Pairwise.xs
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4
5 #include "ppport.h"
6
7 #include "../pairwise.h"
8
9 #include <strings.h>
10
11 MODULE = Pairwise               PACKAGE = Pairwise              
12
13 void
14 pairwise (file)
15                 FILE *file
16         PREINIT:
17                 struct fasta **seqs;
18                 char **output;
19                 int i = 0;
20         PPCODE:
21                 /* read the sequences */
22                 seqs = read_fasta(file);
23                 check_length(seqs);
24
25                 /* do the pairwise comparison */
26                 output = do_pairwise(seqs);
27
28                 /* free the sequences */
29                 while (seqs[i] != NULL)
30                         free_fasta(seqs[i++]);
31                 free(seqs);
32
33                 /* find out much output there is */
34                 while (output[i] != NULL)
35                         i++;
36                 EXTEND(SP, i);
37
38                 /* convert it to perl and free the output */
39                 for (i = 0; output[i] != NULL; i++) {
40                         PUSHs(sv_2mortal( newSVpv(output[i], strlen(output[i])) ));
41                         free(output[i]);
42                 }
43                 free(output);