2 * SRE, Tue Nov 18 11:10:20 1997 [St. Louis]
4 * Test driver for sequence masking routines in masks.c
6 * CVS $Id: masks_test.c,v 1.1.1.1 2005/03/22 08:34:46 cmzmasek Exp $
16 static char banner[] = "\
17 masks_test : testing of repeat masking code in masks.c";
19 static char usage[] = "\
20 Usage: testdriver [-options]\n\
21 Available options are:\n\
22 -h : help; display this usage info\n\
23 -v : verbose output\n\
26 static char experts[] = "\
27 --xnu <file>: apply xnu to seqs in <file>\n\
30 static struct opt_s OPTIONS[] = {
31 { "-h", TRUE, sqdARG_NONE },
32 { "-v", TRUE, sqdARG_NONE },
33 { "--xnu", FALSE, sqdARG_STRING },
35 #define NOPTIONS (sizeof(OPTIONS) / sizeof(struct opt_s))
37 /* The test sequence and result from the XNU software distribution
39 static char *test1 = "\
40 ACDEFGHIKLMNPQRQRQRQRQRQRQRQRQRSTVWYACDEFGHIKLMNPQRQRQRQRQRQ\
41 RQRQRQRSTVWYACDEFGHIKLMNPQRQRQRQRQRQRQRQRQRSTVWYACDEFGHIKLMN\
42 PQRQRQRQRQRQRQRQRQRSTVWYACDEFGHIKLMNPQRQRQRQRQRQRQRQRQRSTVWY\
43 ACDEFGHIKLMNPQRQRQRQRQRQRQRQRQRSTVWY";
45 static char *answer1 = "\
46 ACDEFGHIKLMNPXXXXXXXXXXXXXXXXXXSTVWYACDEFGHIKLMNPXXXXXXXXXXX\
47 XXXXXXXSTVWYACDEFGHIKLMNPXXXXXXXXXXXXXXXXXXSTVWYACDEFGHIKLMN\
48 PXXXXXXXXXXXXXXXXXXSTVWYACDEFGHIKLMNPXXXXXXXXXXXXXXXXXXSTVWY\
49 ACDEFGHIKLMNPXXXXXXXXXXXXXXXXXXSTVWY";
52 main(int argc, char **argv)
60 char *optname; /* name of option found by Getopt() */
61 char *optarg; /* argument found by Getopt() */
62 int optind; /* index in argv[] */
64 char *xnufile; /* NULL, or file to run xnu on */
67 /***********************************************
69 ***********************************************/
74 while (Getopt(argc, argv, OPTIONS, NOPTIONS, usage,
75 &optind, &optname, &optarg)) {
76 if (strcmp(optname, "-v") == 0) { be_verbose = TRUE; }
77 else if (strcmp(optname, "--xnu") == 0) { xnufile = optarg; }
78 else if (strcmp(optname, "-h") == 0) {
79 Banner(stdout, banner);
85 if (argc - optind != 0)
86 Die("Incorrect number of arguments.\n%s\n", usage);
88 SetAlphabet(hmmAMINO);
93 len = (int) strlen(seq);
94 dsq = DigitizeSequence(seq, len);
96 result = MallocOrDie(sizeof(char) * (len+1));
98 for (i = 0; i < len; i++)
99 result[i] = Alphabet[(int) dsq[i+1]];
104 printf("XNU test:\n");
105 for (i = 1; i <= len; i+=60)
107 for (j = i; j < i+60 && j <= len; j++)
108 putc(Alphabet[(int) dsq[j]], stdout);
111 if (strcmp(answer1, result) == 0)
112 printf("-- OK; Identical to expected\n");
115 if (strcmp(answer1, result) != 0)
116 Die("XNU test failed.");
120 /* On demand XNU test.
129 if ((sqfp = SeqfileOpen(xnufile, SQFILE_UNKNOWN, NULL)) == NULL)
130 Die("Failed to open sequence database file %s\n%s\n", xnufile, usage);
131 while (ReadSeq(sqfp, sqfp->format, &seq, &sqinfo))
133 dsq = DigitizeSequence(seq, sqinfo.len);
134 xnum = XNU(dsq, sqinfo.len);
135 result = DedigitizeSequence(dsq, sqinfo.len);
137 printf("%-20s\t%5d\n", sqinfo.name, xnum);
139 WriteSeq(stdout, SQFILE_FASTA, result, &sqinfo);
142 FreeSequence(seq, &sqinfo);