Exemple #1
0
static struct annoRow *asvNextRow(struct annoStreamer *sSelf, char *minChrom, uint minEnd,
				  struct lm *callerLm)
/* Return an annoRow encoding the next VCF record, or NULL if there are no more items. */
{
struct annoStreamVcf *self = (struct annoStreamVcf *)sSelf;
if (minChrom != NULL && sSelf->chrom != NULL && differentString(minChrom, sSelf->chrom))
    errAbort("annoStreamVcf %s: nextRow minChrom='%s' but region chrom='%s'",
	     sSelf->name, minChrom, sSelf->chrom);
if (self->maxRecords > 0 && self->recordCount >= self->maxRecords)
    return NULL;
char **words = nextRowUnfiltered(self, minChrom, minEnd);
if (words == NULL)
    return NULL;
// Skip past any left-join failures until we get a right-join failure, a passing row, or EOF.
boolean rightFail = FALSE;
while (annoFilterRowFails(sSelf->filters, words, self->numCols, &rightFail))
    {
    if (rightFail)
	break;
    words = nextRowUnfiltered(self, minChrom, minEnd);
    if (words == NULL)
	return NULL;
    }
struct vcfRecord *rec = self->record;
char *chrom = getProperChromName(self, rec->chrom);
self->recordCount++;
return annoRowFromStringArray(chrom, rec->chromStart, rec->chromEnd,
			      rightFail, words, self->numCols, callerLm);
}
Exemple #2
0
struct annoRow *aggvIntergenicRow(struct annoGratorGpVar *self, struct variant *variant,
				  boolean *retRJFilterFailed, struct lm *callerLm)
/* If intergenic variants (no overlapping or nearby genes) are to be included in output,
 * make an output row with empty genePred and a gpFx that is empty except for soNumber. */
{
struct annoGrator *gSelf = &(self->grator);
struct annoStreamer *sSelf = &(gSelf->streamer);
char **wordsOut;
lmAllocArray(self->lm, wordsOut, sSelf->numCols);
// Add empty strings for genePred string columns:
int gpColCount = gSelf->mySource->numCols;
int i;
for (i = 0;  i < gpColCount;  i++)
    wordsOut[i] = "";
struct gpFx *intergenicGpFx;
lmAllocVar(self->lm, intergenicGpFx);
intergenicGpFx->allele = firstAltAllele(variant->alleles);
if (isAllNt(intergenicGpFx->allele, strlen(intergenicGpFx->allele)))
    touppers(intergenicGpFx->allele);
intergenicGpFx->soNumber = intergenic_variant;
intergenicGpFx->detailType = none;
aggvStringifyGpFx(&wordsOut[gpColCount], intergenicGpFx, self->lm);
boolean rjFail = (retRJFilterFailed && *retRJFilterFailed);
return annoRowFromStringArray(variant->chrom, variant->chromStart, variant->chromEnd, rjFail,
			      wordsOut, sSelf->numCols, callerLm);
}
Exemple #3
0
static struct annoRow *rowToAnnoRow(struct annoStreamDb *self, char **row, boolean rightFail,
				    struct lm *lm)
/* Extract coords from row and return an annoRow including right-fail status. */
{
row += self->omitBin;
char *chrom = row[self->chromIx];
uint chromStart = sqlUnsigned(row[self->startIx]);
uint chromEnd = sqlUnsigned(row[self->endIx]);
return annoRowFromStringArray(chrom, chromStart, chromEnd, rightFail, row,
			      self->streamer.numCols, lm);
}
Exemple #4
0
struct annoRow *annoRowClone(struct annoRow *rowIn, struct annoStreamer *source)
/* Allocate & return a single annoRow cloned from rowIn. */
{
if (rowIn == NULL)
    return NULL;
if (source->rowType == arWords || source->rowType == arVcf)
    return annoRowFromStringArray(rowIn->chrom, rowIn->start, rowIn->end, rowIn->rightJoinFail,
				  rowIn->data, source->numCols);
else if (source->rowType == arWig)
    return annoRowWigNew(rowIn->chrom, rowIn->start, rowIn->end, rowIn->rightJoinFail,
			 (float *)rowIn->data);
else
    errAbort("annoRowClone: unrecognized type %d", source->rowType);
return NULL;
}
Exemple #5
0
struct annoRow *annoRowClone(struct annoRow *rowIn, enum annoRowType rowType, int numCols,
			     struct lm *lm)
/* Allocate & return a single annoRow cloned from rowIn.  If rowIn is NULL, return NULL.
 * If type is arWig, numCols is ignored. */
{
if (rowIn == NULL)
    return NULL;
if (rowType == arWords)
    return annoRowFromStringArray(rowIn->chrom, rowIn->start, rowIn->end, rowIn->rightJoinFail,
				  rowIn->data, numCols, lm);
else if (rowType == arWig)
    return annoRowWigNew(rowIn->chrom, rowIn->start, rowIn->end, rowIn->rightJoinFail,
			 (float *)rowIn->data, lm);
else
    errAbort("annoRowClone: unrecognized type %d", rowType);
return NULL;
}
Exemple #6
0
static struct annoRow *aggvEffectToRow(struct annoGratorGpVar *self, struct gpFx *effect,
				       struct annoRow *rowIn, struct lm *callerLm)
// convert a single genePred annoRow and gpFx record to an augmented genePred annoRow;
{
struct annoGrator *gSelf = &(self->grator);
struct annoStreamer *sSelf = &(gSelf->streamer);
assert(sSelf->numCols > gSelf->mySource->numCols);

char **wordsOut;
lmAllocArray(self->lm, wordsOut, sSelf->numCols);

// copy the genePred fields over
int gpColCount = gSelf->mySource->numCols;
char **wordsIn = (char **)rowIn->data;
memcpy(wordsOut, wordsIn, sizeof(char *) * gpColCount);

// stringify the gpFx structure 
aggvStringifyGpFx(&wordsOut[gpColCount], effect, callerLm);

return annoRowFromStringArray(rowIn->chrom, rowIn->start, rowIn->end, rowIn->rightJoinFail,
			      wordsOut, sSelf->numCols, callerLm);
}
static struct annoRow *astNextRow(struct annoStreamer *vSelf, char *minChrom, uint minEnd,
				  struct lm *callerLm)
/* Return the next annoRow that passes filters, or NULL if there are no more items. */
{
struct annoStreamTab *self = (struct annoStreamTab *)vSelf;
char **words = nextRowUnfiltered(self, minChrom, minEnd);
if (words == NULL)
    return NULL;
// Skip past any left-join failures until we get a right-join failure, a passing row, or EOF.
boolean rightFail = FALSE;
while (annoFilterRowFails(vSelf->filters, words, vSelf->numCols, &rightFail))
    {
    if (rightFail)
	break;
    words = nextRowUnfiltered(self, minChrom, minEnd);
    if (words == NULL)
	return NULL;
    }
char *chrom = words[self->chromIx];
uint chromStart = sqlUnsigned(words[self->startIx]);
uint chromEnd = sqlUnsigned(words[self->endIx]);
return annoRowFromStringArray(chrom, chromStart, chromEnd, rightFail, words, vSelf->numCols,
			      callerLm);
}