struct qaSeq *qaRead(char *qaName)
/* Read in a .qa file (all records) or die trying. */
{
struct qaSeq *qa, *qaList = NULL;
if (isQacFile(qaName))
    {
    boolean isSwapped;
    FILE *f = qacOpenVerify(qaName, &isSwapped);
    while ((qa = qacReadNext(f, isSwapped)) != NULL)
	{
	slAddHead(&qaList, qa);
	}
    fclose(f);
    }
else
    {
    struct lineFile *lf = lineFileOpen(qaName, TRUE);
    while ((qa = qaReadNext(lf)) != NULL)
	{
	slAddHead(&qaList, qa);
	}
    lineFileClose(&lf);
    }
slReverse(&qaList);
return qaList;
}
예제 #2
0
struct hash *qacReadToHash(char *fileName)
/* Read in a qac file into a hash of qacs keyed by name. */
{
boolean isSwapped;
FILE *f = qacOpenVerify(fileName, &isSwapped);
bits32 compSize, uncSize;
struct qac *qac;
char *name;
struct hash *hash = newHash(18);
int count = 0;

for (;;)
    {
    name = readString(f);
    if (name == NULL)
       break;
    mustReadOne(f, uncSize);
    if (isSwapped)
	uncSize = byteSwap32(uncSize);
    mustReadOne(f, compSize);
    if (isSwapped)
	compSize = byteSwap32(compSize);
    qac = needHugeMem(sizeof(*qac) + compSize - 1);
    qac->uncSize = uncSize;
    qac->compSize = compSize;
    mustRead(f, qac->data, compSize);
    hashAdd(hash, name, qac);
    ++count;
    }
carefulClose(&f);
printf("Read %d qacs from %s\n", count, fileName);
return hash;
}
예제 #3
0
void qacToWig(char *inName, char *outDir)
/* qacToWig - convert from compressed to wiggle format files in out dir */
{
boolean isSwapped;
FILE *in = qacOpenVerify(inName, &isSwapped);
FILE *out = NULL;
struct qaSeq *qa;
int outFileCount = 0;

if (fixed)
    out = mustOpen(outDir, "wb");
else if (name == NULL)
    makeDir(outDir);

while ((qa = qacReadNext(in, isSwapped)) != NULL)
    {
    if (name != NULL)
	{
	if (sameString(qa->name, name))
	    {
	    if (fixed)
		wigFixedWrite(out, qa);
	    else
		wigWrite(outDir, qa);
	    qaSeqFree(&qa);
	    outFileCount++;
	    break;
	    }
	}
    else if (fixed)
        {
        wigFixedWrite(out, qa);
	qaSeqFree(&qa);
        outFileCount = 1;
        continue;
        }
    else
	{
	char outPath[1024];
	safef(outPath, sizeof outPath, "%s/%s.wig", outDir, qa->name);
	wigWrite(outPath, qa);
	outFileCount++;
	}
    qaSeqFree(&qa);
    }
carefulClose(&in);
if (fixed)
    carefulClose(&out);
if (name == NULL)
    verbose(1, "Made %d .wig files in %s\n", outFileCount, outDir);
else if (outFileCount < 1)
    warn("Found no sequences with name \"%s\"\n", name);
}
static void fillInQac(char *qacName, struct hash *hash, struct qaSeq *qaList)
/* Hash contains qaSeq's with DNA sequence but no
 * quality info.  Fill in quality info from .qac file. */
{ 
boolean isSwapped;   
FILE *f = qacOpenVerify(qacName, &isSwapped);
struct qaSeq *qa;

while ((qa = qacReadNext(f, isSwapped)) != NULL)
    {
    /* Transfer qa->qa to hash. */
    attatchQaInfo(hash, qa->name, qa->qa, qa->size);
    qa->qa = NULL;
    qaSeqFree(&qa);
    }
fclose(f);
checkAllPresent(qaList);
}
예제 #5
0
파일: qacToQa.c 프로젝트: blumroy/kentUtils
void qacToQa(char *inName, char *outName)
/* qacToQa - convert from compressed to uncompressed 
 * quality score format. */
{
boolean isSwapped;
FILE *in = qacOpenVerify(inName, &isSwapped);
FILE *out = mustOpen(outName, "wb");
struct qaSeq *qa;
int size = 0;

while ((qa = qacReadNext(in, isSwapped)) != NULL)
    {
    if (name != NULL)
        if (!sameString(qa->name, name))
            continue;
    size += qa->size;
    qaWriteNext(out, qa);
    qaSeqFree(&qa);
    }
verbose(3, "qa total size: %d\n", size);
fclose(in);
fclose(out);
}