コード例 #1
0
    def select(self, *columns, **kwargs):
        """
        Construct a new Query object with the given columns selected.
        =============================================================

        As new_query, except that instead of a root class, a list of
        output column expressions are passed instead.
        """
        if "xml" in kwargs:
            return self.load_query(kwargs["xml"])
        if len(columns) == 1:
            view = columns[0]
            if isinstance(view, Attribute):
                return Query(self.model, self).select(
                    "%s.%s" % (view.declared_in.name, view))

            if isinstance(view, Reference):
                return Query(self.model, self).select(
                    "%s.%s.*" % (view.declared_in.name, view))
            elif not isinstance(view, Column) and not str(view).endswith("*"):
                path = self.model.make_path(view)
                if not path.is_attribute():
                    return Query(self.model, self).select(str(view) + ".*")

        return Query(self.model, self).select(*columns)
コード例 #2
0
ファイル: acceptance.py プロジェクト: david-rhee/toxoMine
from intermine.query import Query
from intermine.model import Model

m = Model('http://www.flymine.org/query/service/model')
q = Query(m)

q.name = 'Foo'
q.description = 'a query made out of pythons'
q.add_view("Gene.name Gene.symbol")
q.add_constraint('Gene', 'LOOKUP', 'eve')
q.add_constraint('Gene.length', '>', 50000)
q.add_constraint('Gene', 'Clone')
q.add_constraint('Gene.symbol', 'ONE OF', ['eve', 'zen'])
q.add_join('Gene.alleles')
q.add_path_description('Gene', 'One of those gene-y things')
print q.to_xml()
print q.to_formatted_xml()