@property
    def query(self):
        if self.args.columns is not None:
            # the user only wants to report a subset of the columns
            query = "SELECT " + str(self.args.columns) + " FROM variants "
        else:
            # report the kitchen sink
            query = "SELECT chrom, start, end, * %s " \
                + "FROM variants" % ", ".join(self.gt_cols)

        query = sql_utils.ensure_columns(query, ['variant_id', 'gene'])
        # add any non-genotype column limits to the where clause
        if self.args.filter:
            query += " WHERE " + self.args.filter

        if hasattr(self.args, 'X'):
            if self.args.X == []:
                self.args.X = ['chrX', 'X']
            part = "chrom IN (%s)" % ", ".join("'%s'" % x for x in self.args.X)
            if " WHERE " in query:
                query += " AND " + part
            else:
                query += " WHERE " + part

        # auto_rec and auto_dom candidates should be limited to
        # variants affecting genes.
        if self.model in ("auto_rec", "auto_dom", "comp_het") or \
           (self.model == "de_novo" and self.args.min_kindreds is not None):

            # we require the "gene" column for the auto_* tools
            if " WHERE " in query:
                query += " AND gene is not NULL"
            else:
                query += " WHERE gene is not NULL"

        # only need to order by gene for comp_het and when min_kindreds is used.
        if self.model == "comp_het" or not (
                self.args.min_kindreds in (None, 1)
                and (self.args.families is None
                     or not "," in self.args.families)):
            query += " ORDER by chrom, gene"

        return query
dataset/ETHPy150Open arq5x/gemini/gemini/gim.py/GeminiInheritanceModel.query/original