Skip to content

cheminfo-py/xrd-tools

Repository files navigation

CIF tools webservice

Docker Image Build and Test CI Python package

REST-API built with flask that exposes pymatgen functionality.

The app used file-based caching.

How to get it up and running

Settings

Before you can run the image there are some settings you have to define. To get started you can cp .env.sample .env.

  • MONGO_HOST=127.0.0.1 Host for the MongoDB for pattern lookup (usually no need to change)
  • MONGO_PORT=27017 Port for MongoDB (usually no need to change)
  • MONGO_DB=xrd-patterns name of MongoDB (do not change)
  • PORT=8100 port used to expose the app
  • WORKERS=2 workers used to run the app (one processor per worker)
  • CONCURRENCY_LIMIT=2 maximum number of concurrent connections

Procedure

  1. Make sure that you have the bson to seed the database in the mongo-seed/dump/xrd-patterns directory. You can download the file from Dropbox
  2. Start the docker-compose with docker-compose up -d
  3. Then enter the mongodb container docker exec -i -t xrd-predict_mongodb_1 bash
  4. Seed the database by running mongorestore dump

  1. If you visit the documentation at localhost:$PORT you can test if the lookup works

Implemented methods

  • GET to / shows some basic info

  • GET to /version shows the version

  • POST to /predictxrd with fileContent data (CIF as string) returns:

    • x: with the 2 theta positions of the reflexes
    • y: intensity of the reflexes
    • hkl array of objects {hkl: , multiplicity: }

    if you also provide jcamp=true you will receive

    • jcamp: a string of the JCAMP-DX file with the predicted pattern

    you can also specify a wavelength which must be one of the following strings: CuKa, CuKa2, CuKa1, CuKb1, MoKa, MoKa2, MoKa1, MoKb1, CrKa, CrKa2, CrKa1, CrKb1, FeKa, FeKa2, FeKa1, FeKb1, CoKa, CoKa2, CoKa1, CoKb1, AgKa, AgKa2, AgKa1, AgKb1.

  • POST to /latticepattern with a request body of the following form

{
  "a": 0,
  "b": 0,
  "c": 0,
  "alpha": 0,
  "beta": 0,
  "gamma": 0,
  "wavelength": "string",
  "jcamp": false
}

returns an answer as /predictxrd

  • GET to /getpattern?dbName= returns and object of the following form
{
  "x": [
    null
  ],
  "y": [
    null
  ],
  "hkls": [
    null
  ],
  "dbName": "string",
  "link": "string",
  "cif": "string",
  "apiVersion": "string"
}