コード例 #1
0
ファイル: qacToWig.c プロジェクト: elmargb/kentUtils
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);
}
コード例 #2
0
int filterByQual(char *faFileName, FILE *f, int minQual, int minQualRun, struct hash *uniqHash)
/* Write out parts of sequence that meet quality standards to fa file in out. 
 * Returns untrimmed size. */
{
char qaFileName[512], dir[256], name[128], ext[64];
struct qaSeq *qa;
int start, size;
int initialSize;

splitPath(faFileName, dir, name, ext);
sprintf(qaFileName, "%s%s.qual", dir, name);
qa = qaMustReadBoth(qaFileName, faFileName);
if (hashLookup(uniqHash, qa->name))
   warn("%s duplicated, ignoring all but first occurence", qa->name);
else
    {
    hashAdd(uniqHash, qa->name, NULL);
    if (trimQa(qa, minQual, minQualRun, &start, &size))
	{
	faWriteNext(f, qa->name, qa->dna + start, size);
	}
    }
initialSize = qa->size;
qaSeqFree(&qa);
return initialSize;
}
コード例 #3
0
void qaSeqFreeList(struct qaSeq **pList)
/* Free a list of QA seq's. */
{
struct qaSeq *el, *next;
for (el = *pList; el != NULL; el = next)
    {
    next = el->next;
    qaSeqFree(&el);
    }
*pList = NULL;
}
コード例 #4
0
ファイル: qaToQac.c プロジェクト: blumroy/kentUtils
void qaToQac(char *inName, char *outName)
/* qaToQac - convert from uncompressed to compressed 
 * quality score format. */
{
struct lineFile *lf = lineFileOpen(inName, TRUE);
FILE *f = mustOpen(outName, "wb");
struct qaSeq *qa;

qacWriteHead(f);
while ((qa = qaReadNext(lf)) != NULL)
    {
    qacWriteNext(f, qa);
    qaSeqFree(&qa);
    }
lineFileClose(&lf);
fclose(f);
}
コード例 #5
0
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);
}
コード例 #6
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);
}