Trait Database using Rails 4
Ruby HTML JavaScript CSS CoffeeScript TeX
Clone or download
dleehr Merge pull request #220 from NESCent/joss-submission
Paper and README updates for JOSS submission
Latest commit d43da8a Jul 20, 2018
Failed to load latest commit information.
app Fix CSV download for summarized data Jan 15, 2015
bin Added missing rails4 scripts Oct 10, 2013
config results of rake rails:update for rails 4.1 Aug 18, 2014
lib secure DOIs Apr 4, 2016
public Add bootstrap Mar 7, 2013
script Added missing rails4 scripts Oct 10, 2013
test Update webmock to use minitest, since rails 4.1 switched Aug 18, 2014
vendor Initial commit Mar 6, 2013
.gitignore Ignore coverage May 13, 2014
.travis.yml Remove allow_failures from .travis.yml May 2, 2014
Gemfile Specify Ruby 2.2.0 in Gemfile Dec 21, 2017
LICENSE.txt Add README.MD and LICENSE.txt Mar 7, 2013
Procfile Add Procfile for heroku May 14, 2014
Rakefile Initial commit Mar 6, 2013
paper.bib Adds for JOSS submission Jul 20, 2018 Adds for JOSS submission Jul 20, 2018


Build Status


TraitDB is a Ruby on Rails web application for storing and searching trait data. It is in development at NESCent to support working groups.


TraitDB is a Rails 4 application. It requires ruby and rubygems to run. Other dependencies are specified in the Gemfile. To get up and running with the development environment, you will need Postgres installed. TraitDB can also be configured to work with MySQL if you wish, but Postgres is preferred.

  1. Clone the repository

    git clone
  2. Install dependencies with bundle install

  3. Set your database credentials as environment variables. config/database.yml will read these values out of the environment. If your database server is on a different host, set the host/port as well:

export TRAITDB_PG_DEV_USER="traitdb_dev_user"
export TRAITDB_PG_DEV_PASS="your-password-here"
  1. Run rake db:setup. This Instructs Rails to connect to your database and create the required users and databases. If your database requires you to authenticate before creating users/databases, you will be prompted for credentials.
  2. If rake db:setup is successful, it will also run a rake db:migrate to create database tables. If not successful, you can create the databases and users manually, then run rake db:migrate manually.
  3. If you wish to enable Google Sign-in (recommended), you will need to
    • Register an application for Google OAuth 2.0
    • Enable the Google+ API
    • Set the Client ID and Client Secret credentials in your environment:
    export TRAITDB_GOOGLE_APP_ID="your-google-app-id"
    export TRAITDB_GOOGLE_APP_SECRET="your-google-app-secret"
  4. Start the server with rails server.
  5. Visit http://localhost:3000 to access the application. You will be shown the about page. If you click Upload, you will be redirected to the sign-in screen. From here, you can sign in with OpenID or a Google Account
  6. Start a delayed_job worker. Delayed job is used to execute dataset imports as a background process. It includes a rake task to start a worker. You can run rake jobs:work in an additional terminal process, or run a worker as a daemon with script/delayed_job start.


Getting Started - Projects and Users

Data in TraitDB is publicly searchable and organized into projects. Initially there are no projects, and only administrators can create projects. Authentication is handled by OpenID, so in order to get started, you must:

  1. After signing in, there will be an entry in the users table with your email address.
  2. Upgrade this user to an Administrator with the following rake command:
$ rake traitdb:upgrade_admin[]
  1. Reload your web browser, you will have an Admin menu option.
  2. Click Admin->Projects, and the New Project button.
  3. Fill out the project details and save the new project

Any authenticated user can upload data to any project, but only administrators can create projects and upload Import Configs.


TraitDB accepts data uploads in CSV format, with a specific focus on data validation and organization. In order to upload data into a project, you must write at least one import configuration file in YAML format. This configuration file will contain the project-specific data for your spreadsheets, as well as allowable values and rules for data relationships and which columns to import, ignore, or convert.

For detailed information on writing import configs, see the documentation on the wiki.

Examples for the configuration files are in the lib/traitdb_import directory.

Generally, the CSV files are required to have the following general characteristics

  1. The first row contains column header names The column names include Taxonomic ranks (e.g. Order, Genus, Species), names of traits, and column names for metadata.
  2. Each data row includes trait data and metadata for one Operational Taxonomic Unit (OTU)
  3. Data for a single trait (column) may be either categorical (One or more string tokens separated by a delimeter) or continuous (floating point values)
  4. Source / Reference information for a trait may be in an associated column

As an admin user, you can upload and manage Import Configs for a project. Authenticated users will be able to choose an Import Config when they upload data to the project.

At the upload stage, the user can get information about the Import Config, or download a template CSV file that conforms to it.


TraitDB is open source under the MIT License. See LICENSE.txt for more information.