1. Installation

machado is a Django framework for Chado.

1.1. Prerequisite

The list bellow contains the softwares and versions required by machado.

PostgreSQL 12

Install PostgreSQL and create a database and user for loading the Chado schema. As postgres user run:

psql
create user username with encrypted password 'password';
create database yourdatabase with owner username;
alter user username createdb;

Don’t forget to configure the PostgreSQL server to allow regular users to connect (pg_hba.conf).

Linux dependencies

Be sure to have the following dependencies installed

sudo apt install zlib1g-dev libbz2-dev liblzma-dev python3-dev

Python 3.8

We strongly recommend creating a new virtualenv for your project

virtualenv -p /usr/bin/python3.8 YOURPROJECT
cd YOURPROJECT
source bin/activate

machado

Just grab the code using GIT and install it:

git clone https://github.com/lmb-embrapa/machado.git src/machado
pip install ./src/machado

1.2. Preparation

From this point on it is assumed you have read the Django introduction and tutorial on the Django project website.

Create a Django project

Inside YOURPROJECT directory create a Django project with the following command:

django-admin startproject WEBPROJECT
cd WEBPROJECT

Then, configure the WEBPROJECT/settings.py file to connect to your Chado database.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',    # Set the DB driver
        'NAME': 'yourdatabase',                       # Set the DB name
        'USER': 'username',                           # Set the DB user
        'PASSWORD': 'password',                       # Set the DB password
        'HOST': 'localhost',                          # Set the DB host
        'PORT': '',                                   # Set the DB port
    },
}

Let Django know about your machado

In the WEBPROJECT/settings.py file, add chado to INSTALLED_APPS section.

INSTALLED_APPS = [
    ...
    'machado',
    'rest_framework',
    'drf_yasg',
    ...
]

(Additional information here: https://docs.djangoproject.com/en/2.1/intro/tutorial02/)

List the machado commands

python manage.py

1.3. Start you app and open the admin interface

You have to run the following command to create django admin tables:

python manage.py migrate

Run tests to check the instalation:

python manage.py test machado

Now, just run the DJango server to access the web interface:

python manage.py runserver

The API interface will be available at http://localhost:8000/machado/api