Esempio n. 1
0
void chainPair(struct seqPair *sp, FILE *f)
/* Make chains for all alignments in sp. */
{
long startTime, dt;
struct axt *axt;
struct cBlock *blockList, *block;
struct chain *chainList = NULL, *chain;

uglyf("%s %d nodes\n", sp->name, slCount(sp->blockList));

/* Make up tree and time it for debugging. */
startTime = clock1000();
chainList = chainBlocks(&sp->blockList, gapCost);
dt = clock1000() - startTime;
uglyf("Made %d chains in %5.3f seconds\n", slCount(chainList), dt*0.001);

/* Dump chains to file. */
for (chain = chainList; chain != NULL; chain = chain->next)
    {
    struct cBlock *first = chain->blockList;
    struct cBlock *last = slLastEl(first);
    struct cBlock *block;
    fprintf(f, "%s Chain %d, score %d, %d %d, %d %d:\n", 
	sp->name, slCount(chain->blockList), chain->score,
	first->qStart, last->qEnd, first->tStart, last->qEnd);
    for (block = chain->blockList; block != NULL; block = block->next)
        {
	fprintf(f, " %s q %d, t %d, score %d\n", sp->name,
		block->qStart, block->tStart, block->score);
	}
    fprintf(f, "\n");
    }
chainFreeList(&chainList);
uglyf("\n");
}
static void setExonBounds(struct cdsExon *exon)
/* set isExonStart/isExonEnd flags on frames associated with an exon */
{
if (exon->frames != NULL)
    {
    exon->frames->mf.isExonStart = TRUE;
    struct exonFrames *ef = slLastEl(exon->frames);
    ef->mf.isExonEnd = TRUE;
    }
}
void jsValidateKeysOnDb(struct joiner *joiner, struct joinerSet *js,
                        char *db, struct hash *keyHash, struct keyHitInfo *khiList)
/* Validate keys pertaining to this database. */
{
    struct joinerField *jf;
    struct hash *localKeyHash = NULL;
    struct keyHitInfo *localKhiList = NULL;
    struct joinerField *keyField;

    if ((keyField = js->fieldList) == NULL)
        return;
    if (keyHash == NULL)
    {
        char *keyDb;
        if (slNameInList(keyField->dbList, db))
        {
            keyDb = db;
        }
        else if (!dbInAnyField(js->fieldList->next, db))
        {
            return;
        }
        else
        {
            if (slCount(keyField->dbList) == 1)
                keyDb = keyField->dbList->name;
            else
            {
                struct slName *lastDb = slLastEl(keyField->dbList);
                keyDb = lastDb->name;
                verbose(1, " note - using %s database as reference for identifier %s\n",
                        keyDb, js->name);
            }
        }
        keyHash = localKeyHash = readKeyHash(keyDb, joiner, keyField,
                                             &localKhiList);
        khiList = localKhiList;
    }
    if (keyHash != NULL)
    {
        for (jf = js->fieldList; jf != NULL; jf = jf->next)
        {
            if (jf != keyField && slNameInList(jf->dbList, db))
            {
                doKeyChecks(db, joiner, js, keyHash, khiList, keyField, jf);
            }
        }
    }
    hashFree(&localKeyHash);
    slFreeList(&localKhiList);
}
Esempio n. 4
0
struct ntContig *readNtFile(char *fileName, 
	struct hash *ntContigHash, struct hash *ntCloneHash)
