- 1 Introduction
- 1.1 A Feature is a Sequence
- 1.2 Modules
- 1.3 Chado Naming Conventions
- 1.4 Design Patterns
- 1.5 View Layers
- 1.6 Inter-schema Bridges
- 1.7 DBMS Functions
A Feature is a Sequence
Chado does not distinguish between a sequence and a sequence feature, on the theory that a feature is a piece of a sequence, and a piece of a sequence is a sequence. Both are represented as a row in the feature table.
We organised the tables into distinct modular components with tightly defined dependencies. This is recogised as good software engineering practice, it allows different software components to focus on the specific data compartments required. It allows for extensibility and schema evolution within specific modules without disrupting the rest of the schema. Finally, it allows for a mix and match approach - it is the authors' hope that the schema modules will be adopted by other model organism and bioinformatics groups; these groups may want to swap in their own table variants within specific modules, or add modules of their own.
- Audit - for database audits
- Companalysis - for data from computational analysis
- Contact - for people, groups, and organizations
- Controlled Vocabulary (cv) - for controlled vocabularies and ontologies
- Expression - for RNA and protein expresssion
- General - for identifiers
- Genetic - for genetic data and genotypes
- Library - for descriptions of molecular libraries
- Map - for maps without sequence
- Organism - for taxonomic data
- Phenotype - for phenotypic data
- Phylogeny - for organisms and phylogenetic trees
- Publication (pub) - for publications and references
- Sequence - for sequences and sequence features
- Stock - for specimens and biological collections
- WWW -
general: NO DEPENDENCIES organism: general pub: general cv: general pub sequence: cv general pub genetic sequence cv general pub expression: sequence cv general pub map: sequence cv general pub
Inter-module Linking Tables
These can be thought of as floating outside of the respective modules they bridge, although they are generally bundled with one or the other module.
REVIEW - Not complete
Chado Naming Conventions
We use lowercase in all tables and column names - DBMSs differ in how they treat case sensitivity. For example, Oracle will automatically capitalize everything. So it's best to be neutral and use lowercase.
In table names, we use underscores for linking tables; e.g. feature_dbxref is a linking table between feature and dbxref.
Where a table name is a noun phrase rather than a single noun, we concatenate the words together. For instance the table for describing feature properties is called featureprop. It could be argued this is harder to read, but it does allow consistent usage of underscores as above. FeatureProp could be used where it is known the DBMS is case insensitive.
In column names, we also use concatenated noun phrases, except in the case of primary or foreign keys, e.g. dbxref_id.
We try to keep column names unique where appropriate, which is useful for large join statements or views, in avoiding column name clash between diﬀerent tables. The convention is to use an abbreviated form of the table name plus a noun describing the column, for instance fmin in the feature table. By consistently using abbreviated forms we stop column names getting too big (many DBMSs will complain about long column names).
Primary and foreign key names
We use the same column name for primary and foreign key columns - very useful for NATURAL JOIN statements.
Constraint names are a concatentation of table name, underscore, the letter c, and a digit. For example: feature_phenotype_c1.
Index names are a concatentation of table name, underscore, the string idx, and a digit. For example: feature_phenotype_idx1.
The names of views are lowercase. Where a table name is a noun phrase rather than a single noun, we concatenate the words together using the underscore. For example the view used to query for nucleotide motifs is called nucleotide_motif and the view used to find exons from pseudogenes is called pseudogenic_exon.
1.1.1 Module System
Views can be thought of as virtual tables. They provide a powerful abstraction layer over the database. All views should be portable across all DBMSs
Views in chado are deﬁned on a per module basis. View deﬁnitions are maintained in the chado/modules/MODULE-NAME/views directory.
Included in the view directory are report views. These can usually be found in a ﬁle called chado/modules/MODULE-NAME/views/MODULE-NAME-report.sql
Collections of view deﬁnitions are bundled into packages, each package is a .sql ﬁle.
DBMS Functions in Chado are entirely optional.
Functions in chado are deﬁned on a per module basis. Function deﬁnitions are maintained in the chado/modules/MODULE-NAME/functions directory.
Collections of function definitions are bundled into packages. Each package comes with an interface descriptions and one or more implementations.
Function Interface Definitions
The interface descriptions are stored in a *.sqlapi file. The syntax used is a variant of SQL and is intended primarily as a consistent way of providing information for human, although it should be parseable by software.
Here is an example, taken from the top of the chado/modules/sequence/functions/subsequence.sqlapi package. This package provides basic subsequencing functions. It has dependencies on two other function packages, declared at the top of the file. The package declares multiple functions, only the first of which is show here, a function for extracting subsequences from the sequence of a feature.
<sql> IMPORT reverse_complement(TEXT) FROM 'sequtil'; IMPORT get_feature_relationship_type_id(TEXT) FROM 'sequence-cv-helper';
-- basic subsequencing functions --
DECLARE FUNCTION subsequence( srcfeature_id INT REFERENCES feature(feature_id), fmin INT, fmax INT, strandINT )
COMMENT ON FUNCTION subsequence(INT,INT,INT,INT) IS 'extracts a subsequence from a feature referenced by srcfeature_id, within the interbase boundaries determined by fmin and fmax, reverse complementing if strand = -1. The sequence can be DNA or AA. Strand must always by >0 for AA sequences'; </sql>
The goal is to provide implementations for different dialects of procedural SQL. Currently only PostgreSQL dialect is supported. The psql implementations are stored in *.plpgsql files.