e2ec5ef77645a662ba31c7cfbd7499794975275a angie Fri Mar 23 16:44:07 2012 -0700 Feature #6152 (Variant Annotation Tool): Initial work, squashed infrom origin/annoGrator branch. Superclasses annoColumn, annoFilter, annoRow, annoStreamer, annoGrator, and annoFormatter define the core interfaces for passing data and configuration to and from components. The annoGrator superclass can join annoRows on position and pass forward all rows of secondary source. The annoGratorQuery module orchestrates the passing of annoRows between the primary source, annoGrator(s) and annoFormatter(s). The subclasses annoStreamDb and annoFormatTab, together with hg/lib/tests/annoGratorTester.c, can join columns of two database tables such as hg19's pgNA12878 and knownGene into tab-separated output. diff --git src/inc/annoGrator.h src/inc/annoGrator.h new file mode 100644 index 0000000..259d525 --- /dev/null +++ src/inc/annoGrator.h @@ -0,0 +1,52 @@ +/* annoGrator -- annoStreamer that integrates genomic annotations from two annoStreamers */ + +// Subclasses of annoGrator can do value-add things such as predict function given +// a variant and a gene; the base class simply intersects by position, returning +// all rows from its internal data source that overlap the position of primaryRow. +// The interface to an annoGrator is almost the same as the interface to an annoStreamer, +// *except* you call integrate() instead of nextRow(). + +#ifndef ANNOGRATOR_H +#define ANNOGRATOR_H + +#include "annoStreamer.h" + +struct annoGrator +/* annoStreamer that can integrate an internal annoStreamer's data + * with data from a primary source. */ + { + struct annoStreamer streamer; // external annoStreamer interface + // Public method that makes this a 'grator: + // Integrate own source's data with single row of primary source's data + struct annoRow *(*integrate)(struct annoGrator *self, struct annoRow *primaryRow, + boolean *retRJFilterFailed); + // Private members -- callers are on the honor system to access these using only methods above. + struct annoStreamer *mySource; // internal source + int numSrcCols; // cache the number of columns we get from mySource + char *prevPChrom; // for detection of unsorted input from primary + uint prevPStart; // for detection of unsorted input from primary + boolean eof; // stop asking internal source for rows when it's done + struct annoRow *qHead; // head of FIFO queue of rows from internal source + struct annoRow *qTail; // head of FIFO queue of rows from internal source + }; + +#endif//ndef ANNOGRATOR_H + +// ---------------------- annoGrator default methods ----------------------- + +struct annoRow *annoGratorIntegrate(struct annoGrator *self, struct annoRow *primaryRow, + boolean *retRJFilterFailed); +/* Given a single row from the primary source, get all overlapping rows from internal + * source, and produce joined output rows. If retRJFilterFailed is non-NULL and any + * overlapping row has a rightJoin filter failure (see annoFilter.h), + * set retRJFilterFailed and stop. */ + +struct annoGrator *annoGratorNew(struct annoStreamer *mySource); +/* Make a new integrator of columns from mySource with (positions of) rows passed to integrate(). + * mySource becomes property of the new annoGrator. */ + +void annoGratorSetQuery(struct annoStreamer *vSelf, struct annoGratorQuery *query); +/* Set query (to be called only by annoGratorQuery which is created after streamers). */ + +void annoGratorClose(struct annoStreamer **pSelf); +/* Free self (including mySource). */