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/annoStreamer.h src/inc/annoStreamer.h new file mode 100644 index 0000000..2dec83d --- /dev/null +++ src/inc/annoStreamer.h @@ -0,0 +1,88 @@ +/* annoStreamer -- returns items sorted by genomic position to successive nextRow calls */ + +#ifndef ANNOSTREAMER_H +#define ANNOSTREAMER_H + +#include "annoColumn.h" +#include "annoFilter.h" +#include "annoRow.h" + +// The real work of fetching and filtering data is left to subclass +// implementations. The purpose of this module is to provide an +// interface for communication with other components of the +// annoGratorQuery framework, and simple methods shared by all +// subclasses. + +// stub in order to avoid problems with circular .h references: +struct annoGratorQuery; + +struct annoStreamer +/* Generic interface to configure a data source's filters and output data, and then + * retrieve data, which must be sorted by genomic position. Subclasses of this + * will do all the actual work. */ + { + struct annoStreamer *next; + // Public methods + // Get autoSql representation (do not modify or free!) + struct asObject *(*getAutoSqlObject)(struct annoStreamer *self); + // Set genomic region for query (should be called only by annoGratorQuerySetRegion) + void (*setRegion)(struct annoStreamer *self, char *chrom, uint rStart, uint rEnd); + // Get and set filters + struct annoFilter *(*getFilters)(struct annoStreamer *self); + void (*setFilters)(struct annoStreamer *self, struct annoFilter *newFilters); + // Get and set output fields + struct annoColumn *(*getColumns)(struct annoStreamer *self); + void (*setColumns)(struct annoStreamer *self, struct annoColumn *newColumns); + // Get next item's output fields from this source + struct annoRow *(*nextRow)(struct annoStreamer *self); + // Close connection to source and free self. + void (*close)(struct annoStreamer **pSelf); + // For use by annoGratorQuery only: hook up query object after creation + void (*setQuery)(struct annoStreamer *self, struct annoGratorQuery *query); + // Private members -- callers are on the honor system to access these using only methods above. + struct annoGratorQuery *query; // The query object that owns this streamer. + boolean positionIsGenome; + char *chrom; + uint regionStart; + uint regionEnd; + struct asObject *asObj; + struct annoFilter *filters; + struct annoColumn *columns; + }; + +// ---------------------- annoStreamer default methods ----------------------- + +struct asObject *annoStreamerGetAutoSqlObject(struct annoStreamer *self); +/* Return parsed autoSql definition of this streamer's data type. */ + +void annoStreamerSetRegion(struct annoStreamer *self, char *chrom, uint rStart, uint rEnd); +/* Set genomic region for query; if chrom is NULL, position is genome. + * Many subclasses should make their own setRegion method that calls this and + * configures their data connection to change to the new position. */ + +struct annoFilter *annoStreamerGetFilters(struct annoStreamer *self); +/* Return supported filters with current settings. Callers can modify and free when done. */ + +void annoStreamerSetFilters(struct annoStreamer *self, struct annoFilter *newFilters); +/* Free old filters and use clone of newFilters. */ + +struct annoColumn *annoStreamerGetColumns(struct annoStreamer *self); +/* Return supported columns with current settings. Callers can modify and free when done. */ + +void annoStreamerSetColumns(struct annoStreamer *self, struct annoColumn *columns); +/* Free old columns and use clone of newColumns. */ + +void annoStreamerInit(struct annoStreamer *self, struct asObject *asObj); +/* Initialize a newly allocated annoStreamer with default annoStreamer methods and + * default filters and columns based on asObj. + * In general, subclasses' constructors will call this first; override nextRow, close, + * and probably setRegion; and then initialize their private data. */ + +void annoStreamerFree(struct annoStreamer **pSelf); +/* Free self. This should be called at the end of subclass close methods, after + * subclass-specific connections are closed and resources are freed. */ + +void annoStreamerSetQuery(struct annoStreamer *self, struct annoGratorQuery *query); +/* Set query (to be called only by annoGratorQuery which is created after streamers). */ + +#endif//ndef ANNOSTREAMER_H