00001
00002
00003
00004 #include "common.h"
00005 #include "ooc.h"
00006 #include "sig.h"
00007
00008 static char const rcsid[] = "$Id: ooc.c,v 1.2 2003/09/09 21:44:02 kent Exp $";
00009
00010 void oocMaskCounts(char *oocFile, bits32 *tileCounts, int tileSize, bits32 maxPat)
00011
00012
00013 {
00014 if (oocFile != NULL)
00015 {
00016 bits32 sig, psz;
00017 FILE *f = mustOpen(oocFile, "rb");
00018 boolean mustSwap = FALSE;
00019
00020 mustReadOne(f, sig);
00021 mustReadOne(f, psz);
00022 if (sig == oocSig)
00023 mustSwap = FALSE;
00024 else if (sig == oocSigSwapped)
00025 {
00026 mustSwap = TRUE;
00027 psz = byteSwap32(psz);
00028 }
00029 else
00030 errAbort("Bad signature on %s\n", oocFile);
00031 if (psz != tileSize)
00032 errAbort("Oligo size mismatch in %s. Expecting %d got %d\n",
00033 oocFile, tileSize, psz);
00034 if (mustSwap)
00035 {
00036 union {bits32 whole; UBYTE bytes[4];} u,v;
00037 while (readOne(f, u))
00038 {
00039 v.bytes[0] = u.bytes[3];
00040 v.bytes[1] = u.bytes[2];
00041 v.bytes[2] = u.bytes[1];
00042 v.bytes[3] = u.bytes[0];
00043 tileCounts[v.whole] = maxPat;
00044 }
00045 }
00046 else
00047 {
00048 bits32 oli;
00049 while (readOne(f, oli))
00050 tileCounts[oli] = maxPat;
00051 }
00052 fclose(f);
00053 }
00054 }
00055
00056 void oocMaskSimpleRepeats(bits32 *tileCounts, int seedSize, bits32 maxPat)
00057
00058 {
00059 int i, j, k;
00060 int tileMask = (1<<(seedSize+seedSize))-1;
00061 for (i=0; i<4; ++i)
00062 {
00063 for (j=0; j<4; ++j)
00064 {
00065 bits32 repeat = 0;
00066 for (k=0; k<8; ++k)
00067 {
00068 repeat <<= 2;
00069 repeat |= i;
00070 repeat <<= 2;
00071 repeat |= j;
00072 }
00073 repeat &= tileMask;
00074 tileCounts[repeat] = maxPat;
00075 }
00076 }
00077 }
00078