Skip to content

Commit

Permalink
Merge pull request #47 from dougli1sqrd/turn-down-logging
Browse files Browse the repository at this point in the history
setting default logging to just report warnings and above. Skipped lines are logged at INFO
  • Loading branch information
dougli1sqrd committed Jun 26, 2017
2 parents 2b4369e + 44daa2b commit 28999bc
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 78 deletions.
11 changes: 7 additions & 4 deletions bin/biogolr-bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main():
description='Command line interface to python-ontobio.golr library'
"""
Provides command line interface onto the ontobio.golr python library, a high level
Provides command line interface onto the ontobio.golr python library, a high level
abstraction layer over Monarch and GO solr indices.
""",
formatter_class=argparse.RawTextHelpFormatter)
Expand All @@ -63,8 +63,11 @@ def main():

if args.verbosity >= 2:
logging.basicConfig(level=logging.DEBUG)
if args.verbosity == 1:
elif args.verbosity == 1:
logging.basicConfig(level=logging.INFO)
else:
logging.basicConfig(level=logging.WARNING)

logging.info("Welcome!")

[subject_category, object_category] = args.category
Expand All @@ -75,12 +78,12 @@ def main():
rows=args.limit,
slim=args.slim,
url=args.url)

for a in assocs:
print("{}\t{}\t{}".format(a['subject'],
a['relation'],
";".join(a['objects'])))


if __name__ == "__main__":
main()
9 changes: 6 additions & 3 deletions bin/biogolr-fqm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def main():
description='Command line interface to python-ontobio.golr library'
"""
Provides command line interface onto the ontobio.golr python library, a high level
Provides command line interface onto the ontobio.golr python library, a high level
abstraction layer over Monarch and GO solr indices.
""",
formatter_class=argparse.RawTextHelpFormatter)
Expand All @@ -65,8 +65,11 @@ def main():

if args.verbosity >= 2:
logging.basicConfig(level=logging.DEBUG)
if args.verbosity == 1:
elif args.verbosity == 1:
logging.basicConfig(level=logging.INFO)
else:
logging.basicConfig(level=logging.WARNING)

logging.info("Welcome!")

r = search_query_as_matrix(facet=args.facet,
Expand All @@ -82,6 +85,6 @@ def main():
data=[trace]
py.plot(data, filename='search-heatmap')


if __name__ == "__main__":
main()
11 changes: 7 additions & 4 deletions bin/biogolr-pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def main():
description='Command line interface to python-ontobio.golr library'
"""
Provides command line interface onto the ontobio.golr python library, a high level
Provides command line interface onto the ontobio.golr python library, a high level
abstraction layer over Monarch and GO solr indices.
""",
formatter_class=argparse.RawTextHelpFormatter)
Expand All @@ -67,15 +67,18 @@ def main():

if args.verbosity >= 2:
logging.basicConfig(level=logging.DEBUG)
if args.verbosity == 1:
elif args.verbosity == 1:
logging.basicConfig(level=logging.INFO)
else:
logging.basicConfig(level=logging.WARNING)

logging.info("Welcome!")

r = pivot_query_as_matrix(facet=args.facet,
fq=args.fq,
facet_pivot_fields=args.pivot,
url=args.url,
is_go=args.legacy_solr,
is_go=args.legacy_solr,
**args.qargs)

print(str(r))
Expand All @@ -85,6 +88,6 @@ def main():
data=[trace]
py.plot(data, filename='pivot-heatmap')


if __name__ == "__main__":
main()
17 changes: 10 additions & 7 deletions bin/biogolr-search.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def main():
description='Command line interface to python-ontobio.golr library'
"""
Provides command line interface onto the ontobio.golr python library, a high level
Provides command line interface onto the ontobio.golr python library, a high level
abstraction layer over Monarch and GO solr indices.
""",
formatter_class=argparse.RawTextHelpFormatter)
Expand All @@ -67,13 +67,16 @@ def main():

parser.add_argument('search', type=str,
help='Search terms')

args = parser.parse_args()

if args.verbosity >= 2:
logging.basicConfig(level=logging.DEBUG)
if args.verbosity == 1:
elif args.verbosity == 1:
logging.basicConfig(level=logging.INFO)
else:
logging.basicConfig(level=logging.WARNING)

logging.info("Welcome!")

facets = []
Expand All @@ -96,7 +99,7 @@ def main():
fq=args.fq,
facet_fields=facets,
url=args.url)

results = q.exec()
#print("RESULTS={}".format(results))
docs = results['associations']
Expand All @@ -109,14 +112,14 @@ def main():
fq=args.fq,
facet_fields=facets,
url=args.url)

results = q.exec()
#print("RESULTS={}".format(results))
docs = results['docs']
print("RESULTS: {}".format(len(docs)))
for r in docs:
print(" {} '{}' {} // {}".format(r['id'],r['label'],r['score'], r['category']))

if len(facets) > 0:
#from collections import OrderedDict
fcs = results['facet_counts']
Expand All @@ -126,6 +129,6 @@ def main():
print("## FACET: {}".format(f))
for k,v in sorted(d.items(), key=lambda t: -t[1]):
print(" {:5d}: {}".format(v,k))

if __name__ == "__main__":
main()
23 changes: 13 additions & 10 deletions bin/ogr.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ def main():

if args.verbosity >= 2:
logging.basicConfig(level=logging.DEBUG)
if args.verbosity == 1:
elif args.verbosity == 1:
logging.basicConfig(level=logging.INFO)
else:
logging.basicConfig(level=logging.WARNING)

logging.info("Welcome!")

handle = args.resource

factory = OntologyFactory()
logging.info("Creating ont object from: {} {}".format(handle, factory))
ont = factory.create(handle)
Expand All @@ -79,7 +82,7 @@ def main():
if dirn == '' and args.to is not None:
dirn = 'u'
searchp = args.search

if args.level is not None:
logging.info("Query for level: {}".format(args.level))
qids = qids + ont.get_level(args.level, relations=args.properties, prefix=args.prefix)
Expand All @@ -98,14 +101,14 @@ def main():
cset = cset.intersection(terms)
dset = dset.union(cset)
qids = qids + list(dset)


if args.query is not None:
qids = qids + ont.sparql(select='*',
body=args.query,
inject_prefixes = ont.prefixes(),
single_column=True)

for id in ont.resolve_names(args.ids,
is_remote = searchp.find('x') > -1,
is_partial_match = searchp.find('p') > -1,
Expand All @@ -127,7 +130,7 @@ def cmd_cycles(handle, args):

cycles = nx.simple_cycles(g)
print(list(cycles))

def cmd_search(handle, args):
for t in args.terms:
results = search(handle, t)
Expand All @@ -147,7 +150,7 @@ def render(ont, query_ids, args):
w.write(ont, query_ids=query_ids, container_predicates=args.container_properties)
#logging.info("Writing subgraph for {}, |nodes|={}".format(ont,len(nodes)))
#w.write_subgraph(ont, nodes, query_ids=query_ids, container_predicates=args.container_properties)

def resolve_ids(ont, ids, args):
r_ids = []
for id in ids:
Expand All @@ -158,6 +161,6 @@ def resolve_ids(ont, ids, args):
r_ids += matches
return r_ids


if __name__ == "__main__":
main()

0 comments on commit 28999bc

Please sign in to comment.