diff --git a/belvu.c b/belvu.c index 30ab956b32b6755ee174ccca555d5845bb70f0f1..3558dd8bd57beaa018729564b523b0ba6e2e58c6 100644 --- a/belvu.c +++ b/belvu.c @@ -249,7 +249,7 @@ * HISTORY: * Last edited: May 28 11:43 2008 (edgrif) * Created: Aug 03 1994 (Erik.Sonnhammer@cgb.ki.se) - * CVS info: $Id: belvu.c,v 1.1 2009-11-03 18:28:23 edgrif Exp $ + * CVS info: $Id: belvu.c,v 1.2 2010-08-31 15:30:55 gb10 Exp $ */ @@ -291,8 +291,6 @@ #include <wh/graph.h> #include <wh/gex.h> #include <wh/key.h> -#define BELVU /* Fix horrible include mess in dotter_.h */ -#include <wh/dotter_.h> #include <wh/menu.h> diff --git a/blxdotter.c b/blxdotter.c index 5bd47cbc5e051f8ed64deab0a7d429a858142b70..1da2249afd43fbc037f297b7dfaa5cc5287dc75e 100644 --- a/blxdotter.c +++ b/blxdotter.c @@ -1004,21 +1004,16 @@ gboolean callDotter(GtkWidget *blxWindow, const gboolean hspsOnly, GError **erro return FALSE; } - /* Get the match sequence. Blixem uses g_malloc consistently now to allocate - * strings but unfortunately dotter will free this string with messfree, so - * we need to copy the result into a string allocated with messalloc. */ + /* Get the match sequence. */ GError *tmpError = NULL; - char *dotterSSeqTemp = getDotterSSeq(blxWindow, &tmpError); - if (!dotterSSeqTemp) + char *dotterSSeq = getDotterSSeq(blxWindow, &tmpError); + + if (!dotterSSeq) { g_propagate_error(error, tmpError); return FALSE; } - char *dotterSSeq = messalloc(strlen(dotterSSeqTemp) + 1); - strcpy(dotterSSeq, dotterSSeqTemp); - g_free(dotterSSeqTemp); - /* Get the coords */ int dotterStart = UNSET_INT, dotterEnd = UNSET_INT, dotterZoom = 0; if (!getDotterRange(blxWindow, dotterSSeq, FALSE, &dotterStart, &dotterEnd, &dotterZoom, &tmpError)) @@ -1031,30 +1026,25 @@ gboolean callDotter(GtkWidget *blxWindow, const gboolean hspsOnly, GError **erro const BlxStrand strand = bc->seqType == BLXSEQ_DNA ? mspGetRefStrand(firstMsp) : blxWindowGetActiveStrand(blxWindow); const int frame = mspGetRefFrame(firstMsp, bc->seqType); - char *querySeqSegmentTemp = getSequenceSegment(bc, - bc->refSeq, - dotterStart, - dotterEnd, - strand, - BLXSEQ_DNA, /* calculated dotter coords are always in terms of DNA seq */ - frame, - FALSE, /* input coords are always left-to-right, even if display reversed */ - bc->displayRev, /* whether to reverse */ - bc->displayRev, /* whether to allow rev strands to be complemented */ - FALSE, /* don't allow translation to a peptide seq */ - &tmpError); - - if (!querySeqSegmentTemp) + char *querySeqSegment = getSequenceSegment(bc, + bc->refSeq, + dotterStart, + dotterEnd, + strand, + BLXSEQ_DNA, /* calculated dotter coords are always in terms of DNA seq */ + frame, + FALSE, /* input coords are always left-to-right, even if display reversed */ + bc->displayRev, /* whether to reverse */ + bc->displayRev, /* whether to allow rev strands to be complemented */ + FALSE, /* don't allow translation to a peptide seq */ + &tmpError); + + if (!querySeqSegment) { g_propagate_error(error, tmpError); return FALSE; } - /* Again, dotter will free this with messfree, so we need to pass a string allocated with messalloc */ - char *querySeqSegment = messalloc(strlen(querySeqSegmentTemp) + 1); - strcpy(querySeqSegment, querySeqSegmentTemp); - g_free(querySeqSegmentTemp); - /* Get the match sequence name (chopping off the letters before the colon, if there is one). */ const char *dotterSName = strchr(mspGetSName(firstMsp), ':'); if (dotterSName) diff --git a/dotter.c b/dotter.c index 0657c408019963bcbc8124bc3015a25bab69fd48..ddd5c67427122a72ad45404c3a970e7713f68b9c 100644 --- a/dotter.c +++ b/dotter.c @@ -29,7 +29,7 @@ * * Mar 17 16:24 1999 (edgrif): Fixed bug which crashed xace when a * negative alignment length was given. * Created: Wed Mar 17 16:23:21 1999 (edgrif) - * CVS info: $Id: dotter.c,v 1.11 2010-08-24 12:27:59 gb10 Exp $ + * CVS info: $Id: dotter.c,v 1.12 2010-08-31 15:30:55 gb10 Exp $ *------------------------------------------------------------------- */ @@ -247,6 +247,7 @@ static int gArrayGetLen(GArray *array); #define drawBlastHSPlinefStr "Draw Blast HSPs (colour = f(score))" #define togglePixelmapStr "Pixelmap" + static void dotterRampChange(BOOL isDrag); static MENU dotterMenu ; static MENUOPT mainMenu[] = { @@ -532,7 +533,7 @@ void dotter (char type, { int i; - messalloccheck(); +// messalloccheck(); /* Reset global statics */ resfac = PixelmapON = 1; @@ -552,7 +553,7 @@ void dotter (char type, blastx = 1; resfac = 3; abetsize = 20; break; - default: fatal("Invalid sequence type passed to Dotter: %c", type); + default: g_error("Invalid sequence type passed to Dotter: %c", type); } /* Option parsing */ @@ -597,18 +598,18 @@ void dotter (char type, handle = handleCreate(); banner = (char *)handleAlloc(0, handle, 1000); - qname = messalloc(strlen(queryname)+1); strcpy(qname, queryname); + qname = g_malloc(strlen(queryname)+1); strcpy(qname, queryname); qseq = queryseq; qoffset = qoff; - sname = messalloc(strlen(subjectname)+1); strcpy(sname, subjectname); + sname = g_malloc(strlen(subjectname)+1); strcpy(sname, subjectname); sseq = subjectseq; soffset = soff; MSPlist = MSPs; MSPoffset = MSPoff; - if (!(qlen = strlen(qseq))) fatal("queryseq is empty"); - if (!(slen = strlen(sseq))) fatal("subjectseq is empty"); + if (!(qlen = strlen(qseq))) g_error("queryseq is empty"); + if (!(slen = strlen(sseq))) g_error("subjectseq is empty"); for (i = 0; i < qlen; i++) qseq[i] = freeupper(qseq[i]); for (i = 0; i < slen; i++) sseq[i] = freeupper(sseq[i]); @@ -652,7 +653,7 @@ void dotter (char type, if (savefile) { if (!(saveFil = fopen (savefile, "wb"))) - fatal("Failed to open %s", savefile); + g_error("Failed to open %s", savefile); } @@ -682,17 +683,17 @@ void dotter (char type, if (qlen4 % 4) qlen4 += 4-(qlen4 % 4); if (qlen/resfac > qlen4*zoom) - fatal("qlen/resfac > qlen4*zoom (%d > %d (%d*%d))", + g_error("qlen/resfac > qlen4*zoom (%d > %d (%d*%d))", qlen/resfac, qlen4*zoom, qlen4, zoom); slen4 = (int)ceil((double)slen/zoom); if (slen4 % 4) slen4 += 4-(slen4 % 4); if (slen > slen4*zoom) - fatal("slen > slen4*zoom (%d > %d (%d*%d))", slen, slen4, zoom, slen4*zoom); + g_error("slen > slen4*zoom (%d > %d (%d*%d))", slen, slen4, zoom, slen4*zoom); datalen = slen4*qlen4; - data = (UCHAR *)messalloc(datalen); + data = (UCHAR *)g_malloc(datalen); } if (savefile) @@ -835,21 +836,6 @@ static void setMenuCheckmarks(void) } -void fatal(char *format, ...) -{ - va_list ap; - - printf("\nFATAL ERROR: "); - - va_start(ap, format); - vprintf(format, ap); - va_end(ap); - - printf("\n"); - exit(1); -} - - static void Help(void) { graphMessage (messprintf("\ @@ -976,12 +962,12 @@ static void loadPlot(char *loadfile) format; if (!(fil = fopen (loadfile, "rb"))) - fatal("Failed to open %s", loadfile); + g_error("Failed to open %s", loadfile); - if ((fread(&format, 1, 1, fil)) != 1) fatal("reading file %s", loadfile); - if ((fread(&zoom, 1, 4, fil)) != 4) fatal("reading file %s", loadfile); - if ((fread(&qlen4, 1, 4, fil)) != 4) fatal("reading file %s", loadfile); - if ((fread(&slen4, 1, 4, fil)) != 4) fatal("reading file %s", loadfile); + if ((fread(&format, 1, 1, fil)) != 1) g_error("reading file %s", loadfile); + if ((fread(&zoom, 1, 4, fil)) != 4) g_error("reading file %s", loadfile); + if ((fread(&qlen4, 1, 4, fil)) != 4) g_error("reading file %s", loadfile); + if ((fread(&slen4, 1, 4, fil)) != 4) g_error("reading file %s", loadfile); #ifdef ALPHA reversebytes(&zoom, 4); reversebytes(&qlen4, 4); @@ -996,19 +982,19 @@ static void loadPlot(char *loadfile) } else if (format == 2) { - if ((fread(&pixelFac, 1, 4, fil)) != 4) fatal("reading file %s", loadfile); - if ((fread(&win, 1, 4, fil)) != 4) fatal("reading file %s", loadfile); - if ((fread(&MNlen, 1, 4, fil)) != 4) fatal("reading file %s", loadfile); + if ((fread(&pixelFac, 1, 4, fil)) != 4) g_error("reading file %s", loadfile); + if ((fread(&win, 1, 4, fil)) != 4) g_error("reading file %s", loadfile); + if ((fread(&MNlen, 1, 4, fil)) != 4) g_error("reading file %s", loadfile); #ifdef ALPHA reversebytes(&pixelFac, 4); reversebytes(&win, 4); reversebytes(&MNlen, 4); #endif - if ((fread(&MATRIX_NAME, 1, MNlen, fil)) != MNlen) fatal("reading file %s", loadfile); + if ((fread(&MATRIX_NAME, 1, MNlen, fil)) != MNlen) g_error("reading file %s", loadfile); MATRIX_NAME[MNlen] = 0; for (i = 0; i < 24; i++) for (j = 0; j < 24; j++) { - if ((fread(&mtx, 1, 4, fil)) != 4) fatal("reading file %s", loadfile); + if ((fread(&mtx, 1, 4, fil)) != 4) g_error("reading file %s", loadfile); #ifdef ALPHA reversebytes(&mtx, 4); #endif @@ -1017,21 +1003,21 @@ static void loadPlot(char *loadfile) dotstart = MNlen + 2329; } else - fatal("Unknown dotter file format version: %d", format); + g_error("Unknown dotter file format version: %d", format); fseek(fil, 0, SEEK_END); n = ftell(fil); if (n-dotstart != qlen4*slen4) - fatal("Wrong number of pixels in %s: %d. Expected %d * %-d = %d\n", + g_error("Wrong number of pixels in %s: %d. Expected %d * %-d = %d\n", loadfile, n, qlen4, slen4, qlen4*slen4); datalen = slen4*qlen4; - data = (UCHAR *)messalloc(datalen); + data = (UCHAR *)g_malloc(datalen); fseek(fil, dotstart, SEEK_SET); if ((n = fread(data, 1, qlen4*slen4, fil)) != qlen4*slen4) - fatal("Read wrong number of pixels from %s: %d. Expected %d * %-d = %d\n", + g_error("Read wrong number of pixels from %s: %d. Expected %d * %-d = %d\n", loadfile, n, qlen4, slen4, qlen4*slen4); fclose(fil); @@ -1260,7 +1246,7 @@ static void calcWindow(void) dotpos = qlen4*dotposs + dotposq; if (dotpos < 0 || dotpos >= datalen) { - messerror ( "Pixel out of bounds (%d) in blastx: %d\n", + g_critical ( "Pixel out of bounds (%d) in blastx: %d\n", datalen-1, dotpos); } else { @@ -1321,7 +1307,7 @@ static void calcWindow(void) dotpos = qlen4*dotposs + dotposq; if (dotpos < 0 || dotpos > datalen-1) { - messerror ( "Pixel out of bounds (%d) in blastp/blastn-forw: %d\n", + g_critical ( "Pixel out of bounds (%d) in blastp/blastn-forw: %d\n", datalen-1, dotpos); } else { @@ -1392,7 +1378,7 @@ static void calcWindow(void) dotpos = qlen4*dotposs + dotposq; if (dotpos < 0 || dotpos >= datalen) { - messerror ( "Pixel out of bounds (%d) in blastn-rev: %d\n", + g_critical ( "Pixel out of bounds (%d) in blastn-rev: %d\n", datalen-1, dotpos); } else { @@ -1419,10 +1405,10 @@ static void calcWindow(void) dotposCopy = qlen4*q + s; if (dotpos < 0 || dotpos >= datalen) - messerror ( "Source pixel out of bounds (%d) in mirrorCopy: %d\n", + g_critical ( "Source pixel out of bounds (%d) in mirrorCopy: %d\n", datalen-1, dotpos); if (dotposCopy < 0 || dotposCopy >= datalen) - messerror ( "Destination pixel out of bounds (%d) in mirrorCopy: %d\n", + g_critical ( "Destination pixel out of bounds (%d) in mirrorCopy: %d\n", datalen-1, dotposCopy); data[dotposCopy] = data[dotpos]; } @@ -1430,7 +1416,7 @@ static void calcWindow(void) } handleDestroy(calcHandle); - messalloccheck(); +// messalloccheck(); pixelmap_done = 1; } @@ -2474,8 +2460,8 @@ static void graphPixelLine(int strength, int sx, int sy, int ex, int ey) dotpos = qlen4*(y) + x; if (dotpos < 0 || dotpos > datalen-1) { - messout("Pixel out of bounds (0-%d) in graphPixelLine: %d." - "Crash imminent.", datalen-1, dotpos); + g_critical("Pixel out of bounds (0-%d) in graphPixelLine: %d." + "Crash imminent.", datalen-1, dotpos); } else { @@ -2645,7 +2631,7 @@ static void drawBlastHSPs(void) graphPixelLine(strength, sx, sy, ex, ey); } else { - messout("Unknown BlastMode = bug -> contact Erik"); + g_critical("Unknown BlastMode = bug -> contact Sanger"); } } } @@ -3180,14 +3166,14 @@ static void initAlignment(void) { /* static int warned=0; - if (!warned) messout("The residue colours of the Aligment tool have been corrupted by Jean." + if (!warned) g_critical("The residue colours of the Aligment tool have been corrupted by Jean." " Send complaints to mieg@kaa.crbm.cnrs-mop.fr"); warned=1;*/ } if (!CrosshairON) { - messout("Turn on the crosshair !"); + g_critical("Turn on the crosshair !"); return; } @@ -3482,7 +3468,7 @@ int findCommand (char *command, char **retp) /* Don't use csh - fails if the path is not set in .cshrc * / if (access(csh, X_OK)) { - messout("Could not find %s", csh); + g_critical("Could not find %s", csh); return 0; } if (!(pipe = (FILE *)popen(messprintf("%s -cf \"which %s\"", csh, command), "r"))) { @@ -3504,7 +3490,7 @@ int findCommand (char *command, char **retp) return 0; */ - path = messalloc(strlen(getenv("PATH"))+1); + path = g_malloc(strlen(getenv("PATH"))+1); /* Don't free 'path' since it changes later on - never mind, we're only calling it once */ @@ -3575,7 +3561,7 @@ static void callDotter(int dotterZoom, int xstart, int ystart, int xend, int yen if (!dotterBinary) { printf("Looking for Dotter ...\n"); if (!findCommand("dotter", &(dotterBinary))) { - messout("Failed to zoom in - %s. " + g_critical("Failed to zoom in - %s. " "($PATH=%s)", dotterBinary, getenv("PATH")); dotterBinary = 0; return; @@ -3758,18 +3744,18 @@ static void initWindow(char *winsize) if (!winsize || freeupper(*winsize) == 'K') { if (win < 3) { - messout("Karlin/Altschul estimate of window size = %d ignored. Using 10 instead.\n", win); + g_critical("Karlin/Altschul estimate of window size = %d ignored. Using 10 instead.\n", win); win = 10; } if (win > 50) { - messout("Karlin/Altschul estimate of window size = %d ignored. Using 50 instead.\n", win); + g_critical("Karlin/Altschul estimate of window size = %d ignored. Using 50 instead.\n", win); win = 50; } return; } if (!atoi(winsize)) - fatal("Bad window size specification: %s", winsize); + g_error("Bad window size specification: %s", winsize); win = atoi(winsize); } @@ -3811,17 +3797,17 @@ static void dotterDestroy(void) } } - /* Free stuff messalloc'ed in calling routine (usually blixem or dotterMain) */ - messfree(qseq); - messfree(sseq); + /* Free stuff g_malloc'ed in calling routine (usually blixem or dotterMain) */ + g_free(qseq); + g_free(sseq); /* Don't free MSP's since that will screw blixem up !!! */ if (graphActivate(dotterGraph)) graphClear(); - messfree(data); - messfree(HSPpixels); + g_free(data); + g_free(HSPpixels); if (graphActivate(alnGraph)) { @@ -4053,7 +4039,7 @@ static void dotterRedraw(void) if (!HSPpixels) { int i; - HSPpixels = (UCHAR *)messalloc(datalen); + HSPpixels = (UCHAR *)g_malloc(datalen); for (i=0; i < datalen; i++) HSPpixels[i] = 0; } @@ -4065,7 +4051,7 @@ static void dotterRedraw(void) if (HSPgaps && !gapwarned) { graphRedraw(); - messout("Note: gapped HSPs are shown ungapped in Dotter."); + g_critical("Note: gapped HSPs are shown ungapped in Dotter."); gapwarned = 1; } } @@ -4106,7 +4092,7 @@ static void readmtx(int MATRIX[24][24], char *mtxfile) if (!(fil = fopen(mtxfile, "r")) && !(fil = fopen(messprintf("%s/%s", getenv("BLASTMAT"), mtxfile), "r"))) - fatal("Failed to open score matrix file %s - not found in ./ or $BLASTMAT/.", mtxfile); + g_error("Failed to open score matrix file %s - not found in ./ or $BLASTMAT/.", mtxfile); /* Ignore header ... */ while (!feof(fil) && *line == '#') @@ -4116,14 +4102,16 @@ static void readmtx(int MATRIX[24][24], char *mtxfile) for (row = 0; row < 24; row++) { if (!(fgets(line, 1024, fil))) - fatal("Wrong number of rows in matrix file: %d (should be 24).", row); + g_error("Wrong number of rows in matrix file: %d (should be 24).", row); p = strtok(line, " \t\n"); for (col = 0; col < 24; col++) { while (*p == '*' || isalpha((int) *p)) p = strtok(NULL, " \t\n"); - if (!p) fatal("Error on row %d in matrix file.", row); + + if (!p) + g_error("Error on row %d in matrix file.", row); MATRIX[row][col] = atoi(p); diff --git a/dotter.h b/dotter.h index 6fb7a936b5381dfc4943e850f5c2c02ef55a2ce6..577449c2c95fa425479a2f712f53f88ed1c276b1 100644 --- a/dotter.h +++ b/dotter.h @@ -28,13 +28,13 @@ * * dotter(type, 0, 0, qseq, 0, 0, sseq, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); * - * NOTE: qseq and sseq must be messalloc'ed in the calling routine. - * They are messfree'd by Dotter. + * NOTE: qseq and sseq must be g_malloc'ed in the calling routine. + * They are g_free'd by Dotter. * * HISTORY: * Last edited: Nov 14 09:19 2007 (edgrif) * Created: Thu Aug 26 17:16:19 1999 (fw) - * CVS info: $Id: dotter.h,v 1.5 2010-08-24 12:27:59 gb10 Exp $ + * CVS info: $Id: dotter.h,v 1.6 2010-08-31 15:30:55 gb10 Exp $ *------------------------------------------------------------------- */ #ifndef DEF_DOTTER_H @@ -55,7 +55,7 @@ void dotter( Name of Horizontal sequence */ char *queryseq, /* Mandatory, NULL terminated string - Horisontal sequence - messfree'd by Dotter */ + Horisontal sequence - g_free'd by Dotter */ int qoff, /* Optional, may be NULL Coordinate offset of horisontal sequence */ @@ -64,7 +64,7 @@ void dotter( Name of vertical sequence */ char *subjectseq, /* Mandatory, NULL terminated string - vertical sequence - messfree'd by Dotter */ + vertical sequence - g_free'd by Dotter */ int soff, /* Optional, may be NULL Coordinate offset of horisontal sequence */ diff --git a/dotterKarlin.c b/dotterKarlin.c index b367138f8f204e210fdcf86a6c4d03872d4edc1a..bb5c2c05ce894bdfbda4bf66ba9365d5afc3fcf1 100644 --- a/dotterKarlin.c +++ b/dotterKarlin.c @@ -1,5 +1,5 @@ /* Last edited: Oct 26 10:45 2003 (edgrif) */ -/* $Id: dotterKarlin.c,v 1.1 2009-11-03 18:28:23 edgrif Exp $ */ +/* $Id: dotterKarlin.c,v 1.2 2010-08-31 15:30:55 gb10 Exp $ */ /* ------------------------------------------------------------- @@ -37,8 +37,6 @@ #include "gex.h" #include "dotter_.h" -#define NA 24 /* Not A residue */ - #define MAXIT 20 /* Maximum number of iterations used in calculating K */ /* For greater accuracy, set SUMLIMIT to 0.00001 */ @@ -214,31 +212,31 @@ See: Karlin, S. & Altschul, S.F. "Methods for Assessing the Statistical /* Check that scores and their associated probabilities are valid */ if (low >= 0.) { - messout("Karlin-Altschul statistics error: There must be at least one negative score in the substitution matrix."); + g_critical("Karlin-Altschul statistics error: There must be at least one negative score in the substitution matrix."); return -1.0; } for (i=range=high-low; i > -low && pr[i] == 0.0; --i); if (i <= -low) { - messout("Karlin-Altschul statistics error: A positive score is impossible in the context of the scoring scheme, the residue composition of the query sequence, and the residue composition assumed for the database."); + g_critical("Karlin-Altschul statistics error: A positive score is impossible in the context of the scoring scheme, the residue composition of the query sequence, and the residue composition assumed for the database."); return -1.0; } for (sum=i=0; i<=range; sum += pr[i++]) if (pr[i] < 0.) { - messout("Karlin-Altschul statistics error: Negative probabilities for scores are disallowed."); + g_critical("Karlin-Altschul statistics error: Negative probabilities for scores are disallowed."); return -1.0; } if (sum<0.99995 || sum>1.00005) printf("Score probabilities sum to %.5lf and will be normalized to 1.", sum); - p = (double *)messalloc(sizeof(*p) * (range+1)); + p = (double *)g_malloc(sizeof(*p) * (range+1)); for (Sum=low,i=0; i<=range; ++i) Sum += i*(p[i]=pr[i]/sum); if (Sum >= 0.) { - messout("Karlin/Altschul statistics failed due to non-negative expected score: %#0.3lg", Sum); + g_critical("Karlin/Altschul statistics failed due to non-negative expected score: %#0.3lg", Sum); return Sum; } @@ -280,7 +278,7 @@ See: Karlin, S. & Altschul, S.F. "Methods for Assessing the Statistical } Sum = 0.; lo = hi = 0; - P = (double *)messalloc(MAXIT* (range+1) * sizeof(*P)); + P = (double *)g_malloc(MAXIT* (range+1) * sizeof(*P)); *P = sum = oldsum = oldsum2 = 1.; for (j=0; j<MAXIT && sum > SUMLIMIT; oldsum = sum, Sum += sum /= ++j) { first = last = range; @@ -307,12 +305,12 @@ See: Karlin, S. & Altschul, S.F. "Methods for Assessing the Statistical ratio = oldsum / oldsum2; if (ratio >= (1.0 - SUMLIMIT*0.001)) { - messerror ("Value calculated for K was too high due to insufficient iterations. " + g_critical ("Value calculated for K was too high due to insufficient iterations. " "Fudging it.") ; *K = 0.1 ; goto OKExit ; /* was: - fatal("Value calculated for K was too high due to insufficient iterations. " + g_error("Value calculated for K was too high due to insufficient iterations. " "Alternatively, the expected average score is insufficiently negative.") ; */ } @@ -331,8 +329,8 @@ See: Karlin, S. & Altschul, S.F. "Methods for Assessing the Statistical OKExit: - messfree(p); - messfree(P); + g_free(p); + g_free(P); return 0; /* Parameters calculated successfully */ } @@ -353,10 +351,10 @@ int winsizeFromlambdak(int mtx[24][24], int *tob, int abetsize, char *qseq, char qij, exp_MSP_score, sum; - n1 = (int *)messalloc((abetsize+4)*sizeof(int)); - n2 = (int *)messalloc((abetsize+4)*sizeof(int)); - fq1 = (double *)messalloc((abetsize+4)*sizeof(double)); - fq2 = (double *)messalloc((abetsize+4)*sizeof(double)); + n1 = (int *)g_malloc((abetsize+4)*sizeof(int)); + n2 = (int *)g_malloc((abetsize+4)*sizeof(int)); + fq1 = (double *)g_malloc((abetsize+4)*sizeof(double)); + fq2 = (double *)g_malloc((abetsize+4)*sizeof(double)); /* Find high and lows score in score matrix */ @@ -400,7 +398,7 @@ int winsizeFromlambdak(int mtx[24][24], int *tob, int abetsize, char *qseq, char /* Calculate probability of each score */ range = highs - lows; - prob = (double *)messalloc(sizeof(double)*(range+1)); + prob = (double *)g_malloc(sizeof(double)*(range+1)); for (i = 0; i <= range; ++i) prob[i] = 0.0; for (i = 0; i < abetsize; ++i) @@ -413,7 +411,7 @@ int winsizeFromlambdak(int mtx[24][24], int *tob, int abetsize, char *qseq, char if ((*exp_res_score = karlin(lows, highs, prob, Lambda, &K, &H))) { - messout("Setting ad hoc values to winsize=%d and expected score=%.3f", 25, *exp_res_score); + g_critical("Setting ad hoc values to winsize=%d and expected score=%.3f", 25, *exp_res_score); return 25; } @@ -444,11 +442,11 @@ int winsizeFromlambdak(int mtx[24][24], int *tob, int abetsize, char *qseq, char *exp_res_score, retval); - messfree(prob); - messfree(n1); - messfree(n2); - messfree(fq1); - messfree(fq2); + g_free(prob); + g_free(n1); + g_free(n2); + g_free(fq1); + g_free(fq2); return retval; } diff --git a/dotterMain.c b/dotterMain.c index 9e49c7478d66f0beece804d57cc0c59a9d3dea23..05feec759c10597bf0075ae9333ccf6d99372136 100644 --- a/dotterMain.c +++ b/dotterMain.c @@ -26,7 +26,7 @@ * HISTORY: * Last edited: Aug 26 15:42 2009 (edgrif) * Created: Thu Aug 26 17:17:30 1999 (fw) - * CVS info: $Id: dotterMain.c,v 1.11 2010-08-24 12:27:59 gb10 Exp $ + * CVS info: $Id: dotterMain.c,v 1.12 2010-08-31 15:30:55 gb10 Exp $ *------------------------------------------------------------------- */ @@ -37,7 +37,8 @@ #include <wh/gex.h> #include <SeqTools/utilities.h> #include <SeqTools/blixem_.h> -#include <wh/dotter_.h> +#include <SeqTools/dotter_.h> +#include <SeqTools/utilities.h> #define UNSET_INT -1 @@ -122,7 +123,7 @@ static char *stringUnprotect(char **textp, char *target) if (!target) { - target = messalloc(count+1); + target = g_malloc(count+1); goto redo; } @@ -141,20 +142,20 @@ static void addBreakline (MSP **MSPlist, char *name, char *desc, int pos, char s *cp; if (!*MSPlist) { - *MSPlist = (MSP *)messalloc(sizeof(MSP)); + *MSPlist = (MSP *)g_malloc(sizeof(MSP)); msp = *MSPlist; } else { msp = *MSPlist; while(msp->next) msp = msp->next; - msp->next = (MSP *)messalloc(sizeof(MSP)); + msp->next = (MSP *)g_malloc(sizeof(MSP)); msp = msp->next; } - msp->qname = messalloc(strlen(name)+1); + msp->qname = g_malloc(strlen(name)+1); strcpy(msp->qname, name); - msp->desc = messalloc(strlen(desc)+1); + msp->desc = g_malloc(strlen(desc)+1); strcpy(msp->desc, desc); if ((cp = (char *)strchr(msp->desc, ' '))) *cp = 0; @@ -227,7 +228,7 @@ static char* getUsageText() #endif ; - usage = messalloc(strlen(usageText) + strlen(dotterVersion) + strlen(cc_date) + 20); + usage = g_malloc(strlen(usageText) + strlen(dotterVersion) + strlen(cc_date) + 20); sprintf(usage, "%s%s, compiled %s\n", usageText, dotterVersion, cc_date); return usage; @@ -236,6 +237,11 @@ static char* getUsageText() int main(int argc, char **argv) { + /* Set the message handlers */ + g_log_set_default_handler(defaultMessageHandler, NULL); + g_log_set_handler(NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL, popupMessageHandler, NULL); + + DotterOptions options = {0, 0, 0, UNSET_INT, UNSET_INT, 0, 0, 1, 0, 0, 0.0, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; char @@ -270,24 +276,24 @@ int main(int argc, char **argv) switch (optc) { case 'b': - options.savefile = messalloc(strlen(optarg)+1); + options.savefile = g_malloc(strlen(optarg)+1); strcpy(options.savefile, optarg); break; case 'c': opts[1] = 'C'; break; case 'D': opts[0] = ' '; break; case 'f': - options.FSfilename = messalloc(strlen(optarg)+1); + options.FSfilename = g_malloc(strlen(optarg)+1); strcpy(options.FSfilename, optarg); break; case 'F': options.seqInSFS = 1; - options.FSfilename = messalloc(strlen(optarg)+1); + options.FSfilename = g_malloc(strlen(optarg)+1); strcpy(options.FSfilename, optarg); break; case 'H': opts[2] = 'H'; break; case 'i': options.install = 0; break; case 'l': - options.loadfile = messalloc(strlen(optarg)+1); + options.loadfile = g_malloc(strlen(optarg)+1); strcpy(options.loadfile, optarg); break; case 'M': - options.mtxfile = messalloc(strlen(optarg)+1); + options.mtxfile = g_malloc(strlen(optarg)+1); strcpy(options.mtxfile, optarg); break; case 'm': options.memoryLimit = atof(optarg); break; case 'p': options.pixelFacset = atoi(optarg); break; @@ -297,19 +303,19 @@ int main(int argc, char **argv) case 's': options.soffset = atoi(optarg); break; case 'S': options.selfcall = 1; - options.qname = messalloc(strlen(argv[optind])+1); strcpy(options.qname, argv[optind]); + options.qname = g_malloc(strlen(argv[optind])+1); strcpy(options.qname, argv[optind]); options.qlen = atoi(argv[optind+1]); - options.sname = messalloc(strlen(argv[optind+2])+1); strcpy(options.sname, argv[optind+2]); + options.sname = g_malloc(strlen(argv[optind+2])+1); strcpy(options.sname, argv[optind+2]); options.slen = atoi(argv[optind+3]); - dotterBinary = messalloc(strlen(argv[optind+4])+1); + dotterBinary = g_malloc(strlen(argv[optind+4])+1); strcpy(dotterBinary, argv[optind+4]); break; case 'W': - options.winsize = messalloc(strlen(optarg)+1); + options.winsize = g_malloc(strlen(optarg)+1); strcpy(options.winsize, optarg); break; case 'w': opts[1] = 'W'; break; case 'z': options.dotterZoom = atoi(optarg); break; - default : fatal("Illegal option"); + default : g_error("Illegal option"); } } @@ -327,7 +333,7 @@ int main(int argc, char **argv) for (i = optind+2; i < argc; i++) len += strlen(argv[i])+1; - Xoptions = messalloc(len+1); + Xoptions = g_malloc(len+1); for (i = optind+2; i < argc; i++) { strcat(Xoptions, argv[i]); @@ -337,20 +343,20 @@ int main(int argc, char **argv) if (options.selfcall) /* Dotter calling dotter */ { - qseq = (char *)messalloc(options.qlen+1); - sseq = (char *)messalloc(options.slen+1); + qseq = (char *)g_malloc(options.qlen+1); + sseq = (char *)g_malloc(options.slen+1); int l = fread(qseq, 1, options.qlen, stdin); if (l != options.qlen) { - fatal("Only read %d chars to qseq, expected %d", l, options.qlen); + g_error("Only read %d chars to qseq, expected %d", l, options.qlen); } qseq[options.qlen] = 0; l = fread(sseq, 1, options.slen, stdin); if (l != options.slen) { - fatal("Only read %d chars to sseq, expected %d", l, options.slen); + g_error("Only read %d chars to sseq, expected %d", l, options.slen); } sseq[options.slen] = 0; @@ -365,12 +371,12 @@ int main(int argc, char **argv) if (!MSPlist) { - MSPlist = (MSP *)messalloc(sizeof(MSP)); + MSPlist = (MSP *)g_malloc(sizeof(MSP)); msp = MSPlist; } else { - msp->next = (MSP *)messalloc(sizeof(MSP)); + msp->next = (MSP *)g_malloc(sizeof(MSP)); msp = msp->next; } @@ -420,7 +426,7 @@ int main(int argc, char **argv) qfilename = argv[optind]; fseek(qfile, 0, SEEK_END); options.qlen = ftell(qfile); - qseq = (char *)messalloc(options.qlen+1); + qseq = (char *)g_malloc(options.qlen+1); fseek(qfile, 0, SEEK_SET); if ((cp = (char *)strrchr(argv[optind], '/'))) @@ -440,7 +446,7 @@ int main(int argc, char **argv) sfilename = argv[optind+1]; fseek(sfile, 0, SEEK_END); options.slen = ftell(sfile); - sseq = (char *)messalloc(options.slen+1); + sseq = (char *)g_malloc(options.slen+1); fseek(sfile, 0, SEEK_SET); if ((cp = (char *)strrchr(argv[optind]+1, '/'))) @@ -474,8 +480,8 @@ int main(int argc, char **argv) cq++; if (++l == 1) { - options.qname = messalloc(strlen(cq)+1); strNamecpy(options.qname, cq); - firstdesc = messalloc(strlen(cq)+1); + options.qname = g_malloc(strlen(cq)+1); strNamecpy(options.qname, cq); + firstdesc = g_malloc(strlen(cq)+1); strcpy(firstdesc, cq); } else @@ -489,7 +495,7 @@ int main(int argc, char **argv) addBreakline (&MSPlist, qfilename, firstdesc, 0, '1'); /* change sequence name to filename */ - options.qname = messalloc(strlen(qfilename)+1); strcpy(options.qname, qfilename); + options.qname = g_malloc(strlen(qfilename)+1); strcpy(options.qname, qfilename); } addBreakline (&MSPlist, qfilename, cq, count, '1'); @@ -521,8 +527,8 @@ int main(int argc, char **argv) if ((cq = (char *)strchr(line, '>'))) { cq++; if (++l == 1) { - options.sname = messalloc(strlen(cq)+1); strNamecpy(options.sname, cq); - firstdesc = messalloc(strlen(cq)+1); + options.sname = g_malloc(strlen(cq)+1); strNamecpy(options.sname, cq); + firstdesc = g_malloc(strlen(cq)+1); strcpy(firstdesc, cq); } else { @@ -535,7 +541,7 @@ int main(int argc, char **argv) addBreakline (&MSPlist, sfilename, firstdesc, 0, '2'); /* change sequence name to filename */ - options.sname = messalloc(strlen(sfilename)+1); strcpy(options.sname, sfilename); + options.sname = g_malloc(strlen(sfilename)+1); strcpy(options.sname, sfilename); } addBreakline (&MSPlist, sfilename, cq, count, '2'); } @@ -591,19 +597,22 @@ int main(int argc, char **argv) printf("\nDetected sequence types: DNA vs. Protein\n"); type = 'X'; } - else fatal("Illegal sequence types: Protein vs. DNA - turn arguments around!\n\n%s", usage); - + else + { + g_error("Illegal sequence types: Protein vs. DNA - turn arguments around!\n\n%s", usage); + } + if (options.revcompq) { if (type != 'X') { - fatal("Revcomp'ing horizontal_sequence only needed in DNA vs. Protein"); + g_error("Revcomp'ing horizontal_sequence only needed in DNA vs. Protein"); } else { - cc = messalloc(options.qlen+1); + cc = g_malloc(options.qlen+1); revComplement(cc, qseq); - messfree(qseq); + g_free(qseq); qseq = cc; } } diff --git a/dotter_.h b/dotter_.h index e031712c394b4fde0ae00a5ef888b51419bfee8e..aacf5fed71d351200717c29b7ec826ae575d6a71 100644 --- a/dotter_.h +++ b/dotter_.h @@ -26,7 +26,7 @@ * HISTORY: * Last edited: Sep 15 08:36 2006 (edgrif) * Created: Thu Aug 26 17:17:58 1999 (fw) - * CVS info: $Id: dotter_.h,v 1.3 2010-05-19 10:27:32 gb10 Exp $ + * CVS info: $Id: dotter_.h,v 1.4 2010-08-31 15:30:55 gb10 Exp $ *------------------------------------------------------------------- */ @@ -35,39 +35,18 @@ #include <SeqTools/dotter.h> -#define AAID_MIN 1 /* Smallest letter value in binary alphabet */ -#define AAID_MAX 24 /* Maximum letter value in binary alphabet */ -#define AAID_CNT 24 /* Number of letters in alphabet */ -#define AAID_NAR (AAID_MAX+1) -#define AAID_IGNORE (AAID_MAX+3) +#define NR 23 /* Not A residue */ +#define NA 24 /* Not A residue */ -#define NA 24 /* Not A residue */ -#define EL (NA+1) /* End of Line */ -#define ES (NA+2) /* End of Sequence */ -#define IC AAID_IGNORE /* Ignore this Character */ - -#define UNKNOWN_AA_CHR 'X' -#define STOP_AA_CHR '*' -#define GAP_AA_CHR '-' - -#define NR 23 /* Not A residue */ #if !defined(NAMESIZE) #define NAMESIZE 10 #endif -char *translate(char *seq, char **code); extern char *stdcode1[]; /* 1-letter amino acid translation code */ int winsizeFromlambdak(int mtx[24][24], int *tob, int abetsize, char *qseq, char *sseq, double *exp_res_score, double *Lambda); -#if !defined BELVU -/* Horrifically the headers for belvu, dotter and blixem all include each other for - * inappropriate reasons..there should some common headers/.o files and all would be - * well.... */ -void fatal(char *format, ...); -#endif - void argvAdd(int *argc, char ***argv, char *s);