Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added non_null_fields #147

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions ontobio/golr/beacon_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,38 @@ def __init__(
keywords=None,
categories=None,
relations=None,
rows=10,
start=None
select_fields=None,
non_null_fields=[],
**kwargs
):
if select_fields == None:
select_fields = _get_select_fields()

if non_null_fields == []:
non_null_fields = ['relation', 'subject', 'object', 'id']

super().__init__(
select_fields=_get_select_fields(),
rows=rows,
start=start
select_fields=select_fields,
non_null_fields=non_null_fields,
**kwargs
)

self.sources = sources
self.targets = targets
self.keywords = keywords
self.categories = categories
self.relations = relations

filters = {}

if self.targets != None and self.targets != []:
filters['closure'] = _make_disjunction(self.targets, '"')
if targets != None and targets != []:
filters['closure'] = _make_disjunction(targets, '"')

if self.keywords != None and self.keywords != []:
filters['label'] = _make_disjunction(self.keywords, '*')
if keywords != None and keywords != []:
filters['label'] = _make_disjunction(keywords, '*')

if self.categories != None and self.categories != []:
filters['category'] = _make_disjunction(self.categories, '*')
if categories != None and categories != []:
filters['category'] = _make_disjunction(categories, '*')

source_disjunction=_make_disjunction(self.sources, '"')
source_disjunction=_make_disjunction(sources, '"')
self.q=_build_query(source_disjunction, filters)

if self.relations != None and relations != []:
relation_disjunction = _make_disjunction(self.relations, '"')
if relations != None and relations != []:
relation_disjunction = _make_disjunction(relations, '"')
self.q += ' AND (relation_label: ' + relation_disjunction + ')'

def _build_query(sources, filters):
Expand Down