For researchers
Python client
The mofplus package — what each class talks to, and what still works unchanged.
The mofplus package is the supported way to use this site from a script. It
predates the rewrite and keeps working against it.
Installing
It ships as part of the group's tooling alongside molsys, which owns the
.mfpx format and the atom-typing machinery. mofplus will import but not do
much without it.
Two classes, two eras
from mofplus import user_api # XML-RPC — nets, building blocks, structures
from mofplus import api # HTTP/JSON — force-field data
user_api speaks the older XML-RPC protocol. It reads ~/.mofplusrc, falls
back to the MFPUSER/MFPPW environment variables, then prompts.
api speaks the newer JSON surface under /ff/. It authenticates with HTTP
Basic and is explicitly connected:
from mofplus import api
mfp = api()
mfp.connect(username, password)
mfp.check_connection() # True
There is also admin_api, a subclass of user_api for curation work. It is a
public contract with consumers outside the maintaining group; it is not going
away without notice.
Common calls
from mofplus import user_api
api = user_api()
api.get_list_of_nets() # every net name
api.get_net("pcu") # writes pcu.mfpx
api.get_net("pcu", out="mol") # a molsys mol object instead
api.get_cs("pcu") # coordination sequences
api.search_cs([[6, 18, 38, 66]], []) # nets matching a sequence
api.get_bb("benzene") # a building block
The out argument on the download methods takes file, mol or str.
from mofplus import api
mfp = api()
mfp.connect(username, password)
mfp.get_FF() # force fields, keyed by name
mfp.get_FFfits(FFID=1) # fits of one force field
mfp.get_params("bnd", fitid) # bond parameters of a fit
mfp.get_FFfrags(["c3_c2h1", "n3_c2h1"]) # fragments covering these atom types
mfp.upload_frag(name, mol) # deposit a fragment (weaver tier)
Credentials
~/.mofplusrc is two positional lines — username, then password — and is read
that way by every installed client. It is unchanged.
The recommended credential for new code is a scoped token; see Move to token authentication for what works today and what needs a client update first.
Talking to the site without the client
Everything the client does is reachable with requests and the
API reference. Reads need no credential at all:
import requests
requests.get("https://mofplus.org/net/pcu.json").json()