1. Installation

machado is a Django framework for Chado.

1.1. Prerequisite

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

PostgreSQL 9.5

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).

Python 3.6

Be sure to have the python development libraries installed (in Ubuntu 18.04, install with ‘apt-get install python3-dev’).

We strongly recommend creating a new virtualenv for your project

virtualenv -p /usr/bin/python3.6 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
python src/machado/setup.py install

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_psycopg2',    # 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',
    ...
]

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

Django rest framework settings

You’ll need to make sure to update your REST framework settings to include DEFAULT_SCHEMA_CLASS explicitly.

REST_FRAMEWORK = {
  'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}

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