X-Git-Url: http://source.jalview.org/gitweb/?p=jpred.git;a=blobdiff_plain;f=sources%2Fpairwise%2FPairwise%2FPairwise.xs;fp=sources%2Fpairwise%2FPairwise%2FPairwise.xs;h=e6434645cd1ec65976ce448067ec7178b47a7067;hp=0000000000000000000000000000000000000000;hb=9aa768067094f24f46f273077f867348e6143711;hpb=eb3001dc41bf6cd46e20fd13fe3efbe9dedf6013 diff --git a/sources/pairwise/Pairwise/Pairwise.xs b/sources/pairwise/Pairwise/Pairwise.xs new file mode 100644 index 0000000..e643464 --- /dev/null +++ b/sources/pairwise/Pairwise/Pairwise.xs @@ -0,0 +1,43 @@ +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include "ppport.h" + +#include "../pairwise.h" + +#include + +MODULE = Pairwise PACKAGE = Pairwise + +void +pairwise (file) + FILE *file + PREINIT: + struct fasta **seqs; + char **output; + int i = 0; + PPCODE: + /* read the sequences */ + seqs = read_fasta(file); + check_length(seqs); + + /* do the pairwise comparison */ + output = do_pairwise(seqs); + + /* free the sequences */ + while (seqs[i] != NULL) + free_fasta(seqs[i++]); + free(seqs); + + /* find out much output there is */ + while (output[i] != NULL) + i++; + EXTEND(SP, i); + + /* convert it to perl and free the output */ + for (i = 0; output[i] != NULL; i++) { + PUSHs(sv_2mortal( newSVpv(output[i], strlen(output[i])) )); + free(output[i]); + } + free(output);