Skip to content

sustainable-processes/pistachio-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pistachio Python SDK

This is the repository for our unofficial python SDK for the Pistachio API.

Installation

pip install git+https://github.com/sustainable-processes/pistachio-python

If you are in the SRE group, see the full instructions at the bottom of this page.

Usage

Sessions

You can set up a session in one of two ways:

from pistachio import Pistachio
base_url = "http://localhost:8898/" #Should match the port from above

# Method 1: with block
with Pistachio(base_url=base_url) as p:
    # Do whatever you need here
    # The session will be closed when the block is exited 
    p.search("suzuki coupling")
    
# Method 2: manually
p = Pistachio(base_url=base_url)
p.renew_session()
p.search("suzuki coupling")
p.end_session()

Methods

Parse a textual query without running a search.

p.parse("GSK")
# {
# "str": "GSK",
# "grouped": True,
# "cacheAllowed": True,
# "tags": [{"end": 3, "tag": "ASSIGNEE", "val": "GlaxoSmithKline"}],
# }

Generate suggestions of queries for the input text.

p.suggest("Suzuki")
# {'suggestions': ['suzuki coupling', 'suzuki-type coupling'],
#  'draw': 0,
#  'tags': [{'end': 6, 'tag': 'NONE'}]}

Search for reactions.

p.search("suzuki coupling")

Get details about a reaction by its id.

p.get_details("176")

Summarize the data for each type of result of a query.

p.summary("suzuki_coupling")

Instructions for the SRE group

If you are not running this on a the server, you need to set up an ssh tunnel to port 8080 (while logged into the VPN.) You can map to any open port on your machine. Below, I used 8898.

$ ssh -NfL localhost:8898:localhost:8080 [email protected]

For an example of how this code is used, see the TL-BO project (link only accessible to the SRE group).

Releases

No releases published

Packages

No packages published

Languages