Giter Club home page Giter Club logo

termite_toolkit's Introduction

Project Description

Python library for making calls to SciBite's TERMite, TExpress and DOCstore The library also enables post-processing of the JSON returned from such requests.

Install

$ pip3 install termite_toolkit

Versions listed on PyPi!

Example call to TERMite

from termite_toolkit import termite
from pprint import pprint


# specify termite API endpoint
termite_home = "http://localhost:9090/termite"

# specify entities to annotate
entities = "DRUG"

# initialise a request builder
t = termite.TermiteRequestBuilder()
# individually add items to your TERMite request
t.set_url(termite_home)
t.set_fuzzy(True)
t.set_text("citrate macrophage colony sildenafil stimulating factor influenza hedgehog")
t.set_entities(entities)
t.set_subsume(True)
t.set_input_format("txt")
t.set_output_format("doc.jsonx")
t.set_reject_ambiguous(False)
t.set_options({'fragmentSize': 20})

# execute the request
termite_response = t.execute(display_request=True)

pprint(termite_response)

Example call to TExpress

from pprint import pprint
from termite_toolkit import texpress

# specify termite API endpoint
termite_home = "http://localhost:9090/termite"
# specify the pattern you wish to search for- this can created in the TERMite UI
pattern = ":(INDICATION):{0,5}:(GENE)"

t = texpress.TexpressRequestBuilder()

# individually add items to your TERMite request
t.set_url(termite_home)
t.set_text("breast cancer brca1")
t.set_subsume(True)
t.set_input_format("txt")
t.set_output_format("json")
t.set_allow_ambiguous(False)
t.set_pattern(pattern)

# execute the request
texpress_response = t.execute(display_request=True)
pprint(texpress_response)

Example call to DOCstore

from termite_toolkit import docstore

# Document co-occurrence of a list of entities
docs = docstore.DocStoreRequestBuilder()
# specify docstore API endpoint and add authentication if necessary
docs.set_url('docstore_address')
docs.set_basic_auth(username='user', password='pw')
# make call to DOCStore
docs_json = docs.get_dcc_docs(['id:GENE$HTT', 'id:GENE$EGFR'], '*', {})
# convert json to df
df = docstore.get_docstore_dcc_df(docs_json)
# print titles of hits
print(df['title'])

License

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.