initial commit
[jalview.git] / forester / archive / RIO / others / hmmer / src / weetest.c
1 /* This is a throwaway wrapper program for doing quick
2  * and dirty tests on sequence databases. Archives of past
3  * versions are kept and logged in RCS.
4  * RCS $Id: weetest.c,v 1.1.1.1 2005/03/22 08:34:07 cmzmasek Exp $
5  * 
6  * Compile with:
7  * 
8 cc -g -o weetest -I ~/lib/squid.linux -L/nfs/wol2/people/eddy/lib/squid.linux weetest.c alphabet.o camJul97.o core_algorithms.o histogram.o hmmio.o mathsupport.o masks.o misc.o modelmakers.o debug.o prior.o trace.o plan7.o states.o tophits.o -lsquid-debug -lm
9  *
10  * or, for optimized version:
11 cc -O2 -o weetest -I ~/lib/squid.linux -L/nfs/wol2/people/eddy/lib/squid.linux weetest.c alphabet.o camJul97.o core_algorithms.o histogram.o hmmio.o mathsupport.o masks.o misc.o modelmakers.o debug.o prior.o trace.o plan7.o states.o tophits.o -lsquid -lm
12  */
13
14 /* This test looks at histogram of protein lengths in Swissprot
15  */
16 #include <stdio.h>
17
18 #include "structs.h"
19 #include "funcs.h"
20 #include "globals.h"
21 #include "squid.h"
22
23 int
24 main(int argc, char **argv)
25 {
26   char   *file;
27   char   *seq;
28   char   *dsq;
29   int     format;
30   SQFILE *sqfp;
31   SQINFO  sqinfo;
32   int     i,x;
33
34   struct histogram_s *h;
35
36   file = argv[1];
37   if (! SeqfileFormat(file, &format, "BLASTDB")) 
38     Die("SeqfileFormat()");
39   if ((sqfp = SeqfileOpen(file, format, "BLASTDB")) == NULL) 
40     Die("SeqfileOpen()");
41
42   h = AllocHistogram(0, 10000, 1000);
43   while (ReadSeq(sqfp, format, &seq, &sqinfo)) 
44     AddToHistogram(h, (float) sqinfo.len);
45
46   GaussianFitHistogram(h, 999999.);
47   PrintASCIIHistogram(stdout, h);
48
49   printf("mean = %f\n", h->param[GAUSS_MEAN]);
50   printf("sd   = %f\n", h->param[GAUSS_SD]);
51
52   SeqfileClose(sqfp);
53   
54   return EXIT_SUCCESS;
55 }