/* Read in NT contig info. (NT contigs are contigs of finished clones.) */
{
struct lineFile *lf;
int lineSize, wordCount;
char *line, *words[8];
struct ntContig *contigList = NULL, *contig = NULL;
struct ntClonePos *pos;
char *contigName;
struct hashEl *hel;

/* Parse file into ntContig/ntClonePos data structures. */
lf = lineFileOpen(fileName, TRUE);
while (lineFileNext(lf, &line, &lineSize))
    {
    wordCount = chopLine(line, words);
    if (wordCount == 0)
        continue;
    if (wordCount != 5)
        errAbort("Expecting 5 words line %d of %s", lf->lineIx, lf->fileName);
    contigName = words[0];
    if (contig == NULL || !sameString(contigName, contig->name))
        {
	AllocVar(contig);
	hel = hashAddUnique(ntContigHash, contigName, contig);
	contig->name = hel->name;
	slAddHead(&contigList, contig);
	}
    AllocVar(pos);
    hel = hashAddUnique(ntCloneHash, words[1], pos);
    pos->name = hel->name;
    pos->ntContig = contig;
    pos->pos = atoi(words[2]);
    pos->orientation = ((words[3][0] == '-') ? -1 : 1);
    pos->size = atoi(words[4]);
    slAddHead(&contig->cloneList, pos);
    }
lineFileClose(&lf);

/* Make sure everything is nicely sorted and sized. */
for (contig = contigList; contig != NULL; contig = contig->next)
    {
    slSort(&contig->cloneList, cmpNtClonePos);
    pos = slLastEl(contig->cloneList);
    contig->size = pos->pos + pos->size;
    }

slReverse(&contigList);
return contigList;
}
Esempio n. 5
0
struct splatAlign *splatExtendTag(struct splatTag *tag,
	struct dnaSeq *qSeqF, struct dnaSeq *qSeqR, struct splix *splix,
	struct axtScoreScheme *scoreScheme)
/* Convert a single tag to an alignment. */
{
int maxSingleGap = 9;
int maxTotalGap = maxSingleGap * 3;
struct splatAlign *ali = tagToAlign(tag, qSeqF, qSeqR, splix, scoreScheme);
struct chain *chain = ali->chain;
chainAddAxtScore(chain, ali->qDna, ali->tDna, scoreScheme);
int qxSize = chain->qSize - chain->qEnd;	/* extra q size. */
int txSize = chain->tSize - chain->tEnd;	/* extra t size. */
if (qxSize > 0 && txSize > 0)
    {
    int qxStart = chain->qEnd;
    int qxEnd = chain->qSize;
    int txStart = chain->tEnd;
    int txEnd = chain->tSize;
    int txMaxSize = qxSize + maxTotalGap;
    if (txSize > txMaxSize)
        txSize = txMaxSize;
    int symAlloc = qxSize + txSize;
    char *qSym, *tSym;
    AllocArray(qSym, symAlloc);
    AllocArray(tSym, symAlloc);
    int symCount, revStartQ, revStartT;
    if (bandExt(FALSE, scoreScheme, 9, 
    		ali->qDna + qxStart, qxSize,  
		ali->tDna + txStart, txSize, 1,
		symAlloc, &symCount, qSym, tSym, &revStartQ, &revStartT))
	{
	struct cBlock *newBlocks = cBlocksFromAliSym(symCount, 
		qSym, tSym, qxStart, txStart);
	struct cBlock *lastOldBlock = slLastEl(chain->blockList);
	lastOldBlock->next = newBlocks;
	chainMergeAbutting(chain);
	chainCalcBounds(chain);
	chainAddAxtScore(chain, ali->qDna, ali->tDna, scoreScheme);
	}
    freeMem(qSym);
    freeMem(tSym);
    }
return ali;
}
void printCloneEndInfo(struct clone *clone, FILE *f)
/* Print out end information on one clone. */
{
struct frag *frag, *endFrag;

if (clone->fragCount == 1)
    {
    frag = clone->fragList;
    printCloneStart(clone, f);
    fprintf(f, "%s\tL\t%s\tR\n", frag->name, frag->name);
    }
else if (clone->isFin || clone->phase >= 2)
    {
    frag = clone->fragList;
    endFrag = slLastEl(clone->fragList);
    printCloneStart(clone, f);
    fprintf(f, "%s\tL\t%s\tR\n", frag->name, endFrag->name);
    }
else 
    {
    int gsCount = slCount(clone->gsList);
    int spCount = slCount(clone->spList);
    if (gsCount == 1 && spCount <= 1 || spCount == 1 && gsCount <= 1)
	{
	if (gsCount == 1)
	    oneSideOut(clone->gsList, clone, f);
	else
	    oneSideOut(clone->spList, clone, f);
	}
    else if (gsCount == 2 || spCount == 2)
	{
	if (gsCount == 2)
	    twoSidesOut(clone->gsList, clone, f);
	else
	    twoSidesOut(clone->spList, clone, f);
	}
    else if (gsCount >= 3 || spCount >= 3)
	{
	warn("Three or more ends (%d %d) in %s, skipping for now",
		gsCount, spCount, clone->name);
	}
    }
}