diff --git a/README.md b/README.md
index b9448e6..05cba1b 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,115 @@
-# mcl
-Mainlab Chado Loader
+## Project
+MCL (Mainlab Chado Loader) is a module that enables users to upload their biological data to chado database schema. Users are required to transfer their biological data into various types of data template files. MCL, then, uploads these data template files into a chado schema. MCL requires each type of data template to have a corresponding class file. MCL predefines the class files for major data template types such as marker, QTL, germplasm, map, project. The flexibility of Chado schema often allows, however, the same type of biological data to be stored in various ways.. When their data are modeled and stored differently in Chado, users can modify these predefined class files. Otherwise users can inherit the existing template class. MCL also allow for users to define a new class file for a new data template. The details of adding a new template are described in "Customization" section.
+
+MCL provides a "Data Template" page that shows the list of all the types of data template that MCL currently supports. A user can view and download each data template file from the list. MCL also provides "Upload Data" page. See more details in "How to upload data" section below. These two pages are linked from the main page of MCL (http://your.site/mcl).
+
+The Mainlab Chado Loader is created by Main Bioinformatics Lab (Main Lab) at Washington State University. Information about the Main Lab can be found at: https://www.bioinfo.wsu.edu
+
+## Requirement
+ - Drupal 7.x
+
+## Version
+1.0.0
+
+##Download
+The MainLab Chado Loader module can be download from GitHub:
+
+https://www.github.com/mainlab-dev/mcl
+
+## Installation
+After downloading the module, extract it into your site's module directory
+(e.g. sites/all/modules) then follow the instructions below:
+
+ 1. Enable the module by using the Drupal administrative interface: Go to: Modules, check 'mcl' (under the MCL) and save or by using the 'drush' command:
+ ```
+ drush pm-enable mcl
+ ```
+ This will create all MCL related tables in public schema and populate the tables with default values. It will also create directories for MCL in Drupal public file directory.
+
+## Administration
+ - Adding/Deleting template types
+
+ A new template type can be added or an existing type can be deleted. The details of adding a new template type are described in "Customization" section.
+
+ - Adding/Deleting templates
+
+ A new template can be added or an existing template can be deleted. The details of adding a new template are described in "Customization" section.
+
+ - Adding/Deleting users
+
+ Site visitors who can upload data to chado schema can be restricted by adding or deleting uploading privilege to a Drupal account holder.
+
+ - Setting MCL global variables.
+
+ MCL has two types of global variables.
+
+ 1. Site specific variables.
+
+ MCL requires a set of the site specific variables for uploading data. An admin page is available for users to assign or change the values for these variables.
+
+ 2. Default / Dummy variables.
+
+ Some columns of Chado tables have NOT NULL constraint but there can be no valid data to enter in some databases. In this situation, users can assign default values for these columns using an MCL admin page.
+
+## Customization
+1. Add a new template type in the admin page.
+
+ a. Assign a new name.
+
+ It must be unique.
+
+ b. Assign a rank.
+
+ The rank of the template type determines the order of templates to be uploaded. Some of data in a template may depend on data on other templates. So data dependency must be taken into consideration when you assign a rank to the new template type.
+
+
+2. Add a new template.
+
+ Users add a new template if they do not want to modify MCL pre-defined template classes.
+
+ a. Template Class file.
+
+ i. Create a new class file for a new template.
+ Users can inherit the pre-defined template class or simply inherit base class of MCL template class (MCL_TEMPATE). The file name of the new class must be the same as the name of the new template name. A class name must be all capitalized and a file name must be lowercase.
+ ```
+ (e.g.) class name MCL_TEMPALTE_STOCK_GDR
+ The file name should be 'mcl_template_stock_gdr.inc'
+ ```
+ ii. Place the newly created class file under the template directory.
+ The template directory is 'mcl/include/class/template/module/'.
+
+ b. Go to the admin page.
+
+ i. Select a template type.
+
+ ii. Assign a new template name.
+ A name of a new template must be unique.
+
+## How to upload data.
+The primary function of this module is to upload biological data to Chado schema. This section covers how to use this module to upload data. There are several steps to complete data uploading.
+
+ 1. Map data to MCL data templates.
+ First, the biological data must be transferred to the current existing data templates. If data do not fit to our pre-defined data templates, modify the existing ones or create a new data template. See the "Customization" section above.
+
+
+ 2. Upload data templates.
+ MCL provides a web form to upload data template files in "Upload Data" page. The hyperlink to this page can be found in the MCL home page. In this page, users can upload their data template files and start running the data uploading job.
+
+MCL data-uploading phases :
+
+ Phase 1: checks syntax errors.
+ It checks syntax errors such as missing columns, missing data in required columns, and miss-spelled column name.
+
+ Phase 2: checks data errors.
+ The data errors are the errors on the data in database. Chado tables have many foreign key relationships and when the data is not found in the parent tables, the loader module throws an error. For instance, genus and species are listed in stock data template. MCL checks if organism_id for these genus and species exists in the organism table. If not found, it throws an error and it adds an appropriate error message to the error log file.
+
+ Phase 3: uploads data templates.
+ After checking errors, it finally starts uploading data in the template to the Chado database.
+
+During the uploading phase, MCL creates several different types of log files and stores in the job directory. MCL seizes the process if it finds an error and ask the user to fix the data. The user goes through all the log files to find the errors and fix them. After fixing the error, the user can come back to the "Upload Job" page to re-upload the fixed data file. Then, the user can re-run the job.
+
+ 3. Check log files.
+ After the completion of the uploading data job, the user needs to view the log file for newly added data to make sure that data have been added into the database.
+
+## Problems/Suggestions
+Mainlab Chado Loader is still under active development. For questions or bug report, please contact the developers at the Main Bioinformatics Lab by emailing to: dev@bioinfo.wsu.edu
diff --git a/includes/admin/mcl.admin.config.inc b/includes/admin/mcl.admin.config.inc
new file mode 100644
index 0000000..af8802f
--- /dev/null
+++ b/includes/admin/mcl.admin.config.inc
@@ -0,0 +1,86 @@
+');
+ $breadcrumb[] = l('Administration', 'admin');
+ $breadcrumb[] = l('MCL', 'admin/mcl');
+
+ // Create the setting form.
+ $form = array();
+
+ // MCL file / directory paths.
+ $form['config_path'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'MCL file / diretory paths',
+ );
+
+ // Drupal file paths.
+ $file_path_public = drupal_realpath('public://');
+ $file_path_private = drupal_realpath('private://');
+
+ // Uploading file directory.
+ $form['config_path']['mcl_file_dir'] = array(
+ '#markup' => t("
Uploading File Directory
" .
+ "Uploaded files are saved in drupal public direcotry ($file_path_public)
")
+ );
+
+ // MCL working directory.
+ $form['config_path']['mcl_working_dir'] = array(
+ '#title' => t('MCL Working Directory'),
+ '#type' => t('textfield'),
+ '#description' => t("Please specify the working directory for MCL."),
+ '#required' => TRUE,
+ '#default_value' => mcl_get_config_setting('mcl_working_dir'),
+ );
+
+ // MCL Library directory.
+ $form['config_path']['mcl_library_dir'] = array(
+ '#title' => t('MCL Library Directasory'),
+ '#type' => t('textfield'),
+ '#description' => t("Please specify the library directory for MCL."),
+ '#required' => TRUE,
+ '#default_value' => mcl_get_config_setting('mcl_library_dir'),
+ );
+ return system_settings_form($form);
+}
+
+/**
+ * Admin form validate.
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_setting_validate($form, &$form_state) {
+
+ // Gets variables.
+ $mcl_working_dir = trim($form_state['values']['mcl_working_dir']);
+ $mcl_library_dir = trim($form_state['values']['mcl_library_dir']);
+
+
+ // Check the working directory.
+ if (!is_writable($mcl_working_dir)) {
+ form_set_error('mcl_working_dir', t("The working directory, $mcl_working_dir, does not exists or is not writeable by the web server."));
+ return;
+ }
+
+ // Check the library directory.
+ if (!is_writable($mcl_library_dir)) {
+ form_set_error('mcl_working_dir', t("The library directory, $mcl_library_dir, does not exists."));
+ return;
+ }
+
+ // Updates variables.
+ variable_set('mcl_working_dir', $mcl_working_dir);
+ variable_set('mcl_library_dir', $mcl_library_dir);
+}
diff --git a/includes/admin/mcl.admin.global_var.inc b/includes/admin/mcl.admin.global_var.inc
new file mode 100644
index 0000000..6595681
--- /dev/null
+++ b/includes/admin/mcl.admin.global_var.inc
@@ -0,0 +1,327 @@
+ 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => TRUE,
+ '#title' => 'Site varibles',
+ );
+ $form['site_var']['table'] = array(
+ '#markup' => _mcl_get_mcl_global_vars_table('SITE'),
+ );
+
+ // Default variables.
+ $form['default_var'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => TRUE,
+ '#title' => 'Default varibles',
+ );
+
+ // Adds default varibles.
+ $form['default_var']['table'] = array(
+ '#markup' => _mcl_get_mcl_global_vars_table('DEFAULT'),
+ );
+
+ // Adds a new variables.
+ $form['add_var'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => TRUE,
+ '#collapsible' => TRUE,
+ '#title' => 'Add a new varibles',
+ );
+ $form['add_var']['type'] = array(
+ '#type' => 'select',
+ '#title' => 'Name',
+ '#options' => MCL_VAR::getTypes(),
+ '#description' => 'Select a type of a variable.',
+ '#attributes' => array('style' => 'width: 250px;'),
+ );
+ $form['add_var']['name'] = array(
+ '#type' => 'textfield',
+ '#title' => 'Name',
+ '#description' => 'Type name of a variable.',
+ '#attributes' => array('style' => 'width: 250px;'),
+ );
+ $form['add_var']['value'] = array(
+ '#type' => 'textfield',
+ '#title' => 'Value',
+ '#description' => 'Type value of a variable.',
+ '#attributes' => array('style' => 'width: 250px;'),
+ );
+ $form['add_var']['description'] = array(
+ '#type' => 'textarea',
+ '#title' => 'Description',
+ '#rows' => 4,
+ '#cols' => 50,
+ '#description' => 'Type description of a variable.',
+ '#attributes' => array('style' => ''),
+ );
+ $form['add_var']['add_var_btn'] = array(
+ '#type' => 'submit',
+ '#name' => 'add_var_btn',
+ '#value' => 'Add a variable',
+ );
+
+ // Sets properties of the form.
+ $form['#prefix'] = '
';
+ $form['#suffix'] = '
';
+ return $form;
+}
+
+/**
+ * Returns all variables of the provided type in a table.
+ *
+ * @param string $type
+ *
+ * @return string
+ */
+function _mcl_get_mcl_global_vars_table($type) {
+
+ // Gets the site varibles.
+ $mcl_vars = MCL_VAR::getGlobalVars($type);
+ $rows = array();
+ foreach ($mcl_vars as $mcl_var) {
+ $row = array(
+ $mcl_var->getName(),
+ $mcl_var->getValue(),
+ $mcl_var->getDescription(),
+ l('Edit', '/admin/mcl/global_var/edit/' . $mcl_var->getVarID()),
+ );
+ $rows[] = $row;
+ }
+ $table_vars = array(
+ 'header' => array('Name', 'Value', 'Description', 'Action'),
+ 'rows' => $rows,
+ 'attributes' => array(),
+ );
+ return theme('table', $table_vars);
+}
+
+/**
+ * Ajax function which returns the form via ajax.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_admin_global_var_form_ajax_callback($form, &$form_state) {
+ return $form;
+}
+
+/**
+ * Validates the form.
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_global_var_form_validate($form, &$form_state) {}
+
+/**
+ * Submits the form.
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_global_var_form_submit($form, &$form_state) {
+
+ // Gets the trigger element.
+ $trigger_elem = $form_state['triggering_element']['#name'];
+
+ // If "add_var_btn" button is clicked.
+ if ($trigger_elem == "add_var_btn") {
+
+ // Gets the variable info.
+ $type = trim($form_state['values']['add_var']['type']);
+ $name = trim($form_state['values']['add_var']['name']);
+ $value = trim($form_state['values']['add_var']['value']);
+ $desc = trim($form_state['values']['add_var']['description']);
+
+ // Checks for duplication.
+ $mcl_var = MCL_VAR::byKey(array('name' => $name, 'type' => $type));
+ if ($mcl_var) {
+ drupal_set_message("Name : $name has already existed. Please pick other name.");
+ }
+ else {
+
+ // Adds a new variable.
+ $details = array(
+ 'type' => $type,
+ 'name' => $name,
+ 'value' => $value,
+ 'description' => $description,
+ );
+ $mcl_var = new MCL_VAR($details);
+ if ($mcl_var->insert()) {
+ drupal_set_message("A new variable has been added.");
+ }
+ else {
+ drupal_set_message("Error : Failed to add a new variable.");
+ }
+ }
+ }
+}
+
+/**
+ * Edits MCL global variables.
+ *
+ * @param array $form
+ * @param array $form_state
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_global_var_edit_form($form, &$form_state, $var_id) {
+
+ // Creates a form.
+ $form = array();
+ $form['#tree'] = TRUE;
+
+ // Global variables.
+ $form['global_var'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => TRUE,
+ '#title' => 'Edit MCL global varible',
+ );
+
+ // Gets MCL_VAR.
+ $mcl_var = MCL_VAR::byKey(array('var_id' => $var_id));
+ if ($mcl_var) {
+ $form['global_var']['mcl_var'] = array(
+ '#value' => $mcl_var,
+ );
+ $form['global_var']['type'] = array(
+ '#title' => 'Type',
+ '#type' => 'select',
+ '#options' => MCL_VAR::getTypes(),
+ '#description' => "The type of the variable.",
+ '#default_value' => $mcl_var->getType(),
+ );
+
+ // If name start with 'SITE_', make it readonly.
+ $name = $mcl_var->getName();
+ if (preg_match("/^SITE\_/", $name)) {
+ $form['global_var']['name'] = array(
+ '#title' => 'Name',
+ '#type' => 'textfield',
+ '#description' => "The name of the variable.",
+ '#value' => $name,
+ '#description' => 'The name of this variable cannot be changed.',
+ '#attributes' => array(
+ 'style' => 'background-color:lightgray;',
+ 'readonly' => 'readonly'
+ ),
+ );
+ }
+ else {
+ $form['global_var']['name'] = array(
+ '#title' => 'Name',
+ '#type' => 'textfield',
+ '#description' => "The name of the variable.",
+ '#required' => TRUE,
+ '#default_value' => $name,
+ );
+ }
+ $form['global_var']['value'] = array(
+ '#title' => 'Value',
+ '#type' => 'textfield',
+ '#description' => "The value of the variable.",
+ '#required' => TRUE,
+ '#default_value' => $mcl_var->getValue(),
+ );
+ $form['global_var']['description'] = array(
+ '#title' => 'Description',
+ '#type' => 'textarea',
+ '#description' => "The description of the variable.",
+ '#default_value' => $mcl_var->getDescription(),
+ );
+ $form['global_var']['update_var_btn'] = array(
+ '#type' => 'submit',
+ '#name' => 'update_var_btn',
+ '#value' => 'Update the variable',
+ );
+ }
+ else {
+ $form['global_var']['error'] = array(
+ '#markup' => "Could not find MCL_VAR for var ID = $var_id",
+ );
+ }
+
+ // Sets properties of the form.
+ $form['#prefix'] = '';
+ $form['#suffix'] = '
';
+ return $form;
+}
+
+/**
+ * Ajax function which returns the form via ajax.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_admin_global_var_edit_form_ajax_callback($form, &$form_state) {
+ return $form;
+}
+
+/**
+ * Validates the form.
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_global_var_edit_form_validate($form, &$form_state) {}
+
+/**
+ * Submits the form.
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_global_var_edit_form_submit($form, &$form_state) {
+
+ // Gets the trigger element.
+ $trigger_elem = $form_state['triggering_element']['#name'];
+
+ // If "Update" button is clicked.
+ if ($trigger_elem == "update_var_btn") {
+
+ // Gets the variable info.
+ $mcl_var = $form['global_var']['mcl_var']['#value'];
+ $type = trim($form_state['values']['global_var']['type']);
+ $name = trim($form_state['values']['global_var']['name']);
+ $value = trim($form_state['values']['global_var']['value']);
+ $desc = trim($form_state['values']['global_var']['description']);
+
+ // Checks for duplication.
+ $tmp_mcl_var = MCL_VAR::byKey(array('name' => $name, 'type' => $type));
+ if ($tmp_mcl_var && ($mcl_var->getVarID() != $tmp_mcl_var->getVarID())) {
+ drupal_set_message("Name : $name has already existed..");
+ }
+ else {
+
+ // Updates the variable.
+ if ($mcl_var) {
+ $mcl_var->setType($type);
+ $mcl_var->setName($name);
+ $mcl_var->setValue($value);
+ $mcl_var->setDescription($desc);
+ if (!$mcl_var->update()) {
+ drupal_set_message("Failed to update the varibale.");
+ }
+ else {
+ drupal_set_message("The variable has been updated.");
+ drupal_goto("admin/mcl/global_var");
+ }
+ }
+ }
+ }
+}
diff --git a/includes/admin/mcl.admin.inc b/includes/admin/mcl.admin.inc
new file mode 100644
index 0000000..f6fd86b
--- /dev/null
+++ b/includes/admin/mcl.admin.inc
@@ -0,0 +1,45 @@
+');
+ $breadcrumb[] = l('Administration', 'admin');
+ drupal_set_breadcrumb($breadcrumb);
+
+ // Page contents.
+ $content = 'MCL admin main page
';
+
+ // Check MCL directories.
+ $dirs = array();
+ $working_dir = mcl_get_config_setting('mcl_working_dir');
+ $dirs['working_dir'] = $working_dir;
+ $dirs['user_dir'] = "$working_dir/user";
+ $content .= 'Checking MCL directories
';
+ foreach ($dirs as $name => $dir) {
+ $content .= "$name : $dir";
+ if (file_exists($dir)) {
+ $content .= " ... ok
";
+ }
+ else {
+ $content .= '
The directory does not exist, trying to create a directory
';
+ if(!file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
+ $content .= 'Fail to create a directory
';
+ watchdog('mcl', $message, array(), WATCHDOG_ERROR);
+ }
+ else {
+ $content .= 'The directory has been created
';
+ }
+ }
+ }
+ return $content;
+}
diff --git a/includes/admin/mcl.admin.template.inc b/includes/admin/mcl.admin.template.inc
new file mode 100644
index 0000000..b594027
--- /dev/null
+++ b/includes/admin/mcl.admin.template.inc
@@ -0,0 +1,212 @@
+ 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'Data Templates',
+ );
+ $form['manage_template']['desc'] = array(
+ '#markup' => t('Manage data templates for Mainlab Chado Loader') . '
',
+ );
+
+ // Form for addinga template.
+ $form['template_add'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => TRUE,
+ '#collapsible' => TRUE,
+ '#title' => 'Add Template',
+ );
+ $form['template_add']['template_type'] = array(
+ '#type' => 'select',
+ '#title' => 'Template Type',
+ '#options' => _get_opt_mcl_template_type(),
+ '#description' => 'Select a type of a template.',
+ '#attributes' => array('style' => 'width: 250px;'),
+ );
+ $form['template_add']['template'] = array(
+ '#type' => 'textfield',
+ '#title' => 'Template Name',
+ '#description' => 'Type name of a template.',
+ '#attributes' => array('style' => 'width: 250px;'),
+ );
+ $form['template_add']['add_template_btn'] = array(
+ '#type' => 'submit',
+ '#name' => 'add_template_btn',
+ '#value' => 'Add Template',
+ '#ajax' => array(
+ 'callback' => "mcl_admin_template_form_ajax_callback",
+ 'wrapper' => 'mcl-admin-template-form',
+ 'effect' => 'fade',
+ 'method' => 'replace',
+ ),
+ );
+
+ // Shows the list of MCL templates.
+ $form['template_list'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'MCL Data Templates',
+ );
+
+ // Edits a new template.
+ $form['template_list']['table']= array(
+ '#markup' => _get_mcl_template_list(),
+ );
+
+ // Sets properties of the form.
+ $form['#prefix'] = '';
+ $form['#suffix'] = '
';
+ return $form;
+}
+
+/**
+ * Returns template types as options.
+ *
+ * @return array
+ */
+function _get_opt_mcl_template_type() {
+
+ // Gets all template types.
+ $mcl_template_types = MCL_TEMPLATE_TYPE::getTemplateTypes();
+ $options = array();
+ foreach ($mcl_template_types as $mcl_template_type) {
+ $options[$mcl_template_type->getTemplateTypeID()] = $mcl_template_type->getType();
+ }
+ return $options;
+}
+
+/**
+ * Returns MCL templates in table.
+ *
+ * @return string
+ */
+function _get_mcl_template_list() {
+
+ // Populates the table with MCL templates.
+ $rows = array();
+ $mcl_templates = MCL_TEMPLATE::getTemplates();
+ foreach ($mcl_templates as $mcl_template) {
+ $template_type = $mcl_template->getTemplateType();
+ $template = $mcl_template->getTemplate();
+ $tmpl = MCL_TEMPLATE::getTemplateByID($mcl_template->getTemplateID());
+
+ // Checks if class has been defined.
+ $class = 'Not Defined';
+ $desc = 'N/A';
+ if ($tmpl) {
+ $class = 'Defined';
+ $desc = $tmpl->defineDescription();
+ }
+
+ // Adds the delete link.
+ $delete_link = '';
+
+ // Adds a row.
+ $row = array(
+ $template_type,
+ $template,
+ $class,
+// $delete_link,
+ $desc,
+ );
+ $rows[] = $row;
+ }
+
+ // Sets the headers.
+ $headers = array(
+ array('data' => 'Template Type', 'style' => 'width:15%'),
+ array('data' => 'Template', 'style' => 'width:10%'),
+ array('data' => 'Class', 'style' => 'width:8%'),
+ //array('data' => 'Action', 'style' => 'width:8%'),
+ 'Description',
+ );
+
+ $table_vars = array(
+ 'header' => $headers,
+ 'rows' => $rows,
+ 'attributes' => array(),
+ );
+ return theme('table', $table_vars);
+}
+
+/**
+ * Ajax function which returns the form via ajax.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_admin_template_form_ajax_callback($form, &$form_state) {
+
+ // Gets the trigger element.
+ $trigger_elem = $form_state['triggering_element']['#name'];
+
+ // If "Add Template" button is clicked.
+ if ($trigger_elem == "add_template_btn") {
+
+ // Gets the template info.
+ $template_type_id = $form_state['values']['template_add']['template_type'];
+ $template = $form_state['values']['template_add']['template'];
+
+ // Adds a template.
+ if ($template) {
+
+ // Checks for duplication.
+ $mcl_template = MCL_TEMPLATE::byKey(array('template' => $template));
+ if ($mcl_template) {
+ drupal_set_message("'$template' has exists. Please pick a different name");
+ }
+ else {
+
+ // Adds a template.
+ $details = array(
+ 'template_type_id' => $template_type_id,
+ 'template' => $template,
+ );
+ $mcl_template = new MCL_TEMPLATE($details);
+ if ($mcl_template->insert()) {
+ drupal_set_message("New template '$template' has been added");
+ }
+ else {
+ drupal_set_message("Error : Failed to add a new template '$template'");
+ }
+
+ // Clears the textfield.
+ $form_state['template_add']['template'] = '';
+ }
+ }
+ else {
+ drupal_set_message('Please type template name');
+ }
+ }
+ return $form;
+}
+
+/**
+ * Validates the form.
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_template_form_validate($form, &$form_state) {}
+
+/**
+ * Submits the form.
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_template_form_submit($form, &$form_state) {}
\ No newline at end of file
diff --git a/includes/admin/mcl.admin.template_type.inc b/includes/admin/mcl.admin.template_type.inc
new file mode 100644
index 0000000..d480947
--- /dev/null
+++ b/includes/admin/mcl.admin.template_type.inc
@@ -0,0 +1,175 @@
+ 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'Data Template Types',
+ );
+ $form['manage_template_type']['desc'] = array(
+ '#markup' => t('Manage template types for Mainlab Chado Loader') . '
',
+ );
+
+ // Form for adding a template type.
+ $form['template_type_add'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => TRUE,
+ '#collapsible' => TRUE,
+ '#title' => 'Add Template Type',
+ );
+ $form['template_type_add']['type'] = array(
+ '#type' => 'textfield',
+ '#title' => 'Template Type',
+ '#description' => 'Enter a type of a template.',
+ '#attributes' => array('style' => 'width: 250px;'),
+ );
+ $form['template_type_add']['rank'] = array(
+ '#type' => 'textfield',
+ '#title' => 'Template Type Rank',
+ '#description' => 'Enter a rank of a template type.',
+ '#attributes' => array('style' => 'width: 250px;'),
+ );
+ $form['template_type_add']['add_template_type_btn'] = array(
+ '#type' => 'submit',
+ '#name' => 'add_template_type_btn',
+ '#value' => 'Add a template type',
+ '#ajax' => array(
+ 'callback' => "mcl_admin_template_type_form_ajax_callback",
+ 'wrapper' => 'mcl-admin-template-type-form',
+ 'effect' => 'fade',
+ 'method' => 'replace',
+ ),
+ );
+
+ // Shows the list of MCL template types.
+ $form['template_type_list'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'MCL Data Template types',
+ );
+
+ // Edits a new template.
+ $form['template_type_list']['table']= array(
+ '#markup' => _get_mcl_template_type_list(),
+ );
+
+ // Sets properties of the form.
+ $form['#prefix'] = '';
+ $form['#suffix'] = '
';
+ return $form;
+}
+
+/**
+ * Returns MCL template types in table.
+ *
+ * @return string
+ */
+function _get_mcl_template_type_list() {
+
+ // Gets all template types.
+ $mcl_template_types = MCL_TEMPLATE_TYPE::getTemplateTypes('rank');
+ $options = array();
+ foreach ($mcl_template_types as $mcl_template_type) {
+ $type = $mcl_template_type->getType();
+ $rank = $mcl_template_type->getRank();
+
+ // Adds a delete link.
+ $delete_link = 'delete';
+
+ // Adds a row.
+ $row = array(
+ $type,
+ $rank,
+ //$delete_link,
+ );
+ $rows[] = $row;
+ }
+
+ // Sets the headers.
+ $headers = array(
+ array('data' => 'Template Type', 'style' => 'width:15%'),
+ array('data' => 'Rank', 'style' => 'width:10%'),
+ //array('data' => 'Action', 'style' => 'width:8%'),
+ );
+
+ $table_vars = array(
+ 'header' => $headers,
+ 'rows' => $rows,
+ 'attributes' => array(),
+ );
+ return theme('table', $table_vars);
+}
+
+/**
+ * Ajax function which returns the form via ajax.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_admin_template_type_form_ajax_callback($form, &$form_state) {
+
+ // Gets the trigger element.
+ $trigger_elem = $form_state['triggering_element']['#name'];
+
+ // If "Add a template type" button is clicked.
+ if ($trigger_elem == "add_template_type_btn") {
+
+ // Gets the template info.
+ $type = $form_state['values']['template_type_add']['type'];
+ $rank = $form_state['values']['template_type_add']['rank'];
+
+ // Checks for duplication.
+ $mcl_template_type = MCL_TEMPLATE_TYPE::byKey(array('type' => $type));
+ if ($mcl_template_type) {
+ drupal_set_message("'$type' has exists. Please pick a different name");
+ }
+ else {
+
+ // Adds a template type.
+ $details = array(
+ 'type' => $type,
+ 'rank' => $rank,
+ );
+ $mcl_template_type = new MCL_TEMPLATE_TYPE($details);
+ if ($mcl_template_type->insert()) {
+ drupal_set_message("New template type '$type' has been added");
+ }
+ else {
+ drupal_set_message("Error : Failed to add a new template type '$type'");
+ }
+
+ // Clears the textfield.
+ $form_state['template_type_add']['type'] = '';
+ }
+ }
+ return $form;
+}
+
+/**
+ * Validates the form.
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_template_type_form_validate($form, &$form_state) {}
+
+/**
+ * Submits the form.
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_template_type_form_submit($form, &$form_state) {}
\ No newline at end of file
diff --git a/includes/admin/mcl.admin.user.inc b/includes/admin/mcl.admin.user.inc
new file mode 100644
index 0000000..94bd312
--- /dev/null
+++ b/includes/admin/mcl.admin.user.inc
@@ -0,0 +1,190 @@
+ 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'MCL Users',
+ );
+ $form['manage_user']['desc'] = array(
+ '#markup' => t('Manage data users') . '
',
+ );
+
+ // Adds a user.
+ $form['mcl_user'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'Add / Remove MCL user',
+ );
+
+ // Shows MCL users.
+ $form['mcl_user']['mcl'] = array(
+ '#type' => 'select',
+ '#title' => t('MCL users'),
+ '#options' => _get_opt_mcl_user_list(TRUE),
+ '#validated' => TRUE,
+ '#size' => 5,
+ '#attributes' => array('style' => 'width: 200px;'),
+ );
+ $form['mcl_user']['remove_user_btn'] = array(
+ '#type' => 'submit',
+ '#name' => 'remove_user_btn',
+ '#value' => 'Remove user',
+ '#ajax' => array(
+ 'callback' => "mcl_admin_user_form_ajax_callback",
+ 'wrapper' => 'mcl-admin-user-form',
+ 'effect' => 'fade',
+ 'method' => 'replace',
+ ),
+ );
+
+ // Shows Druapl users.
+ $form['mcl_user']['non_mcl'] = array(
+ '#type' => 'select',
+ '#title' => t('Non-MCL users'),
+ '#options' => _get_opt_mcl_user_list(FALSE),
+ '#validated' => TRUE,
+ '#size' => 5,
+ '#attributes' => array('style' => 'width: 200px;'),
+ );
+ $form['mcl_user']['add_user_btn'] = array(
+ '#type' => 'submit',
+ '#name' => 'add_user_btn',
+ '#value' => 'Add user',
+ '#ajax' => array(
+ 'callback' => "mcl_admin_user_form_ajax_callback",
+ 'wrapper' => 'mcl-admin-user-form',
+ 'effect' => 'fade',
+ 'method' => 'replace',
+ ),
+ );
+
+ // Sets properties of the form.
+ $form['#prefix'] = '';
+ $form['#suffix'] = '
';
+ return $form;
+}
+
+/**
+ * Returns a list of MCL users. Return all non MCL user if the flag is FALSE.
+ *
+ * @param boolean $flag
+ *
+ * @return array
+ */
+function _get_opt_mcl_user_list($flag = TRUE) {
+ $user_list = array();
+ return MCL_USER::getUserObjects($flag);
+}
+
+/**
+ * Ajax function which returns the form via ajax.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_admin_user_form_ajax_callback($form, &$form_state) {
+ global $user;
+
+ // Gets the trigger element.
+ $trigger_elem = $form_state['triggering_element']['#name'];
+
+ // If "Remove User" button is clicked.
+ if ($trigger_elem == "remove_user_btn") {
+
+
+ // Gets user ID.
+ $user_id = $form_state['values']['mcl_user']['mcl'];
+ if ($user_id) {
+ $mcl_user = MCL_USER::byKey(array('uid' => $user_id));
+ if ($mcl_user->delete()) {
+
+ // Updates user lists.
+ $form['mcl_user']['non_mcl']['#options'] = _get_opt_mcl_user_list(FALSE);
+ $form['mcl_user']['mcl']['#options'] = _get_opt_mcl_user_list(TRUE);
+ }
+ else {
+ drupal_set_message("Error : Removing the MCL user [$user_id].");
+ }
+ }
+ else {
+ drupal_set_message("Please select a user from MCL user list.");
+ }
+ }
+
+ // If the 'Add User' button was clicked.
+ if ($trigger_elem == 'add_user_btn') {
+
+ // Gets the Drupal user.
+ $user_id = $form_state['values']['mcl_user']['non_mcl'];
+ if ($user_id) {
+ $drupal_user = MCL_USER::getDrupalUser($user_id);
+ if ($drupal_user) {
+
+ // Adds a new MCL user.
+ $details = array(
+ 'user_id' => $drupal_user->uid,
+ 'name' => $drupal_user->name,
+ 'uid' => $drupal_user->uid,
+ 'mail' => $drupal_user->mail,
+ );
+ $mcl_user = new MCL_USER($details);
+ if ($mcl_user->insert()) {
+
+ // Updates user lists.
+ $form['mcl_user']['non_mcl']['#options'] = _get_opt_mcl_user_list(FALSE);
+ $form['mcl_user']['mcl']['#options'] = _get_opt_mcl_user_list(TRUE);
+
+ // Creates directories for a user.
+ $user_dir = $mcl_user->getUserDir();
+ if (!file_exists($user_dir)) {
+ mcl_create_dir($user_dir);
+ }
+ $user_tmp_dir = "$user_dir/tmp";
+ if (!file_exists($user_tmp_dir)) {
+ mcl_create_dir($user_tmp_dir);
+ }
+ }
+ else {
+ drupal_set_message("Error : Failed to add a new MCL user [$user_name].");
+ }
+ }
+ else {
+ drupal_set_message("Error : Drupal user [$user_id] not found.");
+ }
+ }
+ else {
+ drupal_set_message("Please select a user from Drupal user list.");
+ }
+ }
+ return $form;
+}
+
+/**
+ * Validates the form.
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_user_form_validate($form, &$form_state) {}
+
+/**
+ * Submits the form.
+ *
+ * @ingroup mcl_admin
+ */
+function mcl_admin_user_form_submit($form, &$form_state) {}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_contact.class.inc b/includes/class/chado_table_class/chado_contact.class.inc
new file mode 100644
index 0000000..9664f5d
--- /dev/null
+++ b/includes/class/chado_table_class/chado_contact.class.inc
@@ -0,0 +1,281 @@
+ 'serial',
+ 'type_id' => 'integer',
+ 'name' => 'character_varying(255)',
+ 'description' => 'character_varying(255)',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->contact_id = array_key_exists('contact_id', $details) ? $details['contact_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->description = array_key_exists('description', $details) ? $details['description'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_CONTACT by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.contact WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['description'] = $this->description;
+ if (is_numeric($this->type_id)) { $fields['type_id'] = $this->type_id; }
+
+ // Inserts the record.
+ $this->contact_id = db_insert('chado.contact')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['description'] = $this->description;
+ if (is_numeric($this->type_id)) { $fields['type_id'] = $this->type_id; }
+
+ // Updates the record.
+ db_update('chado.contact')
+ ->fields($fields)
+ ->condition('contact_id', $this->contact_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.contact')
+ ->condition('contact_id', $this->contact_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the contact_id.
+ *
+ * @retrun serial
+ */
+ public function getContactID() {
+ return $this->contact_id;
+ }
+
+ /**
+ * Updates the contact_id.
+ *
+ * @param serial $contact_id
+ */
+ public function setContactID($contact_id) {
+ $this->contact_id = $contact_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the description.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getDescription() {
+ return $this->description;
+ }
+
+ /**
+ * Updates the description.
+ *
+ * @param character_varying(255) $description
+ */
+ public function setDescription($description) {
+ $this->description = $description;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_contactprop.class.inc b/includes/class/chado_table_class/chado_contactprop.class.inc
new file mode 100644
index 0000000..5746f2f
--- /dev/null
+++ b/includes/class/chado_table_class/chado_contactprop.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'contact_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->contactprop_id = array_key_exists('contactprop_id', $details) ? $details['contactprop_id'] : '';
+ $this->contact_id = array_key_exists('contact_id', $details) ? $details['contact_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_CONTACTPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.contactprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['contact_id'] = $this->contact_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->contactprop_id = db_insert('chado.contactprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['contact_id'] = $this->contact_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.contactprop')
+ ->fields($fields)
+ ->condition('contactprop_id', $this->contactprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.contactprop')
+ ->condition('contactprop_id', $this->contactprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the contactprop_id.
+ *
+ * @retrun serial
+ */
+ public function getContactpropID() {
+ return $this->contactprop_id;
+ }
+
+ /**
+ * Updates the contactprop_id.
+ *
+ * @param serial $contactprop_id
+ */
+ public function setContactpropID($contactprop_id) {
+ $this->contactprop_id = $contactprop_id;
+ }
+
+ /**
+ * Retrieves the contact_id.
+ *
+ * @retrun integer
+ */
+ public function getContactID() {
+ return $this->contact_id;
+ }
+
+ /**
+ * Updates the contact_id.
+ *
+ * @param integer $contact_id
+ */
+ public function setContactID($contact_id) {
+ $this->contact_id = $contact_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_cv.class.inc b/includes/class/chado_table_class/chado_cv.class.inc
new file mode 100644
index 0000000..4a8fa99
--- /dev/null
+++ b/includes/class/chado_table_class/chado_cv.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'name' => 'character_varying(255)',
+ 'definition' => 'text',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->cv_id = array_key_exists('cv_id', $details) ? $details['cv_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->definition = array_key_exists('definition', $details) ? $details['definition'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_CV by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.cv WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['definition'] = $this->definition;
+
+
+ // Inserts the record.
+ db_insert('chado.cv')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['definition'] = $this->definition;
+
+
+ // Updates the record.
+ db_update('chado.cv')
+ ->fields($fields)
+
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.cv')
+
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the cv_id.
+ *
+ * @retrun serial
+ */
+ public function getCvID() {
+ return $this->cv_id;
+ }
+
+ /**
+ * Updates the cv_id.
+ *
+ * @param serial $cv_id
+ */
+ public function setCvID($cv_id) {
+ $this->cv_id = $cv_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the definition.
+ *
+ * @retrun text
+ */
+ public function getDefinition() {
+ return $this->definition;
+ }
+
+ /**
+ * Updates the definition.
+ *
+ * @param text $definition
+ */
+ public function setDefinition($definition) {
+ $this->definition = $definition;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_cvterm.class.inc b/includes/class/chado_table_class/chado_cvterm.class.inc
new file mode 100644
index 0000000..717595b
--- /dev/null
+++ b/includes/class/chado_table_class/chado_cvterm.class.inc
@@ -0,0 +1,352 @@
+ 'serial',
+ 'cv_id' => 'integer',
+ 'name' => 'character_varying(1024)',
+ 'definition' => 'text',
+ 'dbxref_id' => 'integer',
+ 'is_obsolete' => 'integer',
+ 'is_relationshiptype' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->cvterm_id = array_key_exists('cvterm_id', $details) ? $details['cvterm_id'] : '';
+ $this->cv_id = array_key_exists('cv_id', $details) ? $details['cv_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->definition = array_key_exists('definition', $details) ? $details['definition'] : '';
+ $this->dbxref_id = array_key_exists('dbxref_id', $details) ? $details['dbxref_id'] : '';
+ $this->is_obsolete = array_key_exists('is_obsolete', $details) ? $details['is_obsolete'] : 0;
+ $this->is_relationshiptype = array_key_exists('is_relationshiptype', $details) ? $details['is_relationshiptype'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_CVTERM by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.cvterm WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['cv_id'] = $this->cv_id;
+ $fields['name'] = $this->name;
+ $fields['definition'] = $this->definition;
+ $fields['dbxref_id'] = $this->dbxref_id;
+ $fields['is_obsolete'] = (is_numeric($this->is_obsolete)) ? $this->is_obsolete : 0;
+ $fields['is_relationshiptype'] = (is_numeric($this->is_relationshiptype)) ? $this->is_relationshiptype : 0;
+
+
+ // Inserts the record.
+ $this->cvterm_id = db_insert('chado.cvterm')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['cv_id'] = $this->cv_id;
+ $fields['name'] = $this->name;
+ $fields['definition'] = $this->definition;
+ $fields['dbxref_id'] = $this->dbxref_id;
+ $fields['is_obsolete'] = (is_numeric($this->is_obsolete)) ? $this->is_obsolete : 0;
+ $fields['is_relationshiptype'] = (is_numeric($this->is_relationshiptype)) ? $this->is_relationshiptype : 0;
+
+
+ // Updates the record.
+ db_update('chado.cvterm')
+ ->fields($fields)
+ ->condition('cvterm_id', $this->cvterm_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.cvterm')
+ ->condition('cvterm_id', $this->cvterm_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the cvterm_id.
+ *
+ * @retrun serial
+ */
+ public function getCvtermID() {
+ return $this->cvterm_id;
+ }
+
+ /**
+ * Updates the cvterm_id.
+ *
+ * @param serial $cvterm_id
+ */
+ public function setCvtermID($cvterm_id) {
+ $this->cvterm_id = $cvterm_id;
+ }
+
+ /**
+ * Retrieves the cv_id.
+ *
+ * @retrun integer
+ */
+ public function getCvID() {
+ return $this->cv_id;
+ }
+
+ /**
+ * Updates the cv_id.
+ *
+ * @param integer $cv_id
+ */
+ public function setCvID($cv_id) {
+ $this->cv_id = $cv_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(1024)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(1024) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the definition.
+ *
+ * @retrun text
+ */
+ public function getDefinition() {
+ return $this->definition;
+ }
+
+ /**
+ * Updates the definition.
+ *
+ * @param text $definition
+ */
+ public function setDefinition($definition) {
+ $this->definition = $definition;
+ }
+
+ /**
+ * Retrieves the dbxref_id.
+ *
+ * @retrun integer
+ */
+ public function getDbxrefID() {
+ return $this->dbxref_id;
+ }
+
+ /**
+ * Updates the dbxref_id.
+ *
+ * @param integer $dbxref_id
+ */
+ public function setDbxrefID($dbxref_id) {
+ $this->dbxref_id = $dbxref_id;
+ }
+
+ /**
+ * Retrieves the is_obsolete.
+ *
+ * @retrun integer
+ */
+ public function getIsObsolete() {
+ return $this->is_obsolete;
+ }
+
+ /**
+ * Updates the is_obsolete.
+ *
+ * @param integer $is_obsolete
+ */
+ public function setIsObsolete($is_obsolete) {
+ $this->is_obsolete = $is_obsolete;
+ }
+
+ /**
+ * Retrieves the is_relationshiptype.
+ *
+ * @retrun integer
+ */
+ public function getIsRelationshiptype() {
+ return $this->is_relationshiptype;
+ }
+
+ /**
+ * Updates the is_relationshiptype.
+ *
+ * @param integer $is_relationshiptype
+ */
+ public function setIsRelationshiptype($is_relationshiptype) {
+ $this->is_relationshiptype = $is_relationshiptype;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_cvterm_relationship.class.inc b/includes/class/chado_table_class/chado_cvterm_relationship.class.inc
new file mode 100644
index 0000000..0867175
--- /dev/null
+++ b/includes/class/chado_table_class/chado_cvterm_relationship.class.inc
@@ -0,0 +1,283 @@
+ 'serial',
+ 'type_id' => 'integer',
+ 'subject_id' => 'integer',
+ 'object_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->cvterm_relationship_id = array_key_exists('cvterm_relationship_id', $details) ? $details['cvterm_relationship_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->subject_id = array_key_exists('subject_id', $details) ? $details['subject_id'] : '';
+ $this->object_id = array_key_exists('object_id', $details) ? $details['object_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_CVTERM_RELATIONSHIP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.cvterm_relationship WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['type_id'] = $this->type_id;
+ $fields['subject_id'] = $this->subject_id;
+ $fields['object_id'] = $this->object_id;
+
+
+ // Inserts the record.
+ $this->cvterm_relationship_id = db_insert('chado.cvterm_relationship')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['type_id'] = $this->type_id;
+ $fields['subject_id'] = $this->subject_id;
+ $fields['object_id'] = $this->object_id;
+
+
+ // Updates the record.
+ db_update('chado.cvterm_relationship')
+ ->fields($fields)
+ ->condition('cvterm_relationship_id', $this->cvterm_relationship_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.cvterm_relationship')
+ ->condition('cvterm_relationship_id', $this->cvterm_relationship_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the cvterm_relationship_id.
+ *
+ * @retrun serial
+ */
+ public function getCvtermRelationshipID() {
+ return $this->cvterm_relationship_id;
+ }
+
+ /**
+ * Updates the cvterm_relationship_id.
+ *
+ * @param serial $cvterm_relationship_id
+ */
+ public function setCvtermRelationshipID($cvterm_relationship_id) {
+ $this->cvterm_relationship_id = $cvterm_relationship_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the subject_id.
+ *
+ * @retrun integer
+ */
+ public function getSubjectID() {
+ return $this->subject_id;
+ }
+
+ /**
+ * Updates the subject_id.
+ *
+ * @param integer $subject_id
+ */
+ public function setSubjectID($subject_id) {
+ $this->subject_id = $subject_id;
+ }
+
+ /**
+ * Retrieves the object_id.
+ *
+ * @retrun integer
+ */
+ public function getObjectID() {
+ return $this->object_id;
+ }
+
+ /**
+ * Updates the object_id.
+ *
+ * @param integer $object_id
+ */
+ public function setObjectID($object_id) {
+ $this->object_id = $object_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_cvtermprop.class.inc b/includes/class/chado_table_class/chado_cvtermprop.class.inc
new file mode 100644
index 0000000..5054683
--- /dev/null
+++ b/includes/class/chado_table_class/chado_cvtermprop.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'cvterm_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->cvtermprop_id = array_key_exists('cvtermprop_id', $details) ? $details['cvtermprop_id'] : '';
+ $this->cvterm_id = array_key_exists('cvterm_id', $details) ? $details['cvterm_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_CVTERMPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.cvtermprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['cvterm_id'] = $this->cvterm_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->cvtermprop_id = db_insert('chado.cvtermprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['cvterm_id'] = $this->cvterm_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.cvtermprop')
+ ->fields($fields)
+ ->condition('cvtermprop_id', $this->cvtermprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.cvtermprop')
+ ->condition('cvtermprop_id', $this->cvtermprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the cvtermprop_id.
+ *
+ * @retrun serial
+ */
+ public function getCvtermpropID() {
+ return $this->cvtermprop_id;
+ }
+
+ /**
+ * Updates the cvtermprop_id.
+ *
+ * @param serial $cvtermprop_id
+ */
+ public function setCvtermpropID($cvtermprop_id) {
+ $this->cvtermprop_id = $cvtermprop_id;
+ }
+
+ /**
+ * Retrieves the cvterm_id.
+ *
+ * @retrun integer
+ */
+ public function getCvtermID() {
+ return $this->cvterm_id;
+ }
+
+ /**
+ * Updates the cvterm_id.
+ *
+ * @param integer $cvterm_id
+ */
+ public function setCvtermID($cvterm_id) {
+ $this->cvterm_id = $cvterm_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_cvtermsynonym.class.inc b/includes/class/chado_table_class/chado_cvtermsynonym.class.inc
new file mode 100644
index 0000000..ad3fb0d
--- /dev/null
+++ b/includes/class/chado_table_class/chado_cvtermsynonym.class.inc
@@ -0,0 +1,281 @@
+ 'serial',
+ 'cvterm_id' => 'integer',
+ 'synonym' => 'character_varying(1024)',
+ 'type_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->cvtermsynonym_id = array_key_exists('cvtermsynonym_id', $details) ? $details['cvtermsynonym_id'] : '';
+ $this->cvterm_id = array_key_exists('cvterm_id', $details) ? $details['cvterm_id'] : '';
+ $this->synonym = array_key_exists('synonym', $details) ? $details['synonym'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_CVTERMSYNONYM by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.cvtermsynonym WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['cvterm_id'] = $this->cvterm_id;
+ $fields['synonym'] = $this->synonym;
+ if (is_numeric($this->type_id)) { $fields['type_id'] = $this->type_id; }
+
+ // Inserts the record.
+ $this->cvtermsynonym_id = db_insert('chado.cvtermsynonym')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['cvterm_id'] = $this->cvterm_id;
+ $fields['synonym'] = $this->synonym;
+ if (is_numeric($this->type_id)) { $fields['type_id'] = $this->type_id; }
+
+ // Updates the record.
+ db_update('chado.cvtermsynonym')
+ ->fields($fields)
+ ->condition('cvtermsynonym_id', $this->cvtermsynonym_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.cvtermsynonym')
+ ->condition('cvtermsynonym_id', $this->cvtermsynonym_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the cvtermsynonym_id.
+ *
+ * @retrun serial
+ */
+ public function getCvtermsynonymID() {
+ return $this->cvtermsynonym_id;
+ }
+
+ /**
+ * Updates the cvtermsynonym_id.
+ *
+ * @param serial $cvtermsynonym_id
+ */
+ public function setCvtermsynonymID($cvtermsynonym_id) {
+ $this->cvtermsynonym_id = $cvtermsynonym_id;
+ }
+
+ /**
+ * Retrieves the cvterm_id.
+ *
+ * @retrun integer
+ */
+ public function getCvtermID() {
+ return $this->cvterm_id;
+ }
+
+ /**
+ * Updates the cvterm_id.
+ *
+ * @param integer $cvterm_id
+ */
+ public function setCvtermID($cvterm_id) {
+ $this->cvterm_id = $cvterm_id;
+ }
+
+ /**
+ * Retrieves the synonym.
+ *
+ * @retrun character_varying(1024)
+ */
+ public function getSynonym() {
+ return $this->synonym;
+ }
+
+ /**
+ * Updates the synonym.
+ *
+ * @param character_varying(1024) $synonym
+ */
+ public function setSynonym($synonym) {
+ $this->synonym = $synonym;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_db.class.inc b/includes/class/chado_table_class/chado_db.class.inc
new file mode 100644
index 0000000..82f9762
--- /dev/null
+++ b/includes/class/chado_table_class/chado_db.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'name' => 'character_varying(255)',
+ 'description' => 'character_varying(255)',
+ 'urlprefix' => 'character_varying(255)',
+ 'url' => 'character_varying(255)',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->db_id = array_key_exists('db_id', $details) ? $details['db_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->description = array_key_exists('description', $details) ? $details['description'] : '';
+ $this->urlprefix = array_key_exists('urlprefix', $details) ? $details['urlprefix'] : '';
+ $this->url = array_key_exists('url', $details) ? $details['url'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_DB by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.db WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['description'] = $this->description;
+ $fields['urlprefix'] = $this->urlprefix;
+ $fields['url'] = $this->url;
+
+
+ // Inserts the record.
+ $this->db_id = db_insert('chado.db')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['description'] = $this->description;
+ $fields['urlprefix'] = $this->urlprefix;
+ $fields['url'] = $this->url;
+
+
+ // Updates the record.
+ db_update('chado.db')
+ ->fields($fields)
+ ->condition('db_id', $this->db_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.db')
+ ->condition('db_id', $this->db_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the db_id.
+ *
+ * @retrun serial
+ */
+ public function getDbID() {
+ return $this->db_id;
+ }
+
+ /**
+ * Updates the db_id.
+ *
+ * @param serial $db_id
+ */
+ public function setDbID($db_id) {
+ $this->db_id = $db_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the description.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getDescription() {
+ return $this->description;
+ }
+
+ /**
+ * Updates the description.
+ *
+ * @param character_varying(255) $description
+ */
+ public function setDescription($description) {
+ $this->description = $description;
+ }
+
+ /**
+ * Retrieves the urlprefix.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getUrlprefix() {
+ return $this->urlprefix;
+ }
+
+ /**
+ * Updates the urlprefix.
+ *
+ * @param character_varying(255) $urlprefix
+ */
+ public function setUrlprefix($urlprefix) {
+ $this->urlprefix = $urlprefix;
+ }
+
+ /**
+ * Retrieves the url.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getUrl() {
+ return $this->url;
+ }
+
+ /**
+ * Updates the url.
+ *
+ * @param character_varying(255) $url
+ */
+ public function setUrl($url) {
+ $this->url = $url;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_dbxref.class.inc b/includes/class/chado_table_class/chado_dbxref.class.inc
new file mode 100644
index 0000000..c80b824
--- /dev/null
+++ b/includes/class/chado_table_class/chado_dbxref.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'db_id' => 'integer',
+ 'accession' => 'character_varying(255)',
+ 'version' => 'character_varying(255)',
+ 'description' => 'text',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->dbxref_id = array_key_exists('dbxref_id', $details) ? $details['dbxref_id'] : '';
+ $this->db_id = array_key_exists('db_id', $details) ? $details['db_id'] : '';
+ $this->accession = array_key_exists('accession', $details) ? $details['accession'] : '';
+ $this->version = array_key_exists('version', $details) ? $details['version'] : '';
+ $this->description = array_key_exists('description', $details) ? $details['description'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_DBXREF by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.dbxref WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['db_id'] = $this->db_id;
+ $fields['accession'] = $this->accession;
+ $fields['version'] = $this->version;
+ $fields['description'] = $this->description;
+
+
+ // Inserts the record.
+ $this->dbxref_id = db_insert('chado.dbxref')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['db_id'] = $this->db_id;
+ $fields['accession'] = $this->accession;
+ $fields['version'] = $this->version;
+ $fields['description'] = $this->description;
+
+
+ // Updates the record.
+ db_update('chado.dbxref')
+ ->fields($fields)
+ ->condition('dbxref_id', $this->dbxref_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.dbxref')
+ ->condition('dbxref_id', $this->dbxref_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the dbxref_id.
+ *
+ * @retrun serial
+ */
+ public function getDbxrefID() {
+ return $this->dbxref_id;
+ }
+
+ /**
+ * Updates the dbxref_id.
+ *
+ * @param serial $dbxref_id
+ */
+ public function setDbxrefID($dbxref_id) {
+ $this->dbxref_id = $dbxref_id;
+ }
+
+ /**
+ * Retrieves the db_id.
+ *
+ * @retrun integer
+ */
+ public function getDbID() {
+ return $this->db_id;
+ }
+
+ /**
+ * Updates the db_id.
+ *
+ * @param integer $db_id
+ */
+ public function setDbID($db_id) {
+ $this->db_id = $db_id;
+ }
+
+ /**
+ * Retrieves the accession.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getAccession() {
+ return $this->accession;
+ }
+
+ /**
+ * Updates the accession.
+ *
+ * @param character_varying(255) $accession
+ */
+ public function setAccession($accession) {
+ $this->accession = $accession;
+ }
+
+ /**
+ * Retrieves the version.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getVersion() {
+ return $this->version;
+ }
+
+ /**
+ * Updates the version.
+ *
+ * @param character_varying(255) $version
+ */
+ public function setVersion($version) {
+ $this->version = $version;
+ }
+
+ /**
+ * Retrieves the description.
+ *
+ * @retrun text
+ */
+ public function getDescription() {
+ return $this->description;
+ }
+
+ /**
+ * Updates the description.
+ *
+ * @param text $description
+ */
+ public function setDescription($description) {
+ $this->description = $description;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_dbxrefprop.class.inc b/includes/class/chado_table_class/chado_dbxrefprop.class.inc
new file mode 100644
index 0000000..182d9ca
--- /dev/null
+++ b/includes/class/chado_table_class/chado_dbxrefprop.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'dbxref_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->dbxrefprop_id = array_key_exists('dbxrefprop_id', $details) ? $details['dbxrefprop_id'] : '';
+ $this->dbxref_id = array_key_exists('dbxref_id', $details) ? $details['dbxref_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_DBXREFPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.dbxrefprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['dbxref_id'] = $this->dbxref_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->dbxrefprop_id = db_insert('chado.dbxrefprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['dbxref_id'] = $this->dbxref_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.dbxrefprop')
+ ->fields($fields)
+ ->condition('dbxrefprop_id', $this->dbxrefprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.dbxrefprop')
+ ->condition('dbxrefprop_id', $this->dbxrefprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the dbxrefprop_id.
+ *
+ * @retrun serial
+ */
+ public function getDbxrefpropID() {
+ return $this->dbxrefprop_id;
+ }
+
+ /**
+ * Updates the dbxrefprop_id.
+ *
+ * @param serial $dbxrefprop_id
+ */
+ public function setDbxrefpropID($dbxrefprop_id) {
+ $this->dbxrefprop_id = $dbxrefprop_id;
+ }
+
+ /**
+ * Retrieves the dbxref_id.
+ *
+ * @retrun integer
+ */
+ public function getDbxrefID() {
+ return $this->dbxref_id;
+ }
+
+ /**
+ * Updates the dbxref_id.
+ *
+ * @param integer $dbxref_id
+ */
+ public function setDbxrefID($dbxref_id) {
+ $this->dbxref_id = $dbxref_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_eimage.class.inc b/includes/class/chado_table_class/chado_eimage.class.inc
new file mode 100644
index 0000000..45051cc
--- /dev/null
+++ b/includes/class/chado_table_class/chado_eimage.class.inc
@@ -0,0 +1,283 @@
+ 'serial',
+ 'eimage_data' => 'text',
+ 'eimage_type' => 'character_varying(255)',
+ 'image_uri' => 'character_varying(255)',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->eimage_id = array_key_exists('eimage_id', $details) ? $details['eimage_id'] : '';
+ $this->eimage_data = array_key_exists('eimage_data', $details) ? $details['eimage_data'] : '';
+ $this->eimage_type = array_key_exists('eimage_type', $details) ? $details['eimage_type'] : '';
+ $this->image_uri = array_key_exists('image_uri', $details) ? $details['image_uri'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_EIMAGE by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.eimage WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['eimage_data'] = $this->eimage_data;
+ $fields['eimage_type'] = $this->eimage_type;
+ $fields['image_uri'] = $this->image_uri;
+
+
+ // Inserts the record.
+ $this->eimage_id = db_insert('chado.eimage')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['eimage_data'] = $this->eimage_data;
+ $fields['eimage_type'] = $this->eimage_type;
+ $fields['image_uri'] = $this->image_uri;
+
+
+ // Updates the record.
+ db_update('chado.eimage')
+ ->fields($fields)
+ ->condition('eimage_id', $this->eimage_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.eimage')
+ ->condition('eimage_id', $this->eimage_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the eimage_id.
+ *
+ * @retrun serial
+ */
+ public function getEimageID() {
+ return $this->eimage_id;
+ }
+
+ /**
+ * Updates the eimage_id.
+ *
+ * @param serial $eimage_id
+ */
+ public function setEimageID($eimage_id) {
+ $this->eimage_id = $eimage_id;
+ }
+
+ /**
+ * Retrieves the eimage_data.
+ *
+ * @retrun text
+ */
+ public function getEimageData() {
+ return $this->eimage_data;
+ }
+
+ /**
+ * Updates the eimage_data.
+ *
+ * @param text $eimage_data
+ */
+ public function setEimageData($eimage_data) {
+ $this->eimage_data = $eimage_data;
+ }
+
+ /**
+ * Retrieves the eimage_type.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getEimageType() {
+ return $this->eimage_type;
+ }
+
+ /**
+ * Updates the eimage_type.
+ *
+ * @param character_varying(255) $eimage_type
+ */
+ public function setEimageType($eimage_type) {
+ $this->eimage_type = $eimage_type;
+ }
+
+ /**
+ * Retrieves the image_uri.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getImageUri() {
+ return $this->image_uri;
+ }
+
+ /**
+ * Updates the image_uri.
+ *
+ * @param character_varying(255) $image_uri
+ */
+ public function setImageUri($image_uri) {
+ $this->image_uri = $image_uri;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_eimageprop.class.inc b/includes/class/chado_table_class/chado_eimageprop.class.inc
new file mode 100644
index 0000000..8b850bc
--- /dev/null
+++ b/includes/class/chado_table_class/chado_eimageprop.class.inc
@@ -0,0 +1,304 @@
+ 'serial',
+ 'eimage_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->eimageprop_id = array_key_exists('eimageprop_id', $details) ? $details['eimageprop_id'] : '';
+ $this->eimage_id = array_key_exists('eimage_id', $details) ? $details['eimage_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_EIMAGEPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.eimageprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['eimage_id'] = $this->eimage_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ if (is_numeric($this->rank)) { $fields['rank'] = $this->rank; }
+
+ // Inserts the record.
+ $this->eimageprop_id = db_insert('chado.eimageprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['eimage_id'] = $this->eimage_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ if (is_numeric($this->rank)) { $fields['rank'] = $this->rank; }
+
+ // Updates the record.
+ db_update('chado.eimageprop')
+ ->fields($fields)
+ ->condition('eimageprop_id', $this->eimageprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.eimageprop')
+ ->condition('eimageprop_id', $this->eimageprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the eimageprop_id.
+ *
+ * @retrun serial
+ */
+ public function getEimagepropID() {
+ return $this->eimageprop_id;
+ }
+
+ /**
+ * Updates the eimageprop_id.
+ *
+ * @param serial $eimageprop_id
+ */
+ public function setEimagepropID($eimageprop_id) {
+ $this->eimageprop_id = $eimageprop_id;
+ }
+
+ /**
+ * Retrieves the eimage_id.
+ *
+ * @retrun integer
+ */
+ public function getEimageID() {
+ return $this->eimage_id;
+ }
+
+ /**
+ * Updates the eimage_id.
+ *
+ * @param integer $eimage_id
+ */
+ public function setEimageID($eimage_id) {
+ $this->eimage_id = $eimage_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_feature.class.inc b/includes/class/chado_table_class/chado_feature.class.inc
new file mode 100644
index 0000000..4656508
--- /dev/null
+++ b/includes/class/chado_table_class/chado_feature.class.inc
@@ -0,0 +1,488 @@
+ 'serial',
+ 'dbxref_id' => 'integer',
+ 'organism_id' => 'integer',
+ 'name' => 'character_varying(255)',
+ 'uniquename' => 'text',
+ 'residues' => 'text',
+ 'seqlen' => 'integer',
+ 'md5checksum' => 'character(32)',
+ 'type_id' => 'integer',
+ 'is_analysis' => 'boolean',
+ 'is_obsolete' => 'boolean',
+ 'timeaccessioned' => 'timestamp_without_time_zone',
+ 'timelastmodified' => 'timestamp_without_time_zone',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->feature_id = array_key_exists('feature_id', $details) ? $details['feature_id'] : '';
+ $this->dbxref_id = array_key_exists('dbxref_id', $details) ? $details['dbxref_id'] : '';
+ $this->organism_id = array_key_exists('organism_id', $details) ? $details['organism_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->uniquename = array_key_exists('uniquename', $details) ? $details['uniquename'] : '';
+ $this->residues = array_key_exists('residues', $details) ? $details['residues'] : '';
+ $this->seqlen = array_key_exists('seqlen', $details) ? $details['seqlen'] : '';
+ $this->md5checksum = array_key_exists('md5checksum', $details) ? $details['md5checksum'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->is_analysis = array_key_exists('is_analysis', $details) ? $details['is_analysis'] : '';
+ $this->is_obsolete = array_key_exists('is_obsolete', $details) ? $details['is_obsolete'] : '';
+ $this->timeaccessioned = array_key_exists('timeaccessioned', $details) ? $details['timeaccessioned'] : '';
+ $this->timelastmodified = array_key_exists('timelastmodified', $details) ? $details['timelastmodified'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATURE by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.feature WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['organism_id'] = $this->organism_id;
+ $fields['name'] = $this->name;
+ $fields['uniquename'] = $this->uniquename;
+ $fields['residues'] = $this->residues;
+ $fields['md5checksum'] = $this->md5checksum;
+ $fields['type_id'] = $this->type_id;
+ $fields['is_analysis'] = (preg_match("/^(true|false)/i", $this->is_analysis)) ? "'" . $this->is_analysis . "'" : 'false';
+ $fields['is_obsolete'] = (preg_match("/^(true|false)/i", $this->is_obsolete)) ? "'" . $this->is_obsolete . "'" : 'false';
+ $fields['timeaccessioned'] = (!empty($this->timeaccessioned)) ? $this->timeaccessioned : 'now()';
+ $fields['timelastmodified'] = (!empty($this->timelastmodified)) ? $this->timelastmodified : 'now()';
+ if (is_numeric($this->dbxref_id)) { $fields['dbxref_id'] = $this->dbxref_id; }
+ if (is_numeric($this->seqlen)) { $fields['seqlen'] = $this->seqlen; }
+
+ // Inserts the record.
+ $this->feature_id = db_insert('chado.feature')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['organism_id'] = $this->organism_id;
+ $fields['name'] = $this->name;
+ $fields['uniquename'] = $this->uniquename;
+ $fields['residues'] = $this->residues;
+ $fields['md5checksum'] = $this->md5checksum;
+ $fields['type_id'] = $this->type_id;
+ $fields['is_analysis'] = (preg_match("/^(true|false)/i", $this->is_analysis)) ? "'" . $this->is_analysis . "'" : 'false';
+ $fields['is_obsolete'] = (preg_match("/^(true|false)/i", $this->is_obsolete)) ? "'" . $this->is_obsolete . "'" : 'false';
+ $fields['timeaccessioned'] = (!empty($this->timeaccessioned)) ? $this->timeaccessioned : 'now()';
+ $fields['timelastmodified'] = (!empty($this->timelastmodified)) ? $this->timelastmodified : 'now()';
+ if (is_numeric($this->dbxref_id)) { $fields['dbxref_id'] = $this->dbxref_id; }
+ if (is_numeric($this->seqlen)) { $fields['seqlen'] = $this->seqlen; }
+
+ // Updates the record.
+ db_update('chado.feature')
+ ->fields($fields)
+ ->condition('feature_id', $this->feature_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.feature')
+ ->condition('feature_id', $this->feature_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the feature_id.
+ *
+ * @retrun serial
+ */
+ public function getFeatureID() {
+ return $this->feature_id;
+ }
+
+ /**
+ * Updates the feature_id.
+ *
+ * @param serial $feature_id
+ */
+ public function setFeatureID($feature_id) {
+ $this->feature_id = $feature_id;
+ }
+
+ /**
+ * Retrieves the dbxref_id.
+ *
+ * @retrun integer
+ */
+ public function getDbxrefID() {
+ return $this->dbxref_id;
+ }
+
+ /**
+ * Updates the dbxref_id.
+ *
+ * @param integer $dbxref_id
+ */
+ public function setDbxrefID($dbxref_id) {
+ $this->dbxref_id = $dbxref_id;
+ }
+
+ /**
+ * Retrieves the organism_id.
+ *
+ * @retrun integer
+ */
+ public function getOrganismID() {
+ return $this->organism_id;
+ }
+
+ /**
+ * Updates the organism_id.
+ *
+ * @param integer $organism_id
+ */
+ public function setOrganismID($organism_id) {
+ $this->organism_id = $organism_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the uniquename.
+ *
+ * @retrun text
+ */
+ public function getUniquename() {
+ return $this->uniquename;
+ }
+
+ /**
+ * Updates the uniquename.
+ *
+ * @param text $uniquename
+ */
+ public function setUniquename($uniquename) {
+ $this->uniquename = $uniquename;
+ }
+
+ /**
+ * Retrieves the residues.
+ *
+ * @retrun text
+ */
+ public function getResidues() {
+ return $this->residues;
+ }
+
+ /**
+ * Updates the residues.
+ *
+ * @param text $residues
+ */
+ public function setResidues($residues) {
+ $this->residues = $residues;
+ }
+
+ /**
+ * Retrieves the seqlen.
+ *
+ * @retrun integer
+ */
+ public function getSeqlen() {
+ return $this->seqlen;
+ }
+
+ /**
+ * Updates the seqlen.
+ *
+ * @param integer $seqlen
+ */
+ public function setSeqlen($seqlen) {
+ $this->seqlen = $seqlen;
+ }
+
+ /**
+ * Retrieves the md5checksum.
+ *
+ * @retrun character(32)
+ */
+ public function getMd5checksum() {
+ return $this->md5checksum;
+ }
+
+ /**
+ * Updates the md5checksum.
+ *
+ * @param character(32) $md5checksum
+ */
+ public function setMd5checksum($md5checksum) {
+ $this->md5checksum = $md5checksum;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the is_analysis.
+ *
+ * @retrun boolean
+ */
+ public function getIsAnalysis() {
+ return $this->is_analysis;
+ }
+
+ /**
+ * Updates the is_analysis.
+ *
+ * @param boolean $is_analysis
+ */
+ public function setIsAnalysis($is_analysis) {
+ $this->is_analysis = $is_analysis;
+ }
+
+ /**
+ * Retrieves the is_obsolete.
+ *
+ * @retrun boolean
+ */
+ public function getIsObsolete() {
+ return $this->is_obsolete;
+ }
+
+ /**
+ * Updates the is_obsolete.
+ *
+ * @param boolean $is_obsolete
+ */
+ public function setIsObsolete($is_obsolete) {
+ $this->is_obsolete = $is_obsolete;
+ }
+
+ /**
+ * Retrieves the timeaccessioned.
+ *
+ * @retrun timestamp_without_time_zone
+ */
+ public function getTimeaccessioned() {
+ return $this->timeaccessioned;
+ }
+
+ /**
+ * Updates the timeaccessioned.
+ *
+ * @param timestamp_without_time_zone $timeaccessioned
+ */
+ public function setTimeaccessioned($timeaccessioned) {
+ $this->timeaccessioned = $timeaccessioned;
+ }
+
+ /**
+ * Retrieves the timelastmodified.
+ *
+ * @retrun timestamp_without_time_zone
+ */
+ public function getTimelastmodified() {
+ return $this->timelastmodified;
+ }
+
+ /**
+ * Updates the timelastmodified.
+ *
+ * @param timestamp_without_time_zone $timelastmodified
+ */
+ public function setTimelastmodified($timelastmodified) {
+ $this->timelastmodified = $timelastmodified;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_feature_cvterm.class.inc b/includes/class/chado_table_class/chado_feature_cvterm.class.inc
new file mode 100644
index 0000000..8165011
--- /dev/null
+++ b/includes/class/chado_table_class/chado_feature_cvterm.class.inc
@@ -0,0 +1,329 @@
+ 'serial',
+ 'feature_id' => 'integer',
+ 'cvterm_id' => 'integer',
+ 'pub_id' => 'integer',
+ 'is_not' => 'boolean',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->feature_cvterm_id = array_key_exists('feature_cvterm_id', $details) ? $details['feature_cvterm_id'] : '';
+ $this->feature_id = array_key_exists('feature_id', $details) ? $details['feature_id'] : '';
+ $this->cvterm_id = array_key_exists('cvterm_id', $details) ? $details['cvterm_id'] : '';
+ $this->pub_id = array_key_exists('pub_id', $details) ? $details['pub_id'] : '';
+ $this->is_not = array_key_exists('is_not', $details) ? $details['is_not'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATURE_CVTERM by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.feature_cvterm WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['cvterm_id'] = $this->cvterm_id;
+ $fields['pub_id'] = $this->pub_id;
+ $fields['is_not'] = (preg_match("/^(true|false)/i", $this->is_not)) ? "'" . $this->is_not . "'" : 'false';
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->feature_cvterm_id = db_insert('chado.feature_cvterm')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['cvterm_id'] = $this->cvterm_id;
+ $fields['pub_id'] = $this->pub_id;
+ $fields['is_not'] = (preg_match("/^(true|false)/i", $this->is_not)) ? "'" . $this->is_not . "'" : 'false';
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.feature_cvterm')
+ ->fields($fields)
+ ->condition('feature_cvterm_id', $this->feature_cvterm_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.feature_cvterm')
+ ->condition('feature_cvterm_id', $this->feature_cvterm_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the feature_cvterm_id.
+ *
+ * @retrun serial
+ */
+ public function getFeatureCvtermID() {
+ return $this->feature_cvterm_id;
+ }
+
+ /**
+ * Updates the feature_cvterm_id.
+ *
+ * @param serial $feature_cvterm_id
+ */
+ public function setFeatureCvtermID($feature_cvterm_id) {
+ $this->feature_cvterm_id = $feature_cvterm_id;
+ }
+
+ /**
+ * Retrieves the feature_id.
+ *
+ * @retrun integer
+ */
+ public function getFeatureID() {
+ return $this->feature_id;
+ }
+
+ /**
+ * Updates the feature_id.
+ *
+ * @param integer $feature_id
+ */
+ public function setFeatureID($feature_id) {
+ $this->feature_id = $feature_id;
+ }
+
+ /**
+ * Retrieves the cvterm_id.
+ *
+ * @retrun integer
+ */
+ public function getCvtermID() {
+ return $this->cvterm_id;
+ }
+
+ /**
+ * Updates the cvterm_id.
+ *
+ * @param integer $cvterm_id
+ */
+ public function setCvtermID($cvterm_id) {
+ $this->cvterm_id = $cvterm_id;
+ }
+
+ /**
+ * Retrieves the pub_id.
+ *
+ * @retrun integer
+ */
+ public function getPubID() {
+ return $this->pub_id;
+ }
+
+ /**
+ * Updates the pub_id.
+ *
+ * @param integer $pub_id
+ */
+ public function setPubID($pub_id) {
+ $this->pub_id = $pub_id;
+ }
+
+ /**
+ * Retrieves the is_not.
+ *
+ * @retrun boolean
+ */
+ public function getIsNot() {
+ return $this->is_not;
+ }
+
+ /**
+ * Updates the is_not.
+ *
+ * @param boolean $is_not
+ */
+ public function setIsNot($is_not) {
+ $this->is_not = $is_not;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_feature_dbxref.class.inc b/includes/class/chado_table_class/chado_feature_dbxref.class.inc
new file mode 100644
index 0000000..1e83b61
--- /dev/null
+++ b/includes/class/chado_table_class/chado_feature_dbxref.class.inc
@@ -0,0 +1,283 @@
+ 'serial',
+ 'feature_id' => 'integer',
+ 'dbxref_id' => 'integer',
+ 'is_current' => 'boolean',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->feature_dbxref_id = array_key_exists('feature_dbxref_id', $details) ? $details['feature_dbxref_id'] : '';
+ $this->feature_id = array_key_exists('feature_id', $details) ? $details['feature_id'] : '';
+ $this->dbxref_id = array_key_exists('dbxref_id', $details) ? $details['dbxref_id'] : '';
+ $this->is_current = array_key_exists('is_current', $details) ? $details['is_current'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATURE_DBXREF by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.feature_dbxref WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['dbxref_id'] = $this->dbxref_id;
+ $fields['is_current'] = (preg_match("/^(true|false)/i", $this->is_current)) ? "'" . $this->is_current . "'" : 'true';
+
+
+ // Inserts the record.
+ $this->feature_dbxref_id = db_insert('chado.feature_dbxref')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['dbxref_id'] = $this->dbxref_id;
+ $fields['is_current'] = (preg_match("/^(true|false)/i", $this->is_current)) ? "'" . $this->is_current . "'" : 'true';
+
+
+ // Updates the record.
+ db_update('chado.feature_dbxref')
+ ->fields($fields)
+ ->condition('feature_dbxref_id', $this->feature_dbxref_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.feature_dbxref')
+ ->condition('feature_dbxref_id', $this->feature_dbxref_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the feature_dbxref_id.
+ *
+ * @retrun serial
+ */
+ public function getFeatureDbxrefID() {
+ return $this->feature_dbxref_id;
+ }
+
+ /**
+ * Updates the feature_dbxref_id.
+ *
+ * @param serial $feature_dbxref_id
+ */
+ public function setFeatureDbxrefID($feature_dbxref_id) {
+ $this->feature_dbxref_id = $feature_dbxref_id;
+ }
+
+ /**
+ * Retrieves the feature_id.
+ *
+ * @retrun integer
+ */
+ public function getFeatureID() {
+ return $this->feature_id;
+ }
+
+ /**
+ * Updates the feature_id.
+ *
+ * @param integer $feature_id
+ */
+ public function setFeatureID($feature_id) {
+ $this->feature_id = $feature_id;
+ }
+
+ /**
+ * Retrieves the dbxref_id.
+ *
+ * @retrun integer
+ */
+ public function getDbxrefID() {
+ return $this->dbxref_id;
+ }
+
+ /**
+ * Updates the dbxref_id.
+ *
+ * @param integer $dbxref_id
+ */
+ public function setDbxrefID($dbxref_id) {
+ $this->dbxref_id = $dbxref_id;
+ }
+
+ /**
+ * Retrieves the is_current.
+ *
+ * @retrun boolean
+ */
+ public function getIsCurrent() {
+ return $this->is_current;
+ }
+
+ /**
+ * Updates the is_current.
+ *
+ * @param boolean $is_current
+ */
+ public function setIsCurrent($is_current) {
+ $this->is_current = $is_current;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_feature_genotype.class.inc b/includes/class/chado_table_class/chado_feature_genotype.class.inc
new file mode 100644
index 0000000..3282fdb
--- /dev/null
+++ b/includes/class/chado_table_class/chado_feature_genotype.class.inc
@@ -0,0 +1,350 @@
+ 'serial',
+ 'feature_id' => 'integer',
+ 'genotype_id' => 'integer',
+ 'chromosome_id' => 'integer',
+ 'rank' => 'integer',
+ 'cgroup' => 'integer',
+ 'cvterm_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->feature_genotype_id = array_key_exists('feature_genotype_id', $details) ? $details['feature_genotype_id'] : '';
+ $this->feature_id = array_key_exists('feature_id', $details) ? $details['feature_id'] : '';
+ $this->genotype_id = array_key_exists('genotype_id', $details) ? $details['genotype_id'] : '';
+ $this->chromosome_id = array_key_exists('chromosome_id', $details) ? $details['chromosome_id'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : '';
+ $this->cgroup = array_key_exists('cgroup', $details) ? $details['cgroup'] : '';
+ $this->cvterm_id = array_key_exists('cvterm_id', $details) ? $details['cvterm_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATURE_GENOTYPE by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.feature_genotype WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['genotype_id'] = $this->genotype_id;
+ $fields['rank'] = $this->rank;
+ $fields['cgroup'] = $this->cgroup;
+ $fields['cvterm_id'] = $this->cvterm_id;
+ if (is_numeric($this->chromosome_id)) { $fields['chromosome_id'] = $this->chromosome_id; }
+
+ // Inserts the record.
+ $this->feature_genotype_id = db_insert('chado.feature_genotype')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['genotype_id'] = $this->genotype_id;
+ $fields['rank'] = $this->rank;
+ $fields['cgroup'] = $this->cgroup;
+ $fields['cvterm_id'] = $this->cvterm_id;
+ if (is_numeric($this->chromosome_id)) { $fields['chromosome_id'] = $this->chromosome_id; }
+
+ // Updates the record.
+ db_update('chado.feature_genotype')
+ ->fields($fields)
+ ->condition('feature_genotype_id', $this->feature_genotype_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.feature_genotype')
+ ->condition('feature_genotype_id', $this->feature_genotype_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the feature_genotype_id.
+ *
+ * @retrun serial
+ */
+ public function getFeatureGenotypeID() {
+ return $this->feature_genotype_id;
+ }
+
+ /**
+ * Updates the feature_genotype_id.
+ *
+ * @param serial $feature_genotype_id
+ */
+ public function setFeatureGenotypeID($feature_genotype_id) {
+ $this->feature_genotype_id = $feature_genotype_id;
+ }
+
+ /**
+ * Retrieves the feature_id.
+ *
+ * @retrun integer
+ */
+ public function getFeatureID() {
+ return $this->feature_id;
+ }
+
+ /**
+ * Updates the feature_id.
+ *
+ * @param integer $feature_id
+ */
+ public function setFeatureID($feature_id) {
+ $this->feature_id = $feature_id;
+ }
+
+ /**
+ * Retrieves the genotype_id.
+ *
+ * @retrun integer
+ */
+ public function getGenotypeID() {
+ return $this->genotype_id;
+ }
+
+ /**
+ * Updates the genotype_id.
+ *
+ * @param integer $genotype_id
+ */
+ public function setGenotypeID($genotype_id) {
+ $this->genotype_id = $genotype_id;
+ }
+
+ /**
+ * Retrieves the chromosome_id.
+ *
+ * @retrun integer
+ */
+ public function getChromosomeID() {
+ return $this->chromosome_id;
+ }
+
+ /**
+ * Updates the chromosome_id.
+ *
+ * @param integer $chromosome_id
+ */
+ public function setChromosomeID($chromosome_id) {
+ $this->chromosome_id = $chromosome_id;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+
+ /**
+ * Retrieves the cgroup.
+ *
+ * @retrun integer
+ */
+ public function getCgroup() {
+ return $this->cgroup;
+ }
+
+ /**
+ * Updates the cgroup.
+ *
+ * @param integer $cgroup
+ */
+ public function setCgroup($cgroup) {
+ $this->cgroup = $cgroup;
+ }
+
+ /**
+ * Retrieves the cvterm_id.
+ *
+ * @retrun integer
+ */
+ public function getCvtermID() {
+ return $this->cvterm_id;
+ }
+
+ /**
+ * Updates the cvterm_id.
+ *
+ * @param integer $cvterm_id
+ */
+ public function setCvtermID($cvterm_id) {
+ $this->cvterm_id = $cvterm_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_feature_project.class.inc b/includes/class/chado_table_class/chado_feature_project.class.inc
new file mode 100644
index 0000000..58b600e
--- /dev/null
+++ b/includes/class/chado_table_class/chado_feature_project.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'feature_id' => 'integer',
+ 'project_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->feature_project_id = array_key_exists('feature_project_id', $details) ? $details['feature_project_id'] : '';
+ $this->feature_id = array_key_exists('feature_id', $details) ? $details['feature_id'] : '';
+ $this->project_id = array_key_exists('project_id', $details) ? $details['project_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATURE_PROJECT by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.feature_project WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['project_id'] = $this->project_id;
+
+
+ // Inserts the record.
+ $this->feature_project_id = db_insert('chado.feature_project')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['project_id'] = $this->project_id;
+
+
+ // Updates the record.
+ db_update('chado.feature_project')
+ ->fields($fields)
+ ->condition('feature_project_id', $this->feature_project_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.feature_project')
+ ->condition('feature_project_id', $this->feature_project_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the feature_project_id.
+ *
+ * @retrun serial
+ */
+ public function getFeatureProjectID() {
+ return $this->feature_project_id;
+ }
+
+ /**
+ * Updates the feature_project_id.
+ *
+ * @param serial $feature_project_id
+ */
+ public function setFeatureProjectID($feature_project_id) {
+ $this->feature_project_id = $feature_project_id;
+ }
+
+ /**
+ * Retrieves the feature_id.
+ *
+ * @retrun integer
+ */
+ public function getFeatureID() {
+ return $this->feature_id;
+ }
+
+ /**
+ * Updates the feature_id.
+ *
+ * @param integer $feature_id
+ */
+ public function setFeatureID($feature_id) {
+ $this->feature_id = $feature_id;
+ }
+
+ /**
+ * Retrieves the project_id.
+ *
+ * @retrun integer
+ */
+ public function getProjectID() {
+ return $this->project_id;
+ }
+
+ /**
+ * Updates the project_id.
+ *
+ * @param integer $project_id
+ */
+ public function setProjectID($project_id) {
+ $this->project_id = $project_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_feature_pub.class.inc b/includes/class/chado_table_class/chado_feature_pub.class.inc
new file mode 100644
index 0000000..0e6154b
--- /dev/null
+++ b/includes/class/chado_table_class/chado_feature_pub.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'feature_id' => 'integer',
+ 'pub_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->feature_pub_id = array_key_exists('feature_pub_id', $details) ? $details['feature_pub_id'] : '';
+ $this->feature_id = array_key_exists('feature_id', $details) ? $details['feature_id'] : '';
+ $this->pub_id = array_key_exists('pub_id', $details) ? $details['pub_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATURE_PUB by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.feature_pub WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Inserts the record.
+ $this->feature_pub_id = db_insert('chado.feature_pub')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Updates the record.
+ db_update('chado.feature_pub')
+ ->fields($fields)
+ ->condition('feature_pub_id', $this->feature_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.feature_pub')
+ ->condition('feature_pub_id', $this->feature_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the feature_pub_id.
+ *
+ * @retrun serial
+ */
+ public function getFeaturePubID() {
+ return $this->feature_pub_id;
+ }
+
+ /**
+ * Updates the feature_pub_id.
+ *
+ * @param serial $feature_pub_id
+ */
+ public function setFeaturePubID($feature_pub_id) {
+ $this->feature_pub_id = $feature_pub_id;
+ }
+
+ /**
+ * Retrieves the feature_id.
+ *
+ * @retrun integer
+ */
+ public function getFeatureID() {
+ return $this->feature_id;
+ }
+
+ /**
+ * Updates the feature_id.
+ *
+ * @param integer $feature_id
+ */
+ public function setFeatureID($feature_id) {
+ $this->feature_id = $feature_id;
+ }
+
+ /**
+ * Retrieves the pub_id.
+ *
+ * @retrun integer
+ */
+ public function getPubID() {
+ return $this->pub_id;
+ }
+
+ /**
+ * Updates the pub_id.
+ *
+ * @param integer $pub_id
+ */
+ public function setPubID($pub_id) {
+ $this->pub_id = $pub_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_feature_relationship.class.inc b/includes/class/chado_table_class/chado_feature_relationship.class.inc
new file mode 100644
index 0000000..d012c7d
--- /dev/null
+++ b/includes/class/chado_table_class/chado_feature_relationship.class.inc
@@ -0,0 +1,329 @@
+ 'serial',
+ 'subject_id' => 'integer',
+ 'object_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->feature_relationship_id = array_key_exists('feature_relationship_id', $details) ? $details['feature_relationship_id'] : '';
+ $this->subject_id = array_key_exists('subject_id', $details) ? $details['subject_id'] : '';
+ $this->object_id = array_key_exists('object_id', $details) ? $details['object_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATURE_RELATIONSHIP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.feature_relationship WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['subject_id'] = $this->subject_id;
+ $fields['object_id'] = $this->object_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->feature_relationship_id = db_insert('chado.feature_relationship')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['subject_id'] = $this->subject_id;
+ $fields['object_id'] = $this->object_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.feature_relationship')
+ ->fields($fields)
+ ->condition('feature_relationship_id', $this->feature_relationship_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.feature_relationship')
+ ->condition('feature_relationship_id', $this->feature_relationship_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the feature_relationship_id.
+ *
+ * @retrun serial
+ */
+ public function getFeatureRelationshipID() {
+ return $this->feature_relationship_id;
+ }
+
+ /**
+ * Updates the feature_relationship_id.
+ *
+ * @param serial $feature_relationship_id
+ */
+ public function setFeatureRelationshipID($feature_relationship_id) {
+ $this->feature_relationship_id = $feature_relationship_id;
+ }
+
+ /**
+ * Retrieves the subject_id.
+ *
+ * @retrun integer
+ */
+ public function getSubjectID() {
+ return $this->subject_id;
+ }
+
+ /**
+ * Updates the subject_id.
+ *
+ * @param integer $subject_id
+ */
+ public function setSubjectID($subject_id) {
+ $this->subject_id = $subject_id;
+ }
+
+ /**
+ * Retrieves the object_id.
+ *
+ * @retrun integer
+ */
+ public function getObjectID() {
+ return $this->object_id;
+ }
+
+ /**
+ * Updates the object_id.
+ *
+ * @param integer $object_id
+ */
+ public function setObjectID($object_id) {
+ $this->object_id = $object_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_feature_synonym.class.inc b/includes/class/chado_table_class/chado_feature_synonym.class.inc
new file mode 100644
index 0000000..86ed879
--- /dev/null
+++ b/includes/class/chado_table_class/chado_feature_synonym.class.inc
@@ -0,0 +1,329 @@
+ 'serial',
+ 'synonym_id' => 'integer',
+ 'feature_id' => 'integer',
+ 'pub_id' => 'integer',
+ 'is_current' => 'boolean',
+ 'is_internal' => 'boolean',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->feature_synonym_id = array_key_exists('feature_synonym_id', $details) ? $details['feature_synonym_id'] : '';
+ $this->synonym_id = array_key_exists('synonym_id', $details) ? $details['synonym_id'] : '';
+ $this->feature_id = array_key_exists('feature_id', $details) ? $details['feature_id'] : '';
+ $this->pub_id = array_key_exists('pub_id', $details) ? $details['pub_id'] : '';
+ $this->is_current = array_key_exists('is_current', $details) ? $details['is_current'] : '';
+ $this->is_internal = array_key_exists('is_internal', $details) ? $details['is_internal'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATURE_SYNONYM by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.feature_synonym WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['synonym_id'] = $this->synonym_id;
+ $fields['feature_id'] = $this->feature_id;
+ $fields['pub_id'] = $this->pub_id;
+ $fields['is_current'] = (preg_match("/^(true|false)/i", $this->is_current)) ? "'" . $this->is_current . "'" : 'false';
+ $fields['is_internal'] = (preg_match("/^(true|false)/i", $this->is_internal)) ? "'" . $this->is_internal . "'" : 'false';
+
+
+ // Inserts the record.
+ $this->feature_synonym_id = db_insert('chado.feature_synonym')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['synonym_id'] = $this->synonym_id;
+ $fields['feature_id'] = $this->feature_id;
+ $fields['pub_id'] = $this->pub_id;
+ $fields['is_current'] = (preg_match("/^(true|false)/i", $this->is_current)) ? "'" . $this->is_current . "'" : 'false';
+ $fields['is_internal'] = (preg_match("/^(true|false)/i", $this->is_internal)) ? "'" . $this->is_internal . "'" : 'false';
+
+
+ // Updates the record.
+ db_update('chado.feature_synonym')
+ ->fields($fields)
+ ->condition('feature_synonym_id', $this->feature_synonym_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.feature_synonym')
+ ->condition('feature_synonym_id', $this->feature_synonym_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the feature_synonym_id.
+ *
+ * @retrun serial
+ */
+ public function getFeatureSynonymID() {
+ return $this->feature_synonym_id;
+ }
+
+ /**
+ * Updates the feature_synonym_id.
+ *
+ * @param serial $feature_synonym_id
+ */
+ public function setFeatureSynonymID($feature_synonym_id) {
+ $this->feature_synonym_id = $feature_synonym_id;
+ }
+
+ /**
+ * Retrieves the synonym_id.
+ *
+ * @retrun integer
+ */
+ public function getSynonymID() {
+ return $this->synonym_id;
+ }
+
+ /**
+ * Updates the synonym_id.
+ *
+ * @param integer $synonym_id
+ */
+ public function setSynonymID($synonym_id) {
+ $this->synonym_id = $synonym_id;
+ }
+
+ /**
+ * Retrieves the feature_id.
+ *
+ * @retrun integer
+ */
+ public function getFeatureID() {
+ return $this->feature_id;
+ }
+
+ /**
+ * Updates the feature_id.
+ *
+ * @param integer $feature_id
+ */
+ public function setFeatureID($feature_id) {
+ $this->feature_id = $feature_id;
+ }
+
+ /**
+ * Retrieves the pub_id.
+ *
+ * @retrun integer
+ */
+ public function getPubID() {
+ return $this->pub_id;
+ }
+
+ /**
+ * Updates the pub_id.
+ *
+ * @param integer $pub_id
+ */
+ public function setPubID($pub_id) {
+ $this->pub_id = $pub_id;
+ }
+
+ /**
+ * Retrieves the is_current.
+ *
+ * @retrun boolean
+ */
+ public function getIsCurrent() {
+ return $this->is_current;
+ }
+
+ /**
+ * Updates the is_current.
+ *
+ * @param boolean $is_current
+ */
+ public function setIsCurrent($is_current) {
+ $this->is_current = $is_current;
+ }
+
+ /**
+ * Retrieves the is_internal.
+ *
+ * @retrun boolean
+ */
+ public function getIsInternal() {
+ return $this->is_internal;
+ }
+
+ /**
+ * Updates the is_internal.
+ *
+ * @param boolean $is_internal
+ */
+ public function setIsInternal($is_internal) {
+ $this->is_internal = $is_internal;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_featuremap.class.inc b/includes/class/chado_table_class/chado_featuremap.class.inc
new file mode 100644
index 0000000..4811754
--- /dev/null
+++ b/includes/class/chado_table_class/chado_featuremap.class.inc
@@ -0,0 +1,281 @@
+ 'serial',
+ 'name' => 'character_varying(255)',
+ 'description' => 'text',
+ 'unittype_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->featuremap_id = array_key_exists('featuremap_id', $details) ? $details['featuremap_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->description = array_key_exists('description', $details) ? $details['description'] : '';
+ $this->unittype_id = array_key_exists('unittype_id', $details) ? $details['unittype_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATUREMAP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.featuremap WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['description'] = $this->description;
+ if (is_numeric($this->unittype_id)) { $fields['unittype_id'] = $this->unittype_id; }
+
+ // Inserts the record.
+ $this->featuremap_id = db_insert('chado.featuremap')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['description'] = $this->description;
+ if (is_numeric($this->unittype_id)) { $fields['unittype_id'] = $this->unittype_id; }
+
+ // Updates the record.
+ db_update('chado.featuremap')
+ ->fields($fields)
+ ->condition('featuremap_id', $this->featuremap_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.featuremap')
+ ->condition('featuremap_id', $this->featuremap_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the featuremap_id.
+ *
+ * @retrun serial
+ */
+ public function getFeaturemapID() {
+ return $this->featuremap_id;
+ }
+
+ /**
+ * Updates the featuremap_id.
+ *
+ * @param serial $featuremap_id
+ */
+ public function setFeaturemapID($featuremap_id) {
+ $this->featuremap_id = $featuremap_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the description.
+ *
+ * @retrun text
+ */
+ public function getDescription() {
+ return $this->description;
+ }
+
+ /**
+ * Updates the description.
+ *
+ * @param text $description
+ */
+ public function setDescription($description) {
+ $this->description = $description;
+ }
+
+ /**
+ * Retrieves the unittype_id.
+ *
+ * @retrun integer
+ */
+ public function getUnittypeID() {
+ return $this->unittype_id;
+ }
+
+ /**
+ * Updates the unittype_id.
+ *
+ * @param integer $unittype_id
+ */
+ public function setUnittypeID($unittype_id) {
+ $this->unittype_id = $unittype_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_featuremap_contact.class.inc b/includes/class/chado_table_class/chado_featuremap_contact.class.inc
new file mode 100644
index 0000000..d435516
--- /dev/null
+++ b/includes/class/chado_table_class/chado_featuremap_contact.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'featuremap_id' => 'integer',
+ 'contact_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->featuremap_contact_id = array_key_exists('featuremap_contact_id', $details) ? $details['featuremap_contact_id'] : '';
+ $this->featuremap_id = array_key_exists('featuremap_id', $details) ? $details['featuremap_id'] : '';
+ $this->contact_id = array_key_exists('contact_id', $details) ? $details['contact_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATUREMAP_CONTACT by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.featuremap_contact WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featuremap_id'] = $this->featuremap_id;
+ $fields['contact_id'] = $this->contact_id;
+
+
+ // Inserts the record.
+ $this->featuremap_contact_id = db_insert('chado.featuremap_contact')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featuremap_id'] = $this->featuremap_id;
+ $fields['contact_id'] = $this->contact_id;
+
+
+ // Updates the record.
+ db_update('chado.featuremap_contact')
+ ->fields($fields)
+ ->condition('featuremap_contact_id', $this->featuremap_contact_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.featuremap_contact')
+ ->condition('featuremap_contact_id', $this->featuremap_contact_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the featuremap_contact_id.
+ *
+ * @retrun serial
+ */
+ public function getFeaturemapContactID() {
+ return $this->featuremap_contact_id;
+ }
+
+ /**
+ * Updates the featuremap_contact_id.
+ *
+ * @param serial $featuremap_contact_id
+ */
+ public function setFeaturemapContactID($featuremap_contact_id) {
+ $this->featuremap_contact_id = $featuremap_contact_id;
+ }
+
+ /**
+ * Retrieves the featuremap_id.
+ *
+ * @retrun integer
+ */
+ public function getFeaturemapID() {
+ return $this->featuremap_id;
+ }
+
+ /**
+ * Updates the featuremap_id.
+ *
+ * @param integer $featuremap_id
+ */
+ public function setFeaturemapID($featuremap_id) {
+ $this->featuremap_id = $featuremap_id;
+ }
+
+ /**
+ * Retrieves the contact_id.
+ *
+ * @retrun integer
+ */
+ public function getContactID() {
+ return $this->contact_id;
+ }
+
+ /**
+ * Updates the contact_id.
+ *
+ * @param integer $contact_id
+ */
+ public function setContactID($contact_id) {
+ $this->contact_id = $contact_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_featuremap_organism.class.inc b/includes/class/chado_table_class/chado_featuremap_organism.class.inc
new file mode 100644
index 0000000..ba4052b
--- /dev/null
+++ b/includes/class/chado_table_class/chado_featuremap_organism.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'featuremap_id' => 'integer',
+ 'organism_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->featuremap_organism_id = array_key_exists('featuremap_organism_id', $details) ? $details['featuremap_organism_id'] : '';
+ $this->featuremap_id = array_key_exists('featuremap_id', $details) ? $details['featuremap_id'] : '';
+ $this->organism_id = array_key_exists('organism_id', $details) ? $details['organism_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATUREMAP_ORGANISM by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.featuremap_organism WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featuremap_id'] = $this->featuremap_id;
+ $fields['organism_id'] = $this->organism_id;
+
+
+ // Inserts the record.
+ $this->featuremap_organism_id = db_insert('chado.featuremap_organism')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featuremap_id'] = $this->featuremap_id;
+ $fields['organism_id'] = $this->organism_id;
+
+
+ // Updates the record.
+ db_update('chado.featuremap_organism')
+ ->fields($fields)
+ ->condition('featuremap_organism_id', $this->featuremap_organism_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.featuremap_organism')
+ ->condition('featuremap_organism_id', $this->featuremap_organism_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the featuremap_organism_id.
+ *
+ * @retrun serial
+ */
+ public function getFeaturemapOrganismID() {
+ return $this->featuremap_organism_id;
+ }
+
+ /**
+ * Updates the featuremap_organism_id.
+ *
+ * @param serial $featuremap_organism_id
+ */
+ public function setFeaturemapOrganismID($featuremap_organism_id) {
+ $this->featuremap_organism_id = $featuremap_organism_id;
+ }
+
+ /**
+ * Retrieves the featuremap_id.
+ *
+ * @retrun integer
+ */
+ public function getFeaturemapID() {
+ return $this->featuremap_id;
+ }
+
+ /**
+ * Updates the featuremap_id.
+ *
+ * @param integer $featuremap_id
+ */
+ public function setFeaturemapID($featuremap_id) {
+ $this->featuremap_id = $featuremap_id;
+ }
+
+ /**
+ * Retrieves the organism_id.
+ *
+ * @retrun integer
+ */
+ public function getOrganismID() {
+ return $this->organism_id;
+ }
+
+ /**
+ * Updates the organism_id.
+ *
+ * @param integer $organism_id
+ */
+ public function setOrganismID($organism_id) {
+ $this->organism_id = $organism_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_featuremap_pub.class.inc b/includes/class/chado_table_class/chado_featuremap_pub.class.inc
new file mode 100644
index 0000000..b27a4a6
--- /dev/null
+++ b/includes/class/chado_table_class/chado_featuremap_pub.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'featuremap_id' => 'integer',
+ 'pub_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->featuremap_pub_id = array_key_exists('featuremap_pub_id', $details) ? $details['featuremap_pub_id'] : '';
+ $this->featuremap_id = array_key_exists('featuremap_id', $details) ? $details['featuremap_id'] : '';
+ $this->pub_id = array_key_exists('pub_id', $details) ? $details['pub_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATUREMAP_PUB by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.featuremap_pub WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featuremap_id'] = $this->featuremap_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Inserts the record.
+ $this->featuremap_pub_id = db_insert('chado.featuremap_pub')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featuremap_id'] = $this->featuremap_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Updates the record.
+ db_update('chado.featuremap_pub')
+ ->fields($fields)
+ ->condition('featuremap_pub_id', $this->featuremap_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.featuremap_pub')
+ ->condition('featuremap_pub_id', $this->featuremap_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the featuremap_pub_id.
+ *
+ * @retrun serial
+ */
+ public function getFeaturemapPubID() {
+ return $this->featuremap_pub_id;
+ }
+
+ /**
+ * Updates the featuremap_pub_id.
+ *
+ * @param serial $featuremap_pub_id
+ */
+ public function setFeaturemapPubID($featuremap_pub_id) {
+ $this->featuremap_pub_id = $featuremap_pub_id;
+ }
+
+ /**
+ * Retrieves the featuremap_id.
+ *
+ * @retrun integer
+ */
+ public function getFeaturemapID() {
+ return $this->featuremap_id;
+ }
+
+ /**
+ * Updates the featuremap_id.
+ *
+ * @param integer $featuremap_id
+ */
+ public function setFeaturemapID($featuremap_id) {
+ $this->featuremap_id = $featuremap_id;
+ }
+
+ /**
+ * Retrieves the pub_id.
+ *
+ * @retrun integer
+ */
+ public function getPubID() {
+ return $this->pub_id;
+ }
+
+ /**
+ * Updates the pub_id.
+ *
+ * @param integer $pub_id
+ */
+ public function setPubID($pub_id) {
+ $this->pub_id = $pub_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_featuremap_stock.class.inc b/includes/class/chado_table_class/chado_featuremap_stock.class.inc
new file mode 100644
index 0000000..d75beb1
--- /dev/null
+++ b/includes/class/chado_table_class/chado_featuremap_stock.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'featuremap_id' => 'integer',
+ 'stock_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->featuremap_stock_id = array_key_exists('featuremap_stock_id', $details) ? $details['featuremap_stock_id'] : '';
+ $this->featuremap_id = array_key_exists('featuremap_id', $details) ? $details['featuremap_id'] : '';
+ $this->stock_id = array_key_exists('stock_id', $details) ? $details['stock_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATUREMAP_STOCK by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.featuremap_stock WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featuremap_id'] = $this->featuremap_id;
+ $fields['stock_id'] = $this->stock_id;
+
+
+ // Inserts the record.
+ $this->featuremap_stock_id = db_insert('chado.featuremap_stock')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featuremap_id'] = $this->featuremap_id;
+ $fields['stock_id'] = $this->stock_id;
+
+
+ // Updates the record.
+ db_update('chado.featuremap_stock')
+ ->fields($fields)
+ ->condition('featuremap_stock_id', $this->featuremap_stock_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.featuremap_stock')
+ ->condition('featuremap_stock_id', $this->featuremap_stock_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the featuremap_stock_id.
+ *
+ * @retrun serial
+ */
+ public function getFeaturemapStockID() {
+ return $this->featuremap_stock_id;
+ }
+
+ /**
+ * Updates the featuremap_stock_id.
+ *
+ * @param serial $featuremap_stock_id
+ */
+ public function setFeaturemapStockID($featuremap_stock_id) {
+ $this->featuremap_stock_id = $featuremap_stock_id;
+ }
+
+ /**
+ * Retrieves the featuremap_id.
+ *
+ * @retrun integer
+ */
+ public function getFeaturemapID() {
+ return $this->featuremap_id;
+ }
+
+ /**
+ * Updates the featuremap_id.
+ *
+ * @param integer $featuremap_id
+ */
+ public function setFeaturemapID($featuremap_id) {
+ $this->featuremap_id = $featuremap_id;
+ }
+
+ /**
+ * Retrieves the stock_id.
+ *
+ * @retrun integer
+ */
+ public function getStockID() {
+ return $this->stock_id;
+ }
+
+ /**
+ * Updates the stock_id.
+ *
+ * @param integer $stock_id
+ */
+ public function setStockID($stock_id) {
+ $this->stock_id = $stock_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_featuremapprop.class.inc b/includes/class/chado_table_class/chado_featuremapprop.class.inc
new file mode 100644
index 0000000..492fd0c
--- /dev/null
+++ b/includes/class/chado_table_class/chado_featuremapprop.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'featuremap_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->featuremapprop_id = array_key_exists('featuremapprop_id', $details) ? $details['featuremapprop_id'] : '';
+ $this->featuremap_id = array_key_exists('featuremap_id', $details) ? $details['featuremap_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATUREMAPPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.featuremapprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featuremap_id'] = $this->featuremap_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->featuremapprop_id = db_insert('chado.featuremapprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featuremap_id'] = $this->featuremap_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.featuremapprop')
+ ->fields($fields)
+ ->condition('featuremapprop_id', $this->featuremapprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.featuremapprop')
+ ->condition('featuremapprop_id', $this->featuremapprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the featuremapprop_id.
+ *
+ * @retrun serial
+ */
+ public function getFeaturemappropID() {
+ return $this->featuremapprop_id;
+ }
+
+ /**
+ * Updates the featuremapprop_id.
+ *
+ * @param serial $featuremapprop_id
+ */
+ public function setFeaturemappropID($featuremapprop_id) {
+ $this->featuremapprop_id = $featuremapprop_id;
+ }
+
+ /**
+ * Retrieves the featuremap_id.
+ *
+ * @retrun integer
+ */
+ public function getFeaturemapID() {
+ return $this->featuremap_id;
+ }
+
+ /**
+ * Updates the featuremap_id.
+ *
+ * @param integer $featuremap_id
+ */
+ public function setFeaturemapID($featuremap_id) {
+ $this->featuremap_id = $featuremap_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_featurepos.class.inc b/includes/class/chado_table_class/chado_featurepos.class.inc
new file mode 100644
index 0000000..49ecda9
--- /dev/null
+++ b/includes/class/chado_table_class/chado_featurepos.class.inc
@@ -0,0 +1,304 @@
+ 'serial',
+ 'featuremap_id' => 'serial',
+ 'feature_id' => 'integer',
+ 'map_feature_id' => 'integer',
+ 'mappos' => 'double',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->featurepos_id = array_key_exists('featurepos_id', $details) ? $details['featurepos_id'] : '';
+ $this->featuremap_id = array_key_exists('featuremap_id', $details) ? $details['featuremap_id'] : '';
+ $this->feature_id = array_key_exists('feature_id', $details) ? $details['feature_id'] : '';
+ $this->map_feature_id = array_key_exists('map_feature_id', $details) ? $details['map_feature_id'] : '';
+ $this->mappos = array_key_exists('mappos', $details) ? $details['mappos'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATUREPOS by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.featurepos WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['map_feature_id'] = $this->map_feature_id;
+ $fields['mappos'] = $this->mappos;
+
+
+ // Inserts the record.
+ $this->featurepos_id = db_insert('chado.featurepos')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['map_feature_id'] = $this->map_feature_id;
+ $fields['mappos'] = $this->mappos;
+
+
+ // Updates the record.
+ db_update('chado.featurepos')
+ ->fields($fields)
+ ->condition('featurepos_id', $this->featurepos_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.featurepos')
+ ->condition('featurepos_id', $this->featurepos_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the featurepos_id.
+ *
+ * @retrun serial
+ */
+ public function getFeatureposID() {
+ return $this->featurepos_id;
+ }
+
+ /**
+ * Updates the featurepos_id.
+ *
+ * @param serial $featurepos_id
+ */
+ public function setFeatureposID($featurepos_id) {
+ $this->featurepos_id = $featurepos_id;
+ }
+
+ /**
+ * Retrieves the featuremap_id.
+ *
+ * @retrun serial
+ */
+ public function getFeaturemapID() {
+ return $this->featuremap_id;
+ }
+
+ /**
+ * Updates the featuremap_id.
+ *
+ * @param serial $featuremap_id
+ */
+ public function setFeaturemapID($featuremap_id) {
+ $this->featuremap_id = $featuremap_id;
+ }
+
+ /**
+ * Retrieves the feature_id.
+ *
+ * @retrun integer
+ */
+ public function getFeatureID() {
+ return $this->feature_id;
+ }
+
+ /**
+ * Updates the feature_id.
+ *
+ * @param integer $feature_id
+ */
+ public function setFeatureID($feature_id) {
+ $this->feature_id = $feature_id;
+ }
+
+ /**
+ * Retrieves the map_feature_id.
+ *
+ * @retrun integer
+ */
+ public function getMapFeatureID() {
+ return $this->map_feature_id;
+ }
+
+ /**
+ * Updates the map_feature_id.
+ *
+ * @param integer $map_feature_id
+ */
+ public function setMapFeatureID($map_feature_id) {
+ $this->map_feature_id = $map_feature_id;
+ }
+
+ /**
+ * Retrieves the mappos.
+ *
+ * @retrun double
+ */
+ public function getMappos() {
+ return $this->mappos;
+ }
+
+ /**
+ * Updates the mappos.
+ *
+ * @param double $mappos
+ */
+ public function setMappos($mappos) {
+ $this->mappos = $mappos;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_featureposprop.class.inc b/includes/class/chado_table_class/chado_featureposprop.class.inc
new file mode 100644
index 0000000..99ed79a
--- /dev/null
+++ b/includes/class/chado_table_class/chado_featureposprop.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'featurepos_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->featureposprop_id = array_key_exists('featureposprop_id', $details) ? $details['featureposprop_id'] : '';
+ $this->featurepos_id = array_key_exists('featurepos_id', $details) ? $details['featurepos_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATUREPOSPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.featureposprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featurepos_id'] = $this->featurepos_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->featureposprop_id = db_insert('chado.featureposprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['featurepos_id'] = $this->featurepos_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.featureposprop')
+ ->fields($fields)
+ ->condition('featureposprop_id', $this->featureposprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.featureposprop')
+ ->condition('featureposprop_id', $this->featureposprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the featureposprop_id.
+ *
+ * @retrun serial
+ */
+ public function getFeaturepospropID() {
+ return $this->featureposprop_id;
+ }
+
+ /**
+ * Updates the featureposprop_id.
+ *
+ * @param serial $featureposprop_id
+ */
+ public function setFeaturepospropID($featureposprop_id) {
+ $this->featureposprop_id = $featureposprop_id;
+ }
+
+ /**
+ * Retrieves the featurepos_id.
+ *
+ * @retrun integer
+ */
+ public function getFeatureposID() {
+ return $this->featurepos_id;
+ }
+
+ /**
+ * Updates the featurepos_id.
+ *
+ * @param integer $featurepos_id
+ */
+ public function setFeatureposID($featurepos_id) {
+ $this->featurepos_id = $featurepos_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_featureprop.class.inc b/includes/class/chado_table_class/chado_featureprop.class.inc
new file mode 100644
index 0000000..c685994
--- /dev/null
+++ b/includes/class/chado_table_class/chado_featureprop.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'feature_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->featureprop_id = array_key_exists('featureprop_id', $details) ? $details['featureprop_id'] : '';
+ $this->feature_id = array_key_exists('feature_id', $details) ? $details['feature_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_FEATUREPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.featureprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->featureprop_id = db_insert('chado.featureprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['feature_id'] = $this->feature_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.featureprop')
+ ->fields($fields)
+ ->condition('featureprop_id', $this->featureprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.featureprop')
+ ->condition('featureprop_id', $this->featureprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the featureprop_id.
+ *
+ * @retrun serial
+ */
+ public function getFeaturepropID() {
+ return $this->featureprop_id;
+ }
+
+ /**
+ * Updates the featureprop_id.
+ *
+ * @param serial $featureprop_id
+ */
+ public function setFeaturepropID($featureprop_id) {
+ $this->featureprop_id = $featureprop_id;
+ }
+
+ /**
+ * Retrieves the feature_id.
+ *
+ * @retrun integer
+ */
+ public function getFeatureID() {
+ return $this->feature_id;
+ }
+
+ /**
+ * Updates the feature_id.
+ *
+ * @param integer $feature_id
+ */
+ public function setFeatureID($feature_id) {
+ $this->feature_id = $feature_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_genotype.class.inc b/includes/class/chado_table_class/chado_genotype.class.inc
new file mode 100644
index 0000000..4774177
--- /dev/null
+++ b/includes/class/chado_table_class/chado_genotype.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'name' => 'text',
+ 'uniquename' => 'text',
+ 'description' => 'character_varying(255)',
+ 'type_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->genotype_id = array_key_exists('genotype_id', $details) ? $details['genotype_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->uniquename = array_key_exists('uniquename', $details) ? $details['uniquename'] : '';
+ $this->description = array_key_exists('description', $details) ? $details['description'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_GENOTYPE by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.genotype WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['uniquename'] = $this->uniquename;
+ $fields['description'] = $this->description;
+ $fields['type_id'] = $this->type_id;
+
+
+ // Inserts the record.
+ $this->genotype_id = db_insert('chado.genotype')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['uniquename'] = $this->uniquename;
+ $fields['description'] = $this->description;
+ $fields['type_id'] = $this->type_id;
+
+
+ // Updates the record.
+ db_update('chado.genotype')
+ ->fields($fields)
+ ->condition('genotype_id', $this->genotype_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.genotype')
+ ->condition('genotype_id', $this->genotype_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the genotype_id.
+ *
+ * @retrun serial
+ */
+ public function getGenotypeID() {
+ return $this->genotype_id;
+ }
+
+ /**
+ * Updates the genotype_id.
+ *
+ * @param serial $genotype_id
+ */
+ public function setGenotypeID($genotype_id) {
+ $this->genotype_id = $genotype_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun text
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param text $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the uniquename.
+ *
+ * @retrun text
+ */
+ public function getUniquename() {
+ return $this->uniquename;
+ }
+
+ /**
+ * Updates the uniquename.
+ *
+ * @param text $uniquename
+ */
+ public function setUniquename($uniquename) {
+ $this->uniquename = $uniquename;
+ }
+
+ /**
+ * Retrieves the description.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getDescription() {
+ return $this->description;
+ }
+
+ /**
+ * Updates the description.
+ *
+ * @param character_varying(255) $description
+ */
+ public function setDescription($description) {
+ $this->description = $description;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_library.class.inc b/includes/class/chado_table_class/chado_library.class.inc
new file mode 100644
index 0000000..1c2196f
--- /dev/null
+++ b/includes/class/chado_table_class/chado_library.class.inc
@@ -0,0 +1,375 @@
+ 'serial',
+ 'organism_id' => 'integer',
+ 'name' => 'character_varying(255)',
+ 'uniquename' => 'text',
+ 'type_id' => 'integer',
+ 'is_obsolete' => 'integer',
+ 'timeaccessioned' => 'timestamp_without_time_zone',
+ 'timelastmodified' => 'timestamp_without_time_zone',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->library_id = array_key_exists('library_id', $details) ? $details['library_id'] : '';
+ $this->organism_id = array_key_exists('organism_id', $details) ? $details['organism_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->uniquename = array_key_exists('uniquename', $details) ? $details['uniquename'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->is_obsolete = array_key_exists('is_obsolete', $details) ? $details['is_obsolete'] : 0;
+ $this->timeaccessioned = array_key_exists('timeaccessioned', $details) ? $details['timeaccessioned'] : '';
+ $this->timelastmodified = array_key_exists('timelastmodified', $details) ? $details['timelastmodified'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_LIBRARY by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.library WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['organism_id'] = $this->organism_id;
+ $fields['name'] = $this->name;
+ $fields['uniquename'] = $this->uniquename;
+ $fields['type_id'] = $this->type_id;
+ $fields['is_obsolete'] = (is_numeric($this->is_obsolete)) ? $this->is_obsolete : 0;
+ $fields['timeaccessioned'] = (!empty($this->timeaccessioned)) ? $this->timeaccessioned : 'now()';
+ $fields['timelastmodified'] = (!empty($this->timelastmodified)) ? $this->timelastmodified : 'now()';
+
+
+ // Inserts the record.
+ $this->library_id = db_insert('chado.library')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['organism_id'] = $this->organism_id;
+ $fields['name'] = $this->name;
+ $fields['uniquename'] = $this->uniquename;
+ $fields['type_id'] = $this->type_id;
+ $fields['is_obsolete'] = (is_numeric($this->is_obsolete)) ? $this->is_obsolete : 0;
+ $fields['timeaccessioned'] = (!empty($this->timeaccessioned)) ? $this->timeaccessioned : 'now()';
+ $fields['timelastmodified'] = (!empty($this->timelastmodified)) ? $this->timelastmodified : 'now()';
+
+
+ // Updates the record.
+ db_update('chado.library')
+ ->fields($fields)
+ ->condition('library_id', $this->library_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.library')
+ ->condition('library_id', $this->library_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the library_id.
+ *
+ * @retrun serial
+ */
+ public function getLibraryID() {
+ return $this->library_id;
+ }
+
+ /**
+ * Updates the library_id.
+ *
+ * @param serial $library_id
+ */
+ public function setLibraryID($library_id) {
+ $this->library_id = $library_id;
+ }
+
+ /**
+ * Retrieves the organism_id.
+ *
+ * @retrun integer
+ */
+ public function getOrganismID() {
+ return $this->organism_id;
+ }
+
+ /**
+ * Updates the organism_id.
+ *
+ * @param integer $organism_id
+ */
+ public function setOrganismID($organism_id) {
+ $this->organism_id = $organism_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the uniquename.
+ *
+ * @retrun text
+ */
+ public function getUniquename() {
+ return $this->uniquename;
+ }
+
+ /**
+ * Updates the uniquename.
+ *
+ * @param text $uniquename
+ */
+ public function setUniquename($uniquename) {
+ $this->uniquename = $uniquename;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the is_obsolete.
+ *
+ * @retrun integer
+ */
+ public function getIsObsolete() {
+ return $this->is_obsolete;
+ }
+
+ /**
+ * Updates the is_obsolete.
+ *
+ * @param integer $is_obsolete
+ */
+ public function setIsObsolete($is_obsolete) {
+ $this->is_obsolete = $is_obsolete;
+ }
+
+ /**
+ * Retrieves the timeaccessioned.
+ *
+ * @retrun timestamp_without_time_zone
+ */
+ public function getTimeaccessioned() {
+ return $this->timeaccessioned;
+ }
+
+ /**
+ * Updates the timeaccessioned.
+ *
+ * @param timestamp_without_time_zone $timeaccessioned
+ */
+ public function setTimeaccessioned($timeaccessioned) {
+ $this->timeaccessioned = $timeaccessioned;
+ }
+
+ /**
+ * Retrieves the timelastmodified.
+ *
+ * @retrun timestamp_without_time_zone
+ */
+ public function getTimelastmodified() {
+ return $this->timelastmodified;
+ }
+
+ /**
+ * Updates the timelastmodified.
+ *
+ * @param timestamp_without_time_zone $timelastmodified
+ */
+ public function setTimelastmodified($timelastmodified) {
+ $this->timelastmodified = $timelastmodified;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_library_contact.class.inc b/includes/class/chado_table_class/chado_library_contact.class.inc
new file mode 100644
index 0000000..4374e91
--- /dev/null
+++ b/includes/class/chado_table_class/chado_library_contact.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'library_id' => 'integer',
+ 'contact_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->library_contact_id = array_key_exists('library_contact_id', $details) ? $details['library_contact_id'] : '';
+ $this->library_id = array_key_exists('library_id', $details) ? $details['library_id'] : '';
+ $this->contact_id = array_key_exists('contact_id', $details) ? $details['contact_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_LIBRARY_CONTACT by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.library_contact WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['library_id'] = $this->library_id;
+ $fields['contact_id'] = $this->contact_id;
+
+
+ // Inserts the record.
+ $this->library_contact_id = db_insert('chado.library_contact')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['library_id'] = $this->library_id;
+ $fields['contact_id'] = $this->contact_id;
+
+
+ // Updates the record.
+ db_update('chado.library_contact')
+ ->fields($fields)
+ ->condition('library_contact_id', $this->library_contact_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.library_contact')
+ ->condition('library_contact_id', $this->library_contact_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the library_contact_id.
+ *
+ * @retrun serial
+ */
+ public function getLibraryContactID() {
+ return $this->library_contact_id;
+ }
+
+ /**
+ * Updates the library_contact_id.
+ *
+ * @param serial $library_contact_id
+ */
+ public function setLibraryContactID($library_contact_id) {
+ $this->library_contact_id = $library_contact_id;
+ }
+
+ /**
+ * Retrieves the library_id.
+ *
+ * @retrun integer
+ */
+ public function getLibraryID() {
+ return $this->library_id;
+ }
+
+ /**
+ * Updates the library_id.
+ *
+ * @param integer $library_id
+ */
+ public function setLibraryID($library_id) {
+ $this->library_id = $library_id;
+ }
+
+ /**
+ * Retrieves the contact_id.
+ *
+ * @retrun integer
+ */
+ public function getContactID() {
+ return $this->contact_id;
+ }
+
+ /**
+ * Updates the contact_id.
+ *
+ * @param integer $contact_id
+ */
+ public function setContactID($contact_id) {
+ $this->contact_id = $contact_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_library_pub.class.inc b/includes/class/chado_table_class/chado_library_pub.class.inc
new file mode 100644
index 0000000..bec04fe
--- /dev/null
+++ b/includes/class/chado_table_class/chado_library_pub.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'library_id' => 'integer',
+ 'pub_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->library_pub_id = array_key_exists('library_pub_id', $details) ? $details['library_pub_id'] : '';
+ $this->library_id = array_key_exists('library_id', $details) ? $details['library_id'] : '';
+ $this->pub_id = array_key_exists('pub_id', $details) ? $details['pub_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_LIBRARY_PUB by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.library_pub WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['library_id'] = $this->library_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Inserts the record.
+ $this->library_pub_id = db_insert('chado.library_pub')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['library_id'] = $this->library_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Updates the record.
+ db_update('chado.library_pub')
+ ->fields($fields)
+ ->condition('library_pub_id', $this->library_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.library_pub')
+ ->condition('library_pub_id', $this->library_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the library_pub_id.
+ *
+ * @retrun serial
+ */
+ public function getLibraryPubID() {
+ return $this->library_pub_id;
+ }
+
+ /**
+ * Updates the library_pub_id.
+ *
+ * @param serial $library_pub_id
+ */
+ public function setLibraryPubID($library_pub_id) {
+ $this->library_pub_id = $library_pub_id;
+ }
+
+ /**
+ * Retrieves the library_id.
+ *
+ * @retrun integer
+ */
+ public function getLibraryID() {
+ return $this->library_id;
+ }
+
+ /**
+ * Updates the library_id.
+ *
+ * @param integer $library_id
+ */
+ public function setLibraryID($library_id) {
+ $this->library_id = $library_id;
+ }
+
+ /**
+ * Retrieves the pub_id.
+ *
+ * @retrun integer
+ */
+ public function getPubID() {
+ return $this->pub_id;
+ }
+
+ /**
+ * Updates the pub_id.
+ *
+ * @param integer $pub_id
+ */
+ public function setPubID($pub_id) {
+ $this->pub_id = $pub_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_library_synonym.class.inc b/includes/class/chado_table_class/chado_library_synonym.class.inc
new file mode 100644
index 0000000..2162ae2
--- /dev/null
+++ b/includes/class/chado_table_class/chado_library_synonym.class.inc
@@ -0,0 +1,329 @@
+ 'serial',
+ 'synonym_id' => 'integer',
+ 'library_id' => 'integer',
+ 'pub_id' => 'integer',
+ 'is_current' => 'boolean',
+ 'is_internal' => 'boolean',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->library_synonym_id = array_key_exists('library_synonym_id', $details) ? $details['library_synonym_id'] : '';
+ $this->synonym_id = array_key_exists('synonym_id', $details) ? $details['synonym_id'] : '';
+ $this->library_id = array_key_exists('library_id', $details) ? $details['library_id'] : '';
+ $this->pub_id = array_key_exists('pub_id', $details) ? $details['pub_id'] : '';
+ $this->is_current = array_key_exists('is_current', $details) ? $details['is_current'] : '';
+ $this->is_internal = array_key_exists('is_internal', $details) ? $details['is_internal'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_LIBRARY_SYNONYM by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.library_synonym WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['synonym_id'] = $this->synonym_id;
+ $fields['library_id'] = $this->library_id;
+ $fields['pub_id'] = $this->pub_id;
+ $fields['is_current'] = (preg_match("/^(true|false)/i", $this->is_current)) ? "'" . $this->is_current . "'" : 'true';
+ $fields['is_internal'] = (preg_match("/^(true|false)/i", $this->is_internal)) ? "'" . $this->is_internal . "'" : 'false';
+
+
+ // Inserts the record.
+ $this->library_synonym_id = db_insert('chado.library_synonym')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['synonym_id'] = $this->synonym_id;
+ $fields['library_id'] = $this->library_id;
+ $fields['pub_id'] = $this->pub_id;
+ $fields['is_current'] = (preg_match("/^(true|false)/i", $this->is_current)) ? "'" . $this->is_current . "'" : 'true';
+ $fields['is_internal'] = (preg_match("/^(true|false)/i", $this->is_internal)) ? "'" . $this->is_internal . "'" : 'false';
+
+
+ // Updates the record.
+ db_update('chado.library_synonym')
+ ->fields($fields)
+ ->condition('library_synonym_id', $this->library_synonym_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.library_synonym')
+ ->condition('library_synonym_id', $this->library_synonym_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the library_synonym_id.
+ *
+ * @retrun serial
+ */
+ public function getLibrarySynonymID() {
+ return $this->library_synonym_id;
+ }
+
+ /**
+ * Updates the library_synonym_id.
+ *
+ * @param serial $library_synonym_id
+ */
+ public function setLibrarySynonymID($library_synonym_id) {
+ $this->library_synonym_id = $library_synonym_id;
+ }
+
+ /**
+ * Retrieves the synonym_id.
+ *
+ * @retrun integer
+ */
+ public function getSynonymID() {
+ return $this->synonym_id;
+ }
+
+ /**
+ * Updates the synonym_id.
+ *
+ * @param integer $synonym_id
+ */
+ public function setSynonymID($synonym_id) {
+ $this->synonym_id = $synonym_id;
+ }
+
+ /**
+ * Retrieves the library_id.
+ *
+ * @retrun integer
+ */
+ public function getLibraryID() {
+ return $this->library_id;
+ }
+
+ /**
+ * Updates the library_id.
+ *
+ * @param integer $library_id
+ */
+ public function setLibraryID($library_id) {
+ $this->library_id = $library_id;
+ }
+
+ /**
+ * Retrieves the pub_id.
+ *
+ * @retrun integer
+ */
+ public function getPubID() {
+ return $this->pub_id;
+ }
+
+ /**
+ * Updates the pub_id.
+ *
+ * @param integer $pub_id
+ */
+ public function setPubID($pub_id) {
+ $this->pub_id = $pub_id;
+ }
+
+ /**
+ * Retrieves the is_current.
+ *
+ * @retrun boolean
+ */
+ public function getIsCurrent() {
+ return $this->is_current;
+ }
+
+ /**
+ * Updates the is_current.
+ *
+ * @param boolean $is_current
+ */
+ public function setIsCurrent($is_current) {
+ $this->is_current = $is_current;
+ }
+
+ /**
+ * Retrieves the is_internal.
+ *
+ * @retrun boolean
+ */
+ public function getIsInternal() {
+ return $this->is_internal;
+ }
+
+ /**
+ * Updates the is_internal.
+ *
+ * @param boolean $is_internal
+ */
+ public function setIsInternal($is_internal) {
+ $this->is_internal = $is_internal;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_libraryprop.class.inc b/includes/class/chado_table_class/chado_libraryprop.class.inc
new file mode 100644
index 0000000..d0cf38e
--- /dev/null
+++ b/includes/class/chado_table_class/chado_libraryprop.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'library_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->libraryprop_id = array_key_exists('libraryprop_id', $details) ? $details['libraryprop_id'] : '';
+ $this->library_id = array_key_exists('library_id', $details) ? $details['library_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_LIBRARYPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.libraryprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['library_id'] = $this->library_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->libraryprop_id = db_insert('chado.libraryprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['library_id'] = $this->library_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.libraryprop')
+ ->fields($fields)
+ ->condition('libraryprop_id', $this->libraryprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.libraryprop')
+ ->condition('libraryprop_id', $this->libraryprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the libraryprop_id.
+ *
+ * @retrun serial
+ */
+ public function getLibrarypropID() {
+ return $this->libraryprop_id;
+ }
+
+ /**
+ * Updates the libraryprop_id.
+ *
+ * @param serial $libraryprop_id
+ */
+ public function setLibrarypropID($libraryprop_id) {
+ $this->libraryprop_id = $libraryprop_id;
+ }
+
+ /**
+ * Retrieves the library_id.
+ *
+ * @retrun integer
+ */
+ public function getLibraryID() {
+ return $this->library_id;
+ }
+
+ /**
+ * Updates the library_id.
+ *
+ * @param integer $library_id
+ */
+ public function setLibraryID($library_id) {
+ $this->library_id = $library_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_nd_experiment.class.inc b/includes/class/chado_table_class/chado_nd_experiment.class.inc
new file mode 100644
index 0000000..c42f5ef
--- /dev/null
+++ b/includes/class/chado_table_class/chado_nd_experiment.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'nd_geolocation_id' => 'integer',
+ 'type_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->nd_experiment_id = array_key_exists('nd_experiment_id', $details) ? $details['nd_experiment_id'] : '';
+ $this->nd_geolocation_id = array_key_exists('nd_geolocation_id', $details) ? $details['nd_geolocation_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_ND_EXPERIMENT by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.nd_experiment WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_geolocation_id'] = $this->nd_geolocation_id;
+ $fields['type_id'] = $this->type_id;
+
+
+ // Inserts the record.
+ $this->nd_experiment_id = db_insert('chado.nd_experiment')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_geolocation_id'] = $this->nd_geolocation_id;
+ $fields['type_id'] = $this->type_id;
+
+
+ // Updates the record.
+ db_update('chado.nd_experiment')
+ ->fields($fields)
+ ->condition('nd_experiment_id', $this->nd_experiment_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.nd_experiment')
+ ->condition('nd_experiment_id', $this->nd_experiment_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the nd_experiment_id.
+ *
+ * @retrun serial
+ */
+ public function getNdExperimentID() {
+ return $this->nd_experiment_id;
+ }
+
+ /**
+ * Updates the nd_experiment_id.
+ *
+ * @param serial $nd_experiment_id
+ */
+ public function setNdExperimentID($nd_experiment_id) {
+ $this->nd_experiment_id = $nd_experiment_id;
+ }
+
+ /**
+ * Retrieves the nd_geolocation_id.
+ *
+ * @retrun integer
+ */
+ public function getNdGeolocationID() {
+ return $this->nd_geolocation_id;
+ }
+
+ /**
+ * Updates the nd_geolocation_id.
+ *
+ * @param integer $nd_geolocation_id
+ */
+ public function setNdGeolocationID($nd_geolocation_id) {
+ $this->nd_geolocation_id = $nd_geolocation_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_nd_experiment_genotype.class.inc b/includes/class/chado_table_class/chado_nd_experiment_genotype.class.inc
new file mode 100644
index 0000000..f71d0a4
--- /dev/null
+++ b/includes/class/chado_table_class/chado_nd_experiment_genotype.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'nd_experiment_id' => 'integer',
+ 'genotype_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->nd_experiment_genotype_id = array_key_exists('nd_experiment_genotype_id', $details) ? $details['nd_experiment_genotype_id'] : '';
+ $this->nd_experiment_id = array_key_exists('nd_experiment_id', $details) ? $details['nd_experiment_id'] : '';
+ $this->genotype_id = array_key_exists('genotype_id', $details) ? $details['genotype_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_ND_EXPERIMENT_GENOTYPE by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.nd_experiment_genotype WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_experiment_id'] = $this->nd_experiment_id;
+ $fields['genotype_id'] = $this->genotype_id;
+
+
+ // Inserts the record.
+ $this->nd_experiment_genotype_id = db_insert('chado.nd_experiment_genotype')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_experiment_id'] = $this->nd_experiment_id;
+ $fields['genotype_id'] = $this->genotype_id;
+
+
+ // Updates the record.
+ db_update('chado.nd_experiment_genotype')
+ ->fields($fields)
+ ->condition('nd_experiment_genotype_id', $this->nd_experiment_genotype_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.nd_experiment_genotype')
+ ->condition('nd_experiment_genotype_id', $this->nd_experiment_genotype_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the nd_experiment_genotype_id.
+ *
+ * @retrun serial
+ */
+ public function getNdExperimentGenotypeID() {
+ return $this->nd_experiment_genotype_id;
+ }
+
+ /**
+ * Updates the nd_experiment_genotype_id.
+ *
+ * @param serial $nd_experiment_genotype_id
+ */
+ public function setNdExperimentGenotypeID($nd_experiment_genotype_id) {
+ $this->nd_experiment_genotype_id = $nd_experiment_genotype_id;
+ }
+
+ /**
+ * Retrieves the nd_experiment_id.
+ *
+ * @retrun integer
+ */
+ public function getNdExperimentID() {
+ return $this->nd_experiment_id;
+ }
+
+ /**
+ * Updates the nd_experiment_id.
+ *
+ * @param integer $nd_experiment_id
+ */
+ public function setNdExperimentID($nd_experiment_id) {
+ $this->nd_experiment_id = $nd_experiment_id;
+ }
+
+ /**
+ * Retrieves the genotype_id.
+ *
+ * @retrun integer
+ */
+ public function getGenotypeID() {
+ return $this->genotype_id;
+ }
+
+ /**
+ * Updates the genotype_id.
+ *
+ * @param integer $genotype_id
+ */
+ public function setGenotypeID($genotype_id) {
+ $this->genotype_id = $genotype_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_nd_experiment_phenotype.class.inc b/includes/class/chado_table_class/chado_nd_experiment_phenotype.class.inc
new file mode 100644
index 0000000..16b53db
--- /dev/null
+++ b/includes/class/chado_table_class/chado_nd_experiment_phenotype.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'nd_experiment_id' => 'integer',
+ 'phenotype_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->nd_experiment_phenotype_id = array_key_exists('nd_experiment_phenotype_id', $details) ? $details['nd_experiment_phenotype_id'] : '';
+ $this->nd_experiment_id = array_key_exists('nd_experiment_id', $details) ? $details['nd_experiment_id'] : '';
+ $this->phenotype_id = array_key_exists('phenotype_id', $details) ? $details['phenotype_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_ND_EXPERIMENT_PHENOTYPE by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.nd_experiment_phenotype WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_experiment_id'] = $this->nd_experiment_id;
+ $fields['phenotype_id'] = $this->phenotype_id;
+
+
+ // Inserts the record.
+ $this->nd_experiment_phenotype_id = db_insert('chado.nd_experiment_phenotype')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_experiment_id'] = $this->nd_experiment_id;
+ $fields['phenotype_id'] = $this->phenotype_id;
+
+
+ // Updates the record.
+ db_update('chado.nd_experiment_phenotype')
+ ->fields($fields)
+ ->condition('nd_experiment_phenotype_id', $this->nd_experiment_phenotype_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.nd_experiment_phenotype')
+ ->condition('nd_experiment_phenotype_id', $this->nd_experiment_phenotype_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the nd_experiment_phenotype_id.
+ *
+ * @retrun serial
+ */
+ public function getNdExperimentPhenotypeID() {
+ return $this->nd_experiment_phenotype_id;
+ }
+
+ /**
+ * Updates the nd_experiment_phenotype_id.
+ *
+ * @param serial $nd_experiment_phenotype_id
+ */
+ public function setNdExperimentPhenotypeID($nd_experiment_phenotype_id) {
+ $this->nd_experiment_phenotype_id = $nd_experiment_phenotype_id;
+ }
+
+ /**
+ * Retrieves the nd_experiment_id.
+ *
+ * @retrun integer
+ */
+ public function getNdExperimentID() {
+ return $this->nd_experiment_id;
+ }
+
+ /**
+ * Updates the nd_experiment_id.
+ *
+ * @param integer $nd_experiment_id
+ */
+ public function setNdExperimentID($nd_experiment_id) {
+ $this->nd_experiment_id = $nd_experiment_id;
+ }
+
+ /**
+ * Retrieves the phenotype_id.
+ *
+ * @retrun integer
+ */
+ public function getPhenotypeID() {
+ return $this->phenotype_id;
+ }
+
+ /**
+ * Updates the phenotype_id.
+ *
+ * @param integer $phenotype_id
+ */
+ public function setPhenotypeID($phenotype_id) {
+ $this->phenotype_id = $phenotype_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_nd_experiment_project.class.inc b/includes/class/chado_table_class/chado_nd_experiment_project.class.inc
new file mode 100644
index 0000000..81d441c
--- /dev/null
+++ b/includes/class/chado_table_class/chado_nd_experiment_project.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'project_id' => 'integer',
+ 'nd_experiment_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->nd_experiment_project_id = array_key_exists('nd_experiment_project_id', $details) ? $details['nd_experiment_project_id'] : '';
+ $this->project_id = array_key_exists('project_id', $details) ? $details['project_id'] : '';
+ $this->nd_experiment_id = array_key_exists('nd_experiment_id', $details) ? $details['nd_experiment_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_ND_EXPERIMENT_PROJECT by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.nd_experiment_project WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['project_id'] = $this->project_id;
+ $fields['nd_experiment_id'] = $this->nd_experiment_id;
+
+
+ // Inserts the record.
+ $this->nd_experiment_project_id = db_insert('chado.nd_experiment_project')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['project_id'] = $this->project_id;
+ $fields['nd_experiment_id'] = $this->nd_experiment_id;
+
+
+ // Updates the record.
+ db_update('chado.nd_experiment_project')
+ ->fields($fields)
+ ->condition('nd_experiment_project_id', $this->nd_experiment_project_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.nd_experiment_project')
+ ->condition('nd_experiment_project_id', $this->nd_experiment_project_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the nd_experiment_project_id.
+ *
+ * @retrun serial
+ */
+ public function getNdExperimentProjectID() {
+ return $this->nd_experiment_project_id;
+ }
+
+ /**
+ * Updates the nd_experiment_project_id.
+ *
+ * @param serial $nd_experiment_project_id
+ */
+ public function setNdExperimentProjectID($nd_experiment_project_id) {
+ $this->nd_experiment_project_id = $nd_experiment_project_id;
+ }
+
+ /**
+ * Retrieves the project_id.
+ *
+ * @retrun integer
+ */
+ public function getProjectID() {
+ return $this->project_id;
+ }
+
+ /**
+ * Updates the project_id.
+ *
+ * @param integer $project_id
+ */
+ public function setProjectID($project_id) {
+ $this->project_id = $project_id;
+ }
+
+ /**
+ * Retrieves the nd_experiment_id.
+ *
+ * @retrun integer
+ */
+ public function getNdExperimentID() {
+ return $this->nd_experiment_id;
+ }
+
+ /**
+ * Updates the nd_experiment_id.
+ *
+ * @param integer $nd_experiment_id
+ */
+ public function setNdExperimentID($nd_experiment_id) {
+ $this->nd_experiment_id = $nd_experiment_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_nd_experiment_stock.class.inc b/includes/class/chado_table_class/chado_nd_experiment_stock.class.inc
new file mode 100644
index 0000000..9dd7aab
--- /dev/null
+++ b/includes/class/chado_table_class/chado_nd_experiment_stock.class.inc
@@ -0,0 +1,283 @@
+ 'serial',
+ 'nd_experiment_id' => 'integer',
+ 'stock_id' => 'integer',
+ 'type_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->nd_experiment_stock_id = array_key_exists('nd_experiment_stock_id', $details) ? $details['nd_experiment_stock_id'] : '';
+ $this->nd_experiment_id = array_key_exists('nd_experiment_id', $details) ? $details['nd_experiment_id'] : '';
+ $this->stock_id = array_key_exists('stock_id', $details) ? $details['stock_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_ND_EXPERIMENT_STOCK by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.nd_experiment_stock WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_experiment_id'] = $this->nd_experiment_id;
+ $fields['stock_id'] = $this->stock_id;
+ $fields['type_id'] = $this->type_id;
+
+
+ // Inserts the record.
+ $this->nd_experiment_stock_id = db_insert('chado.nd_experiment_stock')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_experiment_id'] = $this->nd_experiment_id;
+ $fields['stock_id'] = $this->stock_id;
+ $fields['type_id'] = $this->type_id;
+
+
+ // Updates the record.
+ db_update('chado.nd_experiment_stock')
+ ->fields($fields)
+ ->condition('nd_experiment_stock_id', $this->nd_experiment_stock_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.nd_experiment_stock')
+ ->condition('nd_experiment_stock_id', $this->nd_experiment_stock_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the nd_experiment_stock_id.
+ *
+ * @retrun serial
+ */
+ public function getNdExperimentStockID() {
+ return $this->nd_experiment_stock_id;
+ }
+
+ /**
+ * Updates the nd_experiment_stock_id.
+ *
+ * @param serial $nd_experiment_stock_id
+ */
+ public function setNdExperimentStockID($nd_experiment_stock_id) {
+ $this->nd_experiment_stock_id = $nd_experiment_stock_id;
+ }
+
+ /**
+ * Retrieves the nd_experiment_id.
+ *
+ * @retrun integer
+ */
+ public function getNdExperimentID() {
+ return $this->nd_experiment_id;
+ }
+
+ /**
+ * Updates the nd_experiment_id.
+ *
+ * @param integer $nd_experiment_id
+ */
+ public function setNdExperimentID($nd_experiment_id) {
+ $this->nd_experiment_id = $nd_experiment_id;
+ }
+
+ /**
+ * Retrieves the stock_id.
+ *
+ * @retrun integer
+ */
+ public function getStockID() {
+ return $this->stock_id;
+ }
+
+ /**
+ * Updates the stock_id.
+ *
+ * @param integer $stock_id
+ */
+ public function setStockID($stock_id) {
+ $this->stock_id = $stock_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_nd_experimentprop.class.inc b/includes/class/chado_table_class/chado_nd_experimentprop.class.inc
new file mode 100644
index 0000000..a513641
--- /dev/null
+++ b/includes/class/chado_table_class/chado_nd_experimentprop.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'nd_experiment_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->nd_experimentprop_id = array_key_exists('nd_experimentprop_id', $details) ? $details['nd_experimentprop_id'] : '';
+ $this->nd_experiment_id = array_key_exists('nd_experiment_id', $details) ? $details['nd_experiment_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_ND_EXPERIMENTPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.nd_experimentprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_experiment_id'] = $this->nd_experiment_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->nd_experimentprop_id = db_insert('chado.nd_experimentprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_experiment_id'] = $this->nd_experiment_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.nd_experimentprop')
+ ->fields($fields)
+ ->condition('nd_experimentprop_id', $this->nd_experimentprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.nd_experimentprop')
+ ->condition('nd_experimentprop_id', $this->nd_experimentprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the nd_experimentprop_id.
+ *
+ * @retrun serial
+ */
+ public function getNdExperimentpropID() {
+ return $this->nd_experimentprop_id;
+ }
+
+ /**
+ * Updates the nd_experimentprop_id.
+ *
+ * @param serial $nd_experimentprop_id
+ */
+ public function setNdExperimentpropID($nd_experimentprop_id) {
+ $this->nd_experimentprop_id = $nd_experimentprop_id;
+ }
+
+ /**
+ * Retrieves the nd_experiment_id.
+ *
+ * @retrun integer
+ */
+ public function getNdExperimentID() {
+ return $this->nd_experiment_id;
+ }
+
+ /**
+ * Updates the nd_experiment_id.
+ *
+ * @param integer $nd_experiment_id
+ */
+ public function setNdExperimentID($nd_experiment_id) {
+ $this->nd_experiment_id = $nd_experiment_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_nd_geolocation.class.inc b/includes/class/chado_table_class/chado_nd_geolocation.class.inc
new file mode 100644
index 0000000..c3912fb
--- /dev/null
+++ b/includes/class/chado_table_class/chado_nd_geolocation.class.inc
@@ -0,0 +1,327 @@
+ 'serial',
+ 'description' => 'character_varying(255)',
+ 'latitude' => 'real',
+ 'longitude' => 'real',
+ 'geodetic_datum' => 'character_varying(32)',
+ 'altitude' => 'real',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->nd_geolocation_id = array_key_exists('nd_geolocation_id', $details) ? $details['nd_geolocation_id'] : '';
+ $this->description = array_key_exists('description', $details) ? $details['description'] : '';
+ $this->latitude = array_key_exists('latitude', $details) ? $details['latitude'] : '';
+ $this->longitude = array_key_exists('longitude', $details) ? $details['longitude'] : '';
+ $this->geodetic_datum = array_key_exists('geodetic_datum', $details) ? $details['geodetic_datum'] : '';
+ $this->altitude = array_key_exists('altitude', $details) ? $details['altitude'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_ND_GEOLOCATION by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.nd_geolocation WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['description'] = $this->description;
+ $fields['geodetic_datum'] = $this->geodetic_datum;
+ if (is_numeric($this->latitude)) { $fields['latitude'] = $this->latitude; }
+ if (is_numeric($this->longitude)) { $fields['longitude'] = $this->longitude; }
+ if (is_numeric($this->altitude)) { $fields['altitude'] = $this->altitude; }
+
+ // Inserts the record.
+ $this->nd_geolocation_id = db_insert('chado.nd_geolocation')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['description'] = $this->description;
+ $fields['geodetic_datum'] = $this->geodetic_datum;
+ if (is_numeric($this->latitude)) { $fields['latitude'] = $this->latitude; }
+ if (is_numeric($this->longitude)) { $fields['longitude'] = $this->longitude; }
+ if (is_numeric($this->altitude)) { $fields['altitude'] = $this->altitude; }
+
+ // Updates the record.
+ db_update('chado.nd_geolocation')
+ ->fields($fields)
+ ->condition('nd_geolocation_id', $this->nd_geolocation_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.nd_geolocation')
+ ->condition('nd_geolocation_id', $this->nd_geolocation_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the nd_geolocation_id.
+ *
+ * @retrun serial
+ */
+ public function getNdGeolocationID() {
+ return $this->nd_geolocation_id;
+ }
+
+ /**
+ * Updates the nd_geolocation_id.
+ *
+ * @param serial $nd_geolocation_id
+ */
+ public function setNdGeolocationID($nd_geolocation_id) {
+ $this->nd_geolocation_id = $nd_geolocation_id;
+ }
+
+ /**
+ * Retrieves the description.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getDescription() {
+ return $this->description;
+ }
+
+ /**
+ * Updates the description.
+ *
+ * @param character_varying(255) $description
+ */
+ public function setDescription($description) {
+ $this->description = $description;
+ }
+
+ /**
+ * Retrieves the latitude.
+ *
+ * @retrun real
+ */
+ public function getLatitude() {
+ return $this->latitude;
+ }
+
+ /**
+ * Updates the latitude.
+ *
+ * @param real $latitude
+ */
+ public function setLatitude($latitude) {
+ $this->latitude = $latitude;
+ }
+
+ /**
+ * Retrieves the longitude.
+ *
+ * @retrun real
+ */
+ public function getLongitude() {
+ return $this->longitude;
+ }
+
+ /**
+ * Updates the longitude.
+ *
+ * @param real $longitude
+ */
+ public function setLongitude($longitude) {
+ $this->longitude = $longitude;
+ }
+
+ /**
+ * Retrieves the geodetic_datum.
+ *
+ * @retrun character_varying(32)
+ */
+ public function getGeodeticDatum() {
+ return $this->geodetic_datum;
+ }
+
+ /**
+ * Updates the geodetic_datum.
+ *
+ * @param character_varying(32) $geodetic_datum
+ */
+ public function setGeodeticDatum($geodetic_datum) {
+ $this->geodetic_datum = $geodetic_datum;
+ }
+
+ /**
+ * Retrieves the altitude.
+ *
+ * @retrun real
+ */
+ public function getAltitude() {
+ return $this->altitude;
+ }
+
+ /**
+ * Updates the altitude.
+ *
+ * @param real $altitude
+ */
+ public function setAltitude($altitude) {
+ $this->altitude = $altitude;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_nd_geolocationprop.class.inc b/includes/class/chado_table_class/chado_nd_geolocationprop.class.inc
new file mode 100644
index 0000000..96d930a
--- /dev/null
+++ b/includes/class/chado_table_class/chado_nd_geolocationprop.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'nd_geolocation_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->nd_geolocationprop_id = array_key_exists('nd_geolocationprop_id', $details) ? $details['nd_geolocationprop_id'] : '';
+ $this->nd_geolocation_id = array_key_exists('nd_geolocation_id', $details) ? $details['nd_geolocation_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_ND_GEOLOCATIONPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.nd_geolocationprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_geolocation_id'] = $this->nd_geolocation_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->nd_geolocationprop_id = db_insert('chado.nd_geolocationprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['nd_geolocation_id'] = $this->nd_geolocation_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.nd_geolocationprop')
+ ->fields($fields)
+ ->condition('nd_geolocationprop_id', $this->nd_geolocationprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.nd_geolocationprop')
+ ->condition('nd_geolocationprop_id', $this->nd_geolocationprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the nd_geolocationprop_id.
+ *
+ * @retrun serial
+ */
+ public function getNdGeolocationpropID() {
+ return $this->nd_geolocationprop_id;
+ }
+
+ /**
+ * Updates the nd_geolocationprop_id.
+ *
+ * @param serial $nd_geolocationprop_id
+ */
+ public function setNdGeolocationpropID($nd_geolocationprop_id) {
+ $this->nd_geolocationprop_id = $nd_geolocationprop_id;
+ }
+
+ /**
+ * Retrieves the nd_geolocation_id.
+ *
+ * @retrun integer
+ */
+ public function getNdGeolocationID() {
+ return $this->nd_geolocation_id;
+ }
+
+ /**
+ * Updates the nd_geolocation_id.
+ *
+ * @param integer $nd_geolocation_id
+ */
+ public function setNdGeolocationID($nd_geolocation_id) {
+ $this->nd_geolocation_id = $nd_geolocation_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_organism.class.inc b/includes/class/chado_table_class/chado_organism.class.inc
new file mode 100644
index 0000000..0367878
--- /dev/null
+++ b/includes/class/chado_table_class/chado_organism.class.inc
@@ -0,0 +1,329 @@
+ 'serial',
+ 'abbreviation' => 'character_varying(255)',
+ 'genus' => 'character_varying(255)',
+ 'species' => 'character_varying(255)',
+ 'common_name' => 'character_varying(255)',
+ 'comment' => 'text',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->organism_id = array_key_exists('organism_id', $details) ? $details['organism_id'] : '';
+ $this->abbreviation = array_key_exists('abbreviation', $details) ? $details['abbreviation'] : '';
+ $this->genus = array_key_exists('genus', $details) ? $details['genus'] : '';
+ $this->species = array_key_exists('species', $details) ? $details['species'] : '';
+ $this->common_name = array_key_exists('common_name', $details) ? $details['common_name'] : '';
+ $this->comment = array_key_exists('comment', $details) ? $details['comment'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_ORGANISM by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.organism WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['abbreviation'] = $this->abbreviation;
+ $fields['genus'] = $this->genus;
+ $fields['species'] = $this->species;
+ $fields['common_name'] = $this->common_name;
+ $fields['comment'] = $this->comment;
+
+
+ // Inserts the record.
+ $this->organism_id = db_insert('chado.organism')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['abbreviation'] = $this->abbreviation;
+ $fields['genus'] = $this->genus;
+ $fields['species'] = $this->species;
+ $fields['common_name'] = $this->common_name;
+ $fields['comment'] = $this->comment;
+
+
+ // Updates the record.
+ db_update('chado.organism')
+ ->fields($fields)
+ ->condition('organism_id', $this->organism_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.organism')
+ ->condition('organism_id', $this->organism_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the organism_id.
+ *
+ * @retrun serial
+ */
+ public function getOrganismID() {
+ return $this->organism_id;
+ }
+
+ /**
+ * Updates the organism_id.
+ *
+ * @param serial $organism_id
+ */
+ public function setOrganismID($organism_id) {
+ $this->organism_id = $organism_id;
+ }
+
+ /**
+ * Retrieves the abbreviation.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getAbbreviation() {
+ return $this->abbreviation;
+ }
+
+ /**
+ * Updates the abbreviation.
+ *
+ * @param character_varying(255) $abbreviation
+ */
+ public function setAbbreviation($abbreviation) {
+ $this->abbreviation = $abbreviation;
+ }
+
+ /**
+ * Retrieves the genus.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getGenus() {
+ return $this->genus;
+ }
+
+ /**
+ * Updates the genus.
+ *
+ * @param character_varying(255) $genus
+ */
+ public function setGenus($genus) {
+ $this->genus = $genus;
+ }
+
+ /**
+ * Retrieves the species.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getSpecies() {
+ return $this->species;
+ }
+
+ /**
+ * Updates the species.
+ *
+ * @param character_varying(255) $species
+ */
+ public function setSpecies($species) {
+ $this->species = $species;
+ }
+
+ /**
+ * Retrieves the common_name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getCommonName() {
+ return $this->common_name;
+ }
+
+ /**
+ * Updates the common_name.
+ *
+ * @param character_varying(255) $common_name
+ */
+ public function setCommonName($common_name) {
+ $this->common_name = $common_name;
+ }
+
+ /**
+ * Retrieves the comment.
+ *
+ * @retrun text
+ */
+ public function getComment() {
+ return $this->comment;
+ }
+
+ /**
+ * Updates the comment.
+ *
+ * @param text $comment
+ */
+ public function setComment($comment) {
+ $this->comment = $comment;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_organism_dbxref.class.inc b/includes/class/chado_table_class/chado_organism_dbxref.class.inc
new file mode 100644
index 0000000..d292864
--- /dev/null
+++ b/includes/class/chado_table_class/chado_organism_dbxref.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'organism_id' => 'integer',
+ 'dbxref_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->organism_dbxref_id = array_key_exists('organism_dbxref_id', $details) ? $details['organism_dbxref_id'] : '';
+ $this->organism_id = array_key_exists('organism_id', $details) ? $details['organism_id'] : '';
+ $this->dbxref_id = array_key_exists('dbxref_id', $details) ? $details['dbxref_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_ORGANISM_DBXREF by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.organism_dbxref WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['organism_id'] = $this->organism_id;
+ $fields['dbxref_id'] = $this->dbxref_id;
+
+
+ // Inserts the record.
+ $this->organism_dbxref_id = db_insert('chado.organism_dbxref')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['organism_id'] = $this->organism_id;
+ $fields['dbxref_id'] = $this->dbxref_id;
+
+
+ // Updates the record.
+ db_update('chado.organism_dbxref')
+ ->fields($fields)
+ ->condition('organism_dbxref_id', $this->organism_dbxref_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.organism_dbxref')
+ ->condition('organism_dbxref_id', $this->organism_dbxref_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the organism_dbxref_id.
+ *
+ * @retrun serial
+ */
+ public function getOrganismDbxrefID() {
+ return $this->organism_dbxref_id;
+ }
+
+ /**
+ * Updates the organism_dbxref_id.
+ *
+ * @param serial $organism_dbxref_id
+ */
+ public function setOrganismDbxrefID($organism_dbxref_id) {
+ $this->organism_dbxref_id = $organism_dbxref_id;
+ }
+
+ /**
+ * Retrieves the organism_id.
+ *
+ * @retrun integer
+ */
+ public function getOrganismID() {
+ return $this->organism_id;
+ }
+
+ /**
+ * Updates the organism_id.
+ *
+ * @param integer $organism_id
+ */
+ public function setOrganismID($organism_id) {
+ $this->organism_id = $organism_id;
+ }
+
+ /**
+ * Retrieves the dbxref_id.
+ *
+ * @retrun integer
+ */
+ public function getDbxrefID() {
+ return $this->dbxref_id;
+ }
+
+ /**
+ * Updates the dbxref_id.
+ *
+ * @param integer $dbxref_id
+ */
+ public function setDbxrefID($dbxref_id) {
+ $this->dbxref_id = $dbxref_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_organism_pub.class.inc b/includes/class/chado_table_class/chado_organism_pub.class.inc
new file mode 100644
index 0000000..5831d7d
--- /dev/null
+++ b/includes/class/chado_table_class/chado_organism_pub.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'organism_id' => 'integer',
+ 'pub_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->organism_pub_id = array_key_exists('organism_pub_id', $details) ? $details['organism_pub_id'] : '';
+ $this->organism_id = array_key_exists('organism_id', $details) ? $details['organism_id'] : '';
+ $this->pub_id = array_key_exists('pub_id', $details) ? $details['pub_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_ORGANISM_PUB by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.organism_pub WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['organism_id'] = $this->organism_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Inserts the record.
+ $this->organism_pub_id = db_insert('chado.organism_pub')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['organism_id'] = $this->organism_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Updates the record.
+ db_update('chado.organism_pub')
+ ->fields($fields)
+ ->condition('organism_pub_id', $this->organism_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.organism_pub')
+ ->condition('organism_pub_id', $this->organism_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the organism_pub_id.
+ *
+ * @retrun serial
+ */
+ public function getOrganismPubID() {
+ return $this->organism_pub_id;
+ }
+
+ /**
+ * Updates the organism_pub_id.
+ *
+ * @param serial $organism_pub_id
+ */
+ public function setOrganismPubID($organism_pub_id) {
+ $this->organism_pub_id = $organism_pub_id;
+ }
+
+ /**
+ * Retrieves the organism_id.
+ *
+ * @retrun integer
+ */
+ public function getOrganismID() {
+ return $this->organism_id;
+ }
+
+ /**
+ * Updates the organism_id.
+ *
+ * @param integer $organism_id
+ */
+ public function setOrganismID($organism_id) {
+ $this->organism_id = $organism_id;
+ }
+
+ /**
+ * Retrieves the pub_id.
+ *
+ * @retrun integer
+ */
+ public function getPubID() {
+ return $this->pub_id;
+ }
+
+ /**
+ * Updates the pub_id.
+ *
+ * @param integer $pub_id
+ */
+ public function setPubID($pub_id) {
+ $this->pub_id = $pub_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_phenotype.class.inc b/includes/class/chado_table_class/chado_phenotype.class.inc
new file mode 100644
index 0000000..2d6c382
--- /dev/null
+++ b/includes/class/chado_table_class/chado_phenotype.class.inc
@@ -0,0 +1,373 @@
+ 'serial',
+ 'uniquename' => 'text',
+ 'observable_id' => 'integer',
+ 'attr_id' => 'integer',
+ 'value' => 'text',
+ 'cvalue_id' => 'integer',
+ 'assay_id' => 'integer',
+ 'name' => 'text',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->phenotype_id = array_key_exists('phenotype_id', $details) ? $details['phenotype_id'] : '';
+ $this->uniquename = array_key_exists('uniquename', $details) ? $details['uniquename'] : '';
+ $this->observable_id = array_key_exists('observable_id', $details) ? $details['observable_id'] : '';
+ $this->attr_id = array_key_exists('attr_id', $details) ? $details['attr_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->cvalue_id = array_key_exists('cvalue_id', $details) ? $details['cvalue_id'] : '';
+ $this->assay_id = array_key_exists('assay_id', $details) ? $details['assay_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_PHENOTYPE by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.phenotype WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['uniquename'] = $this->uniquename;
+ $fields['value'] = $this->value;
+ $fields['name'] = $this->name;
+ if (is_numeric($this->observable_id)) { $fields['observable_id'] = $this->observable_id; }
+ if (is_numeric($this->attr_id)) { $fields['attr_id'] = $this->attr_id; }
+ if (is_numeric($this->cvalue_id)) { $fields['cvalue_id'] = $this->cvalue_id; }
+ if (is_numeric($this->assay_id)) { $fields['assay_id'] = $this->assay_id; }
+
+ // Inserts the record.
+ $this->phenotype_id = db_insert('chado.phenotype')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['uniquename'] = $this->uniquename;
+ $fields['value'] = $this->value;
+ $fields['name'] = $this->name;
+ if (is_numeric($this->observable_id)) { $fields['observable_id'] = $this->observable_id; }
+ if (is_numeric($this->attr_id)) { $fields['attr_id'] = $this->attr_id; }
+ if (is_numeric($this->cvalue_id)) { $fields['cvalue_id'] = $this->cvalue_id; }
+ if (is_numeric($this->assay_id)) { $fields['assay_id'] = $this->assay_id; }
+
+ // Updates the record.
+ db_update('chado.phenotype')
+ ->fields($fields)
+ ->condition('phenotype_id', $this->phenotype_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.phenotype')
+ ->condition('phenotype_id', $this->phenotype_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the phenotype_id.
+ *
+ * @retrun serial
+ */
+ public function getPhenotypeID() {
+ return $this->phenotype_id;
+ }
+
+ /**
+ * Updates the phenotype_id.
+ *
+ * @param serial $phenotype_id
+ */
+ public function setPhenotypeID($phenotype_id) {
+ $this->phenotype_id = $phenotype_id;
+ }
+
+ /**
+ * Retrieves the uniquename.
+ *
+ * @retrun text
+ */
+ public function getUniquename() {
+ return $this->uniquename;
+ }
+
+ /**
+ * Updates the uniquename.
+ *
+ * @param text $uniquename
+ */
+ public function setUniquename($uniquename) {
+ $this->uniquename = $uniquename;
+ }
+
+ /**
+ * Retrieves the observable_id.
+ *
+ * @retrun integer
+ */
+ public function getObservableID() {
+ return $this->observable_id;
+ }
+
+ /**
+ * Updates the observable_id.
+ *
+ * @param integer $observable_id
+ */
+ public function setObservableID($observable_id) {
+ $this->observable_id = $observable_id;
+ }
+
+ /**
+ * Retrieves the attr_id.
+ *
+ * @retrun integer
+ */
+ public function getAttrID() {
+ return $this->attr_id;
+ }
+
+ /**
+ * Updates the attr_id.
+ *
+ * @param integer $attr_id
+ */
+ public function setAttrID($attr_id) {
+ $this->attr_id = $attr_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the cvalue_id.
+ *
+ * @retrun integer
+ */
+ public function getCvalueID() {
+ return $this->cvalue_id;
+ }
+
+ /**
+ * Updates the cvalue_id.
+ *
+ * @param integer $cvalue_id
+ */
+ public function setCvalueID($cvalue_id) {
+ $this->cvalue_id = $cvalue_id;
+ }
+
+ /**
+ * Retrieves the assay_id.
+ *
+ * @retrun integer
+ */
+ public function getAssayID() {
+ return $this->assay_id;
+ }
+
+ /**
+ * Updates the assay_id.
+ *
+ * @param integer $assay_id
+ */
+ public function setAssayID($assay_id) {
+ $this->assay_id = $assay_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun text
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param text $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_project.class.inc b/includes/class/chado_table_class/chado_project.class.inc
new file mode 100644
index 0000000..14fec5f
--- /dev/null
+++ b/includes/class/chado_table_class/chado_project.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'name' => 'character_varying(255)',
+ 'description' => 'character_varying(255)',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->project_id = array_key_exists('project_id', $details) ? $details['project_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->description = array_key_exists('description', $details) ? $details['description'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_PROJECT by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.project WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['description'] = $this->description;
+
+
+ // Inserts the record.
+ $this->project_id = db_insert('chado.project')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['description'] = $this->description;
+
+
+ // Updates the record.
+ db_update('chado.project')
+ ->fields($fields)
+ ->condition('project_id', $this->project_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.project')
+ ->condition('project_id', $this->project_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the project_id.
+ *
+ * @retrun serial
+ */
+ public function getProjectID() {
+ return $this->project_id;
+ }
+
+ /**
+ * Updates the project_id.
+ *
+ * @param serial $project_id
+ */
+ public function setProjectID($project_id) {
+ $this->project_id = $project_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the description.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getDescription() {
+ return $this->description;
+ }
+
+ /**
+ * Updates the description.
+ *
+ * @param character_varying(255) $description
+ */
+ public function setDescription($description) {
+ $this->description = $description;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_project_contact.class.inc b/includes/class/chado_table_class/chado_project_contact.class.inc
new file mode 100644
index 0000000..5bebe6e
--- /dev/null
+++ b/includes/class/chado_table_class/chado_project_contact.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'project_id' => 'integer',
+ 'contact_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->project_contact_id = array_key_exists('project_contact_id', $details) ? $details['project_contact_id'] : '';
+ $this->project_id = array_key_exists('project_id', $details) ? $details['project_id'] : '';
+ $this->contact_id = array_key_exists('contact_id', $details) ? $details['contact_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_PROJECT_CONTACT by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.project_contact WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['project_id'] = $this->project_id;
+ $fields['contact_id'] = $this->contact_id;
+
+
+ // Inserts the record.
+ $this->project_contact_id = db_insert('chado.project_contact')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['project_id'] = $this->project_id;
+ $fields['contact_id'] = $this->contact_id;
+
+
+ // Updates the record.
+ db_update('chado.project_contact')
+ ->fields($fields)
+ ->condition('project_contact_id', $this->project_contact_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.project_contact')
+ ->condition('project_contact_id', $this->project_contact_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the project_contact_id.
+ *
+ * @retrun serial
+ */
+ public function getProjectContactID() {
+ return $this->project_contact_id;
+ }
+
+ /**
+ * Updates the project_contact_id.
+ *
+ * @param serial $project_contact_id
+ */
+ public function setProjectContactID($project_contact_id) {
+ $this->project_contact_id = $project_contact_id;
+ }
+
+ /**
+ * Retrieves the project_id.
+ *
+ * @retrun integer
+ */
+ public function getProjectID() {
+ return $this->project_id;
+ }
+
+ /**
+ * Updates the project_id.
+ *
+ * @param integer $project_id
+ */
+ public function setProjectID($project_id) {
+ $this->project_id = $project_id;
+ }
+
+ /**
+ * Retrieves the contact_id.
+ *
+ * @retrun integer
+ */
+ public function getContactID() {
+ return $this->contact_id;
+ }
+
+ /**
+ * Updates the contact_id.
+ *
+ * @param integer $contact_id
+ */
+ public function setContactID($contact_id) {
+ $this->contact_id = $contact_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_project_pub.class.inc b/includes/class/chado_table_class/chado_project_pub.class.inc
new file mode 100644
index 0000000..f17980f
--- /dev/null
+++ b/includes/class/chado_table_class/chado_project_pub.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'project_id' => 'integer',
+ 'pub_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->project_pub_id = array_key_exists('project_pub_id', $details) ? $details['project_pub_id'] : '';
+ $this->project_id = array_key_exists('project_id', $details) ? $details['project_id'] : '';
+ $this->pub_id = array_key_exists('pub_id', $details) ? $details['pub_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_PROJECT_PUB by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.project_pub WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['project_id'] = $this->project_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Inserts the record.
+ $this->project_pub_id = db_insert('chado.project_pub')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['project_id'] = $this->project_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Updates the record.
+ db_update('chado.project_pub')
+ ->fields($fields)
+ ->condition('project_pub_id', $this->project_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.project_pub')
+ ->condition('project_pub_id', $this->project_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the project_pub_id.
+ *
+ * @retrun serial
+ */
+ public function getProjectPubID() {
+ return $this->project_pub_id;
+ }
+
+ /**
+ * Updates the project_pub_id.
+ *
+ * @param serial $project_pub_id
+ */
+ public function setProjectPubID($project_pub_id) {
+ $this->project_pub_id = $project_pub_id;
+ }
+
+ /**
+ * Retrieves the project_id.
+ *
+ * @retrun integer
+ */
+ public function getProjectID() {
+ return $this->project_id;
+ }
+
+ /**
+ * Updates the project_id.
+ *
+ * @param integer $project_id
+ */
+ public function setProjectID($project_id) {
+ $this->project_id = $project_id;
+ }
+
+ /**
+ * Retrieves the pub_id.
+ *
+ * @retrun integer
+ */
+ public function getPubID() {
+ return $this->pub_id;
+ }
+
+ /**
+ * Updates the pub_id.
+ *
+ * @param integer $pub_id
+ */
+ public function setPubID($pub_id) {
+ $this->pub_id = $pub_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_project_relationship.class.inc b/includes/class/chado_table_class/chado_project_relationship.class.inc
new file mode 100644
index 0000000..0505ec2
--- /dev/null
+++ b/includes/class/chado_table_class/chado_project_relationship.class.inc
@@ -0,0 +1,283 @@
+ 'serial',
+ 'subject_project_id' => 'integer',
+ 'object_project_id' => 'integer',
+ 'type_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->project_relationship_id = array_key_exists('project_relationship_id', $details) ? $details['project_relationship_id'] : '';
+ $this->subject_project_id = array_key_exists('subject_project_id', $details) ? $details['subject_project_id'] : '';
+ $this->object_project_id = array_key_exists('object_project_id', $details) ? $details['object_project_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_PROJECT_RELATIONSHIP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.project_relationship WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['subject_project_id'] = $this->subject_project_id;
+ $fields['object_project_id'] = $this->object_project_id;
+ $fields['type_id'] = $this->type_id;
+
+
+ // Inserts the record.
+ $this->project_relationship_id = db_insert('chado.project_relationship')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['subject_project_id'] = $this->subject_project_id;
+ $fields['object_project_id'] = $this->object_project_id;
+ $fields['type_id'] = $this->type_id;
+
+
+ // Updates the record.
+ db_update('chado.project_relationship')
+ ->fields($fields)
+ ->condition('project_relationship_id', $this->project_relationship_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.project_relationship')
+ ->condition('project_relationship_id', $this->project_relationship_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the project_relationship_id.
+ *
+ * @retrun serial
+ */
+ public function getProjectRelationshipID() {
+ return $this->project_relationship_id;
+ }
+
+ /**
+ * Updates the project_relationship_id.
+ *
+ * @param serial $project_relationship_id
+ */
+ public function setProjectRelationshipID($project_relationship_id) {
+ $this->project_relationship_id = $project_relationship_id;
+ }
+
+ /**
+ * Retrieves the subject_project_id.
+ *
+ * @retrun integer
+ */
+ public function getSubjectProjectID() {
+ return $this->subject_project_id;
+ }
+
+ /**
+ * Updates the subject_project_id.
+ *
+ * @param integer $subject_project_id
+ */
+ public function setSubjectProjectID($subject_project_id) {
+ $this->subject_project_id = $subject_project_id;
+ }
+
+ /**
+ * Retrieves the object_project_id.
+ *
+ * @retrun integer
+ */
+ public function getObjectProjectID() {
+ return $this->object_project_id;
+ }
+
+ /**
+ * Updates the object_project_id.
+ *
+ * @param integer $object_project_id
+ */
+ public function setObjectProjectID($object_project_id) {
+ $this->object_project_id = $object_project_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_projectprop.class.inc b/includes/class/chado_table_class/chado_projectprop.class.inc
new file mode 100644
index 0000000..83cbc0d
--- /dev/null
+++ b/includes/class/chado_table_class/chado_projectprop.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'project_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->projectprop_id = array_key_exists('projectprop_id', $details) ? $details['projectprop_id'] : '';
+ $this->project_id = array_key_exists('project_id', $details) ? $details['project_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_PROJECTPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.projectprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['project_id'] = $this->project_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->projectprop_id = db_insert('chado.projectprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['project_id'] = $this->project_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.projectprop')
+ ->fields($fields)
+ ->condition('projectprop_id', $this->projectprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.projectprop')
+ ->condition('projectprop_id', $this->projectprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the projectprop_id.
+ *
+ * @retrun serial
+ */
+ public function getProjectpropID() {
+ return $this->projectprop_id;
+ }
+
+ /**
+ * Updates the projectprop_id.
+ *
+ * @param serial $projectprop_id
+ */
+ public function setProjectpropID($projectprop_id) {
+ $this->projectprop_id = $projectprop_id;
+ }
+
+ /**
+ * Retrieves the project_id.
+ *
+ * @retrun integer
+ */
+ public function getProjectID() {
+ return $this->project_id;
+ }
+
+ /**
+ * Updates the project_id.
+ *
+ * @param integer $project_id
+ */
+ public function setProjectID($project_id) {
+ $this->project_id = $project_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_pub.class.inc b/includes/class/chado_table_class/chado_pub.class.inc
new file mode 100644
index 0000000..ad4b7d0
--- /dev/null
+++ b/includes/class/chado_table_class/chado_pub.class.inc
@@ -0,0 +1,511 @@
+ 'serial',
+ 'title' => 'text',
+ 'volumetitle' => 'text',
+ 'volume' => 'character_varying(255)',
+ 'series_name' => 'character_varying(255)',
+ 'issue' => 'character_varying(255)',
+ 'pyear' => 'character_varying(255)',
+ 'pages' => 'character_varying(255)',
+ 'miniref' => 'character_varying(255)',
+ 'uniquename' => 'text',
+ 'type_id' => 'integer',
+ 'is_obsolete' => 'boolean',
+ 'publisher' => 'character_varying(255)',
+ 'pubplace' => 'character_varying(255)',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->pub_id = array_key_exists('pub_id', $details) ? $details['pub_id'] : '';
+ $this->title = array_key_exists('title', $details) ? $details['title'] : '';
+ $this->volumetitle = array_key_exists('volumetitle', $details) ? $details['volumetitle'] : '';
+ $this->volume = array_key_exists('volume', $details) ? $details['volume'] : '';
+ $this->series_name = array_key_exists('series_name', $details) ? $details['series_name'] : '';
+ $this->issue = array_key_exists('issue', $details) ? $details['issue'] : '';
+ $this->pyear = array_key_exists('pyear', $details) ? $details['pyear'] : '';
+ $this->pages = array_key_exists('pages', $details) ? $details['pages'] : '';
+ $this->miniref = array_key_exists('miniref', $details) ? $details['miniref'] : '';
+ $this->uniquename = array_key_exists('uniquename', $details) ? $details['uniquename'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->is_obsolete = array_key_exists('is_obsolete', $details) ? $details['is_obsolete'] : '';
+ $this->publisher = array_key_exists('publisher', $details) ? $details['publisher'] : '';
+ $this->pubplace = array_key_exists('pubplace', $details) ? $details['pubplace'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_PUB by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.pub WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['title'] = $this->title;
+ $fields['volumetitle'] = $this->volumetitle;
+ $fields['volume'] = $this->volume;
+ $fields['series_name'] = $this->series_name;
+ $fields['issue'] = $this->issue;
+ $fields['pyear'] = $this->pyear;
+ $fields['pages'] = $this->pages;
+ $fields['miniref'] = $this->miniref;
+ $fields['uniquename'] = $this->uniquename;
+ $fields['type_id'] = $this->type_id;
+ $fields['publisher'] = $this->publisher;
+ $fields['pubplace'] = $this->pubplace;
+ if (preg_match("/^(true|false)/i", $this->is_obsolete)) { $fields['is_obsolete'] = '$this->is_obsolete'; }
+
+ // Inserts the record.
+ $this->pub_id = db_insert('chado.pub')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['title'] = $this->title;
+ $fields['volumetitle'] = $this->volumetitle;
+ $fields['volume'] = $this->volume;
+ $fields['series_name'] = $this->series_name;
+ $fields['issue'] = $this->issue;
+ $fields['pyear'] = $this->pyear;
+ $fields['pages'] = $this->pages;
+ $fields['miniref'] = $this->miniref;
+ $fields['uniquename'] = $this->uniquename;
+ $fields['type_id'] = $this->type_id;
+ $fields['publisher'] = $this->publisher;
+ $fields['pubplace'] = $this->pubplace;
+ if (preg_match("/^(true|false)/i", $this->is_obsolete)) { $fields['is_obsolete'] = '$this->is_obsolete'; }
+
+ // Updates the record.
+ db_update('chado.pub')
+ ->fields($fields)
+ ->condition('pub_id', $this->pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.pub')
+ ->condition('pub_id', $this->pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the pub_id.
+ *
+ * @retrun serial
+ */
+ public function getPubID() {
+ return $this->pub_id;
+ }
+
+ /**
+ * Updates the pub_id.
+ *
+ * @param serial $pub_id
+ */
+ public function setPubID($pub_id) {
+ $this->pub_id = $pub_id;
+ }
+
+ /**
+ * Retrieves the title.
+ *
+ * @retrun text
+ */
+ public function getTitle() {
+ return $this->title;
+ }
+
+ /**
+ * Updates the title.
+ *
+ * @param text $title
+ */
+ public function setTitle($title) {
+ $this->title = $title;
+ }
+
+ /**
+ * Retrieves the volumetitle.
+ *
+ * @retrun text
+ */
+ public function getVolumetitle() {
+ return $this->volumetitle;
+ }
+
+ /**
+ * Updates the volumetitle.
+ *
+ * @param text $volumetitle
+ */
+ public function setVolumetitle($volumetitle) {
+ $this->volumetitle = $volumetitle;
+ }
+
+ /**
+ * Retrieves the volume.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getVolume() {
+ return $this->volume;
+ }
+
+ /**
+ * Updates the volume.
+ *
+ * @param character_varying(255) $volume
+ */
+ public function setVolume($volume) {
+ $this->volume = $volume;
+ }
+
+ /**
+ * Retrieves the series_name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getSeriesName() {
+ return $this->series_name;
+ }
+
+ /**
+ * Updates the series_name.
+ *
+ * @param character_varying(255) $series_name
+ */
+ public function setSeriesName($series_name) {
+ $this->series_name = $series_name;
+ }
+
+ /**
+ * Retrieves the issue.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getIssue() {
+ return $this->issue;
+ }
+
+ /**
+ * Updates the issue.
+ *
+ * @param character_varying(255) $issue
+ */
+ public function setIssue($issue) {
+ $this->issue = $issue;
+ }
+
+ /**
+ * Retrieves the pyear.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getPyear() {
+ return $this->pyear;
+ }
+
+ /**
+ * Updates the pyear.
+ *
+ * @param character_varying(255) $pyear
+ */
+ public function setPyear($pyear) {
+ $this->pyear = $pyear;
+ }
+
+ /**
+ * Retrieves the pages.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getPages() {
+ return $this->pages;
+ }
+
+ /**
+ * Updates the pages.
+ *
+ * @param character_varying(255) $pages
+ */
+ public function setPages($pages) {
+ $this->pages = $pages;
+ }
+
+ /**
+ * Retrieves the miniref.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getMiniref() {
+ return $this->miniref;
+ }
+
+ /**
+ * Updates the miniref.
+ *
+ * @param character_varying(255) $miniref
+ */
+ public function setMiniref($miniref) {
+ $this->miniref = $miniref;
+ }
+
+ /**
+ * Retrieves the uniquename.
+ *
+ * @retrun text
+ */
+ public function getUniquename() {
+ return $this->uniquename;
+ }
+
+ /**
+ * Updates the uniquename.
+ *
+ * @param text $uniquename
+ */
+ public function setUniquename($uniquename) {
+ $this->uniquename = $uniquename;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the is_obsolete.
+ *
+ * @retrun boolean
+ */
+ public function getIsObsolete() {
+ return $this->is_obsolete;
+ }
+
+ /**
+ * Updates the is_obsolete.
+ *
+ * @param boolean $is_obsolete
+ */
+ public function setIsObsolete($is_obsolete) {
+ $this->is_obsolete = $is_obsolete;
+ }
+
+ /**
+ * Retrieves the publisher.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getPublisher() {
+ return $this->publisher;
+ }
+
+ /**
+ * Updates the publisher.
+ *
+ * @param character_varying(255) $publisher
+ */
+ public function setPublisher($publisher) {
+ $this->publisher = $publisher;
+ }
+
+ /**
+ * Retrieves the pubplace.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getPubplace() {
+ return $this->pubplace;
+ }
+
+ /**
+ * Updates the pubplace.
+ *
+ * @param character_varying(255) $pubplace
+ */
+ public function setPubplace($pubplace) {
+ $this->pubplace = $pubplace;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_stock.class.inc b/includes/class/chado_table_class/chado_stock.class.inc
new file mode 100644
index 0000000..5ae1bfc
--- /dev/null
+++ b/includes/class/chado_table_class/chado_stock.class.inc
@@ -0,0 +1,373 @@
+ 'serial',
+ 'dbxref_id' => 'integer',
+ 'organism_id' => 'integer',
+ 'name' => 'character_varying(255)',
+ 'uniquename' => 'text',
+ 'description' => 'text',
+ 'type_id' => 'integer',
+ 'is_obsolete' => 'boolean',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->stock_id = array_key_exists('stock_id', $details) ? $details['stock_id'] : '';
+ $this->dbxref_id = array_key_exists('dbxref_id', $details) ? $details['dbxref_id'] : '';
+ $this->organism_id = array_key_exists('organism_id', $details) ? $details['organism_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->uniquename = array_key_exists('uniquename', $details) ? $details['uniquename'] : '';
+ $this->description = array_key_exists('description', $details) ? $details['description'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->is_obsolete = array_key_exists('is_obsolete', $details) ? $details['is_obsolete'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_STOCK by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.stock WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['uniquename'] = $this->uniquename;
+ $fields['description'] = $this->description;
+ $fields['type_id'] = $this->type_id;
+ $fields['is_obsolete'] = (preg_match("/^(true|false)/i", $this->is_obsolete)) ? "'" . $this->is_obsolete . "'" : 'false';
+ if (is_numeric($this->dbxref_id)) { $fields['dbxref_id'] = $this->dbxref_id; }
+ if (is_numeric($this->organism_id)) { $fields['organism_id'] = $this->organism_id; }
+
+ // Inserts the record.
+ $this->stock_id = db_insert('chado.stock')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['uniquename'] = $this->uniquename;
+ $fields['description'] = $this->description;
+ $fields['type_id'] = $this->type_id;
+ $fields['is_obsolete'] = (preg_match("/^(true|false)/i", $this->is_obsolete)) ? "'" . $this->is_obsolete . "'" : 'false';
+ if (is_numeric($this->dbxref_id)) { $fields['dbxref_id'] = $this->dbxref_id; }
+ if (is_numeric($this->organism_id)) { $fields['organism_id'] = $this->organism_id; }
+
+ // Updates the record.
+ db_update('chado.stock')
+ ->fields($fields)
+ ->condition('stock_id', $this->stock_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.stock')
+ ->condition('stock_id', $this->stock_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the stock_id.
+ *
+ * @retrun serial
+ */
+ public function getStockID() {
+ return $this->stock_id;
+ }
+
+ /**
+ * Updates the stock_id.
+ *
+ * @param serial $stock_id
+ */
+ public function setStockID($stock_id) {
+ $this->stock_id = $stock_id;
+ }
+
+ /**
+ * Retrieves the dbxref_id.
+ *
+ * @retrun integer
+ */
+ public function getDbxrefID() {
+ return $this->dbxref_id;
+ }
+
+ /**
+ * Updates the dbxref_id.
+ *
+ * @param integer $dbxref_id
+ */
+ public function setDbxrefID($dbxref_id) {
+ $this->dbxref_id = $dbxref_id;
+ }
+
+ /**
+ * Retrieves the organism_id.
+ *
+ * @retrun integer
+ */
+ public function getOrganismID() {
+ return $this->organism_id;
+ }
+
+ /**
+ * Updates the organism_id.
+ *
+ * @param integer $organism_id
+ */
+ public function setOrganismID($organism_id) {
+ $this->organism_id = $organism_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the uniquename.
+ *
+ * @retrun text
+ */
+ public function getUniquename() {
+ return $this->uniquename;
+ }
+
+ /**
+ * Updates the uniquename.
+ *
+ * @param text $uniquename
+ */
+ public function setUniquename($uniquename) {
+ $this->uniquename = $uniquename;
+ }
+
+ /**
+ * Retrieves the description.
+ *
+ * @retrun text
+ */
+ public function getDescription() {
+ return $this->description;
+ }
+
+ /**
+ * Updates the description.
+ *
+ * @param text $description
+ */
+ public function setDescription($description) {
+ $this->description = $description;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the is_obsolete.
+ *
+ * @retrun boolean
+ */
+ public function getIsObsolete() {
+ return $this->is_obsolete;
+ }
+
+ /**
+ * Updates the is_obsolete.
+ *
+ * @param boolean $is_obsolete
+ */
+ public function setIsObsolete($is_obsolete) {
+ $this->is_obsolete = $is_obsolete;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_stock_dbxref.class.inc b/includes/class/chado_table_class/chado_stock_dbxref.class.inc
new file mode 100644
index 0000000..48db44d
--- /dev/null
+++ b/includes/class/chado_table_class/chado_stock_dbxref.class.inc
@@ -0,0 +1,283 @@
+ 'serial',
+ 'stock_id' => 'integer',
+ 'dbxref_id' => 'integer',
+ 'is_current' => 'boolean',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->stock_dbxref_id = array_key_exists('stock_dbxref_id', $details) ? $details['stock_dbxref_id'] : '';
+ $this->stock_id = array_key_exists('stock_id', $details) ? $details['stock_id'] : '';
+ $this->dbxref_id = array_key_exists('dbxref_id', $details) ? $details['dbxref_id'] : '';
+ $this->is_current = array_key_exists('is_current', $details) ? $details['is_current'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_STOCK_DBXREF by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.stock_dbxref WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['stock_id'] = $this->stock_id;
+ $fields['dbxref_id'] = $this->dbxref_id;
+ $fields['is_current'] = (preg_match("/^(true|false)/i", $this->is_current)) ? "'" . $this->is_current . "'" : 'true';
+
+
+ // Inserts the record.
+ $this->stock_dbxref_id = db_insert('chado.stock_dbxref')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['stock_id'] = $this->stock_id;
+ $fields['dbxref_id'] = $this->dbxref_id;
+ $fields['is_current'] = (preg_match("/^(true|false)/i", $this->is_current)) ? "'" . $this->is_current . "'" : 'true';
+
+
+ // Updates the record.
+ db_update('chado.stock_dbxref')
+ ->fields($fields)
+ ->condition('stock_dbxref_id', $this->stock_dbxref_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.stock_dbxref')
+ ->condition('stock_dbxref_id', $this->stock_dbxref_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the stock_dbxref_id.
+ *
+ * @retrun serial
+ */
+ public function getStockDbxrefID() {
+ return $this->stock_dbxref_id;
+ }
+
+ /**
+ * Updates the stock_dbxref_id.
+ *
+ * @param serial $stock_dbxref_id
+ */
+ public function setStockDbxrefID($stock_dbxref_id) {
+ $this->stock_dbxref_id = $stock_dbxref_id;
+ }
+
+ /**
+ * Retrieves the stock_id.
+ *
+ * @retrun integer
+ */
+ public function getStockID() {
+ return $this->stock_id;
+ }
+
+ /**
+ * Updates the stock_id.
+ *
+ * @param integer $stock_id
+ */
+ public function setStockID($stock_id) {
+ $this->stock_id = $stock_id;
+ }
+
+ /**
+ * Retrieves the dbxref_id.
+ *
+ * @retrun integer
+ */
+ public function getDbxrefID() {
+ return $this->dbxref_id;
+ }
+
+ /**
+ * Updates the dbxref_id.
+ *
+ * @param integer $dbxref_id
+ */
+ public function setDbxrefID($dbxref_id) {
+ $this->dbxref_id = $dbxref_id;
+ }
+
+ /**
+ * Retrieves the is_current.
+ *
+ * @retrun boolean
+ */
+ public function getIsCurrent() {
+ return $this->is_current;
+ }
+
+ /**
+ * Updates the is_current.
+ *
+ * @param boolean $is_current
+ */
+ public function setIsCurrent($is_current) {
+ $this->is_current = $is_current;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_stock_pub.class.inc b/includes/class/chado_table_class/chado_stock_pub.class.inc
new file mode 100644
index 0000000..03c86ff
--- /dev/null
+++ b/includes/class/chado_table_class/chado_stock_pub.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'stock_id' => 'integer',
+ 'pub_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->stock_pub_id = array_key_exists('stock_pub_id', $details) ? $details['stock_pub_id'] : '';
+ $this->stock_id = array_key_exists('stock_id', $details) ? $details['stock_id'] : '';
+ $this->pub_id = array_key_exists('pub_id', $details) ? $details['pub_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_STOCK_PUB by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.stock_pub WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['stock_id'] = $this->stock_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Inserts the record.
+ $this->stock_pub_id = db_insert('chado.stock_pub')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['stock_id'] = $this->stock_id;
+ $fields['pub_id'] = $this->pub_id;
+
+
+ // Updates the record.
+ db_update('chado.stock_pub')
+ ->fields($fields)
+ ->condition('stock_pub_id', $this->stock_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.stock_pub')
+ ->condition('stock_pub_id', $this->stock_pub_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the stock_pub_id.
+ *
+ * @retrun serial
+ */
+ public function getStockPubID() {
+ return $this->stock_pub_id;
+ }
+
+ /**
+ * Updates the stock_pub_id.
+ *
+ * @param serial $stock_pub_id
+ */
+ public function setStockPubID($stock_pub_id) {
+ $this->stock_pub_id = $stock_pub_id;
+ }
+
+ /**
+ * Retrieves the stock_id.
+ *
+ * @retrun integer
+ */
+ public function getStockID() {
+ return $this->stock_id;
+ }
+
+ /**
+ * Updates the stock_id.
+ *
+ * @param integer $stock_id
+ */
+ public function setStockID($stock_id) {
+ $this->stock_id = $stock_id;
+ }
+
+ /**
+ * Retrieves the pub_id.
+ *
+ * @retrun integer
+ */
+ public function getPubID() {
+ return $this->pub_id;
+ }
+
+ /**
+ * Updates the pub_id.
+ *
+ * @param integer $pub_id
+ */
+ public function setPubID($pub_id) {
+ $this->pub_id = $pub_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_stock_relationship.class.inc b/includes/class/chado_table_class/chado_stock_relationship.class.inc
new file mode 100644
index 0000000..6ac2d10
--- /dev/null
+++ b/includes/class/chado_table_class/chado_stock_relationship.class.inc
@@ -0,0 +1,329 @@
+ 'serial',
+ 'subject_id' => 'integer',
+ 'object_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->stock_relationship_id = array_key_exists('stock_relationship_id', $details) ? $details['stock_relationship_id'] : '';
+ $this->subject_id = array_key_exists('subject_id', $details) ? $details['subject_id'] : '';
+ $this->object_id = array_key_exists('object_id', $details) ? $details['object_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_STOCK_RELATIONSHIP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.stock_relationship WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['subject_id'] = $this->subject_id;
+ $fields['object_id'] = $this->object_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->stock_relationship_id = db_insert('chado.stock_relationship')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['subject_id'] = $this->subject_id;
+ $fields['object_id'] = $this->object_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.stock_relationship')
+ ->fields($fields)
+ ->condition('stock_relationship_id', $this->stock_relationship_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.stock_relationship')
+ ->condition('stock_relationship_id', $this->stock_relationship_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the stock_relationship_id.
+ *
+ * @retrun serial
+ */
+ public function getStockRelationshipID() {
+ return $this->stock_relationship_id;
+ }
+
+ /**
+ * Updates the stock_relationship_id.
+ *
+ * @param serial $stock_relationship_id
+ */
+ public function setStockRelationshipID($stock_relationship_id) {
+ $this->stock_relationship_id = $stock_relationship_id;
+ }
+
+ /**
+ * Retrieves the subject_id.
+ *
+ * @retrun integer
+ */
+ public function getSubjectID() {
+ return $this->subject_id;
+ }
+
+ /**
+ * Updates the subject_id.
+ *
+ * @param integer $subject_id
+ */
+ public function setSubjectID($subject_id) {
+ $this->subject_id = $subject_id;
+ }
+
+ /**
+ * Retrieves the object_id.
+ *
+ * @retrun integer
+ */
+ public function getObjectID() {
+ return $this->object_id;
+ }
+
+ /**
+ * Updates the object_id.
+ *
+ * @param integer $object_id
+ */
+ public function setObjectID($object_id) {
+ $this->object_id = $object_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_stockprop.class.inc b/includes/class/chado_table_class/chado_stockprop.class.inc
new file mode 100644
index 0000000..0553020
--- /dev/null
+++ b/includes/class/chado_table_class/chado_stockprop.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'stock_id' => 'integer',
+ 'type_id' => 'integer',
+ 'value' => 'text',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->stockprop_id = array_key_exists('stockprop_id', $details) ? $details['stockprop_id'] : '';
+ $this->stock_id = array_key_exists('stock_id', $details) ? $details['stock_id'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : 0;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_STOCKPROP by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.stockprop WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['stock_id'] = $this->stock_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Inserts the record.
+ $this->stockprop_id = db_insert('chado.stockprop')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['stock_id'] = $this->stock_id;
+ $fields['type_id'] = $this->type_id;
+ $fields['value'] = $this->value;
+ $fields['rank'] = (is_numeric($this->rank)) ? $this->rank : 0;
+
+
+ // Updates the record.
+ db_update('chado.stockprop')
+ ->fields($fields)
+ ->condition('stockprop_id', $this->stockprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.stockprop')
+ ->condition('stockprop_id', $this->stockprop_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the stockprop_id.
+ *
+ * @retrun serial
+ */
+ public function getStockpropID() {
+ return $this->stockprop_id;
+ }
+
+ /**
+ * Updates the stockprop_id.
+ *
+ * @param serial $stockprop_id
+ */
+ public function setStockpropID($stockprop_id) {
+ $this->stockprop_id = $stockprop_id;
+ }
+
+ /**
+ * Retrieves the stock_id.
+ *
+ * @retrun integer
+ */
+ public function getStockID() {
+ return $this->stock_id;
+ }
+
+ /**
+ * Updates the stock_id.
+ *
+ * @param integer $stock_id
+ */
+ public function setStockID($stock_id) {
+ $this->stock_id = $stock_id;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun text
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param text $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/chado_table_class/chado_synonym.class.inc b/includes/class/chado_table_class/chado_synonym.class.inc
new file mode 100644
index 0000000..575008c
--- /dev/null
+++ b/includes/class/chado_table_class/chado_synonym.class.inc
@@ -0,0 +1,283 @@
+ 'serial',
+ 'name' => 'character_varying(255)',
+ 'type_id' => 'integer',
+ 'synonym_sgml' => 'character_varying(255)',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->synonym_id = array_key_exists('synonym_id', $details) ? $details['synonym_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->type_id = array_key_exists('type_id', $details) ? $details['type_id'] : '';
+ $this->synonym_sgml = array_key_exists('synonym_sgml', $details) ? $details['synonym_sgml'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate CHADO_SYNONYM by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM chado.synonym WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['type_id'] = $this->type_id;
+ $fields['synonym_sgml'] = $this->synonym_sgml;
+
+
+ // Inserts the record.
+ $this->synonym_id = db_insert('chado.synonym')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['type_id'] = $this->type_id;
+ $fields['synonym_sgml'] = $this->synonym_sgml;
+
+
+ // Updates the record.
+ db_update('chado.synonym')
+ ->fields($fields)
+ ->condition('synonym_id', $this->synonym_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('chado.synonym')
+ ->condition('synonym_id', $this->synonym_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the synonym_id.
+ *
+ * @retrun serial
+ */
+ public function getSynonymID() {
+ return $this->synonym_id;
+ }
+
+ /**
+ * Updates the synonym_id.
+ *
+ * @param serial $synonym_id
+ */
+ public function setSynonymID($synonym_id) {
+ $this->synonym_id = $synonym_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the type_id.
+ *
+ * @retrun integer
+ */
+ public function getTypeID() {
+ return $this->type_id;
+ }
+
+ /**
+ * Updates the type_id.
+ *
+ * @param integer $type_id
+ */
+ public function setTypeID($type_id) {
+ $this->type_id = $type_id;
+ }
+
+ /**
+ * Retrieves the synonym_sgml.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getSynonymSgml() {
+ return $this->synonym_sgml;
+ }
+
+ /**
+ * Updates the synonym_sgml.
+ *
+ * @param character_varying(255) $synonym_sgml
+ */
+ public function setSynonymSgml($synonym_sgml) {
+ $this->synonym_sgml = $synonym_sgml;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/excel/mcl_excel.class.inc b/includes/class/excel/mcl_excel.class.inc
new file mode 100644
index 0000000..07bf5fc
--- /dev/null
+++ b/includes/class/excel/mcl_excel.class.inc
@@ -0,0 +1,487 @@
+ Header array
+ *
+ * $header['A'] = array('heading' => 'dataset_name');
+ * $header['B'] = array('heading' => 'ID');
+ * $header['C'] = array('heading' => 'smaple_ID');
+ *
+ */
+ private $sheets = NULL;
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+
+ // Initializes data members.
+ $this->creator = array_key_exists('creator', $details) ? $details['creator'] : 'UNKNOWN';
+ $this->filepath = array_key_exists('filepath', $details) ? $details['filepath'] : '';
+ $this->filename = array_key_exists('filename', $details) ? $details['filename'] : '';
+ $this->title = array_key_exists('title', $details) ? $details['title'] : 'NEW TITLE';
+ $this->subject = array_key_exists('subject ', $details) ? $details['subject '] : '';
+ $this->keywords = array_key_exists('keywords ', $details) ? $details['keywords '] : '';
+ $this->category = array_key_exists('category', $details) ? $details['category'] : '';
+ $this->version = array_key_exists('version', $details) ? $details['version'] : '';
+ $this->sheets = array_key_exists('sheets', $details) ? $details['sheets'] : array();
+ $this->header_flag = array_key_exists('header_flag', $details) ? $details['header_flag'] : TRUE;
+
+ // Updates filename.
+ if ($this->filepath && !$this->filename) {
+ $this->filename = basename($this->filepath);
+ }
+
+ // Sets the default version.
+ if (!$this->version) {
+ $this->version = 'Excel2007';
+ }
+
+ // Creates new PHPExcel object.
+ $this->excel = new PHPExcel();
+
+ // Sets the properties of an Excel file.
+ $this->_setExcelProperties();
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {}
+
+ /**
+ * Creates an excel file.
+ *
+ * @param array $data
+ */
+ public function create($type = 'online') {
+
+ // Returns if $this->data is empty.
+ if (empty($this->sheets)) {
+ return;
+ }
+
+ // Populates excel sheets.
+ $sheet_no = 0;
+ foreach ($this->sheets as $sheet) {
+
+ // Sets header flag.
+ $header_flag = empty($sheet['headers']) ? FALSE : TRUE;
+ $data_flag = empty($sheet['data']) ? FALSE : TRUE;
+
+ // Adds a new worksheet.
+ if ($sheet_no) {
+ $this->excel->createSheet();
+ }
+
+ // Creates an excel sheet.
+ $this->excel->setActiveSheetIndex($sheet_no++);
+
+ // Sets sheet name.
+ $this->excel->getActiveSheet()->setTitle($sheet['name']);
+
+ // Adds headers.
+ if ($header_flag) {
+
+ // Sets the styles of an Excel sheet.
+ $this->_setExcelStyle($sheet['headers']);
+
+ // Writes headers.
+ foreach ($sheet['headers'] as $col_chr => $arr) {
+ $this->excel->getActiveSheet()->setCellValue($col_chr . '1', $arr['heading']);
+ }
+ }
+
+ // Adds data
+ if ($data_flag) {
+
+ // Adds data rows.
+ foreach ($sheet['data'] as $idx => $row) {
+
+ // Process a row.
+ foreach ($row as $cell) {
+
+ // Updates the cell location.
+ $row_no = ($header_flag) ? $idx + 2 : $idx + 1;
+ $loc = $cell['col'] . $row_no;
+
+ // Add a cell.
+ $this->_addCell($loc, $cell);
+ }
+ }
+ }
+ }
+
+ // Downloads the excel file.
+ if ($type == 'online') {
+
+ // Redirects output to a client web browser.
+ header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+ header("Content-Disposition: attachment;filename=" . $this->filename);
+ header('Cache-Control: max-age=0');
+ $this->excel->setActiveSheetIndex(0);
+ $objWriter = PHPExcel_IOFactory::createWriter($this->excel, $this->version);
+ ob_end_clean();
+ $objWriter->save('php://output');
+ exit;
+ }
+ else {
+
+ // Saves the excel file
+ $this->excel->setActiveSheetIndex(0);
+ $objWriter = PHPExcel_IOFactory::createWriter($this->excel, $this->version);
+ $objWriter->save($this->filepath);
+ return TRUE;
+ }
+ }
+
+ /**
+ * Adds a cell to the sheet.
+ *
+ * @param string $loc
+ * @param array $cell
+ */
+ private function _addCell($loc, $cell) {
+
+ // Type : text
+ if ($cell['type'] == 'text') {
+ $this->excel->getActiveSheet()->setCellValue($loc, $cell['value']);
+ }
+
+ // Type : hyperlink
+ else if ($cell['type'] == 'link') {
+ $this->excel->getActiveSheet()->setCellValue($loc, $cell['value']);
+ if (array_key_exists('url', $cell)) {
+
+ // Adds an underline and sets the color for the link.
+ $this->excel->getActiveSheet()->getStyle($col_chr.$row_no)->getFont()->setColor(new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKBLUE ));
+ $this->excel->getStyle($loc)->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
+
+ // Sets URL.
+ $this->excel->getCell($loc)->getHyperlink()->setUrl($cell['url']);
+ }
+ }
+ }
+
+ /**
+ * Creates an Excel file from CSV files.
+ *
+ * @param array $csv_files
+ */
+ public function createFromCSV($csv_files) {
+
+ // Creates reader for reading CSV file.
+ $reader = PHPExcel_IOFactory::createReader('CSV');
+
+ // Creates Excel sheets.
+ $idx = 0;
+ foreach ($csv_files as $csv_filename => $csv_filepath) {
+
+ // Gets the file.
+ if (file_exists($csv_filepath)) {
+
+ // Gets the template name at the top of the line.
+ if (!($fdr = fopen($csv_filepath, 'r'))) {
+ return FALSE;
+ }
+ $tmp = dirname($csv_filepath) . '/tmp';
+ if (!($fdw = fopen($tmp, 'w'))) {
+ return FALSE;
+ }
+
+ // Copies the file except the first line.
+ $line_no = 1;
+ $template = '';
+ while (!feof($fdr)) {
+ $line = fgets($fdr);
+
+ if ($line_no == 1) {
+ $template = substr(trim($line), 1);
+ }
+ else {
+ fputs($fdw, $line);
+ }
+ $line_no++;
+ }
+ fclose($fdr);
+ fclose($fdw);
+
+ // Loads CSV file.
+ if ($idx == 0) {
+ $this->excel = $reader->load($tmp);
+ }
+ else {
+ $reader->setSheetIndex($idx);
+ $reader->LoadIntoExisting($tmp, $this->excel);
+ }
+
+ // Sets the sheet name.
+ $this->excel->getActiveSheet()->setTitle($template);
+ $idx++;
+ }
+ else {
+ return FALSE;
+ }
+ }
+
+ // Saves them to the Excel file.
+ $writer = PHPExcel_IOFactory::createWriter($this->excel, 'Excel2007');
+ $writer->save($this->filepath);
+ return TRUE;
+ }
+
+ /**
+ * Sets the properties of the Excel file.
+ *
+ */
+ private function _setExcelProperties() {
+
+ // Sets Excel File Properties.
+ if ($this->creator) {
+ $this->excel->getProperties()->setCreator($this->creator);
+ $this->excel->getProperties()->setLastModifiedBy($this->creator);
+ }
+ if ($this->title) {
+ $this->excel->getProperties()->setTitle($this->title);
+ }
+ if ($this->subject) {
+ $this->excel->getProperties()->setSubject($this->subject);
+ }
+ if ($this->keywords) {
+ $this->excel->getProperties()->setKeywords($this->keywords);
+ }
+ if ($this->category) {
+ $this->excel->getProperties()->setCategory($this->category);
+ }
+ if ($this->description) {
+ $this->excel->getProperties()->setDescription($this->description);
+ }
+ }
+
+ /**
+ * Sets the style of the Excel sheet.
+ *
+ * @param array $headers
+ */
+ private function _setExcelStyle($headers) {
+
+ // Sets the default styles.
+ $this->excel->getDefaultStyle()->getFont()->setName('Calibri');
+ $this->excel->getDefaultStyle()->getFont()->setSize(11);
+
+ // Sets the style for the headers.
+ foreach ($headers as $col_chr => $arr) {
+ if (array_key_exists('width', $arr)) {
+ $this->excel->getActiveSheet()->getColumnDimension($col_chr)->setWidth($arr['width']);
+ }
+ $this->excel->getActiveSheet()->getStyle($col_chr.'1')->getFont()->setBold(true);
+ $this->excel->getActiveSheet()->getStyle($col_chr.'1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
+ $this->excel->getActiveSheet()->getStyle($col_chr.'1')->getFill()->getStartColor()->setARGB('FFCECECE');
+ }
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the sheets.
+ *
+ * @retrun array
+ */
+ public function getSheets() {
+ return $this->sheets;
+ }
+
+ /**
+ * Updates the sheets.
+ *
+ * @param array $sheets
+ */
+ public function setSheets($sheets) {
+ $this->sheets = $sheets;
+ }
+
+ /**
+ * Retrieves the creator.
+ *
+ * @retrun string
+ */
+ public function getCreator() {
+ return $this->creator;
+ }
+
+ /**
+ * Updates the creator.
+ *
+ * @param string $creator
+ */
+ public function setCreator($creator) {
+ $this->creator = $creator;
+ }
+
+ /**
+ * Retrieves the filename.
+ *
+ * @retrun string
+ */
+ public function getFilename() {
+ return $this->filename;
+ }
+
+ /**
+ * Updates the filename.
+ *
+ * @param string $filename
+ */
+ public function setFilename($filename) {
+ $this->filename = $filename;
+ }
+
+ /**
+ * Retrieves the filepath.
+ *
+ * @retrun string
+ */
+ public function getFilepath() {
+ return $this->filepath;
+ }
+
+ /**
+ * Updates the filepath.
+ *
+ * @param string $filepath
+ */
+ public function setFilepath($filepath) {
+ $this->filepath = $filepath;
+ }
+
+ /**
+ * Retrieves the version.
+ *
+ * @retrun string
+ */
+ public function getVersion() {
+ return $this->version;
+ }
+
+ /**
+ * Updates the version.
+ *
+ * @param string $version
+ */
+ public function setVersion($version) {
+ $this->version = $version;
+ }
+
+ /**
+ * Retrieves the title.
+ *
+ * @retrun string
+ */
+ public function getTitle() {
+ return $this->title;
+ }
+
+ /**
+ * Updates the title.
+ *
+ * @param string $title
+ */
+ public function setTitle($title) {
+ $this->title = $title;
+ }
+
+ /**
+ * Retrieves the subject.
+ *
+ * @retrun string
+ */
+ public function getSubject() {
+ return $this->subject;
+ }
+
+ /**
+ * Updates the subject.
+ *
+ * @param string $subject
+ */
+ public function setSubject($subject) {
+ $this->subject = $subject;
+ }
+
+ /**
+ * Retrieves the keywords.
+ *
+ * @retrun string
+ */
+ public function getKeywords() {
+ return $this->keywords;
+ }
+
+ /**
+ * Updates the keywords.
+ *
+ * @param string $keywords
+ */
+ public function setKeywords($keywords) {
+ $this->keywords = $keywords;
+ }
+
+ /**
+ * Retrieves the category.
+ *
+ * @retrun string
+ */
+ public function getCategory() {
+ return $this->category;
+ }
+
+ /**
+ * Updates the category.
+ *
+ * @param string $category
+ */
+ public function setCategory($category) {
+ $this->category = $category;
+ }
+}
diff --git a/includes/class/file/mcl_file.class.inc b/includes/class/file/mcl_file.class.inc
new file mode 100644
index 0000000..fc802e8
--- /dev/null
+++ b/includes/class/file/mcl_file.class.inc
@@ -0,0 +1,171 @@
+type)) {
+ $this->assignTypeByFilename();
+ }
+
+ // Updates property array ($this->prop_arr).
+ if ($this->prop == '') {
+ $this->prop_arr = array();
+ }
+ else {
+ $this->prop_arr = json_decode($this->prop, TRUE);
+ }
+ }
+
+ /**
+ * @see PUBLIC_MCL_FILE::byKey()
+ */
+ public static function byKey($keys) {
+ $parent = parent::byKey($keys);
+ if ($parent) {
+ return new self($parent->getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see PUBLIC_MCL_FILE::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * @see PUBLIC_MCL_FILE::insert()
+ */
+ public function insert() {
+
+ // Updates the parent:$prop fields.
+ $this->prop = json_encode($this->prop_arr);
+
+ // Insert a new file.
+ return parent::insert();
+ }
+
+ /**
+ * @see PUBLIC_MCL_FILE::update()
+ */
+ public function update() {
+
+ // Updates the parent:$prop fields.
+ $this->prop = json_encode($this->prop_arr);
+
+ // Updates the user properties.
+ return parent::update();
+ }
+
+ /**
+ * @see PUBLIC_MCL_FILE::delete()
+ */
+ public function delete() {
+
+ // Deletes the physical file.
+ if (file_exists($this->filepath)) {
+ unlink($this->filepath);
+ }
+ parent::delete();
+ }
+
+ /**
+ * Assigns the type by filename.
+ *
+ */
+ private function assignTypeByFilename() {
+ if (preg_match("/(xlsx|xls)$/", $this->filename)) {
+ $this->type = 'excel';
+ }
+ else if (preg_match("/\.zip$/", $this->filename)) {
+ $this->type = 'zip';
+ }
+ else if (preg_match("/\.csv$/", $this->filename)) {
+ $this->type = 'csv';
+ }
+ else {
+ $this->type = 'unknown';
+ }
+ }
+
+ /**
+ * Returns files.
+ *
+ * @return array of MCL_FILE objects.
+ */
+ public static function getFiles($type = NULL, $user_id = NULL) {
+
+ // Adds condition.
+ $where_str = '';
+ $args = array();
+ if ($type) {
+ $where_str .= ' AND LOWER(type) = LOWER(:type) ';
+ $args[':type'] = $type;
+ }
+ if ($user_id) {
+ $where_str .= ' AND user_id = :user_id ';
+ $args[':user_id'] = $user_id;
+ }
+ $sql = "SELECT file_id FROM {mcl_file} WHERE 1=1 $where_str ORDER BY submit_date";
+ $files = array();
+ $results = db_query($sql, $args);
+ while ($file_id = $results->fetchField()) {
+ $files[] = MCL_FILE::byKey(array('file_id' => $file_id));
+ }
+ return $files;
+ }
+
+ /**
+ * Deletes all files that associated with the given job from mcl_file.
+ *
+ * @param MCL_JOB $job
+ *
+ * @return boolean
+ */
+ public static function deleteByJob(MCL_JOB $job) {
+
+ // Gets all files by the given job and call delete() to remove files.
+ $sql = "SELECT file_id FROM {mcl_file} WHERE job_id = :job_id";
+ $results = db_query($sql, array(':job_id' => $job->getJobID()));
+ while ($file_id = $results->fetchField()) {
+ $mcl_file = MCL_FILE::byKey(array('file_id' => $file_id));
+ $mcl_file->delete();
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Returns the value of the given key in prop.
+ */
+ public function getPropByKey($key) {
+ if (array_key_exists($key, $this->prop_arr)) {
+ return $this->prop_arr[$key];
+ }
+ return NULL;
+ }
+
+ /**
+ * Updates the value of the given key in prop.
+ */
+ public function setPropByKey($key, $value) {
+ $this->prop_arr[$key] = $value;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/file/mcl_file_csv.class.inc b/includes/class/file/mcl_file_csv.class.inc
new file mode 100644
index 0000000..e077a0d
--- /dev/null
+++ b/includes/class/file/mcl_file_csv.class.inc
@@ -0,0 +1,110 @@
+template = $this->getPropByKey("template");
+ }
+
+ /**
+ * @see MCL_FILE::byKey()
+ */
+ public static function byKey($keys) {
+ $parent = parent::byKey($keys);
+ if ($parent) {
+ return new self($parent->getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see MCL_FILE::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * @see MCL_FILE::insert()
+ */
+ public function insert() {
+ return parent::insert();
+ }
+
+ /**
+ * @see MCL_FILE::update()
+ */
+ public function update() {
+ return parent::update();
+ }
+
+ /**
+ * Checks if the provided job stage has been passed.
+ *
+ * @param integer $job_stage
+ *
+ * @return boolean
+ */
+ public function hasPassed($job_stage) {
+ $passed_stage = $this->getPropByKey('passed_stage');
+ if (is_array($passed_stage)) {
+ if (array_key_exists($job_stage, $passed_stage)) {
+ return $passed_stage[$job_stage];
+ }
+ }
+ return FALSE;
+ }
+
+ /**
+ * Sets passed value.
+ *
+ * @param integer $job_stage
+ * @param boolean $bool
+ */
+ public function setPassed($job_stage, $bool) {
+ $passed_stage = $this->getPropByKey('passed_stage');
+ if (!is_array($passed_stage)) {
+ $passed_stage = array();
+ }
+ $passed_stage[$job_stage] = $bool;
+ $this->setPropByKey('passed_stage', $passed_stage);
+ $this->update();
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the template.
+ *
+ * @retrun string
+ */
+ public function getTemplate() {
+ return $this->template;
+ }
+
+ /**
+ * Updates the template.
+ *
+ * @param string $template
+ */
+ public function setTemplate($template) {
+ $this->template = $template;
+ $this->setPropByKey('template', $template);
+ }
+}
\ No newline at end of file
diff --git a/includes/class/job/mcl_job.class.inc b/includes/class/job/mcl_job.class.inc
new file mode 100644
index 0000000..d755d9e
--- /dev/null
+++ b/includes/class/job/mcl_job.class.inc
@@ -0,0 +1,543 @@
+ 'Error',
+ 'W' => 'Warning',
+ 'N' => 'New Data',
+ 'D' => 'Duplicate',
+ );
+
+ // Temporary variables.
+ protected $msgs = array(
+ 'E' => '',
+ 'W' => '',
+ 'N' => '',
+ 'D' => '',
+ );
+
+ // Job status table.
+ protected $status_label = array(
+ '0' => 'waiting',
+ '10' => 'started',
+ '100' => 'completed',
+ '-100' => 'cancelled',
+ '-200' => 'failed',
+ );
+ protected $status_int = array(
+ 'waiting' => 0,
+ 'started' => 10,
+ 'completed' => 100,
+ 'cancelled' => -100,
+ 'failed' => -200,
+ );
+
+ /**
+ * @see PUBLIC_MCL_JOB::__construct()
+ */
+ public function __construct($details = array()) {
+ parent::__construct($details);
+
+ // Updates property array ($this->prop_arr).
+ if ($this->prop == '') {
+ $this->prop_arr = array();
+ }
+ else {
+ $this->prop_arr = json_decode($this->prop, TRUE);
+ }
+
+ // Updates property array ($this->param_arr).
+ if ($this->param == '') {
+ $this->param_arr = array();
+ }
+ else {
+ $this->param_arr = json_decode($this->param, TRUE);
+ }
+
+ // Updates directories.
+ $working_dir = $this->getPropByKey('working_dir');
+ if ($working_dir) {
+ $this->working_dir = $working_dir;
+ }
+ $user_dir = $this->getPropByKey('user_dir');
+ if ($user_dir) {
+ $this->user_dir = $user_dir;
+ }
+ $job_dir = $this->getPropByKey('job_dir');
+ if ($job_dir) {
+ $this->job_dir = $job_dir;
+ }
+ $log_dir = $this->getPropByKey('log_dir');
+ if ($log_dir) {
+ $this->log_dir = $log_dir;
+ }
+ $file_dir = $this->getPropByKey('file_dir');
+ if ($file_dir) {
+ $this->file_dir = $file_dir;
+ }
+ }
+
+ /**
+ * @see PUBLIC_MCL_JOB::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * @see PUBLIC_MCL_JOB::byKey()
+ */
+ public static function byKey($keys) {
+ $parent = parent::byKey($keys);
+ if ($parent) {
+ return new self($parent->getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see PUBLIC_MCL_JOB::insert()
+ */
+ public function insert() {
+
+ // Updates the parent:$param and parent:$prop fields.
+ $this->param = json_encode($this->param_arr);
+ $this->prop = json_encode($this->prop_arr);
+
+ // Insert a new job.
+ if (parent::insert()) {
+
+ // If $this->working_dir is empty, assigns the default working directory.
+ if (empty($this->working_dir)) {
+ $this->working_dir = mcl_get_config_setting('mcl_working_dir');
+ }
+
+ // Creates the user directory if not exists.
+ if (empty($this->user_dir)) {
+ $drupal_user = MCL_USER::getDrupalUser($this->user_id);
+ $this->user_dir = $this->working_dir . '/' . $drupal_user->name;
+ }
+
+ $this->job_dir = $this->user_dir . '/' . $this->job_id;
+ $this->log_dir = $this->job_dir . '/logs';
+ $this->file_dir = $this->job_dir . '/files';
+ $this->setPropByKey('working_dir', $this->working_dir);
+ $this->setPropByKey('user_dir', $this->user_dir);
+ $this->setPropByKey('job_dir', $this->job_dir);
+ $this->setPropByKey('log_dir', $this->log_dir);
+ $this->setPropByKey('file_dir', $this->file_dir);
+ $this->update();
+
+ // Creates directories.
+ mcl_create_dir($this->job_dir);
+ mcl_create_dir($this->log_dir);
+ mcl_create_dir($this->file_dir);
+ }
+ else {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * @see PUBLIC_MCL_JOB::update()
+ */
+ public function update() {
+
+ // Updates the parent:$param and parent:$prop fields.
+ $this->param = json_encode($this->param_arr);
+ $this->prop = json_encode($this->prop_arr);
+
+ // Updates the user properties.
+ return parent::update();
+ }
+
+ /**
+ * @see PUBLIC_MCL_JOB::delete()
+ */
+ public function delete() {
+ $job_dir = $this->getJobDir();
+
+ // Deletes files associated with this job.
+ MCL_FILE::deleteByJob($this);
+
+ // Deletes the job directory.
+ if (file_exists($job_dir)) {
+ mcl_remove_dir($job_dir);
+ }
+
+ // Delete this job.
+ return parent::delete();
+ }
+
+ /**
+ * Returns jobs that belong to the user.
+ *
+ * @parma integer $user_id
+ *
+ * @return array of MCL_UPLOAD_JOB
+ */
+
+ public static function getJobsByUser($user_id) {
+ $sql = "
+ SELECT J.job_id, J.class_name
+ FROM {mcl_job} J
+ WHERE J.user_id = :user_id
+ ORDER BY J.submit_date DESC
+ ";
+ $results = db_query($sql, array(':user_id' => $user_id));
+ $mcl_jobs = array();
+ while ($obj = $results->fetchObject()) {
+ $class_name = $obj->class_name;
+ $mcl_jobs []= $class_name::byKey(array('job_id' => $obj->job_id));
+ }
+ return $mcl_jobs;
+ }
+
+ /**
+ * Returns job inforamtion table.
+ *
+ * @return string
+ */
+ public function getJobInfoTable() {
+ // To be overridden by Child class.
+ }
+
+ /**
+ * Checks if an error has been occurred.
+ * Return TRUE if no error message found.
+ *
+ * @return boolean
+ */
+ public function noError() {
+ // To be overridden by Child class.
+ }
+
+ /**
+ * Updates the message.
+ *
+ * @param string $key
+ * @param string $msg
+ * @param integer $line_no
+ */
+ public function updateMsg($key, $msg, $line_no = 0) {
+ // To be overridden by Child class.
+ }
+
+ /**
+ * Deletes the messages of the provided type.
+ *
+ * @param string $type
+ */
+ public function deleteMsg($type) {
+ if (array_key_exists($type, $this->msgs)) {
+ $this->msgs[$type] = '';
+ }
+ }
+
+ /**
+ * Resets the logs.
+ *
+ * @param string $template
+ */
+ public function resetLogs($template) {
+ // To be overridden by Child class.
+ }
+
+ /**
+ * Creates folders for various types of logs.
+ *
+ * @return boolean
+ */
+ public function createNewLogs() {
+ // To be overridden by Child class.
+ }
+
+ /**
+ * Keeps the previous log files to other locaiton.
+ */
+ public function KeepLogs() {
+ // To be overridden by Child class.
+ }
+
+ /**
+ * Writes all messages in the message array ($this->msgs) to log files.
+ * Creates 2 copies of a log file. One would be saved in 'recent' and the other
+ * one in 'backups' folder.
+ */
+ public function writeLog() {
+ // To be overridden by Child class.
+ }
+
+ /**
+ * Called before run().
+ */
+ public function preRun() {
+ // To be overridden by Child class.
+ }
+
+ /**
+ * Runs a job.
+ *
+ * @return boolean
+ */
+ public function run() {
+ // To be overridden by Child class.
+ return TRUE;
+ }
+
+ /**
+ * Returns the job inforamtion in array.
+ *
+ * @return array
+ */
+ public function getJobInfo() {
+ // To be overridden by Child class.
+ }
+
+ /**
+ * Called after run().
+ *
+ * @param array $param
+ */
+ public function postRun($param = NULL) {
+ // To be overridden by Child class.
+ }
+
+ /**
+ * Sends a completion email.
+ *
+ */
+ public function sendCompleteEmail() {
+
+ // Gets the owner.
+ $mcl_user = MCL_USER::byKey(array('user_id' => $this->getUserID()));
+
+
+ }
+
+ /**
+ * Sends an error email.
+ *
+ */
+ public function sendErrorEmail() {
+
+ // Gets the owner.
+ $mcl_user = MCL_USER::byKey(array('user_id' => $this->getUserID()));
+
+
+ }
+
+ /**
+ * Changes the working directory. Needs to update job_dir, log_dir
+ * and file_dir.
+ *
+ * @param string $working_dir
+ *
+ * @return boolean
+ */
+ public function changeWorkingDir($working_dir) {
+ $job_dir = "$working_dir/" . $this->job_id;
+ $this->setWorkingDir($working_dir);
+ $this->setJobDir($job_dir);
+ $this->setLogDir("$job_dir/logs");
+ $this->setFileDir("$job_dir/files");
+ return $this->update();
+ }
+
+ /**
+ * Returns the description of message type.
+ *
+ * @param string $type
+ *
+ * @return string
+ */
+ public function getMessageType($type) {
+ return $this->msg_types[$type];
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Returns the array of status_label.
+ *
+ * @return string
+ */
+ public function getStatusLabelArr() {
+ return $this->status_label;
+ }
+
+ /**
+ * Returns the array of status_int.
+ *
+ * @return array
+ */
+ public function getStatusIntArr() {
+ return $this->status_int;
+ }
+
+ /**
+ * Returns the job status label.
+ *
+ * @return string
+ */
+ public function getStatusLabel() {
+ return $this->status_label[$this->status];
+ }
+
+ /**
+ * Retrieves the working directory.
+ *
+ * @retrun string
+ */
+ public function getWorkingDir() {
+ return $this->working_dir;
+ }
+
+ /**
+ * Updates the working directory.
+ *
+ * @param string $working_dir
+ */
+ public function setWorkingDir($working_dir) {
+ $this->working_dir = $working_dir;
+ $this->setPropByKey('working_dir', $working_dir);
+ }
+
+ /**
+ * Retrieves the user directory.
+ *
+ * @retrun string
+ */
+ public function getUserDir() {
+ return $this->user_dir;
+ }
+
+ /**
+ * Updates the user directory.
+ *
+ * @param string $user_dir
+ */
+ public function setUserDir($user_dir) {
+ $this->user_dir = $user_dir;
+ $this->setPropByKey('user_dir', $user_dir);
+ }
+
+ /**
+ * Retrieves the directory of the job.
+ *
+ * @retrun string
+ */
+ public function getJobDir() {
+ return $this->job_dir;
+ }
+
+ /**
+ * Updates the directory of the job.
+ *
+ * @param string $job_dir
+ */
+ public function setJobDir($job_dir) {
+ $this->job_dir = $job_dir;
+ $this->setPropByKey('job_dir', $job_dir);
+ }
+
+ /**
+ * Retrieves the directory of the log files.
+ *
+ * @retrun string
+ */
+ public function getLogDir() {
+ return $this->log_dir;
+ }
+
+ /**
+ * Updates the directory of the log files.
+ *
+ * @param string $log_dir
+ */
+ public function setLogDir($log_dir) {
+ $this->log_dir = $log_dir;
+ $this->setPropByKey('log_dir', $log_dir);
+ }
+
+ /**
+ * Retrieves the directory of the files.
+ *
+ * @retrun string
+ */
+ public function getFileDir() {
+ return $this->file_dir;
+ }
+
+ /**
+ * Updates the directory of the files.
+ *
+ * @param string $file_dir
+ */
+ public function setFileDir($file_dir) {
+ $this->file_dir = $file_dir;
+ $this->setPropByKey('file_dir', $file_dir);
+ }
+
+ /**
+ * Updates the param.
+ *
+ * @param array
+ */
+ public function setParam($param) {
+ parent::setParam($param);
+ $this->param_arr = json_decode($param, TRUE);
+ }
+
+ /**
+ * Returns the value of the given key in param.
+ */
+ public function getParamByKey($key) {
+ if (array_key_exists($key, $this->param_arr)) {
+ return $this->param_arr[$key];
+ }
+ return NULL;
+ }
+
+ /**
+ * Updates the value of the given key in param.
+ */
+ public function setParamByKey($key, $value) {
+ $this->param_arr[$key] = $value;
+ }
+
+ /**
+ * Returns the value of the given key in prop.
+ */
+ public function getPropByKey($key) {
+ if (array_key_exists($key, $this->prop_arr)) {
+ return $this->prop_arr[$key];
+ }
+ return NULL;
+ }
+
+ /**
+ * Updates the value of the given key in prop.
+ */
+ public function setPropByKey($key, $value) {
+ $this->prop_arr[$key] = $value;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/job/mcl_job_manager.class.inc b/includes/class/job/mcl_job_manager.class.inc
new file mode 100644
index 0000000..eaddfca
--- /dev/null
+++ b/includes/class/job/mcl_job_manager.class.inc
@@ -0,0 +1,158 @@
+= :status_bot AND status < :status_top) ";
+ $args[':status_bot'] = 0;
+ $args[':status_top'] = 100;
+ }
+ else {
+
+ // $status is array.
+ if (is_array($status)) {
+ $neg = ($nagate) ? ' NOT ' : '';
+ $sql .= " AND status $neg IN (" . implode(',', $status) . ') ';
+ }
+ else {
+ // Converts status to integer if string was given.
+ $int_status = (preg_match("/^\d+$/", $status)) ? $status : intval($status);
+ $int_status = ($int_status) ? $int_status : '0';
+ $op = ($nagate) ? ' != ' : ' = ';
+ $sql .= " AND status $op :status ";
+ $args[':status'] = $int_status;
+ }
+ }
+ }
+
+ // Returns all jobs that satisfy status.
+ $jobs = array();
+ $result = db_query($sql . " ORDER BY submit_date DESC", $args);
+ while ($job_id = $result->fetchField()) {
+ $jobs[] = MCL_JOB::byKey(array('job_id' => $job_id));
+ }
+ return $jobs;
+ }
+
+ /**
+ * Process jobs in mcl_job table.
+ *
+ * @param string $job_type
+ *
+ * @return boolean
+ */
+ public function processJobs($job_type = NULL) {
+ $no_error_flag = TRUE;
+
+ // Gets all jobs for running.
+ $jobs = $this->getJobs(array('status' => 'RUN', 'job_type' => $job_type));
+ foreach ($jobs as $job) {
+
+ // Process a job.
+ $this->processJob($job);
+ }
+ return $no_error_flag;
+ }
+
+ /**
+ * Process a job.
+ *
+ * @param MCL_JOB $job
+ *
+ * @return boolean
+ */
+ public function processJob(MCL_JOB $mcl_job) {
+ $no_error_flag = TRUE;
+
+ // Updates status as 'started'.
+ if ($mcl_job->getStatus() == 0) {
+ $mcl_job->setStatus(10);
+ $mcl_job->update();
+ }
+
+ // Runs the job if 'run.lock' file does not exist in job directory.
+ $lock_file = $mcl_job->getJobDir() . '/run.lock';
+ $fp = fopen($lock_file, 'w+');
+ if (flock($fp, LOCK_EX|LOCK_NB)) {
+ mcl_print("Processing job : " . $mcl_job->getName() . " [" . $mcl_job->getJobID() . "]", 1, 2);
+
+ // Clears previous log files.
+ $mcl_job->createNewLogs();
+ if (!$mcl_job->run()) {
+ $no_error_flag = FALSE;
+ }
+ $mcl_job->keepLogs();
+ fclose($fp);
+ unlink($lock_file);
+ }
+ else {
+ mcl_print("The job (" . $mcl_job->getJobID() . " = " . $mcl_job->getType() . ") is running...", 1, 2);
+ }
+ return $no_error_flag;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/job/mcl_job_upload.class.inc b/includes/class/job/mcl_job_upload.class.inc
new file mode 100644
index 0000000..ada1de8
--- /dev/null
+++ b/includes/class/job/mcl_job_upload.class.inc
@@ -0,0 +1,1033 @@
+status_label['20'] = 'copying';
+ $this->status_label['30'] = 'syntax error';
+ $this->status_label['40'] = 'data error';
+ $this->status_label['60'] = 'uploading';
+ $this->status_int['copying'] = 20;
+ $this->status_int['syntax error'] = 30;
+ $this->status_int['data error'] = 40;
+ $this->status_int['uploading'] = 60;
+
+ // Creates a MCL_FILE object for the uploaded file.
+ $file_id = $this->getParamByKey('file_id');
+ if ($file_id) {
+ $this->upload_file = MCL_FILE::byKey(array('file_id' => $file_id));
+ }
+ $this->force = $this->getPropByKey('force');
+ $this->csv_dir = $this->getPropByKey('csv_dir');
+ }
+
+ /**
+ * @see MCL_JOB::byKey()
+ */
+ public static function byKey($keys) {
+ $parent = parent::byKey($keys);
+ if ($parent) {
+ return new self($parent->getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see MCL_JOB::insert()
+ */
+ public function insert() {
+ if (parent::insert()) {
+
+ // Creates folders for CSV files.
+ $csv_dir = $this->job_dir . '/csv';
+ if (!file_exists($csv_dir)) {
+ mcl_create_dir($csv_dir);
+ }
+ $this->setCSVDir($csv_dir);
+ return $this->update();
+ }
+ return FALSE;
+ }
+
+ /**
+ * @see MCL_JOB::resetLogs()
+ */
+ public function resetLogs($template) {
+ $this->cur_template = $template;
+ $this->msgs = array();
+ }
+
+ /**
+ * @see MCL_JOB::createNewLogs()
+ */
+ public function createNewLogs() {
+ $dir_new_data = $this->getNewDataLogDir();
+ $dir_prevous = $this->getPreviousLogDir();
+ $dir_recent = $this->getRecentLogDir();
+
+ // Creates 'new_data' and 'previous' folders if not exists.
+ if (!mcl_create_dir($dir_prevous)) {
+ return FALSE;
+ }
+ if (!mcl_create_dir($dir_new_data)) {
+ return FALSE;
+ }
+
+ // Creates or re-create up recent folder.
+ if (file_exists($dir_recent)) {
+ $cmd = "rm -rf $dir_recent";
+ exec($cmd, $output, $return_var);
+ if ($return_var) {
+ return FALSE;
+ }
+ }
+ if (!mcl_create_dir($dir_recent)) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * @see MCL_JOB::KeepLogs()
+ */
+ public function KeepLogs() {
+ $dir_previous = $this->getPreviousLogDir();
+ $dir_recent = $this->getRecentLogDir();
+
+ // Copies 'recent' folder to previous'.
+ $target_dir = "$dir_previous/" . date("Y-m-d-G-i-s");
+ $cmd = "cp -r $dir_recent $target_dir";
+ exec($cmd, $output, $return_var);
+ if ($return_var) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * @see MCL_JOB::noError()
+ */
+ public function noError() {
+ return !array_key_exists('E', $this->msgs);
+ }
+
+ /**
+ * @see MCL_JOB::updateMsg()
+ */
+ public function updateMsg($key, $msg, $line_no = 0) {
+ if (!array_key_exists($key, $this->msgs)) {
+ $this->msgs[$key] = array();
+ }
+ $line_info = ($line_no > 0) ? " at line $line_no\n" : "\n";
+ $this->msgs[$key][$line_no] .= "$msg\n";
+ }
+
+ /**
+ * @see MCL_JOB::writeLog()
+ */
+ public function writeLog() {
+ $template = $this->cur_template;
+ $status = $this->status;
+ $dir_recent = $this->getRecentLogDir();
+ $dir_new_data = $this->getNewDataLogDir();
+
+ // Iterates through log messages and adds a line no.
+ $messages_tmp = array();
+ foreach ($this->msgs as $type => $lines) {
+ if (empty($lines)) {
+ continue;
+ }
+
+ // Sorts by line numbers.
+ ksort($lines);
+ foreach ($lines as $line_no => $msg) {
+
+ // Adds the line number to the messages.
+ if ($line_no == 1) {
+ $messages_tmp[$type] .= ">Required Headers\n$msg\n";
+ }
+ else if ($line_no == 0) {
+ $messages_tmp[$type] .= ">Template\n$msg\n";
+ }
+ else if ($line_no == -1) {
+ $messages_tmp[$type] .= ">Required cvterms\n$msg\n";
+ }
+ else {
+ $messages_tmp[$type] .= ">ln. $line_no --------------\n$msg\n";
+ }
+ }
+ }
+
+ // Creates log files for each type.
+ try {
+
+ foreach ($messages_tmp as $type => $msgs) {
+
+ // Creates a folder.
+ $log_folder = "$dir_recent/$status-$type";
+ mcl_create_dir($log_folder);
+
+ // Sets filename and filepath.
+ $filename = "$status-$type-$template.log";
+ $filepath = "$log_folder/$filename";
+
+ // Opens the log file for writing.
+ $fdw = fopen($filepath, 'w');
+ if (!$fdw) {
+ throw new Exception("Fail to open file for writing [$filepath]");
+ }
+ fputs($fdw, $msgs);
+ mcl_print("-- Log file ($status-$type) for $template created", 2);
+ fclose($fdw);
+
+ // Copies new data log to 'new_data' directory.
+ if ($type == 'N') {
+ $new_data_log = "$dir_new_data/$template-" . date("Y-m-d-G-i-s") . '.log';
+ $cmd = "cp $filepath $new_data_log";
+ exec($cmd);
+ }
+ }
+ }
+ catch (Exception $e) {
+ watchdog('mcl', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+
+ // Shows the error message if exists.
+ $error_flag = !$this->noError();
+ if ($error_flag) {
+ $label = $this->getStatusLabel();
+ mcl_print("[$template] Error found at job status = $status ($label)", 1);
+ }
+ return !$error_flag;
+ }
+
+ /**
+ * @see MCL_JOB::getJobInfoTable()
+ */
+ public function getJobInfoTable() {
+
+ // Gets MCL_FILE.
+ $file = $this->getUploadFile();
+
+ // Gets and set job information.
+ $file_link = "No file found";
+ if (file_exists($file->getFilepath())) {
+ $file_link = l($file->getFilename(), file_create_url($file->getUri()));
+ }
+ $rows = array(
+ array('Name', $this->getName()),
+ array('Type', $this->getType()),
+ array('Status', $this->getStatusLabel()),
+ array('Uploaded File', $file_link),
+ array('Filesize', $file->getFilesize()),
+ array('Submit Date', $this->getSubmitDate()),
+ );
+
+ // Table variables.
+ $table_vars = array(
+ 'header' => NULL,
+ 'rows' => $rows,
+ 'attributes' => array('style' => 'max-width:500px;'),
+ );
+ return theme('table', $table_vars);
+ }
+
+ /**
+ * @see MCL_JOB::getJobInfo()
+ */
+ public function getJobInfo() {
+
+ // Gets directories.
+ $dirs = "\n Job = " . $this->getJobDir() . "\n Working = " . $this->getWorkingDir() .
+ "\n File = " . $this->getFileDir() . "\n CSV = " . $this->getCSVDir() .
+ "\n Log = " . $this->getLogDir() . "\n";
+
+ // Adds base information.
+ $info = array(
+ 'Job ID' => $this->job_id,
+ 'Job Name' => $this->getName(),
+ 'Status' => $this->getStatusLabel(),
+ 'Directories' => $dirs,
+ 'Submit Date' => $this->getSubmitDate(),
+ );
+
+ // Adds re-run command.
+ $rerun_cmd = $this->getPropByKey('rerun_cmd');
+ if ($rerun_cmd) {
+ $info['rerun_cmd'] = $rerun_cmd;
+ }
+ return $info;
+ }
+
+ /**
+ * @see MCL_JOB::run()
+ */
+ public function run() {
+
+ // Runs uploading job.
+ try {
+
+ // Initializes the job.
+ if ($this->status == 10) {
+ mcl_print("==================================", 1, 1, FALSE);
+ mcl_print("Job [" . $this->getJobID() . "] has been started", 1);
+ mcl_print("----------------------------------", 1, 2, FALSE);
+ $this->setStatus(20);
+ $this->update();
+ }
+
+ // Extracts CVS files and copy them.
+ if ($this->status == 20) {
+
+ // Copies all CSV files to the CSV file directory.
+ mcl_print("==================================", 1, 1, FALSE);
+ mcl_print("Phase I : Copying CSV files", 1);
+ mcl_print("----------------------------------", 1, 1, FALSE);
+ if ($this->_copyCSV()) {
+ mcl_print("CSV file created", 1, 2);
+ $this->setStatus(30);
+ $this->update();
+ }
+ else {
+ throw new Exception("Error : Failed to copy CSV files.");
+ }
+ }
+
+ // Runs syntax error check.
+ if ($this->status == 30) {
+
+ // Runs syntax error check each CSV files.
+ mcl_print("==================================", 1, 1, FALSE);
+ mcl_print("Phase II : Running syntax error check", 1);
+ mcl_print("----------------------------------", 1, 1, FALSE);
+ if ($this->_runErrorCheckSyntax()) {
+ mcl_print("Syntax error check completed without error", 1, 2);
+ $this->setStatus(40);
+ $this->update();
+ }
+ else {
+ throw new Exception("\n\tSyntax Error exists : please check error log file.\n\n\n");
+ }
+ }
+
+ // Uploads the data file. The data error check is conducted before
+ // uploading data.
+ if ($this->status == 40) {
+
+ // Uploads CSV files into database.
+ mcl_print("==================================", 1, 1, FALSE);
+ mcl_print("Phase III : Uploading data files", 1);
+ mcl_print("----------------------------------", 1, 1, FALSE);
+ if ($this->_upload_csv()) {
+ mcl_print("Data uploading completed without error", 1, 2);
+ $this->setStatus(60);
+ $this->update();
+ }
+ else {
+ throw new Exception("\n\tUploading data failed : please check error log file.\n\n\n");
+ }
+ }
+
+ // Sends the completion notifiation email.
+ if ($this->status == 60) {
+
+ // Sets the status to '100' and sends completion notifiation email.
+ $this->setStatus(100);
+ $this->update();
+ $this->sendCompleteEmail();
+ }
+ }
+ catch (Exception $e) {
+
+ // Sends an error notifiation email.
+ $this->sendError();
+
+ // Sets the status as 'FAILED'
+ $this->setStatus(-200);
+ $this->update();
+
+ // Keeps the error message.
+ watchdog('mcl', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Sends an error notification email for the following errors.
+ * - syntax error
+ * - data integrity error
+ * - data uploading error
+ *
+ */
+ private function sendError() {
+ $err_msg = '';
+
+ // Sends a syntax error email.
+ if ($this->status == 30) {
+
+
+ }
+
+ // Sends a data uploading error email.
+ else if ($this->status == 40) {
+
+
+ }
+
+ // Sends a data uploading error email.
+ else if ($this->status == 50) {
+
+
+ }
+
+ // Sends an error message.
+ if ($err_msg) {
+ $this->sendErrorEmail($err_msg);
+ }
+ }
+
+ /**
+ * Copy all CSV files to the CSV file directory. If an uploaded
+ * file is Excel, convert it to CSV file(s).
+ *
+ * @return boolean
+ */
+ private function _copyCSV() {
+
+ // Resets variables.
+ $this->resetLogs('COPY_CSV');
+
+ // Gets the upload file.
+ $filepath = $this->upload_file->getFilepath();
+ $file_type = $this->upload_file->getType();
+
+ // If the uploaded file is excel, convert all the sheets in the excel
+ // file into csv files.
+ if ($file_type == 'excel') {
+
+ // Converts Excel file to CSV files.
+ if (!$this->_convertExcel2CSV($filepath)) {
+ $this->updateMsg('E', "Failed to convert to CVS files.");
+ }
+ }
+
+ // Uncompresses (zip) file and copy them to to CSV folder.
+ else if ($file_type == 'zip') {
+
+ // Unzips and copy them to the CSV folder.
+ if ($this->_unzipCSV($filepath)) {
+ $this->updateMsg('E', "Failed to unzip the input file.");
+ }
+
+ // Registers all file in the CSV folder.
+ foreach (glob($this->csv_dir . '/*.csv') as $filename) {
+ $this->_registerCSVFile($this->csv_dir . "/$filename");
+ }
+ }
+
+ // Copies a single CSV file to CSV folder.
+ else if ($file_type == 'csv') {
+ $filename = basename($filepath);
+ $destination = "$csv_dir/$filename";
+
+ if (copy($filepath, $destination)) {
+ $this->_registerCSVFile($destination);
+ }
+ }
+
+ // Error : Invalid file type.
+ else {
+ $this->updateMsg('E', "Invalid file type ($filepath).");
+ }
+
+ // Writes the log files.
+ return $this->writeLog();
+ }
+
+ /**
+ * Extract the template name from the provided file. The moudule name is
+ * specified at the first line of a CSV file.
+ *
+ * @param string $filepath.
+ *
+ * @return string
+ */
+ private function _getTemplateFromFile($filepath) {
+ $template = '';
+
+ // Gets the first line of the file.
+ if (file_exists($filepath)) {
+ $line = fgets(fopen($filepath, 'r'));
+ if (preg_match("/^#([a-zA-Z_]+)$/", $line, $matches)) {
+ $template = $matches[1];
+ }
+ }
+ return $template;
+ }
+
+ /**
+ * Register a CSV file.
+ *
+ * @param string $filepath.
+ *
+ * @return boolean
+ */
+ private function _registerCSVFile($filepath) {
+
+ // Gets the template name from the file.
+ $template = $this->_getTemplateFromFile($filepath);
+ if (!$template) {
+ $this->updateMsg('E', "No template line at the begining of the file.\n$destination.");
+ return FALSE;
+ }
+
+ // Creates MCL_FILE and adds it to this job if not exists.
+ if (!$this->existCSV($template)) {
+ $csv_file = $this->_createMCL_FILE_CSV($destination, $template);
+ if ($csv_file || $csv_file->insert()) {
+
+ // Add a new CSV file.
+ if (!$this->_addCSVFile($csv_file)) {
+ $this->updateMsg('E', "Failed to add CSV file.");
+ }
+ }
+ else {
+ $this->updateMsg('E', "Failed to create CSV file.");
+ }
+ }
+ return TRUE;
+ }
+
+ /**
+ * Unzips the compress file and copy all CSV files to CSV folder.
+ *
+ * @param string $filepath.
+ *
+ * @return boolean
+ */
+ private function _unzipCSV($filepath) {
+
+ // Unzips files to CSV folder
+ $cmd = "unzip -j $filepath -d " . $this->csv_dir;
+ exec($cmd, $output, $return_val);
+ return !$return_val;
+ }
+
+ /**
+ * Converts Exel file to CSV files.
+ *
+ * @param string $filepath.
+ *
+ * @return boolean
+ */
+ private function _convertExcel2CSV($filepath) {
+
+ // Includes PHPExcel libararies.
+ $lib_path = 'sites/all/libraries';
+ require_once("$lib_path/PHPExcel/PHPExcel.php");
+ require_once("$lib_path/PHPExcel/PHPExcel/IOFactory.php");
+
+ // Gets Excel file type [Excel5 | ].
+ $file_type = PHPExcel_IOFactory::identify($filepath);
+
+ // Read input Excel file.
+ $reader = PHPExcel_IOFactory::createReader($file_type);
+ $reader->setReadDataOnly(true);
+ $excel = $reader->load($filepath);
+ $num_sheets = $excel->getSheetCount();
+
+ // Empties CSV folder.
+ mcl_empty_dir($this->csv_dir);
+
+ // Save each sheet as CSV file.
+ $writer = PHPExcel_IOFactory::createWriter($excel, 'CSV');
+ $dup_templates = array();
+ for ($i = 0; $i < $num_sheets; $i++) {
+ $excel->setActiveSheetIndex($i);
+ $template = strtolower($excel->getActiveSheet()->getTitle());
+
+ // Checks for dupliacted sheet name.
+ if (array_key_exists($template, $dup_templates)) {
+ $this->updateMsg('E', "There are duplicated sheet names $template in your file.");
+ return FALSE;
+ }
+ else {
+ $dup_templates[$template] = 1;
+ }
+
+ // Validates sheet name.
+ if (MCL_TEMPLATE::validateTemplate($template)) {
+
+ // Sets CSV filepath.
+ $csv_filepath = $this->csv_dir . "/$template" . '.csv';
+
+ // Write to a CSV file.
+ $writer->setSheetIndex($i);
+ $writer->save($csv_filepath);
+
+ // Add the template name at begining of the file.
+ $file_contents = file_get_contents($csv_filepath);
+ file_put_contents($csv_filepath, "#$template\n" . $file_contents);
+
+ // Creates MCL_FILE if not exists.
+ if (!$this->existCSV($template)) {
+ $csv_file = $this->_createMCL_FILE_CSV($csv_filepath, $template);
+ if ($csv_file && $csv_file->insert()) {
+
+ // Add a new CSV file.
+ if (!$this->_addCSVFile($csv_file)) {
+ $this->updateMsg('E', "Failed to add CSV file.");
+ return FALSE;
+ }
+ }
+ else {
+ $this->updateMsg('E', "Failed to create CSV file.");
+ return FALSE;
+ }
+ }
+ }
+ else {
+ $class_name = 'MCL_TEMPLATE_' . strtoupper($template);
+ $msg = "\nThe sheet name '$template' is not a valid template name.\nIt could be the following reason.\n\n";
+ $msg .= " 1. wrong spell.\n";
+ $msg .= " 2. $class_name is not defined.\n\n";
+ $msg .= "'$template' is skipped.\n\n";
+ $this->updateMsg('W', $msg);
+ }
+ }
+
+ // Updates csv_files in job property.
+ if (!$this->updateCSV($dup_templates)) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Creates a MCL_FILE_CSV object.
+ *
+ * @param string $filepath
+ * @param string $template
+ *
+ * @return MCL_FILE_CSV
+ */
+ private function _createMCL_FILE_CSV($filepath, $template) {
+
+ // CSV file properites.
+ $prop = array(
+ 'template' => $template,
+ );
+
+ // Create a MCL_FILE_CSV object.
+ $details = array(
+ 'filepath' => $filepath,
+ 'filename' => basename($filepath),
+ 'filesize' => filesize($filepath),
+ 'uri' => file_build_uri(mcl_get_rel_filepath($filepath)),
+ 'submit_date' => date("Y-m-d G:i:s"),
+ 'user_id' => $this->getUserID(),
+ 'job_id' => $this->getJobID(),
+ 'prop' => json_encode($prop),
+ );
+ return new MCL_FILE_CSV($details);
+ }
+
+ /**
+ * Adds a new CSV file and updates 'csv_files' in mcl_job.prop.
+ *
+ * @param MCL_FILE $csv_file
+ *
+ * @return boolean
+ */
+ private function _addCSVFile(MCL_FILE $csv_file) {
+
+ // Adds the CSV file to csv_files array in job properties.
+ $csv_files = $this->getPropByKey('csv_files');
+ if (!is_array($csv_files)) {
+ $csv_files = array();
+ }
+ $csv_files[$csv_file->getFileID()] = $csv_file->getFilename();
+ $this->setPropByKey('csv_files', $csv_files);
+ return $this->update();
+ }
+
+ /**
+ * Performs syntax error check on CSV files.
+ *
+ * @return boolean
+ * Return TRUE if no error.
+ */
+ private function _runErrorCheckSyntax() {
+ $no_error_flag = TRUE;
+
+ // Gets all CSV files.
+ $csv_files = $this->getCSVFiles();
+
+ // Performs the error check.
+ foreach ($csv_files as $mcl_file_id => $filename) {
+ mcl_print("[$mcl_file_id] $filename", 1);
+ mcl_print("- Running the syntax error checking : [$mcl_file_id] $filename", 2);
+
+ // Gets the MCL_FILE_CSV object.
+ $csv_file = MCL_FILE_CSV::byKey(array('file_id' => $mcl_file_id));
+
+ // Skips if the error checking has been completed.
+ /*
+ if ($csv_file->hasPassed($this->status_int['syntax error']) && !$this->getForce()) {
+ mcl_print("Skipped - Syntax error has already been checked", 3, 2);
+ continue;
+ }
+ */
+
+ // Resets the logs.
+ $this->resetLogs($csv_file->getTemplate());
+
+ // Runs the syntax error checking.
+ $tmpl_obj = MCL_TEMPLATE::getTemplateClass($this, $csv_file);
+ if ($tmpl_obj->runErrorCheckSyntax()) {
+ $csv_file->setPassed($this->status_int['syntax error'], TRUE);
+ }
+
+ // Writes the log files.
+ $this->writeLog();
+
+ // Checks for errors.
+ if (!$this->noError()) {
+ $no_error_flag = FALSE;
+ }
+ }
+ return $no_error_flag;
+ }
+
+ /**
+ * Uploads CSV files.
+ *
+ * 1. Run data error check.
+ * 2. Upload the CSV file.
+ *
+ * @return boolean
+ */
+ private function _upload_csv() {
+
+ // Gets all CSV files.
+ $csv_files = $this->getCSVFiles();
+
+ // Upload the data.
+ foreach ($csv_files as $mcl_file_id => $filename) {
+
+ // Skips the excluded templates.
+ if (in_array($filename , $this->excludes)) {
+ continue;
+ }
+
+ // Creates a MCL_FILE_CSV object.
+ $csv_file = MCL_FILE_CSV::byKey(array('file_id' => $mcl_file_id));
+ $template = $csv_file->getTemplate();
+
+ // Resets the logs.
+ $this->resetLogs($template);
+
+ // Gets MCL_TEMPLATE object.
+ $tmpl_obj = MCL_TEMPLATE::getTemplateClass($this, $csv_file);
+
+ // Runs the data error checking. Skips if the error checking has been
+ // completed.
+ mcl_print("[$mcl_file_id] $filename", 1);
+ mcl_print("- Running the data error checking", 2);
+// if ($csv_file->hasPassed($this->status_int['data error']) && !$this->getForce()) {
+// mcl_print("Skipped - Data error has already been checked", 3, 2);
+// }
+// else {
+
+ // Runs the data error checking.
+ if ($tmpl_obj->runErrorCheckData()) {
+ $csv_file->setPassed($this->status_int['data error'], TRUE);
+ mcl_print("Data error check passed", 3, 2);
+ }
+
+ // Check if an error occured. If error found, write a log file
+ // and return FALSE.
+ if (!$this->noError()) {
+ $this->writeLog();
+ return FALSE;
+ }
+// }
+
+ // Uploads CSV data file.
+ mcl_print("- Uploading data file", 2);
+
+ // Skips if the data has been uploaded.
+ /*
+ if ($csv_file->hasPassed($this->status_int['uploading'])) {
+ mcl_print("Skipped - Data has already been uploaded", 3, 2);
+ continue;
+ }*/
+
+ // Upload the data file.
+ $transaction = db_transaction();
+ if ($tmpl_obj->uploadData()) {
+ //$csv_file->setPassed($this->status_int['uploading'], TRUE);
+ mcl_print("Data has been uploaded for $template", 3, 2);
+ }
+ else {
+ // If error occurs, rollbacks transaction for this CSV file.
+ $transaction->rollback();
+
+ // Detetes the log for new data.
+ $this->deleteMsg('N');
+ }
+
+ // Write the messages to the logs.
+ $this->writeLog();
+
+ // Check if an error occured. If error found, returns FALSE.
+ if (!$this->noError($template)) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+
+ /**
+ * Return all CSV files in order.
+ *
+ * @return array
+ */
+ public function getCSVFiles() {
+
+ // Gets all CSV files.
+ $csv_files = $this->getPropByKey('csv_files');
+
+ // Ranks CSV files.
+ $csv_files_unsorted = array();
+ foreach ($csv_files as $file_id => $csv_filename) {
+
+ // Gets the rank of csv file.
+ $mcl_file_csv = MCL_FILE_CSV::byKey(array('file_id' => $file_id));
+ $rank = MCL_TEMPLATE::getRank($mcl_file_csv->getTemplate());
+ $info = array('csv_filename' => $csv_filename, 'file_id' => $file_id);
+ $csv_files_unsorted[$rank] = $info;
+ }
+
+ // Sorts CSV files.
+ ksort($csv_files_unsorted);
+ $csv_files_sorted = array();
+ foreach ($csv_files_unsorted as $rank => $info) {
+ $csv_files_sorted[$info['file_id']] = $info['csv_filename'];
+ }
+ return $csv_files_sorted;
+ }
+
+ /**
+ * Checks if CSV file exists.
+ *
+ * @param string $template
+ *
+ * @return boolean
+ */
+ public function existCSV($template) {
+
+ // Gets all CSV files.
+ $csv_files = $this->getPropByKey('csv_files');
+ if (is_array($csv_files)) {
+ foreach ($csv_files as $file_id => $csv_filename) {
+ $csv_file = MCL_FILE_CSV::byKey(array('file_id' => $file_id));
+ $csv_template = $csv_file->getTemplate();
+ if ($template == $csv_file->getTemplate()) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+ }
+
+ /**
+ * Updates csv_files in the job properties.
+ *
+ * @param array $templates
+ *
+ * @return boolean
+ */
+ public function updateCSV($templates) {
+
+ // Gets all CSV files.
+ $csv_files = $this->getPropByKey('csv_files');
+ if (is_array($csv_files)) {
+ $new_csv_files = array();
+ foreach ($csv_files as $file_id => $csv_filename) {
+ $key = preg_replace('/\.csv$/', '', $csv_filename);
+ if (array_key_exists($key, $templates)) {
+ $new_csv_files[$file_id] = $csv_filename;
+ }
+ }
+ $this->setPropByKey('csv_files', $new_csv_files);
+ return $this->update();
+ }
+ return TRUE;
+ }
+
+ /**
+ * Translates status int to label.
+ *
+ * @retrun boolean
+ */
+ public function trStatusIntToLabel($int) {
+ return $this->status_label["$int"];
+ }
+
+ /**
+ * Returns the log directory of the provided type.
+ *
+ * @retrun string
+ */
+ public function getLogDirByType($type) {
+ return $this->getLogDir() . "/$type";
+ }
+
+ /**
+ * Returns the recent log directory.
+ *
+ * @retrun string
+ */
+ public function getRecentLogDir() {
+ return $this->getLogDir() . '/recent';
+ }
+
+ /**
+ * Returns the previous log directory.
+ *
+ * @retrun string
+ */
+ public function getPreviousLogDir() {
+ return $this->getLogDir() . '/previous';
+ }
+
+ /**
+ * Returns the new data log directory.
+ *
+ * @retrun string
+ */
+ public function getNewDataLogDir() {
+ return $this->getLogDir() .'/new_data';
+ }
+
+ /**
+ * Returns the file ID of the uploaded file.
+ *
+ * @retrun integer
+ */
+ public function getFileID() {
+ $file_id = $this->getParamByKey('file_id');
+ if ($file_id) {
+ return intval($file_id);
+ }
+ return NULL;
+ }
+
+ /**
+ * Updates the file ID of the uploaded file.
+ *
+ * @retrun integer
+ */
+ public function setFileID($file_id) {
+
+ // Creates a MCL_FILE object for the uploaded file.
+ $mcl_file = MCL_FILE::byKey(array('file_id' => $file_id));
+ if ($mcl_file) {
+ $this->upload_file = $mcl_file;
+ $this->setParamByKey('file_id', $file_id);
+ }
+ }
+
+ /**
+ * Returns the file ID of the uploaded file.
+ *
+ * @retrun MCL_FILE
+ */
+ public function getMCLFile() {
+ $file_id = $this->getFileID();
+ if (is_int($file_id)) {
+ return MCL_FILE::byKey(array('file_id' => $file_id));
+ }
+ return NULL;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the force flag.
+ *
+ * @retrun boolean
+ */
+ public function getForce() {
+ return $this->force;
+ }
+
+ /**
+ * Updates the force flag.
+ *
+ * @param boolean $force
+ */
+ public function setForce($force) {
+ $this->force = $force;
+ $this->setPropByKey('force', $force);
+ }
+
+ /**
+ * Retrieves the directory of the CSV files.
+ *
+ * @retrun string
+ */
+ public function getCSVDir() {
+ return $this->csv_dir;
+ }
+
+ /**
+ * Updates the directory of the CSV files.
+ *
+ * @param string $csv_dir
+ */
+ public function setCSVDir($csv_dir) {
+ $this->csv_dir = $csv_dir;
+ $this->setPropByKey('csv_dir', $csv_dir);
+ }
+
+ /**
+ * Retrieves the uploaded file.
+ *
+ * @retrun boolean
+ */
+ public function getUploadFile() {
+ return $this->upload_file;
+ }
+
+ /**
+ * Updates the uploaded file.
+ *
+ * @param string $upload_file
+ */
+ public function setUploadFile($upload_file) {
+ $this->upload_file = $upload_file;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_contact.class.inc b/includes/class/mcl_chado_class/mcl_chado_contact.class.inc
new file mode 100644
index 0000000..5f77e96
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_contact.class.inc
@@ -0,0 +1,125 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_CONTACT::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the existance of contact. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $contact
+ * @param string $separator
+ */
+ public static function checkContact(MCL_TEMPLATE $mcl_tmpl, $contact, $separator = '') {
+ if ($contact) {
+
+ // Gets contacts.
+ $names = preg_split($mcl_tmpl->getSepRegex($separator), $contact, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($names as $name) {
+ $name = trim($name);
+ $mcl_contact = MCL_CHADO_CONTACT::getContact($name);
+ if (!$mcl_contact) {
+ $mcl_tmpl->updateMsg('E', "(name) = ($name) not found in contact");
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the contact by name.
+ *
+ * @param string $name
+ *
+ * @return MCL_CHADO_CONTACT
+ */
+ public static function getContact($name) {
+ return MCL_CHADO_CONTACT::bykey(array('name' => $name));
+ }
+
+ /**
+ * Adds a contact.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $name
+ *
+ * @return MCL_CHADO_CONTACT
+ */
+ public static function addContact(MCL_TEMPLATE $mcl_tmpl, $name, $type_id, $description) {
+
+ // Sets the arguments.
+ $args = array(
+ 'name' => $name,
+ );
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_contact = MCL_CHADO_CONTACT::byKey($args);
+ if ($mcl_contact) {
+ $mcl_tmpl->addMsg('D', 'contact', $args);
+ }
+ else {
+
+ // Adds a new contact.
+ $args['type_id'] = $type_id;
+ $args['description'] = $description;
+ $mcl_contact = new MCL_CHADO_CONTACT($args);
+ if ($mcl_contact->insert()) {
+ $mcl_tmpl->addMsg('N', 'contact', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'contact', $args);
+ }
+ }
+ return $mcl_contact;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $separator = '') {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('contactprop', 'contact_id', $this->contact_id, $type_id, $value, $separator);
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_cv.class.inc b/includes/class/mcl_chado_class/mcl_chado_cv.class.inc
new file mode 100644
index 0000000..8dc3052
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_cv.class.inc
@@ -0,0 +1,128 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_CV::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the existance of cv. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv
+ */
+ public static function checkCV(MCL_TEMPLATE $mcl_tmpl, $cv) {
+ if ($cv) {
+
+ // Gets the cv.
+ $mcl_cv = MCL_CHADO_CV::getCV($cv);
+ if (!$mcl_cv) {
+ $mcl_tmpl->updateMsg('E', "(name) = ($cv) not found in cv");
+ }
+ }
+ }
+
+ /**
+ * Returns the cv by name.
+ *
+ * @param string $name
+ *
+ * @return MCL_CHADO_CV
+ */
+ public static function getCV($name) {
+
+ // Updates the name if name is 'SITE_CV'.
+ if ($name == 'SITE_CV') {
+ $name = MCL_VAR::getValueByName($name);
+ }
+ return MCL_CHADO_CV::bykey(array('name' => $name));
+ }
+
+ /**
+ * Adds null cv.
+ *
+ * @return MCL_CHADO_CV
+ */
+ public static function addNull() {
+
+ // Checks if it has already exists.
+ $mcl_cv = MCL_CHADO_CV::getCV('null');
+ if (!$mcl_cv) {
+ $details = array('name' => 'null');
+ $mcl_cv = new MCL_CHADO_CV($details);
+ if (!$mcl_cv->insert()) {
+ return NULL;
+ }
+ }
+ return $mcl_cv;
+ }
+
+ /**
+ * Adds a new cv.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $name
+ * @param string $definition
+ *
+ * return MCL_CHADO_CV
+ */
+ public static function addCV(MCL_TEMPLATE $mcl_tmpl, $name, $definition) {
+
+ // Sets the arguments.
+ $args = array('name' => $name);
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_cv = MCL_CHADO_CV::byKey($args);
+ if ($mcl_cv) {
+ $mcl_tmpl->addMsg('D', 'cv', $args);
+ }
+ else {
+
+ // Adds a new cv.
+ $args['definition'] = $definition;
+ $mcl_cv = new MCL_CHADO_CV($args);
+ if ($mcl_cv->insert()) {
+ $mcl_tmpl->addMsg('N', 'cv', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'cv', $args);
+ }
+ }
+ return $mcl_cv;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_cvterm.class.inc b/includes/class/mcl_chado_class/mcl_chado_cvterm.class.inc
new file mode 100644
index 0000000..0ee10b8
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_cvterm.class.inc
@@ -0,0 +1,334 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_CVTERM::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the existance of cvterm. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ */
+ public static function checkCvterm(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name) {
+ if ($cv_name && $cvterm_name) {
+ // Gets the cvterm.
+ $mcl_cvterm = MCL_CHADO_CVTERM::getCvterm($cv_name, $cvterm_name);
+ if (!$mcl_cvterm) {
+ $mcl_tmpl->updateMsg('E', "(cv_name, cvterm_name) = ($cv_name, $cvterm_name) not found in cvterm");
+ }
+ }
+ }
+
+ /**
+ * Checks the format of the values for quantitative_code and code.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $data_type
+ * @param string $values
+ */
+ public static function checkValues(MCL_TEMPLATE $mcl_tmpl, $data_type, $values) {
+
+ // Checks only for quantitative_code and code.
+ if (preg_match("/^(code|quantitative_code)$/i", $data_type)) {
+ if ($values) {
+
+ // Parses out the values to the codes.
+ $codes = preg_split("/[;]/", $values, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($codes as $code) {
+ $tmp = preg_split("/[:=]/", $code, NULL, PREG_SPLIT_NO_EMPTY);
+ $rank = trim($tmp[0]);
+ $value = trim($tmp[1]);
+
+ // Checks a rank.
+ if (is_infinite($rank)) {
+ $mcl_tmpl->updateMsg('E', "Rank should be an integer ($rank was given)");
+ }
+
+ // Checks a value.
+ if (!$value) {
+ $mcl_tmpl->updateMsg('E', "Value must be non-empty");
+ }
+ }
+ }
+ else {
+ $mcl_tmpl->updateMsg('E', "values cannot be empty for $data_type.");
+ }
+ }
+ }
+
+ /**
+ * Returns the cvterm.
+
+ * @param string $cv_name
+ * @param string $cvterm_name
+ *
+ * @return MCL_CHADO_CVTERM
+ */
+ public static function getCvterm($cv_name, $cvterm_name) {
+ $mcl_cv = MCL_CHADO_CV::getCV($cv_name);
+ if ($mcl_cv) {
+ return MCL_CHADO_CVTERM::bykey(array('cv_id' => $mcl_cv->getCvID(), 'name' => $cvterm_name));
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds null cvterm.
+ *
+ * @return MCL_CHADO_CVTERM
+ */
+ public static function addNull() {
+
+ // Gets null.
+ $mcl_cv = MCL_CHADO_CV::addNull();
+ $mcl_dbxref = MCL_CHADO_DBXREF::addNull();
+
+ // Checks if it has already exists.
+ $mcl_cvterm = MCL_CHADO_CVTERM::getCvterm('null', 'null');
+ if (!$mcl_cvterm) {
+ $details = array(
+ 'name' => 'null',
+ 'cv_id' => $mcl_cv->getCvID(),
+ 'dbxref_id' => $mcl_dbxref->getDbxrefID(),
+ );
+ $mcl_cvterm = new MCL_CHADO_CVTERM($details);
+ if (!$mcl_cvterm->insert()) {
+ return NULL;
+ }
+ }
+ return $mcl_cvterm;
+ }
+
+ /**
+ * Adds a cvterm.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $db_name
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $definition
+ * @param string $accession
+ *
+ * @return MCL_CHADO_CVTERM
+ */
+ public static function addCvterm(MCL_TEMPLATE $mcl_tmpl, $db_name, $cv_name, $cvterm_name, $definition, $accession = '') {
+
+ // Checks parameters.
+ $args = array(
+ 'db_name' => $db_name,
+ 'cv_name' => $cv_name,
+ 'cvterm_name' => $cvterm_name,
+ );
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_cvterm = MCL_CHADO_CVTERM::getCvterm($cv_name, $cvterm_name);
+ if ($mcl_cvterm) {
+ $mcl_tmpl->updateMsg('D', "(cv.name, cvterm.name) = ($cv_name, $cvterm_name) found in cvterm");
+ }
+ else {
+
+ // Gets db.
+ $mcl_db = MCL_CHADO_DB::getDB($db_name);
+ if (!$mcl_db) {
+ $mcl_tmpl->updateMsg('E', "(db.name) = ($db_name) not found in db");
+ return NULL;
+ }
+
+ // Gets cv.
+ $mcl_cv = MCL_CHADO_CV::getCV($cv_name);
+ if (!$mcl_cv) {
+ $mcl_tmpl->updateMsg('E', "(cv.name) = ($cv_name) not found in cv");
+ return NULL;
+ }
+
+ // Sets the accession.
+ if (!$accession) {
+ $accession = strtoupper($mcl_db->getName()) . ":$cvterm_name";
+ }
+
+ // Gets dbxref.
+ $args = array(
+ 'db_id' => $mcl_db->getDbID(),
+ 'accession' => $accession,
+ );
+ $mcl_dbxref = MCL_CHADO_DBXREF::byKey($args);
+ if (!$mcl_dbxref) {
+
+ // Adds a new dbxref.
+ $mcl_dbxref = new MCL_CHADO_DBXREF($args);
+ if ($mcl_dbxref->insert()) {
+ $mcl_tmpl->addMsg('N', 'dbxref', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'dbxref', $args);
+ }
+ }
+
+ // Adds a new cvterm.
+ if ($mcl_dbxref) {
+ $args = array(
+ 'dbxref_id' => $mcl_dbxref->getDbxrefID(),
+ 'cv_id' => $mcl_cv->getCvID(),
+ 'name' => $cvterm_name,
+ 'definition' => $definition,
+ );
+ $mcl_cvterm = new MCL_CHADO_CVTERM($args);
+ if ($mcl_cvterm->insert()) {
+ $mcl_tmpl->addMsg('N', 'cvterm', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'cvterm', $args);
+ }
+ }
+ }
+ return $mcl_cvterm;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param boolean $multiple
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $multiple = FALSE) {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('cvtermprop', 'cvterm_id', $this->cvterm_id, $type_id, $value, $multiple);
+ }
+
+ /**
+ * Adds aliases.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $alias
+ * @param string $separator
+ */
+ public function addAlias(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $alias, $separator = '') {
+
+ if ($alias) {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+
+ // Poluplates the array with aliases.
+ $alias_arr = array();
+ if ($separator) {
+ $alias_arr = preg_split($mcl_tmpl->getSepRegex($separator), $value, NULL, PREG_SPLIT_NO_EMPTY);
+ }
+ else {
+ $alias_arr []= $value;
+ }
+
+ // Adds each alias.
+ $args = array(
+ 'cvterm_id' => $this->cvterm_id,
+ 'type_id' => $type_id,
+ );
+ $rank = 0;
+ foreach ($alias_arr as $val) {
+ $args['synonym'] = $val;
+ $cvtermsynonym = CHADO_CVTERMSYNONYM::byKey($args);
+ if ($cvtermsynonym) {
+ $mcl_tmpl->addMsg('D', 'cvtermsynonym', $args);
+ }
+ else {
+ $cvtermsynonym = new CHADO_CVTERMSYNONYM($args);
+ if ($cvtermsynonym->insert()) {
+ $mcl_tmpl->addMsg('N', 'cvtermsynonym', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'cvtermsynonym', $args);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds the provided values for quantitative_code, code and qualitative.
+ *
+ * Examples of quantitative_code.
+ * 1:none;2:slight;3:medium;4:very greasy
+ * 1:immature (starchy,granular);2:mature (no detectable startch);3:over mature (soft, lacks acid and contains overmature flavors)
+ *
+ * Examples of code.
+ * 0:none;1:present
+ * 1=UMN; 2=Cornell-Geneva; 3=WSU
+ *
+ * Examples of qualitative.
+ * Site; State;
+ * tier; field;
+ * tier; block;
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $data_type
+ * @param string $values
+ */
+ public function addValues(MCL_TEMPLATE $mcl_tmpl, $data_type, $values) {
+
+ // Adds the values for quantitative_code and code.
+ if (preg_match("/^(code|quantitative_code)$/i", $data_type)) {
+
+ // Gets type_id.
+ $cvterm_id_code = $mcl_tmpl->getCvtermID('SITE_CV', 'code');
+
+ // Saves the all codes in cvtermprop table.
+ $this->addProp($mcl_tmpl, 'SITE_CV', 'code_ref', $values);
+
+ // Parses out the values to the codes.
+ $codes = preg_split("/[;]/", $values, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($codes as $code) {
+ $tmp = preg_split("/[:=]/", $code, NULL, PREG_SPLIT_NO_EMPTY);
+ $rank = trim($tmp[0]);
+ $value = trim($tmp[1]);
+
+ // Adds a property.
+ $mcl_tmpl->addPropertyRanked('cvtermprop', 'cvterm_id', $cvterm_id_code, $type_id, $value, $rank);
+ }
+ }
+
+ // Adds the values for qualitative.
+ else if ($data_type == 'qualitative') {
+ $this->addProp($this, 'SITE_CV', 'qualitative', $values, '[;,]');
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_dataset.class.inc b/includes/class/mcl_chado_class/mcl_chado_dataset.class.inc
new file mode 100644
index 0000000..91ea6dc
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_dataset.class.inc
@@ -0,0 +1,189 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_PROJECT::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the existance of dataset. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $name
+ */
+ public static function checkDataset(MCL_TEMPLATE $mcl_tmpl, $name) {
+ if ($name) {
+
+ // Gets the dataset.
+ $mcl_dataset = MCL_CHADO_DATASET::getDataset($name);
+ if (!$mcl_dataset) {
+ $mcl_tmpl->updateMsg('E', "(name) = ($name) not found in project");
+ }
+ }
+ }
+
+ /**
+ * Returns the dataset by name.
+ *
+ * @param string $name
+ *
+ * @return MCL_CHADO_DATASET
+ */
+ public static function getDataset($name) {
+ return MCL_CHADO_DATASET::bykey(array('name' => $name));
+ }
+
+ /**
+ * Adds a dataset.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $uniquename
+ * @param integer $type_id
+ * @param integer $organism_id
+ * @param string $name
+ *
+ * @return MCL_CHADO_DATASET
+ */
+ public static function addDataset(MCL_TEMPLATE $mcl_tmpl, $name) {
+
+ // Sets the arguments.
+ $args = array('name' => $name);
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_dataset = MCL_CHADO_DATASET::byKey($args);
+ if ($mcl_dataset) {
+ $mcl_tmpl->addMsg('D', 'project', $args);
+ }
+ else {
+
+ // Adds a new dataset.
+ $mcl_dataset = new MCL_CHADO_DATASET($args);
+ if ($mcl_dataset->insert()) {
+ $mcl_tmpl->addMsg('N', 'project', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'project', $args);
+ }
+ }
+ return $mcl_dataset;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $separator = '') {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('projectprop', 'project_id', $this->project_id, $type_id, $value, $separator);
+ }
+
+ /**
+ * Gets property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ *
+ * @return string
+ */
+ public function getProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name) {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ return $mcl_tmpl->getProperty('projectprop', 'project_id', $this->project_id, $type_id);
+ }
+
+ /**
+ * Adds contact to project_contact.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $contact
+ * @param string $separator
+ */
+ public function addContact(MCL_TEMPLATE $mcl_tmpl, $contact, $separator = '') {
+ if ($contact) {
+ $names = preg_split($mcl_tmpl->getSepRegex($separator), $contact, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($names as $name) {
+ $name = trim($name);
+ $mcl_contact = MCL_CHADO_CONTACT::byKey(array('name' => $name));
+ if ($mcl_contact) {
+ $mcl_tmpl->addLink('project_contact', 'project_id', $this->project_id, 'contact_id', $mcl_contact->getContactID());
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds a perent dataset.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $dataset_name
+ */
+ public function addParentDataset(MCL_TEMPLATE $mcl_tmpl, $dataset_name) {
+ if ($dataset_name) {
+ $parent = MCL_CHADO_DATASET::getDataset($dataset_name);
+ if ($parent) {
+ $type_id = $mcl_tmpl->getCvtermID('SITE_CV', 'is_a_subproject_of');
+ $mcl_tmpl->addLink('project_relationship', 'subject_project_id', $this->project_id, 'object_project_id', $parent->getProjectID(), $type_id);
+ }
+ }
+ }
+
+ /**
+ * Adds reference to project_pub.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $reference
+ * @param string $separator
+ */
+ public function addReference(MCL_TEMPLATE $mcl_tmpl, $reference, $separator = '') {
+ if ($reference) {
+ $pub_ids = preg_split($mcl_tmpl->getSepRegex($separator), $reference, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($pub_ids as $pub_id) {
+ $pub_id = trim($pub_id);
+ $mcl_pub = MCL_CHADO_PUB::getPub($pub_id);
+ if ($mcl_pub) {
+ $mcl_tmpl->addLink('project_pub', 'project_id', $this->project_id, 'pub_id', $pub_id);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_db.class.inc b/includes/class/mcl_chado_class/mcl_chado_db.class.inc
new file mode 100644
index 0000000..1b53cd2
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_db.class.inc
@@ -0,0 +1,132 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_DB::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the existance of db. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $db
+ */
+ public static function checkDB(MCL_TEMPLATE $mcl_tmpl, $db) {
+ if ($db) {
+
+ // Gets the db.
+ $mcl_db = MCL_CHADO_DB::getDB($db);
+ if (!$mcl_db) {
+ $mcl_tmpl->updateMsg('E', "(name) = ($db) not found in db");
+ }
+ }
+ }
+
+ /**
+ * Returns the db by name.
+ *
+ * @param string $name
+ *
+ * @return MCL_CHADO_DB
+ */
+ public static function getDB($name) {
+
+ // Updates the name if name is 'SITE_DB'.
+ if ($name == 'SITE_DB') {
+ $name = MCL_VAR::getValueByName($name);
+ }
+ return MCL_CHADO_DB::bykey(array('name' => $name));
+ }
+
+ /**
+ * Adds null db.
+ *
+ * @return MCL_CHADO_DB
+ */
+ public static function addNull() {
+
+ // Checks if it has already exists.
+ $mcl_db = MCL_CHADO_DB::getDB('null');
+ if (!$mcl_db) {
+ $details = array('name' => 'null');
+ $mcl_db = new MCL_CHADO_DB($details);
+ if (!$mcl_db->insert()) {
+ return NULL;
+ }
+ }
+ return $mcl_db;
+ }
+
+ /**
+ * Adds a new db.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $name
+ * @param string $prefix_url
+ * @param string $url
+ * @param string $definition
+ *
+ * @return MCL_CHADO_DB
+ */
+ public static function addDB(MCL_TEMPLATE $mcl_tmpl, $name, $prefix_url, $url, $definition) {
+
+ // Sets the arguments.
+ $args = array('name' => $name);
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_db = MCL_CHADO_DB::byKey($args);
+ if ($mcl_db) {
+ $mcl_tmpl->addMsg('D', 'db', $args);
+ }
+ else {
+
+ // Adds a new db.
+ $args['urlprefix'] = $prefix_url;
+ $args['url'] = $url;
+ $args['definition'] = $definition;
+ $mcl_db = new MCL_CHADO_DB($args);
+ if ($mcl_db->insert()) {
+ $mcl_tmpl->addMsg('N', 'db', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'db', $args);
+ }
+ }
+ return $mcl_db;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_dbxref.class.inc b/includes/class/mcl_chado_class/mcl_chado_dbxref.class.inc
new file mode 100644
index 0000000..af921a6
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_dbxref.class.inc
@@ -0,0 +1,116 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_DBXREF::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Adds null dbxref.
+ *
+ * @return MCL_CHADO_DBXREF
+ */
+ public static function addNull() {
+
+ // Gets null db.
+ $mcl_db = MCL_CHADO_DB::addNull();
+
+ // Checks if it has already exists.
+ $mcl_dbxref = MCL_CHADO_DBXREF::byKey(array('accession' => 'local:null'));
+ if (!$mcl_dbxref) {
+ $details = array(
+ 'accession' => 'local:null',
+ 'db_id' => $mcl_db->getDbID(),
+ );
+ $mcl_dbxref = new MCL_CHADO_CVTERM($details);
+ if (!$mcl_dbxref->insert()) {
+ return NULL;
+ }
+ }
+ return $mcl_dbxref;
+ }
+
+ /**
+ * Adds a dbxref.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $db_id
+ * @param string $accession
+ *
+ * @return MCL_CHADO_DBXREF
+ */
+ public static function addDBXref(MCL_TEMPLATE $mcl_tmpl, $db_id, $accession) {
+
+ // Sets the arguments.
+ $args = array(
+ 'db_id' => $db_id,
+ 'accession' => $accession,
+ );
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_dbxref = MCL_CHADO_DBXREF::byKey($args);
+ if ($mcl_dbxref) {
+ $mcl_tmpl->addMsg('D', 'dbxref', $args);
+ }
+ else {
+
+ // Adds a new dbxref.
+ $mcl_dbxref = new MCL_CHADO_DBXREF($args);
+ if ($mcl_dbxref->insert()) {
+ $mcl_tmpl->addMsg('N', 'dbxref', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'dbxref', $args);
+ }
+ }
+ return $mcl_dbxref;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $separator = '') {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('dbxrefrop', 'dbxref_id', $this->dbxref_id, $type_id, $value, $separator);
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_feature.class.inc b/includes/class/mcl_chado_class/mcl_chado_feature.class.inc
new file mode 100644
index 0000000..80a8c12
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_feature.class.inc
@@ -0,0 +1,593 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_FEATURE::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the existance of feature. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $feature
+ * @param string $genus
+ * @param string $species
+ * @param integer $type_id
+ * @param string $separator
+ */
+ public static function checkFeature(MCL_TEMPLATE $mcl_tmpl, $feature, $genus, $species, $type_id, $separator = '') {
+
+ // Gets the organism.
+ $mcl_organism = MCL_CHADO_ORGANISM::getOrganism($genus, $species);
+ if ($mcl_organism) {
+
+ // Gets the uniquenames.
+ $uniquenames = preg_split($mcl_tmpl->getSepRegex($separator), $feature, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($uniquenames as $uniquename) {
+ $uniquename = trim($uniquename);
+ $args = array(
+ 'uniquename' => $uniquename,
+ 'organism_id' => $mcl_organism->getOrganismID(),
+ 'type_id' => $type_id,
+ );
+ $mcl_feature = MCL_CHADO_FEATURE::byKey($args);
+ if (!$mcl_feature) {
+ $mcl_tmpl->updateMsg('E', $mcl_tmpl->arrStr($args) . " not found in feature");
+ }
+ }
+ }
+ else {
+ $mcl_tmpl->updateMsg('E', "(genus, species) = ($genus, $species) not found in organism");
+ }
+ }
+
+ /**
+ * Returns the feature by uniquename, genus, species and type_id.
+ *
+ * @param string $uniquename
+ * @param string $genus
+ * @param string $species
+ *
+ * @return MCL_CHADO_FEATURE
+ */
+ public static function getFeature($uniquename, $genus, $species, $type_id) {
+ $mcl_organism = MCL_CHADO_ORGANISM::getOrganism($genus, $species);
+ if ($mcl_organism) {
+ $args = array(
+ 'uniquename' => $uniquename,
+ 'organism_id' => $mcl_organism->getOrganismID(),
+ 'type_id' => $type_id,
+ );
+ return MCL_CHADO_FEATURE::bykey($args);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a feature.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $uniquename
+ * @param integer $type_id
+ * @param integer $organism_id
+ * @param string $name
+ *
+ * @return MCL_CHADO_FEATURE
+ */
+ public static function addFeature(MCL_TEMPLATE $mcl_tmpl, $uniquename, $name, $type_id, $organism_id) {
+
+ // Sets the arguments.
+ $args = array(
+ 'uniquename' => $uniquename,
+ 'type_id' => $type_id,
+ 'organism_id' => $organism_id,
+ );
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $feature = MCL_CHADO_FEATURE::byKey($args);
+ if ($feature) {
+ $mcl_tmpl->addMsg('D', 'feature', $args);
+ }
+ else {
+
+ // Adds a new feature.
+ $args['name'] = $name;
+ $feature = new MCL_CHADO_FEATURE($args);
+ if ($feature->insert()) {
+ $mcl_tmpl->addMsg('N', 'feature', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'feature', $args);
+ }
+ }
+ return $feature;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $separator = '') {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('featureprop', 'feature_id', $this->feature_id, $type_id, $value, $separator);
+ }
+
+ /**
+ * Adds related feature to feature_relationship.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param MCL_CHADO_FEATURE $mcl_feature
+ * @param integer $type_id
+ */
+ public function addRelatedFeature(MCL_TEMPLATE $mcl_tmpl, $mcl_feature, $type_id) {
+ if ($mcl_feature) {
+ $mcl_tmpl->addRelationship('feature_relationship', 'subject_id', $this->feature_id, 'object_id', $mcl_feature->getFeatureID(), $type_id);
+ }
+ }
+
+ /**
+ * Adds related features to feature_relationship.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $marker
+ * @param integer $feature_type_id
+ * @param integer $relationship_type_id
+ * @param string $separator
+ */
+ public function addRelatedFeatures(MCL_TEMPLATE $mcl_tmpl, $features, $feature_type_id, $relationship_type_id, $separator = '') {
+ if ($features) {
+ $uniquenames = preg_split($mcl_tmpl->getSepRegex($separator), $features, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($uniquenames as $uniquename) {
+ $uniquename = trim($uniquename);
+
+ $args = array(
+ 'uniquename' => $uniquename,
+ 'organism_id' => $this->organism_id,
+ 'type_id' => $feature_type_id,
+ );
+ $mcl_feature = MCL_CHADO_FEATURE::byKey($args);
+ if ($mcl_feature) {
+ $mcl_tmpl->addRelationship('feature_relationship', 'subject_id', $this->feature_id, 'object_id', $mcl_feature->getFeatureID(), $relationship_type_id);
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds a sequnce to this feature.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param array $line
+ * @param string $prefix
+ * @param integer $type_id_feature
+ * @param integer $type_id_relationship
+ *
+ */
+ public function addSequence(MCL_TEMPLATE $mcl_tmpl, $line, $prefix, $type_id_feature, $type_id_relationship) {
+
+ // Builds the pattern.
+ $pattern = "^$prefix(\d+)_(seq|name)";
+
+ // Gets name and seq columns.
+ $sequences = array();
+ foreach ($line as $column => $value) {
+ if (preg_match("/$pattern/", $column, $matches)) {
+ $num = $matches[1];
+ $type = $matches[2];
+ $name = $prefix . $num . '_' . $type;
+ $sequences[$num][$type] = $line[$name];
+ }
+ }
+
+ // Removes unmatched sequences.
+ $matched_seqs = array();
+ foreach ($sequences as $num => $info) {
+ $name = $prefix . $num;
+ if (!array_key_exists('seq', $info) || !array_key_exists('name', $info)) {
+ $mcl_tmpl->updateMsg('W', "$name does not have both name and seq. So it will be skipped");
+ }
+ else {
+ $seq_name = $info['name'];
+ if (empty($info['seq'])) {
+ $mcl_tmpl->updateMsg('W', "sequence for $seq_name is empty. So it will be skipped");
+ }
+ else {
+ $matched_seqs[$seq_name] = $info['seq'];
+ }
+ }
+ }
+
+ // Adds sequences.
+ foreach ($matched_seqs as $seq_name => $seq) {
+ $args = array(
+ 'uniquename' => $this->getUniquename() . '.' . $seq_name,
+ 'name' => $seq_name,
+ 'type_id' => $type_id_feature,
+ 'organism_id' => $this->organism_id,
+ );
+ $mcl_feature = MCL_CHADO_FEATURE::byKey($args);
+ if ($mcl_feature) {
+ $mcl_tmpl->addMsg('D', 'feature', $args);
+ }
+ else {
+
+ // Adds a sequence.
+ $args['residues'] = $seq;
+ $mcl_feature = new MCL_CHADO_FEATURE($args);
+ if ($mcl_feature->insert()) {
+ $mcl_tmpl->addMsg('N', 'feature', $args);
+
+ // Adds a relationship.
+ $this->addRelatedFeature($mcl_tmpl, $mcl_feature, $type_id_relationship);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'feature', $args);
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds accessions to dbxref and feature_dbxref.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param integer $db_id
+ * @param string $dbxref
+ * @param string $separator
+ */
+ public function addDBXref(MCL_TEMPLATE $mcl_tmpl, $db_id, $dbxref, $separator = '') {
+ if ($dbxref) {
+ $accessions = preg_split($mcl_tmpl->getSepRegex($separator), $dbxref, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($accessions as $accession) {
+ $accession = trim($accession);
+ $mcl_dbxref = MCL_CHADO_DBXREF::addDBXref($mcl_tmpl, $db_id, $accession);
+ if ($mcl_dbxref) {
+ $mcl_tmpl->addLink('feature_dbxref', 'feature_id', $this->getFeatureID(), 'dbxref_id', $mcl_dbxref->getDbxrefID());
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds trait to feature_cvterm.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $trait_ontology
+ * @param string $trait_name
+ * @param string $separator
+ */
+ public function addTrait(MCL_TEMPLATE $mcl_tmpl, $trait_ontology, $trait_name, $separator = '') {
+
+ // Gets the trait.
+ $trait = MCL_CHADO_CVTERM::getCvterm($trait_ontology, $trait_name);
+ if ($trait) {
+ $args = array(
+ 'pub_id' => MCL_VAR::getValueByName('PUB_ID'),
+ 'feature_id' => $this->feature_id,
+ 'cvterm_id' => $trait->getCvtermID(),
+ );
+
+ // Checks for duplication.
+ $chado_feature_cvterm = CHADO_FEATURE_CVTERM::byKey($args);
+ if ($chado_feature_cvterm) {
+ $mcl_tmpl->addMsg('D', 'feature_cvterm', $args);
+ }
+ else {
+
+ // Adds a new relationship.
+ $chado_feature_cvterm = new CHADO_FEATURE_CVTERM($args);
+ if ($chado_feature_cvterm->insert()) {
+ $mcl_tmpl->addMsg('N', 'feature_cvterm', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'feature_cvterm', $args);
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds alias to synoym and feature_synoym.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $alias
+ * @param integer $type_id
+ * @param string $separator
+ */
+ public function addAlias(MCL_TEMPLATE $mcl_tmpl, $type_id, $alias, $separator = '') {
+
+ // Sets the arguments.
+ $args = array(
+ 'type_id' => $type_id,
+ 'alias' => $alias,
+ );
+
+ // Checks arguements.
+ if ($mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Sets the default values.
+ $synonym_sgml = '';
+
+ // Adds a synonym.
+ $names = preg_split($mcl_tmpl->getSepRegex($separator), $alias, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($names as $name) {
+ $name = trim($name);
+
+ // Checks for duplication.
+ $args = array(
+ 'type_id' => $type_id,
+ 'name' => $name,
+ );
+ $chado_synonym = CHADO_SYNONYM::byKey($args);
+ if ($chado_synonym) {
+ $mcl_tmpl->addMsg('D', 'synonym', $args);
+ }
+ else {
+
+ // Adds a new synonym.
+ $args['synonym_sgml'] = $synonym_sgml;
+ $chado_synonym = new CHADO_SYNONYM($args);
+ if ($chado_synonym->insert()) {
+ $mcl_tmpl->addMsg('N', 'synonym', $args);
+
+ // Checks for duplication.
+ $args = array(
+ 'pub_id' => MCL_VAR::getValueByName('PUB_ID'),
+ 'feature_id' => $this->feature_id,
+ 'synonym_id' => $chado_synonym->getSynonymID(),
+ );
+ $chado_feature_synonym = CHADO_FEATURE_SYNONYM::byKey($args);
+ if ($chado_feature_synonym) {
+ $mcl_tmpl->addMsg('D', 'feature_synonym', $args);
+ }
+ else {
+
+ // Adds a new relationship.
+ $chado_feature_synonym = new CHADO_FEATURE_SYNONYM($args);
+ if ($chado_feature_synonym->insert()) {
+ $mcl_tmpl->addMsg('N', 'feature_synonym', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'feature_synonym', $args);
+ }
+ }
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'synonym', $args);
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds synoym and feature_synoym.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param MCL_CHADO_SYNONYM $mcl_synonym
+ */
+ public function addSynonym(MCL_TEMPLATE $mcl_tmpl, MCL_CHADO_SYNONYM $mcl_synonym) {
+ if ($mcl_synonym) {
+
+ // Checks for duplication.
+ $args = array(
+ 'synonym_id' => $mcl_synonym->getSynonymID(),
+ 'feature_id' => $this->feature_id,
+ '$pub_id' => MCL_VAR::getValueByName('PUB_ID'),
+ );
+ $chado_feature_synonym = CHADO_FEATURE_SYNONYM::byKey($args);
+ if ($chado_feature_synonym) {
+ $mcl_tmpl->addMsg('D', 'feature_synonym', $args);
+ }
+ else {
+
+ // Adds a new relationship.
+ $chado_feature_synonym = new CHADO_FEATURE_SYNONYM($args);
+ if ($chado_feature_synonym->insert()) {
+ $mcl_tmpl->addMsg('N', 'feature_synonym', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'feature_synonym', $args);
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds contact to feature_contact.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $contact
+ * @param string $separator
+ */
+ public function addContact(MCL_TEMPLATE $mcl_tmpl, $contact, $separator = '') {
+ if ($contact) {
+ $names = preg_split($mcl_tmpl->getSepRegex($separator), $contact, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($names as $name) {
+ $name = trim($name);
+ $mcl_contact = MCL_CHADO_CONTACT::getContact($name);
+ if ($mcl_contact) {
+ $mcl_tmpl->addLink('feature_contact', 'feature_id', $this->feature_id, 'contact_id', $mcl_contact->getContactID());
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds dataset to feature_project.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $dataset_name
+ * @param string $separator
+ */
+ public function addDataset(MCL_TEMPLATE $mcl_tmpl, $dataset_name, $separator = '') {
+ if ($dataset_name) {
+ $names = preg_split($mcl_tmpl->getSepRegex($separator), $dataset_name, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($names as $name) {
+ $name = trim($name);
+ $mcl_dataset = MCL_CHADO_DATASET::getDataset($name);
+ if ($mcl_dataset) {
+ $mcl_tmpl->addLink('feature_project', 'feature_id', $this->feature_id, 'project_id', $mcl_dataset->getProjectID());
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds stock to feature_stock.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $stock
+ * @param string $genus
+ * @param string $species
+ * @param string $separator
+ */
+ public function addStock(MCL_TEMPLATE $mcl_tmpl, $stock, $genus, $species, $separator = '') {
+ if ($stock) {
+
+ // Gets orgaims_id.
+ $mcl_organism = MCL_CHADO_ORGANISM::getOrganism($genus, $species);
+ if ($mcl_organism) {
+
+ $uniquenames = preg_split($mcl_tmpl->getSepRegex($separator), $stock, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($uniquenames as $uniquename) {
+ $uniquename = trim($uniquename);
+ $organism_id = $mcl_organism->getOrganismID();
+
+ // If ':' found in uniquename, update uniquename and organism_id.
+ if (preg_match("/^(.*?)\s+(.*?):(.*?)$/", $uniquename, $matches)) {
+ $genus = trim($matches[1]);
+ $species = trim($matches[2]);
+ $uniquename = trim($matches[3]);
+ $diff_organism = MCL_CHADO_ORGANISM::getOrganism($genus, $species);
+ $organism_id = $diff_organism->getOrganismID();
+ }
+
+ // Adds a stock.
+ $mcl_stock = MCL_CHADO_STOCK::byKey(array('uniquename' => $uniquename, 'organism_id' => $organism_id));
+ if ($mcl_stock) {
+ $mcl_tmpl->addLink('feature_stock', 'feature_id', $this->feature_id, 'stock_id', $mcl_stock->getStockID());
+ }
+ }
+ }
+ else {
+ $this->updateMsg('E', "(genus, species) = ($genus, $species) not found in organism");
+ }
+ }
+ }
+
+ /**
+ * Adds genotype to feature_genotype.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $stock
+ * @param integer $cvterm_id
+ * @param MCL_CHADO_GENOTYPE $genotype
+ */
+ public function addGenotype(MCL_TEMPLATE $mcl_tmpl, $stock, $genus, $cvterm_id, MCL_CHADO_GENOTYPE $genotype) {
+
+ // Checks feature_genotype for duplication.
+ $args = array(
+ 'feature_id' => $this->feature_id,
+ 'genotype_id' => $genotype->getGenotypeID(),
+ '$cvterm_id' => $cvterm_id,
+ );
+ $chado_feature_genotype = CHADO_FEATURE_GENOTYPE::byKey($args);
+ if ($chado_feature_genotype) {
+ $mcl_tmpl->addMsg('D', 'feature_genotype', $args);
+ }
+ else {
+
+ // Adds feature_genotype.
+ $args['cgroup'] = 1;
+ $chado_feature_genotype = new CHADO_FEATURE_GENOTYPE($args);
+ if ($chado_feature_genotype->insert()) {
+ $mcl_tmpl->addMsg('N', 'feature_genotype', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'feature_genotype', $args);
+ }
+ }
+ }
+
+ /**
+ * Adds image to feature_image.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $reference
+ * @param string $separator
+ */
+ public function addImage(MCL_TEMPLATE $mcl_tmpl, $image, $separator = '') {
+ if ($image) {
+ $eimage_ids = preg_split($mcl_tmpl->getSepRegex($separator), $image, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($eimage_ids as $eimage_id) {
+ $eimage_id = trim($eimage_id);
+ $mcl_image = MCL_CHADO_IMAGE::byKey(array('eimage_id' => $eimage_id));
+ if ($mcl_image) {
+ $mcl_tmpl->addLink('feature_image', 'feature_id', $this->feature_id, 'eimage_id', $mcl_image->getEimageID());
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds reference to feature_pub.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $reference
+ * @param string $separator
+ */
+ public function addReference(MCL_TEMPLATE $mcl_tmpl, $reference, $separator = '') {
+ if ($reference) {
+ $pub_ids = preg_split($mcl_tmpl->getSepRegex($separator), $reference, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($pub_ids as $pub_id) {
+ $pub_id = trim($pub_id);
+ $mcl_pub = MCL_CHADO_PUB::getPub($pub_id);
+ if ($mcl_pub) {
+ $mcl_tmpl->addLink('feature_pub', 'feature_id', $this->feature_id, 'pub_id', $pub_id);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_featuremap.class.inc b/includes/class/mcl_chado_class/mcl_chado_featuremap.class.inc
new file mode 100644
index 0000000..71cd049
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_featuremap.class.inc
@@ -0,0 +1,244 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_FEATUREMAP::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the existance of featuremap. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $map
+ * @param string $separator
+ */
+ public static function checkMap(MCL_TEMPLATE $mcl_tmpl, $map, $separator = '') {
+
+ // Gets contact names.
+ $names = preg_split($mcl_tmpl->getSepRegex($separator), $map, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($names as $name) {
+ $name = trim($name);
+ $mcl_map = MCL_CHADO_FEATUREMAP::getMap($name);
+ if (!$mcl_map) {
+ $mcl_tmpl->updateMsg('E', "(name) = ($name) not found in featuremap");
+ }
+ }
+ }
+
+ /**
+ * Checks the map unit for cvterm. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $map_unit
+ * @param string $separator
+ */
+ public static function checkMapUnit(MCL_TEMPLATE $mcl_tmpl, $map_unit, $separator = '') {
+
+ // Gets cvterm for the map unit.
+ $mcl_cvterm = MCL_CHADO_CVTERM::getCvterm('SITE_CV', $map_unit);
+ if (!$mcl_cvterm) {
+ $mcl_tmpl->updateMsg('E', "(map_unit) = ($map_unit) not found in cvterm");
+ }
+ }
+
+ /**
+ * Returns the featuremap by name.
+ *
+ * @param string $name
+ *
+ * @return MCL_CHADO_FEATUREMAP
+ */
+ public static function getMap($name) {
+ return MCL_CHADO_FEATUREMAP::bykey(array('name' => $name));
+ }
+
+ /**
+ * Adds a featuremap.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $name
+ * @param integer $map_unit
+ * @param integer $description
+ *
+ * @return MCL_CHADO_FEATUREMAP
+ */
+ public static function addMap(MCL_TEMPLATE $mcl_tmpl, $name, $map_unit, $description) {
+
+ // Sets the arguments.
+ $args = array('name' => $name);
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_featuremap = MCL_CHADO_FEATUREMAP::byKey($args);
+ if ($mcl_featuremap) {
+ $mcl_tmpl->addMsg('D', 'featuremap', $args);
+ }
+ else {
+
+ // Gets unittype_id from map_unit.
+ $cvterm = MCL_CHADO_CVTERM::getCvterm('SITE_CV', $map_unit);
+ if (!$cvterm) {
+ $mcl_tmpl->updateMsg('E', "map_unit : '$map_unit' found in cvterm");
+ return NULL;
+ }
+
+ // Adds a new map.
+ $args['unittype_id'] = $cvterm->getCvtermID();
+ $args['description'] = $description;
+ $mcl_featuremap = new MCL_CHADO_FEATUREMAP($args);
+ if ($mcl_featuremap->insert()) {
+ $mcl_tmpl->addMsg('N', 'featuremap', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'featuremap', $args);
+ }
+ }
+ return $mcl_featuremap;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $separator = '') {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('featuremapprop', 'featuremap_id', $this->featuremap_id, $type_id, $value, $separator);
+ }
+
+ /**
+ * Adds stock to featuremap_organism.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $genus
+ * @param integer $species
+ * @param string $separator
+ */
+ public function addOrganism(MCL_TEMPLATE $mcl_tmpl, $genus, $species, $separator = '') {
+ if ($genus && $species) {
+ $sps = preg_split($mcl_tmpl->getSepRegex($separator), $species, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($sps as $sp) {
+ $sp = trim($sp);
+
+ // Gets the organism.
+ $mcl_organism = MCL_CHADO_ORGANISM::getOrganism($genus, $sp);
+ if ($mcl_organism) {
+ $mcl_tmpl->addLink('featuremap_organism', 'featuremap_id', $this->featuremap_id, 'organism_id', $mcl_organism->getOrganismID());
+ }
+ else {
+ $mcl_tmpl->updateMsg('E', "(genus, species) = ($genus, $sp) not found in organism");
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds stock to featuremap_stock.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $stock
+ * @param integer $organism_id
+ * @param string $separator
+ */
+ public function addStock(MCL_TEMPLATE $mcl_tmpl, $stock, $genus, $species, $separator = '') {
+ if ($stock) {
+
+ // Gets orgaims_id.
+ $mcl_organism = MCL_CHADO_ORGANISM::getOrganism($genus, $species);
+ if ($mcl_organism) {
+
+ // Adds a stock.
+ $uniquenames = preg_split($mcl_tmpl->getSepRegex($separator), $stock, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($uniquenames as $uniquename) {
+ $uniquename = trim($uniquename);
+ $mcl_stock = MCL_CHADO_STOCK::byKey(array('uniquename' => $uniquename, 'organism_id' => $organism_id));
+ if ($mcl_stock) {
+ $mcl_tmpl->addLink('featuremap_stock', 'featuremap_id', $this->featuremap_id, 'stock_id', $mcl_stock->getStockID());
+ }
+ }
+ }
+ else {
+ $this->updateMsg('E', "(genus, species) = ($genus, $species) not found in organism");
+ }
+ }
+ }
+
+ /**
+ * Adds contact to featuremap_contact.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $contact
+ * @param string $separator
+ */
+ public function addContact(MCL_TEMPLATE $mcl_tmpl, $contact, $separator = '') {
+ if ($contact) {
+ $names = preg_split($mcl_tmpl->getSepRegex($separator), $contact, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($names as $name) {
+ $name = trim($name);
+ $mcl_contact = MCL_CHADO_CONTACT::getContact($name);
+ if ($mcl_contact) {
+ $mcl_tmpl->addLink('featuremap_contact', 'featuremap_id', $this->featuremap_id, 'contact_id', $mcl_contact->getContactID());
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds reference to featuremap_pub.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $reference
+ * @param string $separator
+ */
+ public function addReference(MCL_TEMPLATE $mcl_tmpl, $reference, $separator = '') {
+ if ($reference) {
+ $pub_ids = preg_split($mcl_tmpl->getSepRegex($separator), $reference, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($pub_ids as $pub_id) {
+ $pub_id = trim($pub_id);
+ $mcl_pub = MCL_CHADO_PUB::getPub($pub_id);
+ if ($mcl_pub) {
+ $mcl_tmpl->addLink('featuremap_pub', 'featuremap_id', $this->featuremap_id, 'pub_id', $pub_id);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_featurepos.class.inc b/includes/class/mcl_chado_class/mcl_chado_featurepos.class.inc
new file mode 100644
index 0000000..23efe3d
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_featurepos.class.inc
@@ -0,0 +1,94 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_FEATUREPOS::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Adds a featurepos.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param MCL_CHADO_FEATRUE $target_feature
+ * @param MCL_CHADO_FEATRUEMAP $map
+ * @param MCL_CHADO_FEATRUE $linkage_group
+ *
+ * @return MCL_CHADO_FEATUREPOS
+ */
+ public static function addFeaturepos(MCL_TEMPLATE $mcl_tmpl, MCL_CHADO_FEATRUE $feature, MCL_CHADO_FEATRUEMAP $map, MCL_CHADO_FEATRUE $map_feature) {
+
+ // Sets the arguments.
+ $args = array(
+ 'feature_id' => $feature->getFeatureID(),
+ 'featuremap_id' => $map->getFeaturemapID(),
+ 'map_feature_id' => $map_feature->getFeatureID(),
+ );
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $featurepos = MCL_CHADO_FEATUREPOS::byKey($args);
+ if ($featurepos) {
+ $mcl_tmpl->addMsg('D', 'featurepos', $args);
+ }
+ else {
+
+ // Adds a new featurepos.
+ $args['mappos'] = 0.0;
+ $featurepos = new MCL_CHADO_FEATUREPOS($args);
+ if ($featurepos->insert()) {
+ $mcl_tmpl->addMsg('N', 'featurepos', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'featurepos', $args);
+ }
+ }
+ return $featurepos;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $separator = '') {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('featureposprop', 'featurepos_id', $this->featurepos_id, $type_id, $value, $separator);
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_genotype.class.inc b/includes/class/mcl_chado_class/mcl_chado_genotype.class.inc
new file mode 100644
index 0000000..c6e3255
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_genotype.class.inc
@@ -0,0 +1,80 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_GENOTYPE::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+
+ /**
+ * Adds a genotype.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $uniquename
+ * @param integer $type_id
+ * @param string $description
+ *
+ * @return MCL_CHADO_PHENOTYPE
+ */
+ public static function addGenotype(MCL_TEMPLATE $mcl_tmpl, $uniquename, $type_id, $description) {
+
+ // Sets the arguments.
+ $args = array(
+ 'uniquename' => $uniquename,
+ 'type_id' => $type_id,
+ );
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_genotype = MCL_CHADO_GENOTYPE::byKey($args);
+ if ($mcl_genotype) {
+ $mcl_tmpl->addMsg('D', 'genotype', $args);
+ }
+ else {
+
+ // Adds a new genotype.
+ $args['description'] = $description;
+ $mcl_genotype = new MCL_CHADO_GENOTYPE($args);
+ if ($mcl_genotype->insert()) {
+ $mcl_tmpl->addMsg('N', 'genotype', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'genotype', $args);
+ }
+ }
+ return $mcl_genotype;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_image.class.inc b/includes/class/mcl_chado_class/mcl_chado_image.class.inc
new file mode 100644
index 0000000..bcb49cc
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_image.class.inc
@@ -0,0 +1,113 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_EIMAGE::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the existance of eimage. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $image
+ * @param string $separator
+ */
+ public static function checkImage(MCL_TEMPLATE $mcl_tmpl, $image, $separator = '') {
+ if ($image) {
+
+ // Gets eimage_id.
+ $eimage_ids = preg_split($mcl_tmpl->getSepRegex($separator), $image, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($eimage_ids as $eimage_id) {
+ $eimage_id = trim($eimage_id);
+ $args = array('eimage_id' => $eimage_id);
+ $mcl_image = MCL_CHADO_IMAGE::byKey($args);
+ if (!$mcl_image) {
+ $mcl_tmpl->addMsg('D', 'eimage', $args);
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds an image.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $eimage_data
+ * @param string $eimage_type
+ * @param string $image_uri
+ *
+ * @return MCL_CHADO_DBXREF
+ */
+ public static function addImage(MCL_TEMPLATE $mcl_tmpl, $eimage_data, $eimage_type, $image_uri) {
+
+ // Sets the arguments.
+ $args = array(
+ 'eimage_data' => $eimage_data,
+ 'eimage_type' => $eimage_type,
+ 'image_uri' => $image_uri,
+ );
+
+ // Checks parameters.
+ if ($eimage_data && $eimage_type && $image_uri) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_image = MCL_CHADO_IMAGE::byKey($args);
+ if ($mcl_image) {
+ $mcl_tmpl->addMsg('D', 'eimage', $args);
+ }
+ else {
+ // Adds a new image.
+ $mcl_image = new MCL_CHADO_IMAGE($args);
+ if ($mcl_image->insert()) {
+ $mcl_tmpl->addMsg('N', 'eimage', $args);
+ }
+ }
+ return $mcl_image;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $separator = '') {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('eimageprop', 'eimage_id', $this->eimage_id, $type_id, $value, $separator);
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_library.class.inc b/includes/class/mcl_chado_class/mcl_chado_library.class.inc
new file mode 100644
index 0000000..6ad713b
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_library.class.inc
@@ -0,0 +1,207 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_LIBRARY::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the existance of library. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $uniquename
+ * @param integer $type_id
+ * @param integer $organism_id
+ */
+ public static function checkLibrary(MCL_TEMPLATE $mcl_tmpl, $uniquename, $type_id, $organism_id) {
+ if ($uniquename && $type_id) {
+
+ // Gets the library.
+ $mcl_library = MCL_CHADO_LIBRARY::getLibrary($uniquename, $type_id, $organism_id);
+ if (!$mcl_library) {
+ $args = array(
+ 'uniquename' => $uniquename,
+ 'type_id' => $type_id,
+ 'organism_id' => $organism_id,
+ );
+ $mcl_tmpl->addMsg('E', 'library', $args);
+ }
+ }
+ }
+
+ /**
+ * Returns the library.
+ *
+ * @param string $uniquename
+ * @param integer $type_id
+ *
+ * @return MCL_CHADO_LIBRARY
+ */
+ public static function getLibrary($uniquename, $type_id) {
+ $keys = array(
+ 'uniquename' => $uniquename,
+ 'type_id' => $type_id,
+ 'organism_id' => MCL_VAR::getValueByName('ORGANISM_ID'),
+ );
+ return MCL_CHADO_LIBRARY::bykey($keys);
+ }
+
+ /**
+ * Adds a new library.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $uniquename
+ * @param integer $type_id
+ *
+ * @return MCL_CHADO_LIBRARY
+ */
+ public static function addLibrary(MCL_TEMPLATE $mcl_tmpl, $uniquename, $type_id) {
+
+ // Sets the arguments.
+ $args = array(
+ 'uniquename' => $uniquename,
+ 'type_id' => $type_id,
+ );
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $args['organism_id'] = MCL_VAR::getValueByName('ORGANISM_ID');
+ $mcl_library = MCL_CHADO_LIBRARY::byKey($args);
+ if ($mcl_library) {
+ $mcl_tmpl->addMsg('D', 'library', $args);
+ }
+ else {
+
+ // Adds a new library.
+ $args['name'] = $uniquename;
+ $mcl_library = new MCL_CHADO_LIBRARY($args);
+ if ($mcl_library->insert()) {
+ $mcl_tmpl->addMsg('N', 'library', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'library', $args);
+ }
+ }
+ return $mcl_library;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $separator = '') {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('libraryprop', 'library_id', $this->library_id, $type_id, $value, $separator);
+ }
+
+ /**
+ * Adds synoym and library_synoym.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param MCL_CHADO_SYNONYM $mcl_synonym
+ */
+ public function addSynonym(MCL_TEMPLATE $mcl_tmpl, MCL_CHADO_SYNONYM $mcl_synonym) {
+ if ($mcl_synonym) {
+
+ // Checks for duplication.
+ $args = array(
+ 'synonym_id' => $mcl_synonym->getSynonymID(),
+ 'library_id' => $this->library_id,
+ '$pub_id' => MCL_VAR::getValueByName('PUB_ID'),
+ );
+ $chado_library_synonym = CHADO_LIBRARY_SYNONYM::byKey($args);
+ if ($chado_library_synonym) {
+ $mcl_tmpl->addMsg('D', 'library_synonym', $args);
+ }
+ else {
+
+ // Adds a new relationship.
+ $chado_library_synonym = new CHADO_LIBRARY_SYNONYM($args);
+ if ($chado_library_synonym->insert()) {
+ $mcl_tmpl->addMsg('N', 'library_synonym', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'library_synonym', $args);
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds contact to library_contact.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $contact
+ * @param string $separator
+ */
+ public function addContact(MCL_TEMPLATE $mcl_tmpl, $contact, $separator = '') {
+ if ($contact) {
+ $names = preg_split($mcl_tmpl->getSepRegex($separator), $contact, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($names as $name) {
+ $name = trim($name);
+ $mcl_contact = MCL_CHADO_CONTACT::byKey(array('name' => $name));
+ if ($mcl_contact) {
+ $mcl_tmpl->addLink('library_contact', 'library_id', $this->library_id, 'contact_id', $mcl_contact->getContactID());
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds reference to library_pub.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $reference
+ * @param string $separator
+ */
+ public function addReference(MCL_TEMPLATE $mcl_tmpl, $reference, $separator = '') {
+ if ($reference) {
+ $pub_ids = preg_split($mcl_tmpl->getSepRegex($separator), $reference, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($pub_ids as $pub_id) {
+ $pub_id = trim($pub_id);
+ $mcl_pub = MCL_CHADO_PUB::getPub($pub_id);
+ if ($mcl_pub) {
+ $mcl_tmpl->addLink('library_pub', 'library_id', $this->library_id, 'pub_id', $pub_id);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_location.class.inc b/includes/class/mcl_chado_class/mcl_chado_location.class.inc
new file mode 100644
index 0000000..fba5775
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_location.class.inc
@@ -0,0 +1,237 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * Checks the site code. Write the error messasge to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string site_code
+ */
+ public static function checkSiteCode(MCL_TEMPLATE $mcl_tmpl, $site_code) {
+ if ($site_code) {
+
+ // TODO:
+ $description = $site_code;
+
+ // Gets nd_geolocation.
+ $args = array(
+ 'description' => $description,
+ );
+ $bim_location = MCL_CHADO_LOCATION::byKey($args);
+ if (!$bim_location) {
+ $mcl_tmpl->addMsg('E', 'nd_geolocation', $args);
+ }
+ }
+ }
+
+ /**
+ * Returns nd_geolocation_id of the provided site code. If site code
+ * is empty, return the default nd_geolocation_id.
+ *
+ * @param string $site_code
+ *
+ * @return integer nd_geolocation_id
+ */
+ public static function getLocationIDBySiteCode($site_code) {
+ $nd_geolocation_id = NULL;
+
+ if ($site_code) {
+
+ // TODO:
+ $description = $site_code;
+
+ // Gets nd_geolocation.
+ $args = array(
+ 'description' => $description,
+ );
+ $mcl_location = MCL_CHADO_LOCATION::byKey($args);
+ if ($mcl_location) {
+ $nd_geolocation_id = $mcl_location->getNdGeolocationID();
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'nd_geolocation', $args);
+ }
+ }
+ else {
+
+ // Returns a default nd_geolocation_id.
+ $nd_geolocation_id = MCL_VAR::getValueByName('ND_GEOLOCATION_ID');
+ }
+ return $nd_geolocation_id;
+ }
+
+ /**
+ * Checks the site name. Write the error messasge to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $site_name
+ */
+ public static function checkSite(MCL_TEMPLATE $mcl_tmpl, $site_name) {
+ if ($site_name) {
+
+ // Gets nd_geolocation.
+ $args = array(
+ 'description' => $site_name,
+ );
+ $bim_location = MCL_CHADO_LOCATION::byKey($args);
+ if (!$bim_location) {
+ $mcl_tmpl->addMsg('E', 'nd_geolocation', $args);
+ }
+ }
+ }
+
+ /**
+ * Returns nd_geolocation_id of the provided site name. If site name
+ * is empty, return the default nd_geolocation_id.
+ *
+ * @param string $site_name
+ *
+ * @return integer nd_geolocation_id
+ */
+ public static function getLocationIDBySite($site_name) {
+
+ // Sets the default nd_geolocation_id.
+ $nd_geolocation_id = MCL_VAR::getValueByName('ND_GEOLOCATION_ID');
+
+ // Gets the nd_geolocation_id.
+ if ($site_name) {
+
+ // Gets nd_geolocation.
+ $args = array(
+ 'description' => $site_name,
+ );
+ $mcl_location = MCL_CHADO_LOCATION::byKey($args);
+ if ($mcl_location) {
+ $nd_geolocation_id = $mcl_location->getNdGeolocationID();
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'nd_geolocation', $args);
+ }
+ }
+ return $nd_geolocation_id;
+ }
+
+ /**
+ * Adds 'Not Available' location.
+ *
+ * @return MCL_CHADO_LOCATION
+ */
+ public static function addNA() {
+
+ // Checks if it has already exists.
+ $mcl_location = MCL_CHADO_LOCATION::byKey(array('description' => 'Not Available'));
+ if (!$mcl_location) {
+ $details = array('description' => 'Not Available');
+ $mcl_location = new MCL_CHADO_LOCATION($details);
+ if (!$mcl_location->insert()) {
+ return NULL;
+ }
+ }
+ return $mcl_location;
+ }
+
+ /**
+ * Adds a location.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $name
+ * @param array $loc_info
+ * Valid keys for $loc_info array
+ * - latitude
+ * - longitude
+ * - altitude
+ * - geodetic_datum
+ *
+ * @return MCL_CHADO_LOCATION
+ */
+ public static function addLocation(MCL_TEMPLATE $mcl_tmpl, $name, $loc_info = NULL) {
+
+ // Sets the arguments.
+ $args = array('description' => $name);
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks $loc_info.
+ if (!empty($loc_info)) {
+ $valid_keys = array('latitude', 'longitude', 'altitude', 'geodetic_datum');
+ foreach ($loc_info as $key => $value) {
+ if (!in_array($key, $valid_keys)) {
+ $mcl_tmpl->updateMsg('E', "$key is an invalid attribute of nd_geolocation table");
+ return NULL;
+ }
+ }
+ }
+
+ // Checks for duplication.
+ $mcl_location = MCL_CHADO_LOCATION::byKey($args);
+ if ($mcl_location) {
+ $mcl_tmpl->addMsg('D', 'nd_geolocation', $args);
+ }
+ else {
+
+ // Adds location information if provided.
+ if ($loc_info) {
+ $loc_info['description'] = $name;
+ $args = $loc_info;
+ }
+
+ // Adds a new location.
+ $mcl_location = new MCL_CHADO_LOCATION($args);
+ if ($mcl_location->insert()) {
+ $mcl_tmpl->addMsg('N', 'nd_geolocation', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'nd_geolocation', $args);
+ }
+ }
+ return $mcl_location;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $separator = '') {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('nd_geolocationprop', 'nd_geolocation_id', $this->nd_geolocation_id, $type_id, $value, $separator);
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_nd_experiment.class.inc b/includes/class/mcl_chado_class/mcl_chado_nd_experiment.class.inc
new file mode 100644
index 0000000..7ff25d3
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_nd_experiment.class.inc
@@ -0,0 +1,340 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_ND_EXPERIMENT::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the existance of contact. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $contact
+ * @param string $separator
+ */
+ public static function checkCrossNumber(MCL_TEMPLATE $mcl_tmpl, $dataset_name, $cross_number) {
+ if ($cross_number) {
+
+ // Checks for dataset_name.
+ if ($dataset_name) {
+ $dataset = MCL_CHADO_DATASET::getDataset($dataset_name);
+ if ($dataset) {
+
+ // Checks cross_number.
+ $sql = "
+ SELECT NEP.nd_experiment_id
+ FROM {chado.nd_experimentprop} NEP
+ INNER JOIN {chado.nd_experiment_project} NEPR on NEPR.nd_experiment_id = NEP.nd_experiment_id
+ WHERE NEPR.project_id = :project_id
+ AND NEP.type_id = :type_id
+ AND LOWER(NEP.value) = LOWER(:value)
+ ";
+ $args = array(
+ ':project_id' => $dataset->getProjectID(),
+ ':value' => $cross_number,
+ ':type_id' => $mcl_tmpl->cvterms['SITE_CV']['cross_number'],
+ );
+ $results = db_query($sql, $args);
+ $nd_experiment_id = $results->fetchField();
+ if ($nd_experiment_id) {
+
+ // Checks maternal parent.
+ $args = array(
+ 'nd_experiment_id' => $nd_experiment_id,
+ 'type_id' => $mcl_tmpl->cvterms['SITE_CV']['maternal_parent'],
+ );
+ $nd_experiment_stock = CHADO_ND_EXPERIMENT_STOCK::byKey($args);
+
+ if (!$nd_experiment_stock) {
+ $mcl_tmpl->updateMsg('E', "The maternal parent of the cross ($cross_number) does not found");
+ }
+
+ // Checks paternal parent.
+ $args = array(
+ 'nd_experiment_id' => $nd_experiment_id,
+ 'type_id' => $mcl_tmpl->cvterms['SITE_CV']['paternal_parent'],
+ );
+ $nd_experiment_stock = CHADO_ND_EXPERIMENT_STOCK::byKey($args);
+ if (!$nd_experiment_stock) {
+ $mcl_tmpl->updateMsg('E', "The paternal parent of the cross ($cross_number) does not found");
+ }
+ }
+ }
+ else {
+ $mcl_tmpl->updateMsg('E', "dataset_name ($dataset_name) not found in project");
+ }
+ }
+ else {
+ $mcl_tmpl->updateMsg('E', "Since cross_number is not empty, dataset_name must be specified");
+ }
+ }
+ }
+
+ /**
+ * Returns parent by cross number.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param integer $cvterm_id_parent
+ * @param string $dataset_name
+ * @param string cross_number
+ *
+ * @return MCL_CHADO_STOCK
+ */
+ public static function getParentByCrossNumber(MCL_TEMPLATE $mcl_tmpl, $cvterm_id_parent, $dataset_name, $cross_number) {
+
+ // Gets project_id.
+ $dataset = MCL_CHADO_DATASET::getDataset($dataset_name);
+ if ($dataset) {
+
+ // Gets the stock_id of the specified parent.
+ $sql= "
+ SELECT NES.stock_id
+ FROM {chado.nd_experiment_stock} NES
+ INNER JOIN {chado.nd_experimentprop} NEP on NEP.nd_experiment_id = NES.nd_experiment_id
+ INNER JOIN {chado.nd_experiment_project} NEPR on NEPR.nd_experiment_id = NES.nd_experiment_id
+ WHERE NES.type_id = :type_id_nes
+ AND NEP.type_id = :type_id_nep
+ AND NEPR.project_id = :project_id
+ AND LOWER(NEP.value) = LOWER(:cross_number)
+ ";
+ $args = array(
+ ':type_id_nes' => $cvterm_id_parent,
+ ':type_id_nep' => $mcl_tmpl->getCvtermID('SITE_CV', 'cross_number'),
+ ':project_id' => $dataset->getProjectID(),
+ ':cross_number' => $cross_number,
+ );
+ $results = db_qery($sql, $args);
+ $stock_id = $results->fetchField();
+ if ($stock_id) {
+ return MCL_CHADO_STOCK::byKey(array('stock_id' => $stock_id));
+ }
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a nd_experiment.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param integer $type_id
+ * @param integer $nd_geolocation_id
+ * @param string $dup_value
+ *
+ * @return MCL_CHADO_ND_EXPERIMENT
+ */
+ public static function addNdExperiment(MCL_TEMPLATE $mcl_tmpl, $type_id, $nd_geolocation_id, $cvterm_id, $dup_value) {
+
+ // Sets the arguments.
+ $args = array(
+ 'type_id' => $type_id,
+ 'nd_geolocation_id' => $nd_geolocation_id,
+ 'cvterm_id' => $cvterm_id,
+ 'dup_value' => $dup_value,
+ );
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $args = array(
+ 'type_id' => $cvterm_id,
+ 'value' => $dup_value,
+ );
+ $chado_nd_experimentprop = CHADO_ND_EXPERIMENTPROP::byKey($args);
+ if ($chado_nd_experimentprop) {
+ $mcl_tmpl->updateMsg('D', "nd_experiment of the dup_value ($dup_value) for $cvterm_id already exists");
+ $mcl_nd_experiment = MCL_CHADO_ND_EXPERIMENT::byKey(array('nd_experiment_id' => $chado_nd_experimentprop->getNdExperimentID()));
+ }
+ else {
+
+ // Adds a new nd_experiment.
+ $args = array(
+ 'type_id' => $type_id,
+ 'nd_geolocation_id' => $nd_geolocation_id,
+ );
+ $mcl_nd_experiment = new MCL_CHADO_ND_EXPERIMENT($args);
+ if ($mcl_nd_experiment->insert()) {
+ $mcl_tmpl->addMsg('N', 'nd_experiment', $args);
+
+ // Adds a new nd_experimentprop.
+ $args = array(
+ 'nd_experiment_id' => $mcl_nd_experiment->getNdExperimentID(),
+ 'type_id' => $cvterm_id,
+ 'value' => $dup_value,
+ );
+ $chado_nd_experimentprop = new CHADO_ND_EXPERIMENTPROP($args);
+ if ($chado_nd_experimentprop->insert()) {
+ $mcl_tmpl->addMsg('N', 'nd_experimentprop', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'nd_experimentprop', $args);
+ }
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'nd_experiment', $args);
+ }
+ }
+ return $mcl_nd_experiment;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $separator = '') {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('featuremapprop', 'featuremap_id', $this->featuremap_id, $type_id, $value, $separator);
+ }
+
+ /**
+ * Adds stock to featuremap_organism.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $genus
+ * @param integer $species
+ * @param string $separator
+ */
+ public function addOrganism(MCL_TEMPLATE $mcl_tmpl, $genus, $species, $separator = '') {
+ if ($genus && $species) {
+ $sps = preg_split($mcl_tmpl->getSepRegex($separator), $species, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($sps as $sp) {
+ $sp = trim($sp);
+
+ // Gets the organism.
+ $mcl_organism = MCL_CHADO_ORGANISM::getOrganism($genus, $sp);
+ if ($mcl_organism) {
+ $mcl_tmpl->addLink('featuremap_organism', 'featuremap_id', $this->featuremap_id, 'organism_id', $mcl_organism->getOrganismID());
+ }
+ else {
+ $mcl_tmpl->updateMsg('E', "(genus, species) = ($genus, $sp) not found in organism");
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds stock to nd_experiment_stock.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param MCL_CHADO_STOCK $stock
+ */
+ public function addStock(MCL_TEMPLATE $mcl_tmpl, MCL_CHADO_STOCK $mcl_stock, $type_id) {
+ if ($mcl_stock && $type_id) {
+ $mcl_tmpl->addLink('nd_experiment_stock', 'nd_experiment_id', $this->nd_experiment_id, 'stock_id', $mcl_stock->getStockID(), $type_id);
+ }
+ }
+
+ /**
+ * Adds phenotype to nd_experiment_phenotype.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param MCL_CHADO_PHENOTYPE $phenotype
+ */
+ public function addPhenotype(MCL_TEMPLATE $mcl_tmpl, MCL_CHADO_PHENOTYPE $mcl_phenotype) {
+ if ($mcl_phenotype) {
+ $mcl_tmpl->addLink('nd_experiment_phenotype', 'nd_experiment_id', $this->nd_experiment_id, 'phenotype_id', $mcl_phenotype->getPhenotypeID());
+ }
+ }
+
+ /**
+ * Adds genotype to nd_experiment_genotype.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param MCL_CHADO_GENOTYPE $genotype
+ */
+ public function addGenotype(MCL_TEMPLATE $mcl_tmpl, MCL_CHADO_GENOTYPE $mcl_genotype) {
+ if ($mcl_genotype) {
+ $mcl_tmpl->addLink('nd_experiment_genotype', 'nd_experiment_id', $this->nd_experiment_id, 'genotype_id', $mcl_genotype->getGenotypeID());
+ }
+ }
+
+ /**
+ * Adds dataset to nd_experiment_project.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $dataset_name
+ */
+ public function addDataset(MCL_TEMPLATE $mcl_tmpl, $dataset_name) {
+ if ($dataset_name) {
+ $mcl_dataset = MCL_CHADO_DATASET::getDataset($dataset_name);
+ $mcl_tmpl->addLink('nd_experiment_project', 'nd_experiment_id', $this->nd_experiment_id, 'project_id', $mcl_dataset->getProjectID());
+ }
+ }
+
+ /**
+ * Adds contact to nd_experiment_contact.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $contact
+ * @param string $separator
+ */
+ public function addContact(MCL_TEMPLATE $mcl_tmpl, $contact, $separator = '') {
+ if ($contact) {
+ $names = preg_split($mcl_tmpl->getSepRegex($separator), $contact, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($names as $name) {
+ $name = trim($name);
+ $mcl_contact = MCL_CHADO_CONTACT::getContact($name);
+ if ($mcl_contact) {
+ $mcl_tmpl->addLink('nd_experiment_contact', 'nd_experiment_id', $this->nd_experiment_id, 'contact_id', $mcl_contact->getContactID());
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds reference to feature_pub.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $reference
+ * @param string $separator
+ */
+ public function addReference(MCL_TEMPLATE $mcl_tmpl, $reference, $separator = '') {
+ if ($reference) {
+ $pub_ids = preg_split($mcl_tmpl->getSepRegex($separator), $reference, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($pub_ids as $pub_id) {
+ $pub_id = trim($pub_id);
+ $mcl_pub = MCL_CHADO_PUB::getPub($pub_id);
+ if ($mcl_pub) {
+ $mcl_tmpl->addLink('fnd_experiment__pub', 'nd_experiment_id', $this->nd_experiment_id, 'pub_id', $pub_id);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_organism.class.inc b/includes/class/mcl_chado_class/mcl_chado_organism.class.inc
new file mode 100644
index 0000000..32634e4
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_organism.class.inc
@@ -0,0 +1,121 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_ORGANISM::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Returns all organism_id for the given crop.
+ *
+ * @param integer $crop_id
+ *
+ * @return array of organism objects
+ */
+ public static function getOrganismsByCropID($crop_id) {
+
+ // Gets all orgainsm for the selected crop.
+ $crop_organism_ids = MCL_CROP::getOrganismIDs($crop_id);
+ $organism_arr = array();
+ foreach ($crop_organism_ids as $organism_id) {
+ $organism = CHADO_ORGANISM::byKey(array('organism_id' => $organism_id));
+ $organism_arr[$organism->getOrganismID()] = $organism->getGenus() . ' ' . $organism->GetSpecies();
+ }
+ return $organism_arr;
+ }
+
+ /**
+ * Checks the existance of orgainsm. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $genus
+ * @param string $species
+ * @param string separator
+ */
+ public static function checkOrganism(MCL_TEMPLATE $mcl_tmpl, $genus, $species, $separator = '') {
+ if ($genus && $species) {
+
+ $sps = preg_split($mcl_tmpl->getSepRegex($separator), $species, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($sps as $sp) {
+ $sp = trim($sp);
+
+ // Gets the orgainsm.
+ $mcl_orgainsm = MCL_CHADO_ORGANISM::getOrganism($genus, $sp);
+ if (!$mcl_orgainsm) {
+ $mcl_tmpl->updateMsg('E', "(genus, species) = ($genus, $sp) not found in organism");
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the orgainsm by genus and species.
+ *
+ * @param string $genus
+ * @param string $species
+ *
+ * @return MCL_CHADO_ORGANISM
+ */
+ public static function getOrganism($genus, $species) {
+ $args = array(
+ 'genus' => $genus,
+ 'species' => $species,
+ );
+ return MCL_CHADO_ORGANISM::bykey($args);
+ }
+
+ /**
+ * Adds null organism.
+ *
+ * @return MCL_CHADO_ORGANISM
+ */
+ public static function addNull() {
+
+ // Gets null cvterm.
+ $mcl_cvterm = MCL_CHADO_CVTERM::addNull();
+
+ // Checks if it has already exists.
+ $mcl_organism = MCL_CHADO_ORGANISM::getOrganism('null', 'null');
+ if (!$mcl_organism) {
+ $details = array(
+ 'genus' => 'null',
+ 'species' => 'null',
+ );
+ $mcl_organism = new MCL_CHADO_ORGANISM($details);
+ if (!$mcl_organism->insert()) {
+ return NULL;
+ }
+ }
+ return $mcl_organism;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_phenotype.class.inc b/includes/class/mcl_chado_class/mcl_chado_phenotype.class.inc
new file mode 100644
index 0000000..de6ed17
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_phenotype.class.inc
@@ -0,0 +1,69 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a phenotype.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $uniquename
+ * @param integer $attr_id
+ * @param string $value
+ *
+ * @return MCL_CHADO_PHENOTYPE
+ */
+ public static function addPhenotype(MCL_TEMPLATE $mcl_tmpl, $uniquename, $attr_id, $value) {
+
+ // Sets the arguments.
+ $args = array('uniquename' => $uniquename);
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_phenotype = MCL_CHADO_PHENOTYPE::byKey($args);
+ if ($mcl_phenotype) {
+ $mcl_tmpl->addMsg('D', 'phenotype', $args);
+ }
+ else {
+
+ // Adds a new phenotype.
+ $args['value'] = $value;
+ $args['attr_id'] = $attr_id;
+ $mcl_phenotype = new MCL_CHADO_PHENOTYPE($args);
+ if ($mcl_phenotype->insert()) {
+ $mcl_tmpl->addMsg('N', 'phenotype', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'phenotype', $args);
+ }
+ }
+ return $mcl_phenotype;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_pub.class.inc b/includes/class/mcl_chado_class/mcl_chado_pub.class.inc
new file mode 100644
index 0000000..ac1cbb6
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_pub.class.inc
@@ -0,0 +1,95 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_PUB::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the existance of db. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $reference
+ * @param string $separator
+ */
+ public static function checkPUB(MCL_TEMPLATE $mcl_tmpl, $reference, $separator) {
+ if ($reference) {
+
+ // Checks the pub.
+ $pub_ids = preg_split($mcl_tmpl->getSepRegex($separator), $reference, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($pub_ids as $pub_id) {
+ $pub_id = trim($pub_id);
+ $pub = MCL_CHADO_PUB::getPub($pub_id);
+ if (!$pub) {
+ $mcl_tmpl->updateMsg('E', "(pub_id) = ($pub_id) not found in pub");
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the pub by pub_id.
+ *
+ * @param integer pub_id
+ *
+ * @return MCL_CHADO_PUB
+ */
+ public static function getPub($pub_id) {
+ return MCL_CHADO_PUB::bykey(array('pub_id' => $pub_id));
+ }
+
+ /**
+ * Adds null pub.
+ *
+ * @return MCL_CHADO_PUB
+ */
+ public static function addNull() {
+
+ // Gets null cvterm.
+ $mcl_cvterm = MCL_CHADO_CVTERM::addNull();
+
+ // Checks if it has already exists.
+ $mcl_pub = MCL_CHADO_PUB::byKey(array('uniquename' => 'null'));
+ if (!$mcl_pub) {
+ $details = array(
+ 'uniquename' => 'null',
+ 'type_id' => $mcl_cvterm->getCvtermID(),
+ );
+ $mcl_pub = new MCL_CHADO_PUB($details);
+ if (!$mcl_pub->insert()) {
+ return NULL;
+ }
+ }
+ return $mcl_pub;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_stock.class.inc b/includes/class/mcl_chado_class/mcl_chado_stock.class.inc
new file mode 100644
index 0000000..700f4b7
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_stock.class.inc
@@ -0,0 +1,390 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_STOCK::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Returns stock types.
+ *
+ * @return array of stock types.
+ */
+ public static function getStockTypeArray() {
+
+ // Gets all stock types.
+ $stock_arr = array();
+ foreach (self::$stock_types as $stock_type) {
+ $mcl_cvterm = MCL_CHADO_CVTERM::getCvterm('SITE_CV', $stock_type);
+ if ($mcl_cvterm) {
+ $stock_arr[$mcl_cvterm->getCvtermID()] = $stock_type;
+ }
+ }
+ return $stock_arr;
+ }
+
+ /**
+ * Checks the type of stock. If not, write the error messasge to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $stock_type
+ */
+ public static function checkType(MCL_TEMPLATE $mcl_tmpl, $stock_type) {
+ if ($stock_type) {
+ if (!in_array(strtolower($stock_type), $mcl_tmpl->valid_stock_types)) {
+ $mcl_tmpl->updateMsg('E', "Error - germplasm_type : '$stock_type' is not valid germplasm type");
+ }
+ else {
+ $cvterm = MCL_CHADO_CVTERM::getCvterm('SITE_CV', $stock_type);
+ if (!$cvterm) {
+ $mcl_tmpl->updateMsg('E', "Error - germplasm_type : '$stock_type' does not exist");
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks the existance of stock. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $stock
+ * @param string $genus
+ * @param string $species
+ * @param string $separator
+ */
+ public static function checkStock(MCL_TEMPLATE $mcl_tmpl, $stock, $genus, $species, $separator = '') {
+ if ($stock) {
+
+ // Gets the organism.
+ $mcl_organism = MCL_CHADO_ORGANISM::getOrganism($genus, $species);
+ if ($mcl_organism) {
+
+ // Gets the uniquenames.
+ $uniquenames = preg_split($mcl_tmpl->getSepRegex($separator), $stock, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($uniquenames as $uniquename) {
+ $uniquename = trim($uniquename);
+ $args = array(
+ 'uniquename' => $uniquename,
+ 'organism_id' => $mcl_organism->getOrganismID(),
+ );
+ $mcl_stock = MCL_CHADO_STOCK::byKey($args);
+ if (!$mcl_stock) {
+ $mcl_tmpl->updateMsg('E', $mcl_tmpl->arrStr($args) . " not found in stock");
+ }
+ }
+ }
+ else {
+ $mcl_tmpl->updateMsg('E', "(genus, species) = ($genus, $species) not found in organism");
+ }
+ }
+ }
+
+ /**
+ * Checks the format of alias. Write the error messasge to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $alias
+ * @param string $separator
+ */
+ public static function checkAlias(MCL_TEMPLATE $mcl_tmpl, $alias, $separator = '') {
+ if ($alias) {
+
+ // Gets the alias.
+ $aliases = preg_split($mcl_tmpl->getSepRegex($separator), $alias, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($aliases as $value) {
+ $tmp = preg_split("/:/", $value);
+ $num_elem = sizeof($tmp);
+ if ($num_elem > 2) {
+ $mcl_tmpl->updateMsg('E', "$value is not a valid format. It should be alias_type:alias");
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the stock by uniquename, genus and species.
+ *
+ * @param string $uniquename
+ * @param string $genus
+ * @param string $species
+ *
+ * @return MCL_CHADO_STOCK
+ */
+ public static function getStock($uniquename, $genus, $species) {
+ $organism = MCL_CHADO_ORGANISM::getOrganism($genus, $species);
+ $args = array(
+ 'uniquename' => $uniquename,
+ 'organism_id' => $organism->getOrganismID(),
+ );
+ return MCL_CHADO_STOCK::bykey($argsas);
+ }
+
+ /**
+ * Adds a stock.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $uniquename
+ * @param integer $organism_id
+ * @param integer $type_id
+ * @param string $name
+ *
+ * @return MCL_CHADO_STOCK
+ */
+ public static function addStock(MCL_TEMPLATE $mcl_tmpl, $uniquename, $name, $organism_id, $type_id) {
+
+ // Sets the arguments.
+ $args = array(
+ 'uniquename' => $uniquename,
+ 'organism_id' => $organism_id,
+ );
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_stock = MCL_CHADO_STOCK::byKey($args);
+ if ($mcl_stock) {
+ $mcl_tmpl->addMsg('D', 'stock', $args);
+ }
+ else {
+
+ // Adds a new stock.
+ $args['type_id'] = $type_id;
+ $args['name'] = $name;
+ $mcl_stock = new MCL_CHADO_STOCK($args);
+ if ($mcl_stock->insert()) {
+ $mcl_tmpl->addMsg('N', 'stock', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'stock', $args);
+ }
+ }
+ return $mcl_stock;
+ }
+
+ /**
+ * Adds a property.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProp(MCL_TEMPLATE $mcl_tmpl, $cv_name, $cvterm_name, $value, $separator = '') {
+ $type_id = $mcl_tmpl->getCvtermID($cv_name, $cvterm_name);
+ $mcl_tmpl->addProperty('stockprop', 'stock_id', $this->stock_id, $type_id, $value, $separator);
+ }
+
+ /**
+ * Adds a related stock.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param MCL_CHADO_STOCK $stock
+ * @param integer $type_id_relationship
+ */
+ public function addRelatedStock(MCL_TEMPLATE $mcl_tmpl, MCL_CHADO_STOCK $stock, $type_id_relationship) {
+ if ($stock) {
+ $mcl_tmpl->addRelationship('stock_relationship', 'subject_id', $this->stock_id, 'object_id', $stock->getStockID(), $type_id_relationship);
+ }
+ }
+
+ /**
+ * Adds a progeny.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cross_number
+ */
+ public function addProgeny(MCL_TEMPLATE $mcl_tmpl, $project_id, $cross_number) {
+ if ($project_id && $cross_number) {
+
+ // Gets the maternal parent.
+ $maternal_parent = MCL_CHADO_ND_EXPERIMENT::getParentByCrossNumber($mcl_tmpl, $mcl_tmpl->cvterms['SITE_CV']['maternal_parent'], $project_id, $cross_number);
+ $this->addRelatedStock($mcl_tmpl, $maternal_parent, $mcl_tmpl->cvterms['SITE_CV']['is_a_maternal_parent_of']);
+
+ // Gets the paternal parent.
+ $paternal_parent = MCL_CHADO_ND_EXPERIMENT::getParentByCrossNumber($htis, $mcl_tmpl->cvterms['SITE_CV']['paternal_parent'], $project_id, $cross_number);
+ $this->addRelatedStock($mcl_tmpl, $paternal_parent, $mcl_tmpl->cvterms['SITE_CV']['is_a_paternal_parent_of']);
+
+ // Gets nd_experiment_id.
+ $sql = "
+ SELECT NEP.nd_experiment_id
+ FROM nd_experimentprop NEP
+ INNER JOIN nd_experiment_project NEPR on NEPR.nd_experiment_id = NEP.nd_experiment_id
+ WHERE LOWER(NEP.value) = LOWER(:value)
+ AND NEP.type_id = :type_id
+ AND NEP.project_id = :project_id
+ ";
+ $args = array(
+ ':value' => $cross_number,
+ ':type_id' => $mcl_tmpl->cvterms['SITE_CV']['cross_number'],
+ ':project_id' => $project_id,
+ );
+ $results = db_query($sql, $args);
+ $nd_experiment_id = $results->fetchField();
+
+ // Adds a progeny.
+ $mcl_tmpl->addLink('nd_experiment_stock', 'stock_id', $this->stock_id, 'nd_experiment_id', $nd_experiment_id, $mcl_tmpl->cvterms['SITE_CV']['progeny']);
+ }
+ }
+
+ /**
+ * Adds a parent.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $uniquename
+ * @param integer $organism_id
+ * @param integer $type_id_relationship
+ */
+ public function addParent(MCL_TEMPLATE $mcl_tmpl, $uniquename, $organism_id, $type_id_relationship) {
+ if ($uniquename && $organism_id && $type_id_relationship) {
+ $args = array(
+ 'uniquename' => $uniquename,
+ 'organism_id' => $organism_id
+ );
+ $parent = MCL_CHADO_STOCK::byKey($args);
+ if ($parent) {
+
+ // Adds a relationship.
+ $parent->addRelatedStock($mcl_tmpl, $this, $type_id_relationship);
+ }
+ else {
+ $mcl_tmpl->updateMsg('E', "Parent '$uniquename' dose not exists in stock table.");
+ }
+ }
+ }
+
+ /**
+ * Adds alias to stockprop.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $reference
+ * @param string $separator
+ */
+ public function addAlias(MCL_TEMPLATE $mcl_tmpl, $alias, $separator = '') {
+ if ($alias) {
+ $aliases = preg_split($mcl_tmpl->getSepRegex($separator), $alias, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($aliases as $value) {
+ $tmp = preg_split("/:/", $value);
+ $alias_type = 'alias';
+ if (sizeof($tmp) > 1) {
+ $alias_type = $tmp[0];
+ $value = $tmp[1];
+ }
+ $alias_type = (strtolower($alias_type) == 'cultivar') ? 'cultivar' : 'alias';
+ $this->addProp($mcl_tmpl, 'SITE_CV', $alias_type, $value);
+ }
+ }
+ }
+
+ /**
+ * Adds a dbxref to stock_dbxref.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param MCL_CHADO_DBXREF $dbxref
+ */
+ public function addDBXref(MCL_TEMPLATE $mcl_tmpl, MCL_CHADO_DBXREF $dbxref) {
+ $mcl_tmpl->addLink('stock_dbxref', 'stock_id', $this->stock_id, 'dbxref_id', $dbxref->getDbxrefID());
+ }
+
+ /**
+ * Adds contact to stock_contact.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $contact
+ * @param string $separator
+
+ public function addContact(MCL_TEMPLATE $mcl_tmpl, $contact, $separator = '') {
+ if ($contact) {
+ $names = preg_split($mcl_tmpl->getSepRegex($separator), $contact, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($names as $name) {
+ $name = trim($name);
+ $mcl_contact = MCL_CHADO_CONTACT::getContact($name);
+ if ($mcl_contact) {
+ $mcl_tmpl->addLink('stock_contact', 'stock_id', $this->stock_id, 'contact_id', $mcl_contact->getContactID());
+ }
+ }
+ }
+ } */
+
+ /**
+ * Adds image to stock_image.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $reference
+ * @param string $separator
+ */
+ public function addImage(MCL_TEMPLATE $mcl_tmpl, $image, $separator = '') {
+ if ($image) {
+ $eimage_ids = preg_split($mcl_tmpl->getSepRegex($separator), $image, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($eimage_ids as $eimage_id) {
+ $eimage_id = trim($eimage_id);
+ $mcl_image = MCL_CHADO_IMAGE::byKey(array('eimage_id' => $eimage_id));
+ if ($mcl_image) {
+ $mcl_tmpl->addLink('stock_image', 'stock_id', $this->stock_id, 'eimage_id', $mcl_image->getEimageID());
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds reference to stock_pub.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $reference
+ * @param string $separator
+ */
+ public function addReference(MCL_TEMPLATE $mcl_tmpl, $reference, $separator = '') {
+ if ($reference) {
+ $pub_ids = preg_split($mcl_tmpl->getSepRegex($separator), $reference, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($pub_ids as $pub_id) {
+ $pub_id = trim($pub_id);
+ $mcl_pub = MCL_CHADO_PUB::getPub($pub_id);
+ if ($mcl_pub) {
+ $mcl_tmpl->addLink('stock_pub', 'stock_id', $this->stock_id, 'pub_id', $pub_id);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_synonym.class.inc b/includes/class/mcl_chado_class/mcl_chado_synonym.class.inc
new file mode 100644
index 0000000..0ca8ae7
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_synonym.class.inc
@@ -0,0 +1,93 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see CHADO_SYNONYM::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Returns the synonym by name and type_id.
+ *
+ * @param string $name
+ * @param string $type_id
+ *
+ * @return MCL_CHADO_SYNONYM
+ */
+ public static function getSynonym($name, $type_id) {
+ $args = array(
+ 'name' => $name,
+ 'type_id' => $type_id,
+ );
+ return MCL_CHADO_SYNONYM::bykey($args);
+ }
+
+ /**
+ * Adds a synonym.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $name
+ * @param string $type_id
+ *
+ * @return MCL_CHADO_SYNONYM
+ */
+ public static function addSynonym(MCL_TEMPLATE $mcl_tmpl, $name, $type_id) {
+
+ // Sets the arguments.
+ $args = array(
+ 'name' => $name,
+ 'type_id' => $type_id,
+ );
+
+ // Checks the arguments.
+ if (!$mcl_tmpl->checkReqArgs($args)) {
+ return NULL;
+ }
+
+ // Checks for duplication.
+ $mcl_synonym = MCL_CHADO_SYNONYM::byKey($args);
+ if ($mcl_synonym) {
+ $mcl_tmpl->addMsg('D', 'synonym', $args);
+ }
+ else {
+
+ // Adds a new synonym.
+ $mcl_synonym = new MCL_CHADO_SYNONYM($args);
+ if ($mcl_synonym->insert()) {
+ $mcl_tmpl->addMsg('N', 'synonym', $args);
+ }
+ else {
+ $mcl_tmpl->addMsg('E', 'synonym', $args);
+ }
+ }
+ return $mcl_synonym;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_chado_class/mcl_chado_trait.class.inc b/includes/class/mcl_chado_class/mcl_chado_trait.class.inc
new file mode 100644
index 0000000..004aa0c
--- /dev/null
+++ b/includes/class/mcl_chado_class/mcl_chado_trait.class.inc
@@ -0,0 +1,98 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * @see MCL_CHADO_CVTERM::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Checks the plant trait ontology. If not, write the error messasge
+ * to the log.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $cv_name
+ * @param string $cvterm_name
+ */
+ public static function checkCategory(MCL_TEMPLATE $mcl_tmpl, $trait_category, $trait_descriptor_set) {
+ if ($trait_category) {
+ if (!in_array(strtolower($trait_category), $mcl_tmpl->valid_plant_trait_ontologies)) {
+ $mcl_tmpl->updateMsg('E', "Error - trait category : '$trait_category' is not a valid trait category");
+ }
+ else {
+ $cvterm_trait_category = MCL_CHADO_CVTERM::getCvterm($trait_descriptor_set, $trait_category);
+ if (!$cvterm_trait_category) {
+ $mcl_tmpl->updateMsg('E', "Error - (trait_descriptor_set, trait category ) : ($trait_descriptor_set, $trait_category) does not exist");
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds a trait.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $db_name
+ * @param string $cv_name
+ * @param string $cvterm_name
+ * @param string $definition
+ * @param string $accession
+ *
+ * @return MCL_CHADO_CVTERM
+ */
+ public static function addTrait(MCL_TEMPLATE $mcl_tmpl, $db_name, $cv_name, $cvterm_name, $definition, $accession = '') {
+ $mcl_cvterm = MCL_CHADO_CVTERM::addCvterm($mcl_tmpl, $db_name, $cv_name, $cvterm_name, $definition, $accession);
+ return MCL_CHADO_TRAIT::byKey(array('cvterm_id' => $mcl_cvterm->getCvtermID()));
+ }
+
+ /**
+ * Adds a category.
+ *
+ * @param MCL_TEMPLATE $mcl_tmpl
+ * @param string $trait_ontology
+ * @param string $triat_category
+ * @param integer $type_id
+ * @param string $separator
+ */
+ public function addCategory(MCL_TEMPLATE $mcl_tmpl, $trait_descriptor_set, $triat_category, $type_id, $separator = '') {
+ if ($triat_category) {
+ $categories = preg_split("/[,;]/", $triat_category, NULL, PREG_SPLIT_NO_EMPTY);
+ foreach ($categories as $category) {
+ $mcl_category = MCL_CHADO_CVTERM::getCvterm($trait_descriptor_set, $category);
+ if ($mcl_category) {
+ $mcl_tmpl->addRelationship('cvterm_relationship', 'subject_id', $this->cvterm_id, 'object_id', $mcl_category->getCvtermID(), $type_id);
+ }
+ else {
+ $this->updateMsg('W', "Warning trait_category : '$category' not found cvterm");
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_class_loader.class.inc b/includes/class/mcl_class_loader.class.inc
new file mode 100644
index 0000000..fee596d
--- /dev/null
+++ b/includes/class/mcl_class_loader.class.inc
@@ -0,0 +1,90 @@
+module_path = $module_path;
+ $this->class_path = "$module_path/includes/class";
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {}
+
+ /**
+ * Register autoloader.
+ *
+ * @param string $class_name
+ *
+ * @return boolean
+ */
+ public function register() {
+ spl_autoload_register(array($this, 'loadClass'));
+ }
+
+ /**
+ * Loads a class file.
+ *
+ * @param string $class_name
+ *
+ * @return boolean
+ */
+ public function loadClass($class_name) {
+
+ // Gets the path to the class file.
+ $path = '/';
+ if (preg_match("/^PUBLIC_MCL_/", $class_name, $matches)) {
+ $path .= 'public_table_class/';
+ }
+ else if (preg_match("/^CHADO_/", $class_name, $matches)) {
+ $path .= 'chado_table_class/';
+ }
+ else if (preg_match("/^MCL_CHADO/", $class_name, $matches)) {
+ $path .= 'mcl_chado_class/';
+ }
+ else if (preg_match("/^MCL_EXCEL/", $class_name, $matches)) {
+ $path .= 'excel/';
+ }
+ else if (preg_match("/^MCL_FILE/", $class_name, $matches)) {
+ $path .= 'file/';
+ }
+ else if (preg_match("/^MCL_JOB/", $class_name, $matches)) {
+ $path .= 'job/';
+ }
+
+ else if (preg_match("/^MCL_TABLE/", $class_name, $matches)) {
+ $path .= 'table/';
+ }
+ else if (preg_match("/^MCL_(TEMPLATE|TEMPLATE_TYPE)$/", $class_name, $matches)) {
+ $path .= 'template/';
+ }
+ else if (preg_match("/^MCL_TEMPLATE/", $class_name, $matches)) {
+ $path .= 'template/module/';
+ }
+ else if (preg_match("/^MCL_([A-Z\_]+)/", $class_name, $matches)) {
+ // Does nothing. The file is in the root of class directory.
+ }
+ else {
+ return FALSE;
+ }
+
+ // Includes the class file.
+ $class_filepath = $this->class_path . $path . strtolower($class_name) . '.class.inc';
+ require_once($class_filepath);
+ return TRUE;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_user.class.inc b/includes/class/mcl_user.class.inc
new file mode 100644
index 0000000..dc170e3
--- /dev/null
+++ b/includes/class/mcl_user.class.inc
@@ -0,0 +1,183 @@
+prop_arr).
+ if ($this->prop == '') {
+ $this->prop_arr = array();
+ }
+ else {
+ $this->prop_arr = json_decode($this->prop, TRUE);
+ }
+ }
+
+ /**
+ * @see PUBLIC_MCL_USER::byKey()
+ */
+ public static function byKey($keys) {
+ $parent = parent::byKey($keys);
+ if ($parent) {
+ return new self($parent->getMemberArr());
+ }
+ return $parent;
+ }
+
+ /**
+ * @see PUBLIC_MCL_USER::insert()
+ */
+ public function insert() {
+
+ // Updates the parent:$prop field.
+ $this->prop = json_encode($this->prop_arr);
+
+ // Insert a new user.
+ return parent::insert();
+ }
+
+ /**
+ * @see PUBLIC_MCL_USER::update()
+ */
+ public function update() {
+
+ // Updates the parent:$prop field.
+ $this->prop = json_encode($this->prop_arr);
+
+ // Updates the user properties.
+ return parent::update();
+ }
+
+
+ /**
+ * Returns a list of MCL users. Return all non MCL user if the flag is FALSE.
+ *
+ * @param boolean $flag
+ *
+ * @return array of objects
+ */
+ public static function getUserObjects($flag = TRUE) {
+
+ // Get the MLC or non-MLC users..
+ $sql = "SELECT MU.* FROM {mcl_user} MU ORDER BY MU.name";
+ if (!$flag) {
+ $sql = "
+ SELECT U.*
+ FROM {users} U
+ WHERE U.uid NOT IN (SELECT MU.uid FROM {mcl_user} MU)
+ ORDER BY U.name
+ ";
+ }
+
+ // Gets users.
+ $users = array();
+ $results = db_query($sql);
+ while ($user_obj = $results->fetchObject()) {
+ if ($user_obj->uid > 0 && $user_obj->name)
+ $users[$user_obj->uid] = $user_obj->name;
+ }
+ return $users;
+ }
+
+ /**
+ * Returns Drupal user object.
+ *
+ * @param integer $user_id
+ *
+ * @return object
+ */
+ public static function getDrupalUser($user_id) {
+ $sql = "SELECT U.* FROM {users} U WHERE U.uid = :uid";
+ $results = db_query($sql, array(':uid' => $user_id));
+ return $results->fetchObject();
+ }
+
+ /**
+ * Adds a new user to mcl_user table.
+ *
+ * @param integer $user_id
+ *
+ * @return MCL_USER|NULL
+ */
+ public static function addUser($user_id) {
+
+ // Checks if the user is alreay in system.
+ $mcl_user = MCL_USER::byKey(array('user_id' => $user_id));
+ if ($mcl_user) {
+ return $mcl_user;
+ }
+
+ // Gets the user properties.
+ $sql = "SELECT * FROM {users} WHERE uid = :id";
+ $args = array(':id' => $user_id);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ $details['user_id'] = $user_id;
+ $new_user = new MCL_USER($details);
+ if ($new_user->insert()) {
+ return $new_user;
+ }
+ return NULL;
+ }
+
+ /**
+ * Returns the user directory of this user.
+ *
+ * @return string
+ */
+ public function getUserDir() {
+
+ // Builds the user directory path.
+ $user_dir = mcl_get_config_setting('mcl_working_dir') . '/user/' . $this->getName();
+
+ // Creates the directory if not exists.
+ mcl_create_dir($user_dir);
+ return $user_dir;
+ }
+
+ /**
+ * Returns the URL of the user directory of this user.
+ *
+ * @return string
+ */
+ public function getUserDirURL() {
+
+ // Gets the user directory.
+ $user_dir = $this->getUserDir();
+
+ // Converts into URL
+ $user_url = 'public://mcl/user/' . $this->getName();
+ return $user_url;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Returns the value of the given key in prop.
+ */
+ public function getPropByKey($key) {
+ if (array_key_exists($key, $this->prop_arr)) {
+ return $this->prop_arr[$key];
+ }
+ return NULL;
+ }
+
+ /**
+ * Updates the value of the given key in prop.
+ */
+ public function setPropByKey($key, $value) {
+ $this->prop_arr[$key] = $value;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/mcl_var.class.inc b/includes/class/mcl_var.class.inc
new file mode 100644
index 0000000..40122bd
--- /dev/null
+++ b/includes/class/mcl_var.class.inc
@@ -0,0 +1,117 @@
+getMemberArr());
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new variable.
+ *
+ * @param string $name
+ * @param string $value
+ *
+ * @return boolean
+ */
+ public static function addVar($type, $name, $value, $desc) {
+
+ // Checks for duplication.
+ $details = array('name' => $name);
+ $mcl_var = MCL_VAR::byKey($details);
+ if (!$mcl_var) {
+
+ // Adds a new variable.
+ $details['type'] = $type;
+ $details['value'] = $value;
+ $details['description'] = $desc;
+ $mcl_var = new MCL_VAR($details);
+ if (!$mcl_var->insert()) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+
+ /**
+ * Returns the value of the provided name of the site variable.
+ *
+ * @param string $name
+ *
+ * @return string
+ */
+ public static function getValueByName($name) {
+ $mcl_var = MCL_VAR::byKey(array('name' => $name));
+ if ($mcl_var) {
+ return $mcl_var->getValue();
+ }
+ return '';
+ }
+
+ /**
+ * Returns the types of MCL global variable.
+ *
+ * @return array
+ */
+ public static function getTypes() {
+ return array(
+ 'site' => 'SITE',
+ 'default' => 'DEFAULT',
+ );
+ }
+
+ /**
+ * Returns MCL global variable.
+ *
+ * @param string $type
+ *
+ * @return array of MCL_VAR
+ */
+ public static function getGlobalVars($type) {
+ $sql = "
+ SELECT V.var_id
+ FROM {mcl_var} V
+ WHERE LOWER(V.type) = LOWER(:type)
+ ORDER BY V.name
+ ";
+ $args = ($type) ? array(':type' => $type) : array();
+ $results = db_query($sql, $args);
+ $mcl_vars = array();
+ while ($var_id = $results->fetchField()) {
+ $mcl_vars[] = MCL_VAR::byKey(array('var_id' => $var_id));
+ }
+ return $mcl_vars;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+}
\ No newline at end of file
diff --git a/includes/class/public_table_class/public_mcl_file.class.inc b/includes/class/public_table_class/public_mcl_file.class.inc
new file mode 100644
index 0000000..a6ebbd2
--- /dev/null
+++ b/includes/class/public_table_class/public_mcl_file.class.inc
@@ -0,0 +1,419 @@
+ 'serial',
+ 'type' => 'character_varying(255)',
+ 'filename' => 'character_varying(255)',
+ 'filepath' => 'character_varying(512)',
+ 'filesize' => 'integer',
+ 'uri' => 'character_varying(255)',
+ 'user_id' => 'integer',
+ 'job_id' => 'integer',
+ 'submit_date' => 'timestamp_without_time_zone',
+ 'prop' => 'text',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->file_id = array_key_exists('file_id', $details) ? $details['file_id'] : '';
+ $this->type = array_key_exists('type', $details) ? $details['type'] : '';
+ $this->filename = array_key_exists('filename', $details) ? $details['filename'] : '';
+ $this->filepath = array_key_exists('filepath', $details) ? $details['filepath'] : '';
+ $this->filesize = array_key_exists('filesize', $details) ? $details['filesize'] : 0;
+ $this->uri = array_key_exists('uri', $details) ? $details['uri'] : '';
+ $this->user_id = array_key_exists('user_id', $details) ? $details['user_id'] : '';
+ $this->job_id = array_key_exists('job_id', $details) ? $details['job_id'] : '';
+ $this->submit_date = array_key_exists('submit_date', $details) ? $details['submit_date'] : NULL;
+ $this->prop = array_key_exists('prop', $details) ? $details['prop'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate PUBLIC_MCL_FILE by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM mcl_file WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['type'] = $this->type;
+ $fields['filename'] = $this->filename;
+ $fields['filepath'] = $this->filepath;
+ $fields['filesize'] = (is_numeric($this->filesize)) ? $this->filesize : 0;
+ $fields['uri'] = $this->uri;
+ $fields['user_id'] = $this->user_id;
+ $fields['submit_date'] = $this->submit_date;
+ $fields['prop'] = $this->prop;
+ if (is_numeric($this->job_id)) { $fields['job_id'] = $this->job_id; }
+
+ // Inserts the record.
+ $this->file_id = db_insert('mcl_file')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['type'] = $this->type;
+ $fields['filename'] = $this->filename;
+ $fields['filepath'] = $this->filepath;
+ $fields['filesize'] = (is_numeric($this->filesize)) ? $this->filesize : 0;
+ $fields['uri'] = $this->uri;
+ $fields['user_id'] = $this->user_id;
+ $fields['submit_date'] = $this->submit_date;
+ $fields['prop'] = $this->prop;
+ if (is_numeric($this->job_id)) { $fields['job_id'] = $this->job_id; }
+
+ // Updates the record.
+ db_update('mcl_file')
+ ->fields($fields)
+ ->condition('file_id', $this->file_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('mcl_file')
+ ->condition('file_id', $this->file_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the file_id.
+ *
+ * @retrun serial
+ */
+ public function getFileID() {
+ return $this->file_id;
+ }
+
+ /**
+ * Updates the file_id.
+ *
+ * @param serial $file_id
+ */
+ public function setFileID($file_id) {
+ $this->file_id = $file_id;
+ }
+
+ /**
+ * Retrieves the type.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getType() {
+ return $this->type;
+ }
+
+ /**
+ * Updates the type.
+ *
+ * @param character_varying(255) $type
+ */
+ public function setType($type) {
+ $this->type = $type;
+ }
+
+ /**
+ * Retrieves the filename.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getFilename() {
+ return $this->filename;
+ }
+
+ /**
+ * Updates the filename.
+ *
+ * @param character_varying(255) $filename
+ */
+ public function setFilename($filename) {
+ $this->filename = $filename;
+ }
+
+ /**
+ * Retrieves the filepath.
+ *
+ * @retrun character_varying(512)
+ */
+ public function getFilepath() {
+ return $this->filepath;
+ }
+
+ /**
+ * Updates the filepath.
+ *
+ * @param character_varying(512) $filepath
+ */
+ public function setFilepath($filepath) {
+ $this->filepath = $filepath;
+ }
+
+ /**
+ * Retrieves the filesize.
+ *
+ * @retrun integer
+ */
+ public function getFilesize() {
+ return $this->filesize;
+ }
+
+ /**
+ * Updates the filesize.
+ *
+ * @param integer $filesize
+ */
+ public function setFilesize($filesize) {
+ $this->filesize = $filesize;
+ }
+
+ /**
+ * Retrieves the uri.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getUri() {
+ return $this->uri;
+ }
+
+ /**
+ * Updates the uri.
+ *
+ * @param character_varying(255) $uri
+ */
+ public function setUri($uri) {
+ $this->uri = $uri;
+ }
+
+ /**
+ * Retrieves the user_id.
+ *
+ * @retrun integer
+ */
+ public function getUserID() {
+ return $this->user_id;
+ }
+
+ /**
+ * Updates the user_id.
+ *
+ * @param integer $user_id
+ */
+ public function setUserID($user_id) {
+ $this->user_id = $user_id;
+ }
+
+ /**
+ * Retrieves the job_id.
+ *
+ * @retrun integer
+ */
+ public function getJobID() {
+ return $this->job_id;
+ }
+
+ /**
+ * Updates the job_id.
+ *
+ * @param integer $job_id
+ */
+ public function setJobID($job_id) {
+ $this->job_id = $job_id;
+ }
+
+ /**
+ * Retrieves the submit_date.
+ *
+ * @retrun timestamp_without_time_zone
+ */
+ public function getSubmitDate() {
+ return $this->submit_date;
+ }
+
+ /**
+ * Updates the submit_date.
+ *
+ * @param timestamp_without_time_zone $submit_date
+ */
+ public function setSubmitDate($submit_date) {
+ $this->submit_date = $submit_date;
+ }
+
+ /**
+ * Retrieves the prop.
+ *
+ * @retrun text
+ */
+ public function getProp() {
+ return $this->prop;
+ }
+
+ /**
+ * Updates the prop.
+ *
+ * @param text $prop
+ */
+ public function setProp($prop) {
+ $this->prop = $prop;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/public_table_class/public_mcl_job.class.inc b/includes/class/public_table_class/public_mcl_job.class.inc
new file mode 100644
index 0000000..e014d5c
--- /dev/null
+++ b/includes/class/public_table_class/public_mcl_job.class.inc
@@ -0,0 +1,442 @@
+ 'serial',
+ 'name' => 'character_varying(255)',
+ 'type' => 'character_varying(255)',
+ 'class_name' => 'character_varying(255)',
+ 'status' => 'integer',
+ 'param' => 'text',
+ 'prop' => 'text',
+ 'user_id' => 'integer',
+ 'program_id' => 'integer',
+ 'submit_date' => 'timestamp_without_time_zone',
+ 'complete_date' => 'timestamp_without_time_zone',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->job_id = array_key_exists('job_id', $details) ? $details['job_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->type = array_key_exists('type', $details) ? $details['type'] : '';
+ $this->class_name = array_key_exists('class_name', $details) ? $details['class_name'] : '';
+ $this->status = array_key_exists('status', $details) ? $details['status'] : '';
+ $this->param = array_key_exists('param', $details) ? $details['param'] : '';
+ $this->prop = array_key_exists('prop', $details) ? $details['prop'] : '';
+ $this->user_id = array_key_exists('user_id', $details) ? $details['user_id'] : '';
+ $this->program_id = array_key_exists('program_id', $details) ? $details['program_id'] : '';
+ $this->submit_date = array_key_exists('submit_date', $details) ? $details['submit_date'] : NULL;
+ $this->complete_date = array_key_exists('complete_date', $details) ? $details['complete_date'] : NULL;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate PUBLIC_MCL_JOB by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM mcl_job WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['type'] = $this->type;
+ $fields['class_name'] = $this->class_name;
+ $fields['param'] = $this->param;
+ $fields['prop'] = $this->prop;
+ $fields['user_id'] = $this->user_id;
+ $fields['submit_date'] = $this->submit_date;
+ if (is_numeric($this->status)) { $fields['status'] = $this->status; }
+ if (is_numeric($this->program_id)) { $fields['program_id'] = $this->program_id; }
+ if (!empty($this->complete_date)) { $fields['complete_date'] = $this->complete_date; }
+
+ // Inserts the record.
+ $this->job_id = db_insert('mcl_job')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['type'] = $this->type;
+ $fields['class_name'] = $this->class_name;
+ $fields['param'] = $this->param;
+ $fields['prop'] = $this->prop;
+ $fields['user_id'] = $this->user_id;
+ $fields['submit_date'] = $this->submit_date;
+ if (is_numeric($this->status)) { $fields['status'] = $this->status; }
+ if (is_numeric($this->program_id)) { $fields['program_id'] = $this->program_id; }
+ if (!empty($this->complete_date)) { $fields['complete_date'] = $this->complete_date; }
+
+ // Updates the record.
+ db_update('mcl_job')
+ ->fields($fields)
+ ->condition('job_id', $this->job_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('mcl_job')
+ ->condition('job_id', $this->job_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the job_id.
+ *
+ * @retrun serial
+ */
+ public function getJobID() {
+ return $this->job_id;
+ }
+
+ /**
+ * Updates the job_id.
+ *
+ * @param serial $job_id
+ */
+ public function setJobID($job_id) {
+ $this->job_id = $job_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the type.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getType() {
+ return $this->type;
+ }
+
+ /**
+ * Updates the type.
+ *
+ * @param character_varying(255) $type
+ */
+ public function setType($type) {
+ $this->type = $type;
+ }
+
+ /**
+ * Retrieves the class_name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getClassName() {
+ return $this->class_name;
+ }
+
+ /**
+ * Updates the class_name.
+ *
+ * @param character_varying(255) $class_name
+ */
+ public function setClassName($class_name) {
+ $this->class_name = $class_name;
+ }
+
+ /**
+ * Retrieves the status.
+ *
+ * @retrun integer
+ */
+ public function getStatus() {
+ return $this->status;
+ }
+
+ /**
+ * Updates the status.
+ *
+ * @param integer $status
+ */
+ public function setStatus($status) {
+ $this->status = $status;
+ }
+
+ /**
+ * Retrieves the param.
+ *
+ * @retrun text
+ */
+ public function getParam() {
+ return $this->param;
+ }
+
+ /**
+ * Updates the param.
+ *
+ * @param text $param
+ */
+ public function setParam($param) {
+ $this->param = $param;
+ }
+
+ /**
+ * Retrieves the prop.
+ *
+ * @retrun text
+ */
+ public function getProp() {
+ return $this->prop;
+ }
+
+ /**
+ * Updates the prop.
+ *
+ * @param text $prop
+ */
+ public function setProp($prop) {
+ $this->prop = $prop;
+ }
+
+ /**
+ * Retrieves the user_id.
+ *
+ * @retrun integer
+ */
+ public function getUserID() {
+ return $this->user_id;
+ }
+
+ /**
+ * Updates the user_id.
+ *
+ * @param integer $user_id
+ */
+ public function setUserID($user_id) {
+ $this->user_id = $user_id;
+ }
+
+ /**
+ * Retrieves the program_id.
+ *
+ * @retrun integer
+ */
+ public function getProgramID() {
+ return $this->program_id;
+ }
+
+ /**
+ * Updates the program_id.
+ *
+ * @param integer $program_id
+ */
+ public function setProgramID($program_id) {
+ $this->program_id = $program_id;
+ }
+
+ /**
+ * Retrieves the submit_date.
+ *
+ * @retrun timestamp_without_time_zone
+ */
+ public function getSubmitDate() {
+ return $this->submit_date;
+ }
+
+ /**
+ * Updates the submit_date.
+ *
+ * @param timestamp_without_time_zone $submit_date
+ */
+ public function setSubmitDate($submit_date) {
+ $this->submit_date = $submit_date;
+ }
+
+ /**
+ * Retrieves the complete_date.
+ *
+ * @retrun timestamp_without_time_zone
+ */
+ public function getCompleteDate() {
+ return $this->complete_date;
+ }
+
+ /**
+ * Updates the complete_date.
+ *
+ * @param timestamp_without_time_zone $complete_date
+ */
+ public function setCompleteDate($complete_date) {
+ $this->complete_date = $complete_date;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/public_table_class/public_mcl_template.class.inc b/includes/class/public_table_class/public_mcl_template.class.inc
new file mode 100644
index 0000000..4fc1b78
--- /dev/null
+++ b/includes/class/public_table_class/public_mcl_template.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'template' => 'character_varying(255)',
+ 'template_type_id' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->template_id = array_key_exists('template_id', $details) ? $details['template_id'] : '';
+ $this->template = array_key_exists('template', $details) ? $details['template'] : '';
+ $this->template_type_id = array_key_exists('template_type_id', $details) ? $details['template_type_id'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate PUBLIC_MCL_TEMPLATE by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM mcl_template WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['template'] = $this->template;
+ $fields['template_type_id'] = $this->template_type_id;
+
+
+ // Inserts the record.
+ $this->template_id = db_insert('mcl_template')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['template'] = $this->template;
+ $fields['template_type_id'] = $this->template_type_id;
+
+
+ // Updates the record.
+ db_update('mcl_template')
+ ->fields($fields)
+ ->condition('template_id', $this->template_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('mcl_template')
+ ->condition('template_id', $this->template_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the template_id.
+ *
+ * @retrun serial
+ */
+ public function getTemplateID() {
+ return $this->template_id;
+ }
+
+ /**
+ * Updates the template_id.
+ *
+ * @param serial $template_id
+ */
+ public function setTemplateID($template_id) {
+ $this->template_id = $template_id;
+ }
+
+ /**
+ * Retrieves the template.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getTemplate() {
+ return $this->template;
+ }
+
+ /**
+ * Updates the template.
+ *
+ * @param character_varying(255) $template
+ */
+ public function setTemplate($template) {
+ $this->template = $template;
+ }
+
+ /**
+ * Retrieves the template_type_id.
+ *
+ * @retrun integer
+ */
+ public function getTemplateTypeID() {
+ return $this->template_type_id;
+ }
+
+ /**
+ * Updates the template_type_id.
+ *
+ * @param integer $template_type_id
+ */
+ public function setTemplateTypeID($template_type_id) {
+ $this->template_type_id = $template_type_id;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/public_table_class/public_mcl_template_type.class.inc b/includes/class/public_table_class/public_mcl_template_type.class.inc
new file mode 100644
index 0000000..37fad60
--- /dev/null
+++ b/includes/class/public_table_class/public_mcl_template_type.class.inc
@@ -0,0 +1,260 @@
+ 'serial',
+ 'type' => 'character_varying(255)',
+ 'rank' => 'integer',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->template_type_id = array_key_exists('template_type_id', $details) ? $details['template_type_id'] : '';
+ $this->type = array_key_exists('type', $details) ? $details['type'] : '';
+ $this->rank = array_key_exists('rank', $details) ? $details['rank'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate PUBLIC_MCL_TEMPLATE_TYPE by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM mcl_template_type WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['type'] = $this->type;
+ $fields['rank'] = $this->rank;
+
+
+ // Inserts the record.
+ $this->template_type_id = db_insert('mcl_template_type')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['type'] = $this->type;
+ $fields['rank'] = $this->rank;
+
+
+ // Updates the record.
+ db_update('mcl_template_type')
+ ->fields($fields)
+ ->condition('template_type_id', $this->template_type_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('mcl_template_type')
+ ->condition('template_type_id', $this->template_type_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the template_type_id.
+ *
+ * @retrun serial
+ */
+ public function getTemplateTypeID() {
+ return $this->template_type_id;
+ }
+
+ /**
+ * Updates the template_type_id.
+ *
+ * @param serial $template_type_id
+ */
+ public function setTemplateTypeID($template_type_id) {
+ $this->template_type_id = $template_type_id;
+ }
+
+ /**
+ * Retrieves the type.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getType() {
+ return $this->type;
+ }
+
+ /**
+ * Updates the type.
+ *
+ * @param character_varying(255) $type
+ */
+ public function setType($type) {
+ $this->type = $type;
+ }
+
+ /**
+ * Retrieves the rank.
+ *
+ * @retrun integer
+ */
+ public function getRank() {
+ return $this->rank;
+ }
+
+ /**
+ * Updates the rank.
+ *
+ * @param integer $rank
+ */
+ public function setRank($rank) {
+ $this->rank = $rank;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/public_table_class/public_mcl_user.class.inc b/includes/class/public_table_class/public_mcl_user.class.inc
new file mode 100644
index 0000000..e0206f0
--- /dev/null
+++ b/includes/class/public_table_class/public_mcl_user.class.inc
@@ -0,0 +1,308 @@
+ 'integer',
+ 'name' => 'character_varying(255)',
+ 'uid' => 'integer',
+ 'mail' => 'character_varying(255)',
+ 'prop' => 'text',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->user_id = array_key_exists('user_id', $details) ? $details['user_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->uid = array_key_exists('uid', $details) ? $details['uid'] : '';
+ $this->mail = array_key_exists('mail', $details) ? $details['mail'] : '';
+ $this->prop = array_key_exists('prop', $details) ? $details['prop'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate PUBLIC_MCL_USER by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM mcl_user WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['user_id'] = $this->user_id;
+ $fields['name'] = $this->name;
+ $fields['uid'] = $this->uid;
+ $fields['mail'] = $this->mail;
+ $fields['prop'] = $this->prop;
+
+
+ // Inserts the record.
+ $this->user_id = db_insert('mcl_user')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['user_id'] = $this->user_id;
+ $fields['name'] = $this->name;
+ $fields['uid'] = $this->uid;
+ $fields['mail'] = $this->mail;
+ $fields['prop'] = $this->prop;
+
+
+ // Updates the record.
+ db_update('mcl_user')
+ ->fields($fields)
+ ->condition('user_id', $this->user_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('mcl_user')
+ ->condition('user_id', $this->user_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the user_id.
+ *
+ * @retrun integer
+ */
+ public function getUserID() {
+ return $this->user_id;
+ }
+
+ /**
+ * Updates the user_id.
+ *
+ * @param integer $user_id
+ */
+ public function setUserID($user_id) {
+ $this->user_id = $user_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the uid.
+ *
+ * @retrun integer
+ */
+ public function getUid() {
+ return $this->uid;
+ }
+
+ /**
+ * Updates the uid.
+ *
+ * @param integer $uid
+ */
+ public function setUid($uid) {
+ $this->uid = $uid;
+ }
+
+ /**
+ * Retrieves the mail.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getMail() {
+ return $this->mail;
+ }
+
+ /**
+ * Updates the mail.
+ *
+ * @param character_varying(255) $mail
+ */
+ public function setMail($mail) {
+ $this->mail = $mail;
+ }
+
+ /**
+ * Retrieves the prop.
+ *
+ * @retrun text
+ */
+ public function getProp() {
+ return $this->prop;
+ }
+
+ /**
+ * Updates the prop.
+ *
+ * @param text $prop
+ */
+ public function setProp($prop) {
+ $this->prop = $prop;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/public_table_class/public_mcl_var.class.inc b/includes/class/public_table_class/public_mcl_var.class.inc
new file mode 100644
index 0000000..522b48c
--- /dev/null
+++ b/includes/class/public_table_class/public_mcl_var.class.inc
@@ -0,0 +1,306 @@
+ 'serial',
+ 'name' => 'character_varying(255)',
+ 'type' => 'character_varying(255)',
+ 'value' => 'character_varying(1024)',
+ 'description' => 'text',
+ );
+
+ /**
+ * Implements the class constructor.
+ *
+ * @param $details
+ */
+ public function __construct($details = array()) {
+ // Initializes data members.
+ $this->member_arr = $details;
+ $this->var_id = array_key_exists('var_id', $details) ? $details['var_id'] : '';
+ $this->name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->type = array_key_exists('type', $details) ? $details['type'] : '';
+ $this->value = array_key_exists('value', $details) ? $details['value'] : '';
+ $this->description = array_key_exists('description', $details) ? $details['description'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generate PUBLIC_MCL_VAR by key(s).
+ */
+ public static function byKey($keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ $where_arr = array();
+ $args = array();
+ foreach ($keys as $key => $value) {
+
+ // Returns NULL if $value is empty string.
+ if ($value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ $data_type = self::$data_types[$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array($data_type, array('serial', 'integer'))) {
+ if (!is_int((int)$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", $data_type)) {
+ $where_arr []= " LOWER($key) = LOWER(:$key) ";
+ }
+ else {
+ $where_arr []= " $key = :$key ";
+ }
+ $args[":$key"] = $keys[$key];
+ }
+
+ // Gets the table properties.
+ $sql = "SELECT * FROM mcl_var WHERE " . implode(" AND " , $where_arr);
+ $details = db_query($sql, $args)->fetch(PDO::FETCH_ASSOC);
+ if ($details) {
+ return new self($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Adds a new record.
+ */
+ public function insert() {
+
+ $transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ $dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['type'] = $this->type;
+ $fields['value'] = $this->value;
+ $fields['description'] = $this->description;
+
+
+ // Inserts the record.
+ $this->var_id = db_insert('mcl_var')
+ ->fields($fields)
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Updates the record.
+ */
+ public function update() {
+
+ $transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ $fields = array();
+ $fields['name'] = $this->name;
+ $fields['type'] = $this->type;
+ $fields['value'] = $this->value;
+ $fields['description'] = $this->description;
+
+
+ // Updates the record.
+ db_update('mcl_var')
+ ->fields($fields)
+ ->condition('var_id', $this->var_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * Delete the record.
+ */
+ public function delete() {
+
+ $transaction = db_transaction();
+ try {
+
+ db_delete('mcl_var')
+ ->condition('var_id', $this->var_id, '=')
+ ->execute();
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog('mod', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType($member) {
+ return $this->data_types[$member];
+ }
+
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return $this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array $member_arr
+ */
+ public function setMemberArr($member_arr) {
+ $this->member_arr = $member_arr;
+ }
+
+ /**
+ * Retrieves the var_id.
+ *
+ * @retrun serial
+ */
+ public function getVarID() {
+ return $this->var_id;
+ }
+
+ /**
+ * Updates the var_id.
+ *
+ * @param serial $var_id
+ */
+ public function setVarID($var_id) {
+ $this->var_id = $var_id;
+ }
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the type.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getType() {
+ return $this->type;
+ }
+
+ /**
+ * Updates the type.
+ *
+ * @param character_varying(255) $type
+ */
+ public function setType($type) {
+ $this->type = $type;
+ }
+
+ /**
+ * Retrieves the value.
+ *
+ * @retrun character_varying(1024)
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Updates the value.
+ *
+ * @param character_varying(1024) $value
+ */
+ public function setValue($value) {
+ $this->value = $value;
+ }
+
+ /**
+ * Retrieves the description.
+ *
+ * @retrun text
+ */
+ public function getDescription() {
+ return $this->description;
+ }
+
+ /**
+ * Updates the description.
+ *
+ * @param text $description
+ */
+ public function setDescription($description) {
+ $this->description = $description;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/table/mcl_table.class.inc b/includes/class/table/mcl_table.class.inc
new file mode 100644
index 0000000..fe75376
--- /dev/null
+++ b/includes/class/table/mcl_table.class.inc
@@ -0,0 +1,323 @@
+name = $name;
+ $this->schema_name = $schema_name;
+ $this->attrs = array();
+ $this->unique_keys = array();
+ $this->sqls = array();
+
+ // Sets class name.
+ $this->class_name = strtoupper($schema_name . '_' . $class_name);
+
+ // Sets data types.
+ $this->data_types = array(
+ 'NUMERIC' => array('serial', 'smallint', 'bigint', 'integer', 'double', 'real'),
+ 'DATE' => array('timestamp', 'timestamp_without_time_zone'),
+ );
+
+ // Sets contraints.
+ $this->constraints = array('unique', 'foreign');
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {}
+
+ /**
+ * Adds a unique key.
+ *
+ * @param array $info.
+ */
+ public function addUniqueKey($info) {
+ $this->unique_keys[$info['name']] = $info['attrs'];
+ }
+
+ /**
+ * Adds a SQL statement.
+ *
+ * @param string $type
+ * @param string $sql
+ */
+ public function addSQL($type, $sql) {
+
+ // Adds a SQL.
+ if (in_array($type, $this->constraints)) {
+ if (array_key_exists($type, $this->sqls)) {
+ $this->sqls[$type][] = $sql;
+ }
+ else {
+ $this->sqls[$type] = array($sql);
+ }
+ }
+ else {
+ $this->sqls[$type] = $sql;
+ }
+ }
+
+ /**
+ * Return the SQL statement.
+ *
+ * @param string $type
+ *
+ * @return string
+ */
+ public function getSQL($type) {
+ $sqls = '';
+
+ // Returns the SQL.
+ if (in_array($type, $this->constraints)) {
+ if (array_key_exists($type, $this->sqls)) {
+ $arr = $this->sqls[$type];
+ if ($arr) {
+ $sqls = implode("\n", $arr);
+ }
+ }
+ }
+ else {
+ if (array_key_exists($type, $this->sqls)) {
+ $sqls = $this->sqls[$type];
+ }
+ }
+ return $sqls;
+ }
+
+ /**
+ * Returns the number of unique keys.
+ *
+ * @return integer.
+ */
+ public function getNumUniqueKeys() {
+ return sizeof(array_keys($this->unique_keys));
+ }
+
+ /**
+ * Checks if this table has primary key.
+ *
+ * @returns boolean TRUE|FALSE
+ */
+ public function hasPrimaryKey($info) {
+ return !empty($this->primary_key);
+ }
+
+ /**
+ * Checks if this table has unique keys.
+ *
+ * @returns boolean TRUE|FALSE
+ */
+ public function hasUniqueKey($info) {
+ return !empty($this->unique_keys);
+ }
+
+ /**
+ * Adds a table attribute.
+ *
+ * @param MCL_TABLE_ATTR $attr.
+ *
+ */
+ public function addAttr(MCL_TABLE_ATTR $attr) {
+ $this->attrs[$attr->getName()] = $attr;
+ }
+
+ /**
+ * Print a schema for this table.
+ *
+ * @param MCL_TABLE_ATTR $attr.
+ *
+ */
+ public function printSchema() {
+ print "\n[" . $this->name . "]\n";
+ foreach ($this->attrs as $attr_name => $attr_obj) {
+ $attr_obj->printSchema();
+ }
+ }
+
+ /**
+ * Retrieves the attribute of the given name.
+ *
+ * @retrun MCL_TABLE_ATTR
+ */
+ public function getAttr($attr_name) {
+ return $this->attrs[$attr_name];
+ }
+
+ /**
+ * Updates the attribute of the given name.
+ *
+ * @param MCL_TABLE_ATTR $attr
+ */
+ public function setAttr($attr_name, $attr) {
+ $this->attrs[$attr_name] = $attr;
+ }
+
+ /**
+ * Retrieves the data type of the given attribute.
+ *
+ * @param MCL_TABLE_ATTR $attr
+ */
+ public function getDataType($attr_name) {
+ $this->attrs[$attr_name]->getDataType();
+ }
+
+ /**
+ * Updates the data type of the given attribute.
+ *
+ * @param MCL_TABLE_ATTR $attr
+ */
+ public function setDataType($attr_name, $type) {
+ $this->attrs[$attr_name]->setDataType($type);
+ }
+
+ /**
+ * Checks the data type of the given attribute.
+ *
+ * @retrun MCL_TABLE_ATTR
+ */
+ public function isDataTypeNumeric($attr_name) {
+ $data_type = $this->getDataType($attr_name);
+ return in_array($data_type, $this->data_types['NUMERIC']);
+ }
+
+ /**
+ * Returns the data types of the provided type.
+ *
+ * @param $type
+ *
+ * @return array
+ * Data types
+ */
+ public function getDataTypes($type) {
+ return $this->data_types[$type];
+ }
+
+ // Defines getters and setters below.
+ /**
+ * Retrieves the name.
+ *
+ * @retrun string
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param string $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the schema name.
+ *
+ * @retrun string
+ */
+ public function getSchemaName() {
+ return $this->schema_name;
+ }
+
+ /**
+ * Updates the schema name.
+ *
+ * @param string $schema_name
+ */
+ public function setSchemaName($schema_name) {
+ $this->schema_name = $schema_name;
+ }
+
+ /**
+ * Retrieves the class name.
+ *
+ * @retrun integer
+ */
+ public function getClassName() {
+ return $this->class_name;
+ }
+
+ /**
+ * Updates the class name.
+ *
+ * @param string $class_name
+ */
+ public function setClassName($class_name) {
+ $this->class_name = $class_name;
+ }
+
+ /**
+ * Retrieves the attributes.
+ *
+ * @retrun array
+ */
+ public function getAttrs() {
+ return $this->attrs;
+ }
+
+ /**
+ * Updates the attributes.
+ *
+ * @param array $attrs
+ */
+ public function setAttrs($attrs) {
+ $this->attrs = $attrs;
+ }
+
+ /**
+ * Retrieves the primary key.
+ *
+ * @retrun string
+ */
+ public function getPrimaryKey() {
+ return $this->primary_key;
+ }
+
+ /**
+ * Updates the primary key.
+ *
+ * @param array $primary_key
+ */
+ public function setPrimaryKey($primary_key) {
+ $this->primary_key = $primary_key;
+ }
+
+ /**
+ * Retrieves the unique keys.
+ *
+ * @retrun array
+ */
+ public function getUniqueKeys() {
+ return $this->unique_keys;
+ }
+
+ /**
+ * Updates the unique keys.
+ *
+ * @param array $unique_keys
+ */
+ public function setUniqueKeys($unique_keys) {
+ $this->unique_keys = $unique_keys;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/table/mcl_table_attr.class.inc b/includes/class/table/mcl_table_attr.class.inc
new file mode 100644
index 0000000..954fd48
--- /dev/null
+++ b/includes/class/table/mcl_table_attr.class.inc
@@ -0,0 +1,122 @@
+name = array_key_exists('name', $details) ? $details['name'] : '';
+ $this->data_type = array_key_exists('data_type', $details) ? $details['data_type'] : '';
+ $this->not_null = array_key_exists('not_null', $details) ? $details['not_null'] : FALSE;
+ $this->default = array_key_exists('default', $details) ? $details['default'] : '';
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Print schema for this attribute.
+ */
+ public function printSchema() {
+ $attr_info_str = sprintf("\t%s : %s", $this->name, $this->data_type);
+ if ($this->not_null) {
+ $attr_info_str .= ' NOT NULL';
+ }
+ if ($this->default) {
+ $attr_info_str .= ' DEFAULT ' . $this->default;
+ }
+ print $attr_info_str . "\n";
+ }
+
+ // Defines getters and setters below.
+
+ /**
+ * Retrieves the name.
+ *
+ * @retrun character_varying(255)
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Updates the name.
+ *
+ * @param character_varying(255) $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Retrieves the data_type.
+ *
+ * @retrun string
+ */
+ public function getDataType() {
+ return $this->data_type;
+ }
+
+ /**
+ * Updates the data_type.
+ *
+ * @param string $data_type
+ */
+ public function setDataType($data_type) {
+ $this->data_type = $data_type;
+ }
+
+ /**
+ * Retrieves the not_null.
+ *
+ * @retrun boolean
+ */
+ public function getIsNull() {
+ return $this->not_null;
+ }
+
+ /**
+ * Updates the not_null.
+ *
+ * @param boolean $not_null
+ */
+ public function setIsNull($not_null) {
+ $this->not_null = $not_null;
+ }
+
+ /**
+ * Retrieves the default.
+ *
+ * @retrun string
+ */
+ public function getDefault() {
+ return $this->default;
+ }
+
+ /**
+ * Updates the default.
+ *
+ * @param string $default
+ */
+ public function setDefault($default) {
+ $this->default = $default;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/table/mcl_table_class_writer.class.inc b/includes/class/table/mcl_table_class_writer.class.inc
new file mode 100644
index 0000000..ce3a374
--- /dev/null
+++ b/includes/class/table/mcl_table_class_writer.class.inc
@@ -0,0 +1,882 @@
+table = $table;
+ $this->output_dir = $writer->getOutputDir();
+ $this->namespace = $writer->getNamespace();
+ $this->extends = $extends;
+
+ // Updates the data type arrays.
+ $this->data_type_numeric = $table->getDataTypes('NUMERIC');
+ $this->data_type_date = $table->getDataTypes('DATE');
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Align the all columns with the longest string in the column.
+ */
+ private function _alignCol($rows, $indent) {
+
+ // Gets the length of the longest string in each column.
+ $lens = array();
+ foreach ($rows as $i => $row) {
+ foreach ($row as $j => $col) {
+ $len = strlen($col);
+
+ // Assigns zero if not assigned.
+ if (empty($lens[$j])) {
+ $lens[$j] = 0;
+ }
+ if ($lens[$j] < $len) {
+ $lens[$j] = $len;
+ }
+ }
+ }
+
+ // Aligns them.
+ $aligned = '';
+ foreach ($rows as $i => $row) {
+ $row_line = '';
+ foreach ($row as $j => $col) {
+ $row_line .= ($j == 0) ? str_repeat(' ', $indent) : ' ';
+
+ $longet_col = $lens[$j];
+ $row_line .= $col . str_repeat(' ', $longet_col - strlen($col));
+ }
+ $aligned .= rtrim($row_line) . "\n";
+ }
+ return $aligned;
+ }
+
+ /**
+ * Lists all attributes. Skips the attribute with 'NOT NULL' if no value
+ * has been assigned.
+ *
+ * @return string
+ */
+ private function _getAttrList($table, $indent) {
+ $attrs = $table->getAttrs();
+ $rows_not_null = array();
+ $rows_null = array();
+ foreach ($attrs as $name => $attr_obj) {
+ $data_type = $attr_obj->getDataType();
+ $not_null = $attr_obj->getIsNull();
+ if ($data_type != 'serial') {
+ if (in_array($data_type, $this->data_type_numeric)) {
+ if ($not_null) {
+ $default = $attr_obj->getDefault();
+ if ($default != '') {
+ $row = array("\$fields['$name']", '=', "(is_numeric(\$this->$name))", "? \$this->$name", ": $default;");
+ }
+ else {
+ $row = array("\$fields['$name']", '=', "\$this->$name;");
+ }
+ $rows_not_null[] = $row;
+ }
+ else {
+ $row = array("if (is_numeric(\$this->$name))", "{ \$fields['$name']", '=', "\$this->$name; }");
+ $rows_null[] = $row;
+ }
+ }
+ else if ($data_type == 'boolean') {
+ $regex = '"/^(true|false)/i"';
+ if ($not_null) {
+ $row = array("\$fields['$name']", '=', "(preg_match($regex, \$this->$name))", "? \"'\" . \$this->$name . \"'\"", ": '" . $attr_obj->getDefault() . "';");
+ $rows_not_null[] = $row;
+ }
+ else {
+ $row = array("if (preg_match($regex, \$this->$name))", "{ \$fields['$name']", '=', "'\$this->$name'; }");
+ $rows_null[] = $row;
+ }
+ }
+ else if (preg_match("/^timestamp/", $data_type)) {
+ if ($not_null) {
+ $default = $attr_obj->getDefault();
+ if ($default != '') {
+ $row = array("\$fields['$name']", '=', "(!empty(\$this->$name))", "? \$this->$name", ": '$default';");
+ }
+ else {
+ $row = array("\$fields['$name']", '=', "\$this->$name;");
+ }
+ $rows_not_null[] = $row;
+ }
+ else {
+ $row = array("if (!empty(\$this->$name))", "{ \$fields['$name']", '=', "\$this->$name; }");
+ $rows_null[] = $row;
+ }
+ }
+ else {
+ $row = array("\$fields['$name']", '=', "\$this->$name;");
+ $rows_not_null[] = $row;
+ }
+ }
+ }
+ $attr_list = rtrim($this->_alignCol($rows_not_null, $indent), "\n") . "\n";
+ $attr_list .= rtrim($this->_alignCol($rows_null, $indent), "\n");
+ return $attr_list;
+ }
+
+ /**
+ * Generate a class definition file.
+ *
+ * @return boolean
+ */
+ public function generateClassFile() {
+
+ // Gets class definition.
+ $code = $this->getClassDef($this->table);
+
+ // Opens the table class file.
+ $table_name = $this->table->getName();
+ $schema_name = $this->table->getSchemaName();
+ $class_file_name = $schema_name . '_' . $table_name . '.class.inc';
+ if (!($fdw = fopen($this->output_dir . "/$class_file_name", 'w'))) {
+ print "Error : opening file ($table_name) for writing\n";
+ RETURN FALSE;
+ }
+ fputs($fdw, $code);
+ fclose($fdw);
+ return TRUE;
+ }
+
+ /**
+ * Generate a table definition file.
+ *
+ * @return string
+ */
+ public function generateTableFile() {
+
+ // Gets class definition.
+ $code = $this->getTableDef($this->table);
+
+ // Opens the table class file.
+ $table_name = $this->table->getName();
+ $schema_name = $this->table->getSchemaName();
+ $table_file_name = $schema_name . '.' . $table_name . '.table.sql';
+ if (!($fdw = fopen($this->output_dir . "/$table_file_name", 'w'))) {
+ print "Error : opening file ($table_name) for writing\n";
+ RETURN FALSE;
+ }
+ fputs($fdw, $code);
+ fclose($fdw);
+ return TRUE;
+ }
+
+ /**
+ * Get the table definition.
+ *
+ * @param MCL_TABLE $table
+ * @param string $type
+ *
+ * @return string
+ * SQL statement of the provided type.`
+ */
+ public static function getTableDef(MCL_TABLE $table, $type = 'ALL') {
+ $table_def = '';
+
+ // Gets table info.
+ $table_name = $table->getName();
+ $schema_name = $table->getSchemaName();
+
+ // CREATE TABLE.
+ if ($type == 'ALL' || $type == 'TABLE') {
+ $table_def .= "--\n";
+ $table_def .= "-- Name: $table_name; Type: TABLE; Schema: $schema_name; Owner: -; Tablespace: \n";
+ $table_def .= "--\n";
+ $table_def .= $table->getSQL('TABLE');
+ }
+
+ // PRIMARY KEY.
+ if ($type == 'ALL' || $type == 'PRIMARY') {
+ $primary_key = $table->getSQL('PRIMARY');
+ if ($primary_key) {
+ $table_def .= "--\n";
+ $table_def .= "-- Name: --; Type: CONSTRAINT; Schema: $schema_name; Owner: -; Tablespace: \n";
+ $table_def .= "--\n";
+ $table_def .= $primary_key;
+ }
+ }
+
+ // UNIQUE KEY.
+ if ($type == 'ALL' || $type == 'UNIQUE') {
+ $unique_key = $table->getSQL('UNIQUE');
+ if ($unique_key) {
+ $table_def .= "--\n";
+ $table_def .= "-- Name: --; Type: CONSTRAINT; Schema: $schema_name; Owner: -; Tablespace: \n";
+ $table_def .= "--\n";
+ $table_def .= $unique_key;
+ }
+ }
+
+ // FOREIGN KEY.
+ if ($type == 'ALL' || $type == 'FOREIGN') {
+ $foreign_key = $table->getSQL('FOREIGN');
+ if ($foreign_key) {
+ $table_def .= "--\n";
+ $table_def .= "-- Name: --; Type: FK CONSTRAINT; Schema: $schema_name; Owner: -; Tablespace: \n";
+ $table_def .= "--\n";
+ $table_def .= $foreign_key;
+ }
+ }
+ return $table_def;
+ }
+
+ /**
+ * Get the class definition.
+ *
+ * @return string
+ */
+ private function getClassDef($table) {
+
+ // Sets class name.
+ $table_name = $table->getName();
+ $class_name = strtoupper($table->getClassName());
+
+ // Sets base table.
+ $base_class = '';
+ if ($this->extends) {
+ $base_class = ' extends ' . $this->extends;
+ }
+
+ // Gets the all sections.
+ $namespace = $this->getNamespaceLine();
+ $data_members = $this->getDataMembers();
+ $data_types = $this->getDataTypes();
+ $constructor = $this->getConstructor();
+ $destructor = $this->getDestructor();
+ $generate_by_key = $this->getGenerateByKey('drupal');
+ $func_insert = $this->getFuncInsert('drupal');
+ $func_update = $this->getFuncUpdate('drupal');
+ $func_delete = $this->getFuncDelete('drupal');
+ $getter_data_type = $this->getGetterDataType();
+ $getter_setter_member_arr = $this->getGetterSetterMemberArr();
+ $getters_setters = $this->getGettersSetters();
+
+ // Generates the class codes.
+ $code = <<< CLASS_CODE
+table->getAttrs();
+
+ // Adds data members.
+ $rows = array();
+
+ // Adds $member_arr at the top.
+ $rows[] = array('protected', '$member_arr', '= NULL;');
+
+ // Adds table attributes.
+ foreach ($attrs as $name => $attr_obj) {
+ $row = array(
+ 'protected', "\$$name", '= NULL;'
+ );
+ $rows[] = $row;
+ }
+ return rtrim($this->_alignCol($rows, 2), "\n");
+ }
+
+ /**
+ * Return the data types.
+ */
+ function getDataTypes() {
+
+ // Gets the data members from table attributes.
+ $attrs = $this->table->getAttrs();
+
+ // Creates table array,
+ $data_types = " protected static \$data_types = array(\n";
+ $rows = array();
+ foreach ($attrs as $name => $attr_obj) {
+ $data_type = $attr_obj->getDataType();
+ $row = array("'$name'", '=>', "'$data_type',");
+ $rows[] = $row;
+ }
+ $data_types .= $this->_alignCol($rows, 4);
+ $data_types .= ' );';
+ return $data_types;
+ }
+
+ /**
+ * Returns the constructor of this class.
+ */
+ // Returns the constructor of this class.
+ function getConstructor() {
+
+ // Initializes data members.
+ $attrs = $this->table->getAttrs();
+ $rows = array();
+
+ // Copies $details to $member_arr.
+ $rows[] = array(
+ '$this->member_arr', '=', '$details;'
+ );
+ // Initializes data members.
+ foreach ($attrs as $name => $attr_obj) {
+
+ // Checks for default value.
+ $default = $attr_obj->getDefault();
+ $default_value = "''";
+ if ($default != '') {
+ if (in_array($attr_obj->getDataType(), $this->data_type_numeric)) {
+ $default_value = $default;
+ }
+ else {
+ //TODO : Handles default value is non-numeric.
+ //$default_value = sprintf("'%s'", $default);
+ }
+ }
+ else {
+ // Sets default value to be NULL if data type is timestamp.
+ if (in_array($attr_obj->getDataType(), $this->data_type_date)) {
+ $default_value = "NULL";
+ }
+ }
+ $row = array(
+ '$this->' . $name, '=', "array_key_exists('$name', \$details)", '?', "\$details['$name']", ": $default_value;"
+ );
+ $rows[] = $row;
+ }
+ $init_data_members = rtrim($this->_alignCol($rows, 4), "\n");
+
+ $code = <<< CLASS_CODE
+ public function __construct(\$details = array()) {
+ // Initializes data members.
+$init_data_members
+ }
+CLASS_CODE;
+ return $code;
+ }
+
+ /**
+ * Return the desctructor of this class.
+ */
+ function getDestructor() {
+ $code = <<< CLASS_CODE
+ public function __destruct() {
+ }
+CLASS_CODE;
+ return $code;
+ }
+
+ /**
+ * Returns the generate by key(s) of this class.
+ */
+ function getGenerateByKey($type = NULL) {
+ $table = $this->table;
+ $table_name = $table->getName();
+ $schema_name = $this->table->getSchemaName();
+
+ // Updates table name. Adds schema if not 'public'.
+ if ($schema_name != 'public') {
+ $table_name = $schema_name . '.' . $table_name;
+ }
+
+ // By key.
+ $code = <<< CLASS_CODE
+ public static function byKey(\$keys) {
+
+ // Returns NULL if non-integer value are given to the data member whose
+ // data type is 'integer'.
+ \$where_arr = array();
+ \$args = array();
+ foreach (\$keys as \$key => \$value) {
+
+ // Returns NULL if \$value is empty string.
+ if (\$value === '') {
+ return NULL;
+ }
+
+ // Gets data type.
+ \$data_type = self::\$data_types[\$key];
+
+ // Checks the value if data type is 'integer'.
+ if (in_array(\$data_type, array('serial', 'integer'))) {
+ if (!is_int((int)\$value)) {
+ return NULL;
+ }
+ }
+
+ // Adds LOWER() function to the characters.
+ if (preg_match("/^(char|text)/", \$data_type)) {
+ \$where_arr []= " LOWER(\$key) = LOWER(:\$key) ";
+ }
+ else {
+ \$where_arr []= " \$key = :\$key ";
+ }
+ \$args[":\$key"] = \$keys[\$key];
+ }
+
+ // Gets the table properties.
+ \$sql = "SELECT * FROM {$table_name} WHERE " . implode(" AND " , \$where_arr);
+ \$details = db_query(\$sql, \$args)->fetch(PDO::FETCH_ASSOC);
+ if (\$details) {
+ return new self(\$details);
+ }
+ return NULL;
+ }
+CLASS_CODE;
+ return $code;
+ }
+
+ /**
+ * Returns insert function().
+ */
+ function getFuncInsert($type = NULL) {
+ $module_name = 'mod';
+ $table = $this->table;
+ $table_name = $table->getName();
+ $primary_key = $table->getPrimaryKey();
+ $schema_name = $this->table->getSchemaName();
+
+ // Updates table name. Adds schema if not 'public'.
+ if ($schema_name != 'public') {
+ $table_name = $schema_name . '.' . $table_name;
+ }
+
+ // Sets primary key if exist.
+ $db_insert = "db_insert('$table_name')";
+ if ($primary_key) {
+ $db_insert = "\$this->$primary_key = " . $db_insert;
+ }
+
+ // Lists all attributes.
+ $attr_list = $this->_getAttrList($table, 8);
+
+ $code = <<< CLASS_CODE
+ public function insert() {
+
+ \$transaction = db_transaction();
+ try {
+
+ // TODO:Checks for duplication.
+ \$dup = FALSE;
+
+ // Inserts the record if not duplicated.
+ if (!\$dup) {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ \$fields = array();
+$attr_list
+
+ // Inserts the record.
+ $db_insert
+ ->fields(\$fields)
+ ->execute();
+ }
+ }
+ catch (Exception \$e) {
+ \$transaction->rollback();
+ watchdog('$module_name', \$e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+CLASS_CODE;
+ return $code;
+ }
+
+ /**
+ * Return update function().
+ */
+ function getFuncUpdate($type = NULL) {
+ $module_name = 'mod';
+ $table = $this->table;
+ $table_name = $table->getName();
+ $primary_key = $table->getPrimaryKey();
+ $unique_keys = $table->getUniqueKeys();
+ $num_unique_key = $table->getNumUniqueKeys();
+ $schema_name = $this->table->getSchemaName();
+
+ // Updates table name. Adds schema if not 'public'.
+ if ($schema_name != 'public') {
+ $table_name = $schema_name . '.' . $table_name;
+ }
+
+ // Lists all attributes.
+ $attr_list = $this->_getAttrList($table, 6);
+
+ $attrs = $table->getAttrs();
+ $rows = array();
+ foreach ($attrs as $name => $attr_obj) {
+ if ($name != $primary_key) {
+ $row = array("'$name'", '=>', "\$this->$name,");
+ $rows[] = $row;
+ }
+ }
+ $attrs_data = rtrim($this->_alignCol($rows, 10), "\n");
+
+ // Adds conditions.
+ $conditions = '';
+ if ($primary_key) {
+ $conditions = " ->condition('$primary_key', \$this->$primary_key, '=')\n\n";
+ }
+ else if ($num_unique_key == 1) {
+ $keys = array_pop($unique_keys);
+ foreach ($keys as $name) {
+ $conditions .= " ->condition('$name', \$this->$name, '=')\n";
+ }
+ }
+ $conditions = rtrim($conditions, "\n");
+
+ // Writes update function.
+ $code = <<< CLASS_CODE
+ public function update() {
+
+ \$transaction = db_transaction();
+ try {
+
+ // Populates all fields. The attribute with 'NOT NULL' would be skipped
+ // if the value is empty.
+ \$fields = array();
+$attr_list
+
+ // Updates the record.
+ db_update('$table_name')
+ ->fields(\$fields)
+$conditions
+ ->execute();
+ }
+ catch (Exception \$e) {
+ \$transaction->rollback();
+ watchdog('$module_name', \$e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+CLASS_CODE;
+ return $code;
+ }
+
+ /**
+ * Return delete function().
+ */
+ function getFuncDelete($type = NULL) {
+ $module_name = 'mod';
+ $table = $this->table;
+ $table_name = $table->getName();
+ $primary_key = $table->getPrimaryKey();
+ $unique_keys = $table->getUniqueKeys();
+ $num_unique_key = $table->getNumUniqueKeys();
+ $schema_name = $this->table->getSchemaName();
+
+ // Updates table name. Adds schema if not 'public'.
+ if ($schema_name != 'public') {
+ $table_name = $schema_name . '.' . $table_name;
+ }
+
+ // Checks the data type of the primary key. Quotes if not numeric.
+ $is_data_type_numeric = FALSE;//$table->isDataTypeNumeric($priamry_key_attr);
+ $priamry_key_value = ($is_data_type_numeric) ? '$this->' . $primary_key : "'\$this->$primary_key'";
+
+ // Adds conditions.
+ $conditions = '';
+ if ($primary_key) {
+ $conditions = " ->condition('$primary_key', \$this->$primary_key, '=')\n\n";
+ }
+ else if ($num_unique_key == 1) {
+ $keys = array_pop($unique_keys);
+ foreach ($keys as $name) {
+ $conditions .= " ->condition('$name', \$this->$name, '=')\n";
+ }
+ }
+ $conditions = rtrim($conditions, "\n");
+
+ // Default.
+ if (!$type) {
+ $code = <<< CLASS_CODE
+ public function delete() {
+ \$sql = "DELETE FROM $table_name WHERE $primary_key = $priamry_key_value";
+ }
+CLASS_CODE;
+ }
+ else if ($type == 'drupal') {
+ $code = <<< CLASS_CODE
+ public function delete() {
+
+ \$transaction = db_transaction();
+ try {
+
+ db_delete('$table_name')
+$conditions
+ ->execute();
+ }
+ catch (Exception \$e) {
+ \$transaction->rollback();
+ watchdog('$module_name', \$e->getMessage(), array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+ }
+CLASS_CODE;
+ }
+ return $code;
+ }
+
+ /**
+ * Returns the getter for data type of a member.
+ */
+ function getGetterDataType() {
+
+ $code = <<< CLASS_CODE
+ /**
+ * Retrieves the data type of the member.
+ *
+ * @retrun various
+ */
+ public function getDataType(\$member) {
+ return \$this->data_types[\$member];
+ }
+CLASS_CODE;
+ return $code;
+ }
+
+ /**
+ * Return the getter and setter for the data member array.
+ */
+ function getGetterSetterMemberArr() {
+
+ $code = <<< CLASS_CODE
+ /**
+ * Retrieves the data member array.
+ *
+ * @retrun array
+ */
+ public function getMemberArr() {
+ return \$this->member_arr;
+ }
+
+ /**
+ * Updates the data member array.
+ *
+ * @param array \$member_arr
+ */
+ public function setMemberArr(\$member_arr) {
+ \$this->member_arr = \$member_arr;
+ }
+CLASS_CODE;
+ return $code;
+ }
+
+ /**
+ * Return the setters and getters for all data members.
+ */
+ function getGettersSetters() {
+ $table = $this->table;
+
+ // Gets all attributes.
+ $attrs = $table->getAttrs();
+ $getGettersSetters = "";
+ foreach ($attrs as $name => $attr_obj) {
+
+ // Replaces id with ID.
+ $tmp = preg_replace('/_id$/', '_ID', $name);
+ $tmp = ucwords(str_replace('_', ' ', $tmp));
+ $func_name = str_replace(' ', '', $tmp);
+ $getter = $this->_getGetter($name, $func_name, $attr_obj->getDataType());
+ $setter = $this->_getSetter($name, $func_name, $attr_obj->getDataType());
+ $getGettersSetters .= "$getter\n\n$setter\n\n";
+ }
+ return rtrim($getGettersSetters, "\n");
+ }
+
+ /**
+ * Returns the getter.
+ */
+ private function _getGetter($var_name, $func_name, $type) {
+
+ // Updates the function name.
+ $func_name = 'get' . $func_name;
+ $code = <<< CLASS_CODE
+ /**
+ * Retrieves the $var_name.
+ *
+ * @retrun $type
+ */
+ public function $func_name() {
+ return \$this->$var_name;
+ }
+CLASS_CODE;
+ return $code;
+ }
+
+ /**
+ * Returns the setter.
+ */
+ private function _getSetter($var_name, $func_name, $type) {
+
+ // Updates the function name.
+ $func_name = 'set' . $func_name;
+ $code = <<< CLASS_CODE
+ /**
+ * Updates the $var_name.
+ *
+ * @param $type \$$var_name
+ */
+ public function $func_name(\$$var_name) {
+ \$this->$var_name = \$$var_name;
+ }
+CLASS_CODE;
+ return $code;
+ }
+
+ // Defines getters and setters below.
+
+ /**
+ * Retrieves the table.
+ *
+ * @retrun MCL_TABLE object
+ */
+ public function getTable() {
+ return $this->table;
+ }
+
+ /**
+ * Updates the table.
+ *
+ * @param MCL_TABLE $table
+ */
+ public function setTable($table) {
+ $this->table = $table;
+ }
+
+ /**
+ * Retrieves the output dir.
+ *
+ * @retrun string
+ */
+ public function getOutputDir() {
+ return $this->output_dir;
+ }
+
+ /**
+ * Updates the output dir.
+ *
+ * @param string $output_dir
+ */
+ public function setOutputDir($output_dir) {
+ $this->output_dir = $output_dir;
+ }
+
+ /**
+ * Retrieves the namespace.
+ *
+ * @retrun string
+ */
+ public function getNamespace() {
+ return $this->namespace;
+ }
+
+ /**
+ * Updates the namespace.
+ *
+ * @param string $namespace
+ */
+ public function setNamespace($namespace) {
+ $this->namespace = $namespace;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/table/mcl_table_info.class.inc b/includes/class/table/mcl_table_info.class.inc
new file mode 100644
index 0000000..676ea04
--- /dev/null
+++ b/includes/class/table/mcl_table_info.class.inc
@@ -0,0 +1,329 @@
+data_format = array(
+ 'TYPE_1' => array('text', 'smallint', 'bigint', 'serial', 'integer', 'double', 'real', 'boolean', 'date', 'bytea'),
+ 'TYPE_2' => array('character'),
+ 'TYPE_3' => array(),
+ 'TYPE_4' => array('timestamp'),
+ );
+
+ // Reads the table file.
+ $tables = $this->readTableFile($table_file);
+
+ // Reads the schema file.
+ $this->readSchemaFile($schema_file, $tables);
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Read table file.
+ */
+ public function readTableFile($table_file) {
+
+ // Opens the table file.
+ if (!($fdr = fopen($table_file, 'r'))) {
+ print "Error : opening file ($table_file) for reading\n";
+ exit;
+ }
+
+ // Gets all the table name from the table file.
+ $tables = array();
+ while (!feof($fdr)) {
+ $line = trim(fgets($fdr));
+ if ($line == '') {
+ continue;
+ }
+ $tmp = preg_split("/\s+/", $line);
+ $table_name = $class_name = trim($tmp[0]);
+ if (!empty($tmp[1])) {
+ $class_name = trim($tmp[1]);
+ }
+ $tables[$table_name] = array('CLASS_NAME' => $class_name, 'EXISTS' => FALSE);
+ }
+ fclose($fdr);
+ return $tables;
+ }
+
+ /**
+ * Reads schema file.
+ *
+ * @param string $schema_file
+ * @param array $tables
+ */
+ private function readSchemaFile($schema_file, $tables) {
+
+ // Opens the schema file.
+ if (!($fdr = fopen($schema_file, 'r'))) {
+ print "Error : Opening file ($schema_file) for reading\n";
+ exit;
+ }
+
+ // Gets all the table info. from the schema file.
+ $table_name = '';
+ $schema_name = '';
+ $table_info = array();
+ $flag_table_def = FALSE;
+ $flag_constraint = FALSE;
+ $flag_comment = FALSE;
+ $cur_table = NULL;
+ $target_tables = array_keys($tables);
+ $sql = '';
+ while (!feof($fdr)) {
+ $line_orig = fgets($fdr);
+ $line = trim($line_orig);
+ if ($line == '') {
+ $flag_constraint = FALSE;
+ continue;
+ }
+ if (preg_match("/^SET search_path = (\S+),/i", $line, $matches)) {
+ $schema_name = strtolower($matches[1]);
+ }
+ else if (preg_match("/^CREATE TABLE (\S+)\s/i", $line, $matches)) {
+ $table_name = strtolower($matches[1]);
+ if (in_array($table_name, $target_tables)) {
+ $table_info[$table_name] = new MCL_TABLE($table_name, $schema_name, $tables[$table_name]['CLASS_NAME']);
+ $flag_table_def = TRUE;
+ $sql = str_replace('CREATE TABLE ', 'CREATE TABLE IF NOT EXISTS ', $line_orig);
+ $tables[$table_name]['EXISTS'] = TRUE;
+ }
+ continue;
+ }
+ else if (preg_match("/^ALTER SEQUENCE ([A-Za-z0-9_]+) OWNED BY ([A-Za-z0-9_]+)\.([A-Za-z0-9_]+)/i", $line, $matches)) {
+ $seq_table_name = strtolower($matches[2]);
+ $seq_attr_name = strtolower($matches[3]);
+ if (in_array($seq_table_name, $target_tables)) {
+ $table_info[$seq_table_name]->setDataType($seq_attr_name, 'serial');
+ }
+ }
+ else if (preg_match("/^ALTER TABLE ONLY (\S+)$/i", $line, $matches)) {
+ $table_name = strtolower($matches[1]);
+
+ if (in_array($table_name, $target_tables)) {
+ $sql = $line_orig;
+ $cur_table = $table_info[$table_name];
+ $flag_constraint = TRUE;
+ continue;
+ }
+ }
+ else if ($flag_table_def && $line == ');') {
+
+ // Adds statement to the table.
+ $table_info[$table_name]->addSQL('TABLE', $sql . "$line\n");
+
+ // Marks as End of TABLE.
+ $flag_table_def = FALSE;
+ $sql = '';
+ continue;
+ }
+
+ // Reads table definition line.
+ if ($flag_table_def) {
+ $attr = $this->parseTableDef($line);
+ if ($attr) {
+ $table_info[$table_name]->addAttr($attr);
+ }
+ $sql .= $line_orig;
+ }
+
+ // Reads constraint line.
+ if ($flag_constraint) {
+ if ($cur_table) {
+ $const = $this->parseConstraint($line);
+ if ($const['type'] == 'PRIMARY') {
+ $cur_table->setPrimaryKey($const['attr']);
+ $cur_table->addSQL($const['type'], $sql . $line_orig);
+ }
+ else if ($const['type'] == 'UNIQUE') {
+ $cur_table->addUniqueKey($const);
+ $cur_table->addSQL($const['type'], $sql . $line_orig);
+ }
+ else if ($const['type'] == 'FOREIGN') {
+ $cur_table->addSQL($const['type'], $sql . $line_orig);
+ }
+ }
+ $sql = '';
+ $cur_table = NULL;
+ $flag_constraint = FALSE;
+ }
+ }
+ fclose($fdr);
+ $this->setTableInfo($table_info);
+
+ // Displays all the names of tables that do not exists in the current
+ // schema.
+ $warn = '';
+ foreach ($tables as $table_name => $info) {
+ if (!$info['EXISTS']) {
+ $warn .= " >$table_name does not exists\n";
+ }
+ }
+ if ($warn) {
+ print "\n =============================================\n";
+ print " The following tables do not exist in $schema_name.\n";
+ print " --------------------------------------------\n";
+ print "$warn\n\n";
+ }
+ }
+
+ /**
+ * Parse constraint line.
+ */
+ private function parseConstraint($line) {
+ $const = array();
+
+ if (preg_match("/^ADD CONSTRAINT (.*) PRIMARY KEY \((.*)\);$/", $line, $matches)) {
+ $const_name = strtolower($matches[1]);
+ $attr = strtolower($matches[2]);
+ $const = array(
+ 'name' => $const_name,
+ 'type' => 'PRIMARY',
+ 'attr' => $attr,
+ );
+ }
+ else if (preg_match("/^ADD CONSTRAINT (.*) UNIQUE \((.*)\);$/", $line, $matches)) {
+ $const_name = strtolower($matches[1]);
+ $attrs = strtolower($matches[2]);
+ $const = array(
+ 'name' => $const_name,
+ 'type' => 'UNIQUE',
+ 'attrs' => preg_split("/\s*,\s*/", $attrs),
+ );
+ }
+ else if (preg_match("/^ADD CONSTRAINT (.*) FOREIGN KEY \((.*)\) REFERENCES (.*)\((.*)\)/", $line, $matches)) {
+ $const_name = strtolower($matches[1]);
+ $attr = strtolower($matches[2]);
+ $fk_table = strtolower($matches[3]);
+ $fk_attr = strtolower($matches[4]);
+ $const = array(
+ 'name' => $const_name,
+ 'type' => 'FOREIGN',
+ 'fk_table' => $fk_table,
+ 'fk_attr' => $fk_attr,
+ );
+ }
+ else if (preg_match("/^ADD CONSTRAINT/", $line)) {
+ print "\n\n\n\tError : Unknown constraint type\n\n\t$line\n\n\n";
+ exit;
+ }
+ return $const;
+ }
+
+ /**
+ * Parses table definition line.
+ */
+ private function parseTableDef($line) {
+ $details = array();
+
+ // Removes the last comma if exists.
+ $line = preg_replace("/\s*,$/", '', $line);
+
+ // Checks if it is NOT NULL.
+ $not_null = FALSE;
+ $trimed_line = preg_replace("/\s+NOT NULL\$/", '', $line);
+ if ($trimed_line != $line) {
+ $not_null = TRUE;
+ }
+ $details['not_null'] = $not_null;
+
+ // Parses out table defintion line.
+ $tmp = preg_split("/\s/", $line);
+
+ // Skips if the first column is 'CONSTRAINT'.
+ $attr_name = trim(array_shift($tmp));
+
+ // Removes double quotation on attribute name if exists.
+ if (preg_match('/^"(.*)"$/', $attr_name, $matches)) {
+ $attr_name = $matches[1];
+ }
+
+ if ($attr_name != 'CONSTRAINT') {
+ $details['name'] = $attr_name;
+ $details['data_type'] = $this->getDataType($tmp);
+
+ // Adds the default value if exists.
+ if (preg_match("/\s+DEFAULT\s+(.*?)\s+/", $line, $matches)) {
+ $details['default'] = $matches[1];
+ }
+ return new MCL_TABLE_ATTR($details);
+ }
+ return NULL;
+ }
+
+ /**
+ * Get data type.
+ */
+ private function getDataType ($arr) {
+ if (preg_match("/character\(/", $arr[0])) {
+ return $arr[0];
+ }
+ else if (in_array($arr[0], $this->data_format['TYPE_1'])) {
+ return $arr[0];
+ }
+ else if (in_array($arr[0], $this->data_format['TYPE_2'])) {
+ return $arr[0] . '_' . $arr[1];
+ }
+ else if (in_array($arr[0], $this->data_format['TYPE_3'])) {
+ return $arr[0] . '_' . $arr[1] . '_' . $arr[2];
+ }
+ else if (in_array($arr[0], $this->data_format['TYPE_4'])) {
+ return $arr[0] . '_' . $arr[1] . '_' . $arr[2] . '_' . $arr[3];
+ }
+ else {
+ print "\n\n\t\tUnknow data type : " . $arr[0] . "\t\t\n";
+ exit;
+ }
+ }
+
+ /**
+ * Prints schema for all tables.
+ */
+ public function printSchema() {
+ $table_info = $this->getTableInfo();
+ foreach ($table_info as $table_name => $table_obj) {
+ $table_obj->printSchema();
+ print "\n";
+ }
+ }
+
+ // Defines setters and getters below.
+
+ /**
+ * Retrieves the table_info.
+ *
+ * @retrun array
+ */
+ public function getTableInfo() {
+ return $this->table_info;
+ }
+
+ /**
+ * Updates the table_info.
+ *
+ * @param array $table_info
+ */
+ public function setTableInfo($table_info) {
+ $this->table_info = $table_info;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/table/mcl_table_writer.class.inc b/includes/class/table/mcl_table_writer.class.inc
new file mode 100644
index 0000000..f3b8576
--- /dev/null
+++ b/includes/class/table/mcl_table_writer.class.inc
@@ -0,0 +1,156 @@
+table_info = $table_info;
+ $this->output_dir = $output_dir;
+ $this->namespace = $namespace;
+ }
+
+ /**
+ * Implements the class destructor.
+ */
+ public function __destruct() {
+ }
+
+ /**
+ * Generates the class files for all the tables.
+ *
+ * @return boolean
+ */
+ public function generateClassFiles() {
+ $flag = TRUE;
+
+ // Generates class files for all the tables.
+ $tables = $this->table_info->getTableInfo();
+ foreach ($tables as $table_name => $table) {
+ print "Generating class file for $table_name\n";
+ $class_writer = new MCL_TABLE_CLASS_WRITER($table, $this);
+ if (!$class_writer->generateClassFile()) {
+ $flag = FALSE;
+ }
+ }
+ return $flag;
+ }
+
+ /**
+ * Generates the table definition files for all the tables.
+ */
+ public function generateTableFiles($all = FALSE) {
+
+ // Generates the definition files for all the tables.
+ $tables = $this->table_info->getTableInfo();
+
+ // Writes the table definitions to one file.
+ if ($all) {
+
+ // Gets the table definitions for all tables.
+ // We need to place the statements for creating tables first and then
+ // places the statements for adding constraints.
+ $code = '';
+ $table = NULL;
+
+ // SQL : TABLE.
+ foreach ($tables as $table_name => $table) {
+ $code .= MCL_TABLE_CLASS_WRITER::getTableDef($table, 'TABLE');
+ }
+
+ // SQL : PRIMARY, UNIQUE and FOREIGN.
+ foreach ($tables as $table_name => $table) {
+ $class_writer = new MCL_TABLE_CLASS_WRITER($table, $this);
+ $code .= MCL_TABLE_CLASS_WRITER::getTableDef($table, 'PRIMARY');
+ $code .= MCL_TABLE_CLASS_WRITER::getTableDef($table, 'UNIQUE');
+ $code .= MCL_TABLE_CLASS_WRITER::getTableDef($table, 'FOREIGN');
+ }
+
+ // Opens the table file.
+ $table_file_name = $table->getSchemaName() . '.all.table.sql';
+ if (!($fdw = fopen($this->output_dir . "/$table_file_name", 'w'))) {
+ print "Error : opening file for writing\n";
+ RETURN FALSE;
+ }
+ fputs($fdw, $code);
+ fclose($fdw);
+ }
+ // Writes the table definition to an individula file.
+ else {
+ foreach ($tables as $table_name => $table) {
+ print "Generating definition file for $table_name\n";
+ $class_writer = new MCL_TABLE_CLASS_WRITER($table, $this);
+ $class_writer->generateTableFile();
+ }
+ }
+ }
+
+ // Defines getters and setters below.
+ /**
+ * Retrieves the table_info.
+ *
+ * @retrun TASK_INFO object
+ */
+ public function getTaskInfo() {
+ return $this->table_info;
+ }
+
+ /**
+ * Updates the table_info.
+ *
+ * @param TASK_INFO $table_info
+ */
+ public function setTaskInfo($table_info) {
+ $this->table_info = $table_info;
+ }
+
+ /**
+ * Retrieves the output_dir.
+ *
+ * @retrun string
+ */
+ public function getOutputDir() {
+ return $this->output_dir;
+ }
+
+ /**
+ * Updates the output_dir.
+ *
+ * @param string $output_dir
+ */
+ public function setOutputDir($output_dir) {
+ $this->output_dir = $output_dir;
+ }
+
+ /**
+ * Retrieves the namespace.
+ *
+ * @retrun string
+ */
+ public function getNamespace() {
+ return $this->namespace;
+ }
+
+ /**
+ * Updates the namespace.
+ *
+ * @param string $namespace
+ */
+ public function setNamespace($namespace) {
+ $this->namespace = $namespace;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/mcl_template.class.inc b/includes/class/template/mcl_template.class.inc
new file mode 100644
index 0000000..50f4d6b
--- /dev/null
+++ b/includes/class/template/mcl_template.class.inc
@@ -0,0 +1,1233 @@
+csv = array_key_exists('csv', $details) ? $details['csv'] : NULL;
+ $this->job = array_key_exists('job', $details) ? $details['job'] : NULL;
+
+ // Initialize variables.
+ $this->line_no = -1;
+
+ // Updates the template_type.
+ $this->template_type = MCL_TEMPLATE_TYPE::byKey(array('template_type_id' => $this->template_type_id));
+
+ // Sets the headers.
+ $this->headers = $this->defineHeaders();
+
+ // Sets the cvterms.
+ $this->cvterms = $this->defineCvterms();
+ }
+
+ /**
+ * @see PUBLIC_MCL_TEMPLATE::byKey()
+ */
+ public static function byKey($keys) {
+ $parent = parent::byKey($keys);
+ if ($parent) {
+ return new self($parent->getMemberArr());
+ }
+ }
+
+ /**
+ * @see PUBLIC_MCL_TEMPLATE::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Return the description of of template properties for both Excel and CSV
+ * files.
+ *
+ * @return string
+ * The description of a template.
+ */
+ public static function getProperties() {
+
+ // Sets the headers.
+ $headers = array(
+ 'Prefix',
+ array('data' => 'Column Type', 'style' => 'width:80px;'),
+ 'Description'
+ );
+
+ // Special column table.
+ $desc_REQ = "The star symbol indicates a required column. All the values in this column must be provided";
+ $desc_PROP = "A column name followed by double pound signs must be a cvterm name. The cvterm is used as a type of a property table.";
+ $desc_DESC = "A column name followed by single pound sign must be a cvterm name. The cvterm is used as a descriptor of evaluation data in the column." .
+ "
(e.g.) #brix #pH #fruit_weight";
+ $desc_SEQ = "A column name followed by a tilde symbol indicates that the column holds sequnce information.";
+
+ $rows = array(
+ array('*', 'required', $desc_REQ),
+ array('##', 'property', $desc_PROP),
+ array('#', 'descriptor', $desc_DESC),
+ array('~', 'descriptor', $desc_SEQ),
+ );
+ $table_vars = array(
+ 'header' => $headers,
+ 'rows' => $rows,
+ 'attributes' => array(),
+ );
+ $table = theme('table', $table_vars);
+
+ // Excel format properties.
+ $items = array();
+ $items[] = "Column names are case-insensitive.";
+ $items[] = "Data sheet name must match a template name.";
+ $items[] = "special column - special charcter at the begining of column name.\n$table";
+ $excel_prop = theme('item_list', array('items' => $items));
+
+ // CSV format properties.
+ $items = array();
+ $items[] = "The first line of CSV file must start with '#' followed by a template name.";
+ $items[] = "The second line of a CSV file must with '#' followed by headers.";
+ $items[] = "Data section starts from the third line. Each column should be double quoted and separated by commas.";
+ $csv_prop = theme('item_list', array('items' => $items));
+
+ $desc = <<< DESC
+ Data in Excel format
+ $excel_prop
+ Data in CSV format
+ $csv_prop
+ (e.g.)
+ #contact
+ #"*name","first_name","last_name","alias","*type","lab","institution"
+ "N","F","L","", "person","Main Lab", "WSU"
+
+DESC;
+ return $desc;
+ }
+
+ /**
+ * Gets the description of this template.
+ *
+ * @return string
+ * The description of this template.
+ */
+ public function defineDescription() {
+ // To be overridden by Child class.
+ return '';
+ }
+
+ /**
+ * Gets headers used in this template.
+ *
+ * @return array of header columns.
+ */
+ public function defineHeaders() {
+ // To be overridden by Child class.
+ return array();
+ }
+
+ /**
+ * Gets cvterms used in this template.
+ *
+ * @return array of cvterms.
+ */
+ public function defineCvterms() {
+ // To be overridden by Child class.
+ return array();
+ }
+
+ /**
+ * Adds a template.
+ *
+ * @param string $template_type
+ * @param string $template
+ *
+ * @return boolean
+ */
+ public static function addTemplate($template_type, $template, $headers = '', $cverms = '', $description = '') {
+
+ // Gets the template type.
+ $mcl_template_type = MCL_TEMPLATE_TYPE::byKey(array('type' => $template_type));
+ if (!$mcl_template_type) {
+ return FALSE;
+ }
+
+ // Check for duplication.
+ $mcl_template = PUBLIC_MCL_TEMPLATE::byKey(array('template' => $template));
+ if (!$mcl_template) {
+
+ // Adds a new template.
+ $details = array(
+ 'template' => $template,
+ 'headers' => $headers,
+ 'cverms' => $cverms,
+ 'description' => $description,
+ 'template_type_id' => $mcl_template_type->getTemplateTypeID(),
+ );
+ $mcl_template = new MCL_TEMPLATE($details);
+ if (!$mcl_template->insert()) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+
+ /**
+ * Returns template information in array. Adds the information for
+ * creating two excel sheets for header definition and data template.
+ *
+ * @return array
+ * It holds information about this template.
+ */
+ public function getTemplateInfo() {
+ $tmp = $this->defineHeaders();
+
+ // Adds info. for header definition.
+ $def_sheet = array();
+ $def_sheet['name'] = 'Headers';
+
+ // Sets headers.
+ $headers = array();
+ $headers['A'] = array('heading' => 'Name', 'width' => 25);
+ $headers['B'] = array('heading' => 'Required', 'width' => 10);
+ $headers['C'] = array('heading' => 'Definition', 'width' => 100);
+ $def_sheet['headers'] = $headers;
+
+ // Sets data.
+ $data = array();
+ foreach ($tmp as $heading => $prop) {
+ $name = array(
+ 'col' => 'A',
+ 'type' => 'text',
+ 'value' => $heading,
+ );
+ $req = array(
+ 'col' => 'B',
+ 'type' => 'text',
+ 'value' => ($prop['req']) ? 'REQ' : ''
+ );
+ $def = array(
+ 'col' => 'C',
+ 'type' => 'text',
+ 'value' => $prop['desc'],
+ );
+
+ $data[] = array($name, $req, $def);
+ }
+ $def_sheet['data'] = $data;
+
+ // Adds info. for data.
+ $data_sheet = array();
+ $data_sheet['name'] = $this->template;
+
+ // Sets headers.
+ $headers = array();
+ $col_char = 'A';
+ foreach ($tmp as $heading => $prop) {
+ $label = $heading;
+ $header = array();
+ $cell = array();
+
+ // Adds a label if exists.
+ if (array_key_exists('label', $prop)) {
+ $label = $prop['label'];
+ }
+
+ // Adds a prefix to heading.
+ $prefix = ($prop['req']) ? '*' : '';
+ $header['heading'] = $prefix . $label;
+
+ // Adds width if defined.
+ if (array_key_exists('width', $prop)) {
+ $header['width'] = $prop['width'];
+ }
+ $headers[$col_char++] = $header;
+ }
+ $data_sheet['headers'] = $headers;
+
+ // Adds both header definition and data sheets.
+ return array($def_sheet, $data_sheet);
+ }
+
+ /**
+ * Checks if a template for this template exists. Also checks if
+ * a class file for this template exists.
+ *
+ * @param string $template
+ *
+ * @return boolean
+ */
+ public static function validateTemplate($template) {
+
+ // Checks if a template for this template exists.
+ $mcl_template = MCL_TEMPLATE::byKey(array('template' => $template));
+ if ($mcl_template) {
+
+ // Checks if class file for this template is defined.
+ $class_name = 'MCL_TEMPLATE_' . strtoupper($template);
+ return class_exists($class_name);
+ }
+ return FALSE;
+ }
+
+ /**
+ * Gets the rank of the template. The rank is based on the type of template.
+ *
+ * @param string $template
+ *
+ * @return integer
+ * The rank of the template.
+ *
+ */
+ public static function getRank($template) {
+
+ // Gets the rank of the template.
+ $mcl_template = MCL_TEMPLATE::byKey(array('template' => $template));
+ return $mcl_template->template_type->getRank();
+ }
+
+ /**
+ * Returns MCL_TEMPLATE object.
+ *
+ * @param MCL_JOB_UPLOAD $job
+ * @param MCL_FILE_CSV $csv
+ *
+ * @return MCL_TEMPLATE
+ */
+ public static function getTemplateClass(MCL_JOB_UPLOAD $job, MCL_FILE_CSV $csv) {
+
+ // Gets the child class object of MCL_TEMPLATE.
+ $class_name = 'MCL_TEMPLATE_' . strtoupper($csv->getTemplate());
+ $mcl_template = $class_name::byKey(array('template' => $csv->getTemplate()));
+ $mcl_template->setJob($job);
+ $mcl_template->setCSV($csv);
+ return $mcl_template;
+ }
+
+ /**
+ * Returns MCL_TEMPLATE object.
+ *
+ * @param integer $template_id
+ *
+ * @return Descendance of MCL_TEMPLATE
+ */
+ public static function getTemplateByID($template_id) {
+
+ // Gets the template.
+ $mcl_template = MCL_TEMPLATE::byKey(array('template_id' => $template_id));
+ $template = $mcl_template->getTemplate();
+
+ // Gets the child class object of MCL_TEMPLATE.
+ $class_name = 'MCL_TEMPLATE_' . strtoupper($template);
+ if (!class_exists($class_name)) {
+ return NULL;
+ }
+ return $class_name::byKey(array('template_id' => $template_id));
+ }
+
+ /**
+ * Returns the all templates.
+ *
+ * @return array of MCL_TEMPLATE.
+ */
+ public static function getTemplates() {
+ $sql = "
+ SELECT T.template_id
+ FROM {mcl_template} T
+ INNER JOIN {mcl_template_type} TT on TT.template_type_id = T.template_type_id
+ ORDER BY TT.rank, T.template
+ ";
+ $mcl_templates = array();
+ $result = db_query($sql);
+ while ($template_id = $result->fetchField()) {
+ $mcl_templates []= MCL_TEMPLATE::byKey(array('template_id' => $template_id));
+ }
+ return $mcl_templates;
+ }
+
+ /**
+ * Updates the headers. All headers to be lowercase.
+ *
+ * @return boolean
+ */
+ public function updateHeaders() {
+ $headers = $this->defineHeaders();
+ $updated_headers = array();
+ foreach ($headers as $header => $prop) {
+ $prop['col'] = -1;
+ $updated_headers[strtolower($header)] = $prop;
+ }
+ return $updated_headers;
+ }
+
+ /**
+ * Updates cvterms array.
+ *
+ * @return boolean
+ */
+ public function updateCvterms() {
+ $error = FALSE;
+
+ // Gets cvterm IDs.
+ foreach ($this->cvterms as $cv_name => $cvterms) {
+ $tmp_cv_name = $cv_name;
+
+ // Updates $tmp_cv_name if it is SITE_CV.
+ if ($cv_name == 'SITE_CV') {
+ $mcl_var = MCL_VAR::byKey(array('name' => $tmp_cv_name));
+ if (!$mcl_var) {
+ $this->updateMsg('E', "Error : SITE_CV not found");
+ $error = TRUE;
+ continue;
+ }
+ $tmp_cv_name = $mcl_var->getValue();
+ }
+
+ // Gets CV.
+ $cv = CHADO_CV::byKey(array('name' => $tmp_cv_name));
+ if (!$cv) {
+ $this->updateMsg('E', "Error : Could not find cv_id for $tmp_cv_name -$cv_name");
+ $error = TRUE;
+ continue;
+ }
+
+ // Gets cvterms.
+ $cv_id = $cv->getCvID();
+ foreach ($cvterms as $cvterm_name => $dummy) {
+ $cvterm = CHADO_CVTERM::byKey(array('name' => $cvterm_name, 'cv_id' => $cv_id));
+ if ($cvterm) {
+ $this->cvterms[$cv_name][$cvterm_name] = $cvterm->getCvtermID();
+ }
+ else {
+ $this->updateMsg('E', "Error : Could not find cvterm : $cvterm_name [cv_id = $cv_id].");
+ $error = TRUE;
+ }
+ }
+ }
+ return !$error;
+ }
+
+ /**
+ * Returns the information of the headers in table.
+ *
+ * @return string
+ */
+ public function getHeaderTable() {
+
+ // Sets red star.
+ $star = '*';
+
+ // Populates the rows with the headers.
+ $rows = array();
+ foreach ($this->headers as $name => $info) {
+
+ // Shows a label if exists.
+ if (array_key_exists('label', $info)) {
+ $name = $info['label'];
+ }
+ $name = ($info['req']) ? "$star $name" : $name;
+ $row = array($name, $info['desc']);
+ $rows []= $row;
+ }
+ $table_vars = array(
+ 'header' => array('Column', 'Description'),
+ 'rows' => $rows,
+ 'empty' => 'No header found',
+ 'attributes' => array(),
+ );
+ $table = theme('table', $table_vars);
+
+ // Adds the footer.
+ $footer = "$star Required field
";
+ return $table.$footer;
+ }
+
+ /**
+ * Returns the information of the cvterms in table.
+ *
+ * @return string
+ */
+ public function getCvtermTable() {
+
+ // Populates the rows with the cvterms.
+ $rows = array();
+ foreach ($this->cvterms as $cv_name => $cvterms) {
+ if ($cv_name == 'SITE_CV') {
+ $cv_name = MCL_VAR::getValueByName('SITE_CV');
+ }
+ ksort($cvterms);
+ foreach ($cvterms as $cvterm_name => $cvterm_id) {
+ $row = array($cv_name, $cvterm_name);
+ $rows []= $row;
+ }
+ }
+ $table_vars = array(
+ 'header' => array('cv.name', 'cvterm.name'),
+ 'rows' => $rows,
+ 'empty' => 'No cvterm found',
+ 'attributes' => array(),
+ );
+ return theme('table', $table_vars);
+ }
+
+ /**
+ * Checks if this job stage has been passed.
+ *
+ * @return boolean
+ */
+ public function isPassed() {
+ return $this->job->noError($this->template);
+ }
+
+ /**
+ * Updates the message.
+ *
+ * @param string $key
+ * @param string $msg
+ */
+ public function updateMsg($key, $msg) {
+ $this->job->updateMsg($key, $msg, $this->line_no);
+ }
+
+ /**
+ * Adds the message.
+ *
+ * @param string $key
+ * @param string $table
+ * @param array $args
+ */
+ public function addMsg($key, $table, $args) {
+ $msg = '';
+ if ($key == 'N') {
+ $msg = "Added to $table : " . $this->arrStr($args);
+ }
+ else if ($key == 'E') {
+ $msg = "Failed to upload to $table : " . $this->arrStr($args);
+ }
+ else if ($key == 'D') {
+ $msg = "Duplicated found in $table : " . $this->arrStr($args);
+ }
+ $this->job->updateMsg($key, $msg, $this->line_no);
+ }
+
+ /**
+ * Runs syntax error check.
+ *
+ * The input file should have
+ * 1st line : pound sign (#) and template name.
+ * 2nd line : headers with asteric for required fields.
+ * 3rd line : data section starts.
+ *
+ * Syntax error checking includes the following errors.
+ * 1. Validation on header names.
+ * 2. duplicated headers.
+ * 3. The number of columns in data section.
+ * 4. Missing required fields.
+ * 5. Missing value on the requried fields.
+ *
+ * @return boolean
+ */
+ public function runErrorCheckSyntax() {
+ $header_flag = TRUE;
+ $template_flag = TRUE;
+ $num_cols_headers = -1;
+ $line_no = 0;
+ $header_dup_arr = array();
+
+ // Opens the input file.
+ $infile = $this->csv->getFilepath();
+ if (!($fh = fopen($infile, 'r'))) {
+ $this->updateMsg('E', "Error : Fail to open the input file : $infile.");
+ return;
+ }
+ while(!feof($fh)) {
+
+ $this->setLineNo($line_no++);
+ $line = trim(fgets($fh));
+ if (!$line) {
+ continue;
+ }
+
+ // Skips the template line.
+ if ($template_flag) {
+ $template_flag = FALSE;
+ }
+
+ // Handles the headers line.
+ else if ($header_flag) {
+ $header_flag = FALSE;
+
+ // Tokenizes the line.
+ $columns = $this->_tokenizeLine($line, TRUE);
+ $num_cols = sizeof($columns);
+
+ // Sets the number of columns of the headers.
+ $num_cols_headers = $num_cols;
+
+ // Checks each column.
+ for ($i =0; $i < sizeof($columns); $i++) {
+ $column_name_orig = $columns[$i];
+
+ // Skips if column is emtpy.
+ if (!$column_name_orig) {
+ continue;
+ }
+
+ // Checks if column has valid name and saves the position of the column.
+ // Ignore the column name starting with '#', '@' or '$'.
+ $column_name = strtolower($column_name_orig);
+ if (!array_key_exists($column_name, $this->headers) && !preg_match("/^[#@$~]/", $column_name)) {
+ $this->updateMsg('W', "Invalid header : '$column_name_orig' is not valid header name, so this column would be ignored.");
+ }
+ else {
+
+ // Checks header name for duplication.
+ if (array_key_exists($column_name, $header_dup_arr)) {
+ $dup_column = $header_dup_arr[$column_name];
+ $this->updateMsg('E', "Duplicated header : Found duplicated header '$column_name_orig' at column $dup_column and $i. Please removed either one.");
+ }
+ else {
+ $this->headers[$column_name]['col'] = $i;
+ $header_dup_arr[$column_name] = $i;
+ }
+ }
+ }
+
+ // Checks if required columns exists.
+ foreach ($this->headers as $column => $prop) {
+ if ($prop['req'] && (!array_key_exists('col', $prop) || $prop['col'] < 0)) {
+ $this->updateMsg('E', "Error : Required column [$column] does not exists.");
+ }
+ }
+ }
+
+ // Handles data lines.
+ else {
+
+ // Tokenizes the line. Skips the rest of data section if no data is in the line.
+ $columns = $this->_tokenizeLine($line, FALSE);
+ if (empty($columns)) {
+ break;
+ }
+
+ // The number of columns in data line.
+ if ($num_cols != $num_cols_headers) {
+ $this->updateMsg('E', "Error : Invalid number of columns ($num_cols/$num_cols_headers)");
+ }
+
+ // Checks if the value of required column not empty.
+ foreach ($this->headers as $column => $prop) {
+ if ($prop['req']) {
+ $col = $this->headers[$column]['col'];
+ $value = $columns[$col];
+ if (!$value && $value === '') {
+ $this->updateMsg('E', "Error : Missing data on column [$column]");
+ }
+ }
+ }
+ }
+ }
+ fclose($fh);
+ return $this->isPassed();
+ }
+
+ /**
+ * Cleanup the input line and return it in an array.
+ * Removes double quote. If $headers is TRUE, remove '*'. It returns
+ * an empty array if no data present in a data line.
+ *
+ * @param string $line
+ * @param boolean $headers
+ *
+ * @return array
+ */
+ private function _tokenizeLine($line, $headers = FALSE) {
+
+ // Tokenizes the line.
+ $columns = preg_split('/","/', $line);
+ $data_str = '';
+ foreach ($columns as &$column) {
+ $column = trim($column, '"');
+ if ($headers) {
+ $column = trim(strtolower(str_replace('*', '', $column)));
+ }
+ $data_str .= $column;
+ }
+ if (trim($data_str)) {
+ return $columns;
+ }
+ return array();
+ }
+
+ /**
+ * Run data error check.
+ *
+ * Data error checking includes the following errors.
+ * - existence of data
+ * - consistency of data
+ *
+ * @return boolean
+ */
+ public function runErrorCheckData() {
+ $header_flag = TRUE;
+ $template_flag = TRUE;
+ $line_no = 0;
+
+ // Updates $cvterms for the template.
+ if (!$this->updateCvterms()) {
+ return FALSE;
+ }
+
+ // Opens the input file.
+ $infile = $this->csv->getFilePath();
+ if (!($fh = fopen($infile, 'r'))) {
+ $this->updateMsg('E', "Error : Fail to open the input file : $infile.");
+ return FALSE;
+ }
+ while(!feof($fh)) {
+ $line_no++;
+ $line = trim(fgets($fh));
+ if (!$line) {
+ continue;
+ }
+
+ // Skips the template line.
+ if ($template_flag) {
+ $template_flag = FALSE;
+ }
+
+ // Handles the headers line.
+ else if ($header_flag) {
+ $header_flag = FALSE;
+
+ // Tokenizes the line.
+ $columns = $this->_tokenizeLine($line, TRUE);
+
+ // Saves the position of the column.
+ for ($i =0; $i < sizeof($columns); $i++) {
+ $column_name = $columns[$i];
+
+ // Skips if column is emtpy.
+ if (!$column_name) {
+ continue;
+ }
+
+ // Sets column #.
+ if (array_key_exists($column_name, $this->headers) || preg_match("/^#/", $column_name)) {
+ $this->headers[$column_name]['col'] = $i;
+ }
+ }
+ }
+
+ // Handles data lines.
+ else {
+
+ // Tokenizes the line. Skips the rest of data section if no data is in the line.
+ $columns = $this->_tokenizeLine($line, FALSE);
+ if (empty($columns)) {
+ break;
+ }
+
+ // Populates the data line array.
+ $line_arr = array();
+ foreach ($this->headers as $column => $prop) {
+ if ($prop['col'] > -1) {
+ $line_arr[$column] = trim($columns[$prop['col']]);
+ }
+ }
+ $this->setLineNo($line_no);
+ $this->runErrorCheckDataLine($line_arr);
+ }
+ }
+ fclose($fh);
+ return $this->isPassed();
+ }
+
+ /**
+ * Checks a data line for this template.
+ *
+ * @param associative array $line
+ */
+ public function runErrorCheckDataLine($line) {
+ // Defined in child class.
+ }
+
+ /**
+ * Uploads a CSV data file.
+ *
+ * @return boolean
+ */
+ public function uploadData() {
+ $header_flag = TRUE;
+ $template_flag = TRUE;
+ $line_no = 0;
+
+ // Updates the cvterms for the template.
+ if (!$this->updateCvterms()) {
+ $this->updateMsg('E', "Error : Updating cvterms.");
+ return FALSE;
+ }
+
+ // Opens the input file.
+ $infile = $this->csv->getFilePath();
+ if (!($fh = fopen($infile, 'r'))) {
+ $this->updateMsg('E', "Error : Fail to open the input file : $infile.");
+ return FALSE;
+ }
+ while(!feof($fh)) {
+ $line_no++;
+ $line = trim(fgets($fh));
+ if (!$line) {
+ continue;
+ }
+
+ // Skips the template line.
+ if ($template_flag) {
+ $template_flag = FALSE;
+ }
+
+ // Handles the headers line.
+ else if ($header_flag) {
+ $header_flag = FALSE;
+
+ // Tokenizes the line.
+ $columns = $this->_tokenizeLine($line, TRUE);
+ if (empty($columns)) {
+ break;
+ }
+
+ // Saves the position of the column.
+ for ($i =0; $i < sizeof($columns); $i++) {
+ $column_name = $columns[$i];
+ if (array_key_exists($column_name, $this->headers) || preg_match("/^[#@~]/", $column_name)) {
+ $this->headers[$column_name]['col'] = $i;
+ }
+ }
+ }
+
+ // Handles data lines.
+ else {
+
+ // Tokenizes the line. Skips the rest of data section if no data is in the line.
+ $columns = $this->_tokenizeLine($line, FALSE);
+ if (empty($columns)) {
+ break;
+ }
+
+ // Populates the data line array.
+ $line_arr = array();
+ foreach ($this->headers as $column => $prop) {
+ if ($prop['col'] > -1) {
+ $line_arr[$column] = trim($columns[$prop['col']]);
+ }
+ }
+ $this->setLineNo($line_no);
+ $this->uploadDataLine($line_arr);
+ }
+ }
+ fclose($fh);
+ return $this->isPassed();
+ }
+
+ /**
+ * Upload a data line for this template.
+ *
+ * @param associative array $line
+ */
+ public function uploadDataLine($line) {
+ // Defined in child class.
+ }
+
+ /**
+ * Adds one or more properties
+ *
+ * @param string $table_name
+ * @param string $target_field
+ * @param integer $target_id
+ * @param integer $type_id
+ * @param string $value
+ * @param string $separator
+ */
+ public function addProperty($table_name, $target_field, $target_id, $type_id, $value, $separator = '') {
+ if ($value) {
+
+ // Checks duplication before adding a new property.
+ $args = array(
+ $target_field => $target_id,
+ 'type_id' => $type_id,
+ );
+ $class_name = strtoupper('CHADO_' . $table_name);
+ $obj = $class_name::byKey($args);
+ if ($obj) {
+ $this->addMsg('D', $table_name, $args);
+ }
+ else {
+
+ // Poluplates the array with values.
+ $value_arr = preg_split($this->getSepRegex($separator), $value, NULL, PREG_SPLIT_NO_EMPTY);
+
+ // Adds each property.
+ $rank = 0;
+ foreach ($value_arr as $val) {
+ $args['value'] = $val;
+ $args['rank'] = $rank++;
+ $obj = new $class_name($args);
+ if ($obj->insert()) {
+ $this->addMsg('N', $table_name, $args);
+ }
+ else {
+ $this->addMsg('E', $table_name, $args);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds one property with the specified rank.
+ *
+ * @param string $table_name
+ * @param string $target_field
+ * @param integer $target_id
+ * @param integer $type_id
+ * @param string $value
+ * @param integer $rank
+ */
+ public function addPropertyRanked($table_name, $target_field, $target_id, $type_id, $value, $rank) {
+ if ($value) {
+
+ // Checks duplication before adding a new property.
+ $args = array(
+ $target_field => $target_id,
+ 'type_id' => $type_id,
+ 'rank' => $rank,
+ );
+ $class_name = strtoupper('CHADO_' . $table_name);
+ $obj = $class_name::byKey($args);
+ if ($obj) {
+ $this->addMsg('D', $table_name, $args);
+ }
+ else {
+
+ // Adds a property.
+ $obj = new $class_name($args);
+ if ($obj->insert()) {
+ $this->addMsg('N', $table_name, $args);
+ }
+ else {
+ $this->addMsg('E', $table_name, $args);
+ }
+ }
+ }
+ }
+
+ /**
+ * Gets the property.
+ *
+ * @param string $table_name
+ * @param string $target_field
+ * @param integer $target_id
+ * @param integer $type_id
+ */
+ public function getProperty($table_name, $target_field, $target_id, $type_id) {
+
+ // Gets the value of the property table.
+ $args = array(
+ $target_field => $target_id,
+ 'type_id' => $type_id,
+ );
+ $class_name = strtoupper('CHADO_' . $table_name);
+ $obj = $class_name::byKey($args);
+ if ($obj) {
+ return $obj->getValue();
+ }
+ else {
+ return '';
+ }
+ }
+
+ /**
+ * Adds a relationship.
+ *
+ * @param string $table_name
+ * @param string $subject_field
+ * @param integer $subject_id
+ * @param string $object_field
+ * @param string $object_id
+ * @param integer $type_id
+ */
+ public function addRelationship($table_name, $subject_field, $subject_id, $object_field, $object_id, $type_id) {
+ if ($subject_id && $object_id && $type_id) {
+
+ // Checks duplication before adding a new relationship.
+ $args = array(
+ $subject_field => $subject_id,
+ $object_field => $object_id,
+ 'type_id' => $type_id,
+ );
+ $class_name = strtoupper('CHADO_' . $table_name);
+ $obj = $class_name::byKey($args);
+ if ($obj) {
+ $this->addMsg('D', $table_name, $args);
+ }
+ else {
+
+ // Adds a new relationship.
+ $obj = new $class_name($args);
+ if ($obj->insert()) {
+ $this->addMsg('N', $table_name, $args);
+ }
+ else {
+ print "here:$table_name\n";
+ $this->addMsg('E', $table_name, $args);
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds a link (Adding to a linking table).
+ *
+ * @param string $table_name
+ * @param string $field_1
+ * @param integer $id_1
+ * @param string $field_2
+ * @param string $id_2
+ */
+ public function addLink($table_name, $field_1, $id_1, $field_2, $id_2, $type_id = NULL) {
+ if ($id_1 && $id_2) {
+
+ // Checks for a duplication before adding a new relationship.
+ $args = array(
+ $field_1 => $id_1,
+ $field_2 => $id_2,
+ );
+ if ($type_id) {
+ $args['type_id'] = $type_id;
+ }
+ $class_name = strtoupper('CHADO_' . $table_name);
+ $obj = $class_name::byKey($args);
+ if ($obj) {
+ $this->addMsg('D', $table_name, $args);
+ }
+ else {
+
+ // Adds a new link.
+ $obj = new $class_name($args);
+ if ($obj->insert()) {
+ $this->addMsg('N', $table_name, $args);
+ }
+ else {
+ $this->addMsg('E', $table_name, $args);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the template summary.
+ */
+ public function templateSummary() {
+
+ $summary = "\n\n\t================================\n" .
+ "\tTemplate : " . $this->template . "\n" .
+ "\tType : " . $this->template_type . "\n" .
+ "\t--------------------------------\n";
+
+
+
+
+
+ return $summary;
+ }
+
+ /**
+ * Creates a string from array.
+ *
+ * @param assoc array $args
+ * @param string $field_1
+ * @param integer $id_1
+ * @param string $field_2
+ * @param string $id_2
+ */
+ public function arrStr($args) {
+ if (empty($args)) {
+ return '';
+ }
+ $keys = '';
+ $values = '';
+ $flag = TRUE;
+ foreach ($args as $key => $value) {
+ $prefix = ', ';
+ if ($flag) {
+ $prefix = '';
+ $flag = FALSE;
+ }
+ $keys .= $prefix . $key;
+ $values .= $prefix . $value;
+ }
+ return "($keys) = ($values)";
+ }
+
+ /**
+ * Returns the regular expression of the separator.
+ *
+ * @param string
+ */
+ public function getSepRegex($separator) {
+ return ($separator) ? "/$separator/" : '/@@@@@/';
+ }
+
+ /**
+ * Retrieves the cvterm_id.
+ *
+ * @param string $cv_name
+ * @param string $cvterm_name
+ *
+ * @return integer
+ */
+ public function getCvtermID($cv_name, $cvterm_name) {
+ return $this->cvterms[$cv_name][$cvterm_name];
+ }
+
+ /**
+ * Checks argments for empty.
+ *
+ * @param array $args
+ *
+ * @return boolean
+ */
+ public function checkReqArgs($args) {
+ foreach ($args as $key => $value) {
+ if ($value == '') {
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+
+ /**
+ * Checks if there are data in a row.
+ *
+ * @param array $line
+ * @param string $regex
+ *
+ * @return boolean
+ * Returns TRUE if data row are empty.
+ */
+ public function isEmptyRow($line, $regex = '') {
+ $data_str = '';
+ foreach ($line as $column => $value) {
+ if (preg_match("/$regex/", $column)) {
+ $data_str .= trim($line[$column]);
+ }
+ }
+ return empty($data_str);
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+ /**
+ * Retrieves the headers.
+ *
+ * @return string
+ */
+ public function getHeaders() {
+ return $this->headers;
+ }
+
+ /**
+ * Updates the headers.
+ *
+ * @param string $headers
+ */
+ public function setHeaders($headers) {
+ $this->headers = $headers;
+ }
+
+ /**
+ * Retrieves the job.
+ *
+ * @return MCL_JOB
+ */
+ public function getJob() {
+ return $this->job;
+ }
+
+ /**
+ * Updates the job.
+ *
+ * @param MCL_JOB $job
+ */
+ public function setJob($job) {
+ $this->job = $job;
+ }
+
+ /**
+ * Retrieves the csv.
+ *
+ * @return MCL_CSV_FILE
+ */
+ public function getCSV() {
+ return $this->csv;
+ }
+
+ /**
+ * Updates the csv.
+ *
+ * @param MCL_CSV_FILE $csv
+ */
+ public function setCSV($csv) {
+ $this->csv = $csv;
+ }
+
+ /**
+ * Retrieves the template type.
+ *
+ * @return string
+ */
+ public function getTemplateType() {
+ return $this->template_type->getType();
+ }
+
+ /**
+ * Updates the template type.
+ *
+ * @param string $template_type
+ */
+ public function setTemplateType($template_type) {
+ $this->template_type->setType($template_type);
+ }
+
+ /**
+ * Retrieves the line no.
+ *
+ * @return integer
+ */
+ public function getLineNo() {
+ return $this->line_no;
+ }
+
+ /**
+ * Updates the line no.
+ *
+ * @param integer $line_no
+ */
+ public function setLineNo($line_no) {
+ $this->line_no = $line_no;
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/mcl_template_type.class.inc b/includes/class/template/mcl_template_type.class.inc
new file mode 100644
index 0000000..28e7fb0
--- /dev/null
+++ b/includes/class/template/mcl_template_type.class.inc
@@ -0,0 +1,64 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see PUBLIC_MCL_TEMPLATE_TYPE::__destruct()
+ */
+ public function __destruct() {
+ parent::__destruct();
+ }
+
+ /**
+ * Returns template information in array. Adds the information for
+ * creating two excel sheets for header definition and data template.
+ *
+ * @param string $order_by
+ *
+ * @return array of MCL_TEMPLATE_TYPE
+ */
+ public static function getTemplateTypes($order_by = '') {
+
+ // Updates $order_by.
+ $order_by_str = 'ORDER BY TT.type';
+ if ($order_by) {
+ $order_by_str = 'ORDER BY TT.' . $order_by;
+ }
+
+ // Gets template types
+ $sql = "SELECT template_type_id FROM {mcl_template_type} TT $order_by_str";
+ $mcl_template_types = array();
+ $results = db_query($sql);
+ while ($template_type_id = $results->fetchField()) {
+ $mcl_template_types []= MCL_TEMPLATE_TYPE::byKey(array('template_type_id' => $template_type_id));
+ }
+ return $mcl_template_types;
+ }
+
+ /*
+ * Defines getters and setters below.
+ */
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_contact.class.inc b/includes/class/template/module/mcl_template_contact.class.inc
new file mode 100644
index 0000000..cf1a78d
--- /dev/null
+++ b/includes/class/template/module/mcl_template_contact.class.inc
@@ -0,0 +1,145 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for contact sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'contact_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the contact (person, institution, etc)."),
+ 'alias' => array('req' => FALSE, 'width' => 10, 'desc' => "Any alias of the contact."),
+ 'type' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the contact - choose one from person, company, institution, lab or organization)."),
+ 'first_name' => array('req' => FALSE, 'width' => 12, 'desc' => "First name of the person."),
+ 'last_name' => array('req' => FALSE, 'width' => 12, 'desc' => "Last name of the person."),
+ 'institution' => array('req' => FALSE, 'width' => 12, 'desc' => "Name of the institution the person belongs to."),
+ 'lab' => array('req' => FALSE, 'width' => 10, 'desc' => "Name of the lab the person belongs to."),
+ 'address' => array('req' => FALSE, 'width' => 10, 'desc' => "Address of the contact."),
+ 'email' => array('req' => FALSE, 'width' => 10, 'desc' => "Email of the contact."),
+ 'phone' => array('req' => FALSE, 'width' => 10, 'desc' => "Phone number of the contact."),
+ 'fax' => array('req' => FALSE, 'width' => 10, 'desc' => "Fax number of the contact."),
+ 'title' => array('req' => FALSE, 'width' => 10, 'desc' => "Job title of the person."),
+ 'country' => array('req' => FALSE, 'width' => 10, 'desc' => "Country of the contact."),
+ 'source' => array('req' => FALSE, 'width' => 10, 'desc' => "Source of the data when the contact information is obtained from other databases."),
+ 'last_update' => array('req' => FALSE, 'width' => 12, 'desc' => "Date of the last update."),
+ 'url' => array('req' => FALSE, 'width' => 10, 'desc' => "URL of home page."),
+ 'comments' => array('req' => FALSE, 'width' => 14, 'desc' => "Any comments of the contact."),
+ 'keywords' => array('req' => FALSE, 'width' => 15, 'desc' => "A maximum of 5 keywords that best describe the person's area of work."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['person'] = -1;
+ $cvterms['SITE_CV']['institution'] = -1;
+ $cvterms['SITE_CV']['organization'] = -1;
+ $cvterms['SITE_CV']['database'] = -1;
+ $cvterms['SITE_CV']['company'] = -1;
+ $cvterms['SITE_CV']['lab'] = -1;
+ $cvterms['SITE_CV']['first_name'] = -1;
+ $cvterms['SITE_CV']['last_name'] = -1;
+ $cvterms['SITE_CV']['phone'] = -1;
+ $cvterms['SITE_CV']['fax'] = -1;
+ $cvterms['SITE_CV']['email'] = -1;
+ $cvterms['SITE_CV']['address'] = -1;
+ $cvterms['SITE_CV']['country'] = -1;
+ $cvterms['SITE_CV']['title'] = -1;
+ $cvterms['SITE_CV']['keywords'] = -1;
+ $cvterms['SITE_CV']['alias'] = -1;
+ $cvterms['SITE_CV']['source'] = -1;
+ $cvterms['SITE_CV']['last_update'] = -1;
+ $cvterms['SITE_CV']['comments'] = -1;
+ $cvterms['SITE_CV']['url'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks contact type.
+ $first_name = $line['first_name'];
+ $last_name = $line['last_name'];
+ $type = $line['type'];
+ if ($type == 'person') {
+ if (!$first_name || !$last_name) {
+ $this->updateMsg('E', "type : first_name and last_name must be not empty");
+ }
+ }
+ else {
+
+ // Checks for the cvterm_id of the type.
+ $valid_types = array('person', 'institution', 'lab', 'organization', 'database', 'company');
+ if (!in_array($type, $valid_types)) {
+ $this->updateMsg('E', "Invalid contact type : $type not found in cvterm");
+ }
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Adds a contact.
+ $type_id = $this->cvterms['SITE_CV'][$line['type']];
+ $contact = MCL_CHADO_CONTACT::addContact($this, $line['contact_name'], $type_id, $line['description']);
+ if ($contact) {
+
+ // Adds properties.
+ $contact->addProp($this, 'SITE_CV', 'institution', $line['institution']);
+ $contact->addProp($this, 'SITE_CV', 'lab', $line['lab']);
+ $contact->addProp($this, 'SITE_CV', 'first_name', $line['first_name']);
+ $contact->addProp($this, 'SITE_CV', 'last_name', $line['last_name']);
+ $contact->addProp($this, 'SITE_CV', 'email', $line['email']);
+ $contact->addProp($this, 'SITE_CV', 'phone', $line['phone']);
+ $contact->addProp($this, 'SITE_CV', 'fax', $line['fax']);
+ $contact->addProp($this, 'SITE_CV', 'address', $line['address']);
+ $contact->addProp($this, 'SITE_CV', 'country', $line['country']);
+ $contact->addProp($this, 'SITE_CV', 'title', $line['title']);
+ $contact->addProp($this, 'SITE_CV', 'last_update', $line['last_update']);
+ $contact->addProp($this, 'SITE_CV', 'url', $line['url']);
+ $contact->addProp($this, 'SITE_CV', 'comments', $line['comments']);
+ $contact->addProp($this, 'SITE_CV', 'keywords', $line['keywords'], '[,;]');
+
+ // Adds aliases.
+ $contact->addProp($this, 'SITE_CV', 'alias', $line['alias'], '[,;]');
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_cross.class.inc b/includes/class/template/module/mcl_template_cross.class.inc
new file mode 100644
index 0000000..b79d2aa
--- /dev/null
+++ b/includes/class/template/module/mcl_template_cross.class.inc
@@ -0,0 +1,121 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for cross sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'dataset_name' => array('req' => TRUE, 'width' => 17, 'desc' => "Name of the dataset (super-dataset or sub-category) to which the cross belongs. The details of the dataset should be given in the 'Dataset' sheet."),
+ 'site_name' => array('req' => FALSE, 'width' => 10, 'desc' => "Site information where the stock for the phenotyping is planted. It should match 'site_name' in the 'Site' sheet."),
+ 'cross_number' => array('req' => TRUE, 'width' => 17, 'desc' => "ID number or name for this specific cross."),
+ 'mother' => array('req' => TRUE, 'width' => 13, 'desc' => "ID name or number for the seed parent for the cross. This ID must also be an entry in the Stock sheet."),
+ 'mother_location' => array('req' => FALSE, 'width' => 17, 'desc' => "Location details for the mother of this cross (eg. Plant location, individual stock name, etc)."),
+ 'father' => array('req' => TRUE, 'width' => 13, 'desc' => "ID name or number for the pollen parent for the cross. This ID must also be an entry in the Stock sheet."),
+ 'father_location' => array('req' => FALSE, 'width' => 17, 'desc' => "Location details for the father of this cross (eg. Plant location, individual stock name, etc)."),
+ 'cross_date' => array('req' => FALSE, 'width' => 15, 'desc' => "Date for the cross."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['cross_experiment'] = -1;
+ $cvterms['SITE_CV']['cross_date'] = -1;
+ $cvterms['SITE_CV']['cross_number'] = -1;
+ $cvterms['SITE_CV']['mother_location'] = -1;
+ $cvterms['SITE_CV']['father_location'] = -1;
+ $cvterms['SITE_CV']['maternal_parent'] = -1;
+ $cvterms['SITE_CV']['paternal_parent'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks dataset.
+ MCL_CHADO_DATASET::checkDataset($this, $line['dataset_name']);
+
+ // Gets genus and species from cross_number.
+ $genus = '';
+ $species = '';
+
+
+ // Checks maternal parent.
+ MCL_CHADO_STOCK::checkStock($this, $line['mother'], $genus, $species);
+
+ // Checks paternal parent.
+ MCL_CHADO_STOCK::checkStock($this, $line['father'], $genus, $species);
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Gets genus and species from cross_number.
+
+
+
+
+ // Adds a nd_eperiment.
+ $dup_key = $line['dataset_name'] . '_' . $line['cross_number'];
+ $nd_experiment = MCL_CHADO_ND_EXPERIMENT::addNdExperiment($this, $this->cvterms['SITE_CV']['cross_experiment'], $nd_geolocation_id, $this->cvterms['SITE_CV']['cross_number'], $dup_key);
+ if ($nd_experiment) {
+
+ // Adds properties.
+ $nd_experiment->addProp($this, 'SITE_CV', 'cross_number', $line['cross_number']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'cross_date', $line['cross_date']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'mother_location', $line['mother_location']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'father_location', $line['father_location']);
+
+ // Adds a dataset.
+ $nd_experiment->addDataset($this, $line['dataset_name']);
+
+ // Adds a maternal parent.
+ $maternal_parent = MCL_CHADO_STOCK::getStock($line['mother'], $line['mother_genus'], $line['mother_species']);
+ $nd_experiment->addStock($this, $maternal_parent, $this->cvterms['SITE_CV']['maternal_parent']);
+
+ // Adds a paternal parent.
+ $paternal_parent = MCL_CHADO_STOCK::getStock($line['father'], $line['father_genus'], $line['father_species']);
+ $nd_experiment->addStock($this, $maternal_parent, $this->cvterms['SITE_CV']['paternal_parent']);;
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_cv.class.inc b/includes/class/template/module/mcl_template_cv.class.inc
new file mode 100644
index 0000000..d24c7b8
--- /dev/null
+++ b/includes/class/template/module/mcl_template_cv.class.inc
@@ -0,0 +1,68 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for cv sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'cv_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the control vocabulary or ontology."),
+ 'definition' => array('req' => FALSE, 'width' => 15, 'desc' => "Definition of the control vocabulary."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Adds a cv.
+ $cv = MCL_CHADO_CV::addCV($this, $line['cv_name'], $line['definition']);
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_cvterm.class.inc b/includes/class/template/module/mcl_template_cvterm.class.inc
new file mode 100644
index 0000000..49e069c
--- /dev/null
+++ b/includes/class/template/module/mcl_template_cvterm.class.inc
@@ -0,0 +1,77 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for cvterm sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'db_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the db."),
+ 'cv_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the control vocabulary."),
+ 'cvterm_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the cvterm."),
+ 'accession' => array('req' => TRUE, 'width' => 10, 'desc' => "Accession of the cvterm."),
+ 'definition' => array('req' => FALSE, 'width' => 15, 'desc' => "Definition of the cvterm."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks db.
+ MCL_CHADO_DB::checkDB($this, $line['db_name']);
+
+ // Checks cv.
+ MCL_CHADO_CV::checkCV($this, $line['cv_name']);
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Adds a cvterm.
+ $cvterm = MCL_CHADO_CVTERM::addCvterm($this, $line['db_name'], $line['cv_name'], $line['cvterm_name'], $line['definition'], $line['accession']);
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_dataset.class.inc b/includes/class/template/module/mcl_template_dataset.class.inc
new file mode 100644
index 0000000..f6c02c6
--- /dev/null
+++ b/includes/class/template/module/mcl_template_dataset.class.inc
@@ -0,0 +1,121 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for dataset sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'dataset_name' => array('req' => TRUE, 'width' => 20, 'desc' => "Names of the datasets."),
+ 'type' => array('req' => TRUE, 'width' => 12, 'desc' => "Breeding, growing (for cultivar performance data), diversity (for study of genetic diversity) or QTL."),
+ 'sub_type' => array('req' => FALSE, 'width' => 12, 'desc' => "To specify whether the markers used were SSR or SNP when the dataset is SSR or SNP genotyping data."),
+ 'super_dataset' => array('req' => FALSE, 'width' => 16, 'desc' => "Larger dataset that this sub_dataset belngs to."),
+ 'trait_descriptor_set' => array('req' => FALSE, 'width' => 16, 'desc' => "The name of the trait descriptor set that each dataset or breeder uses. This is a required column if a type of a dataset is 'breeding'."),
+ 'pi' => array('req' => FALSE, 'width' => 12, 'desc' => "Principal Investigator (eg. breeder, corresponding author of the QTL paper) of the Dataset. It should match a 'contact_name' column in 'Contact' sheet."),
+ 'crop' => array('req' => FALSE, 'width' => 10, 'desc' => "Name of the crop for the dataset."),
+ 'comments' => array('req' => FALSE, 'width' => 15, 'desc' => "Any comments for the dataset."),
+ 'reference' => array('req' => FALSE, 'width' => 10, 'desc' => "pub_id for any reference if the dataset is from publication."),
+ 'description' => array('req' => FALSE, 'width' => 90, 'desc' => "General description of the dataset (purpose, target, how many crosses, etc)."),
+ );
+
+ // Adds labels.
+ $headers['pi']['label'] = 'PI';
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['project_type'] = -1;
+ $cvterms['SITE_CV']['trait_descriptor'] = -1;
+ $cvterms['SITE_CV']['sub_type'] = -1;
+ $cvterms['SITE_CV']['description'] = -1;
+ $cvterms['SITE_CV']['comments'] = -1;
+ $cvterms['SITE_CV']['crop'] = -1;
+ $cvterms['SITE_CV']['is_a_subproject_of'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks 'trait_descriptor_set' column. The column becomes required column
+ // if dataset type is 'breeding'.
+ if ($line['type'] == 'breeding') {
+ MCL_CHADO_CV::checkCV($this, $line['trait_descriptor_set']);
+ }
+
+ // Checks super_datatset.
+ MCL_CHADO_DATASET::checkDataset($this, $line['super_datatset']);
+
+ // Checks PI.
+ MCL_CHADO_CONTACT::checkContact($this, $line['pi']);
+
+ // Checks references.
+ MCL_CHADO_PUB::checkPub($this, $line['reference'], '[;,]');
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Adds a dataset.
+ $dataset = MCL_CHADO_DATASET::addDataset($this, $line['dataset_name']);
+ if ($dataset) {
+
+ // Adds properties.
+ $dataset->addProp($this, 'SITE_CV', 'project_type', $line['type']);
+ $dataset->addProp($this, 'SITE_CV', 'trait_descriptor', $line['trait_descriptor_set']);
+ $dataset->addProp($this, 'SITE_CV', 'sub_type', $line['sub_type']);
+ $dataset->addProp($this, 'SITE_CV', 'description', $line['description']);
+ $dataset->addProp($this, 'SITE_CV', 'crop', $line['crop']);
+ $dataset->addProp($this, 'SITE_CV', 'comments', $line['comments']);
+
+ // Adds PI.
+ $dataset->addContact($this, $line['pi']);
+
+ // Adds a parent.
+ $dataset->addParentDataset($this, $line['super_datatset']);
+
+ // Adds references.
+ $dataset->addReference($this, $line['reference'], "[;,]");
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_db.class.inc b/includes/class/template/module/mcl_template_db.class.inc
new file mode 100644
index 0000000..16e8015
--- /dev/null
+++ b/includes/class/template/module/mcl_template_db.class.inc
@@ -0,0 +1,70 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for db sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'db_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the db."),
+ 'url_prefix' => array('req' => FALSE, 'width' => 10, 'desc' => "Prefix of the URL."),
+ 'url' => array('req' => FALSE, 'width' => 10, 'desc' => "URL of the db."),
+ 'description' => array('req' => FALSE, 'width' => 15, 'desc' => "Description of the db."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Adds a db
+ $db = MCL_CHADO_DB::addDB($this, $line['db_name'], $line['url_prefix'], $line['url'], $line['description']);
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_descriptor.class.inc b/includes/class/template/module/mcl_template_descriptor.class.inc
new file mode 100644
index 0000000..073193a
--- /dev/null
+++ b/includes/class/template/module/mcl_template_descriptor.class.inc
@@ -0,0 +1,124 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for descriptor sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'trait_descriptor_set' => array('req' => FALSE, 'width' => 20, 'desc' => "The name of the trait descriptor set. If the database has one trait descriptor set for all public trait evaluation data, it can be specified in the loader."),
+ 'descriptor_name' => array('req' => TRUE, 'width' => 15, 'desc' => "Any trait descriptor that a breeder uses in their own program. These descriptors would be used as column heads the Cross or Phenotype sheets, with a '#' prefix."),
+ 'alias' => array('req' => FALSE, 'width' => 15, 'desc' => "Alias of the descriptor."),
+ 'data_type' => array('req' => TRUE, 'width' => 15, 'desc' => "The type of data (date, quantitative_code, quantitative, code, etc.)."),
+ 'trait_name' => array('req' => FALSE, 'width' => 20, 'desc' => "crop trait ontology term (no specific protocol or code is involved with trait name) that corresponds to the trait descriptor (name). This should exist in 'Trait' sheet."),
+ 'values' => array('req' => FALSE, 'width' => 10, 'desc' => "Code definition for a coded descriptor."),
+ 'data_unit' => array('req' => FALSE, 'width' => 10, 'desc' => "Unit for the trait descriptor."),
+ 'definition' => array('req' => FALSE, 'width' => 90, 'desc' => "Definition of the descriptor."),
+// 'image_file' => array('req' => FALSE, 'width' => 10, 'desc' => "The image file for the descriptor."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['alias'] = -1;
+ $cvterms['SITE_CV']['data_type'] = -1;
+ $cvterms['SITE_CV']['data_unit'] = -1;
+ $cvterms['SITE_CV']['image_file'] = -1;
+ $cvterms['SITE_CV']['code_ref'] = -1;
+ $cvterms['SITE_CV']['qualitative'] = -1;
+ $cvterms['SITE_CV']['code'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks SITE_DB.
+ MCL_CHADO_DB::checkDB($this, MCL_VAR::getValueByName('SITE_DB'));
+
+ // Checks CV for trait_descriptor_set.
+ MCL_CHADO_CV::checkCV($this, $line['trait_descriptor_set']);
+
+ // Checks values.
+ MCL_CHADO_CVTERM::checkValues($this, $line['type'], $line['values']);
+
+ // Checks data type.
+ if (!in_array($line['data_type'], $this->valid_descriptor_types)) {
+ $this->updateMsg('E', "Error - data type : '" . $line['data_type'] . "' is not valid descriptor type");
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Gets db.
+ $db = MCL_CHADO_DB::getDB(MCL_VAR::getValueByName('SITE_DB'));
+
+ // Gets cv.
+ $cv = MCL_CHADO_CV::getCV($line['trait_descriptor_set']);
+
+ // Adds a descriptor.
+ $descriptor = MCL_CHADO_CVTERM::addCvterm($this, $db->getName(), $cv->getName(), $line['descriptor_name'], $line['definition']);
+ if ($descriptor) {
+
+ // Adds properties.
+ $descriptor->addProp($this, 'SITE_CV', 'data_type', $line['data_type']);
+ $descriptor->addProp($this, 'SITE_CV', 'data_unit', $line['data_unit']);
+ $descriptor->addProp($this, 'SITE_CV', 'image_file', $line['image_file']);
+
+ // Adds aliases.
+ $descriptor->addAlias($this, 'SITE_CV', 'alias', $line['alias'], '[,;]');
+
+ // Adds values.
+ $descriptor->addValues($this, $line['data_type'], $line['values']);
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_field_book.class.inc b/includes/class/template/module/mcl_template_field_book.class.inc
new file mode 100644
index 0000000..de05b2c
--- /dev/null
+++ b/includes/class/template/module/mcl_template_field_book.class.inc
@@ -0,0 +1,73 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for field book sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'dataset_name' => array('req' => TRUE,'width' => 10, 'desc' => ''),
+ 'id' => array('req' => TRUE,'width' => 10, 'desc' => ''),
+ 'sample_id' => array('req' => TRUE,'width' => 10, 'desc' => ''),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['clone'] = -1;
+ $cvterms['SITE_CV']['sample'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+
+
+
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_genotype.class.inc b/includes/class/template/module/mcl_template_genotype.class.inc
new file mode 100644
index 0000000..936d431
--- /dev/null
+++ b/includes/class/template/module/mcl_template_genotype.class.inc
@@ -0,0 +1,192 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for genotype sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'dataset_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the genotyping dataset. It should match a dataset_name in 'Dataset' sheet."),
+ 'stock_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the stock genotyped. It should match an 'stock_namme' of the 'Stock' sheet."),
+// 'genus' => array('req' => TRUE, 'width' => 10, 'desc' => ""),
+// 'species' => array('req' => TRUE, 'width' => 10, 'desc' => ""),
+ 'sample_id' => array('req' => TRUE, 'width' => 10, 'desc' => "ID of a sample. Normally it is the same as ID unless the user want to keep tract of genotype of a specific sample."),
+ 'clone_id' => array('req' => FALSE, 'width' => 10, 'desc' => "ID of a clone if known."),
+ 'marker' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the marker used for genotyping. It should match a marker_name in the 'Marker' sheet."),
+// 'marker_genus' => array('req' => TRUE, 'width' => 10, 'desc' => ""),
+// 'marker_species' => array('req' => TRUE, 'width' => 10, 'desc' => ""),
+ 'storage_id' => array('req' => FALSE, 'width' => 10, 'desc' => "Any storage ID for the DNA sample."),
+ 'plot' => array('req' => FALSE, 'width' => 10, 'desc' => "Field position where the plant material was collected from."),
+ 'row' => array('req' => FALSE, 'width' => 10, 'desc' => "Field position where the plant material was collected from."),
+ 'position' => array('req' => FALSE, 'width' => 10, 'desc' => "Field position where the plant material was collected from."),
+ 'collector' => array('req' => FALSE, 'width' => 10, 'desc' => "People who collected the plant material."),
+ 'collection_date' => array('req' => FALSE, 'width' => 10, 'desc' => "Date when the plant material was collected. It should match 'contact_name' in the Contact sheet. Multiple names can be added with a semicolon (;) in between."),
+ 'genotyping_date' => array('req' => FALSE, 'width' => 10, 'desc' => "Any size standard used."),
+ 'instrument' => array('req' => FALSE, 'width' => 10, 'desc' => "Any instrument used for genotyping."),
+ 'size_standard' => array('req' => FALSE, 'width' => 10, 'desc' => "Date of the genotyping experiment."),
+ 'data_year' => array('req' => FALSE, 'width' => 10, 'desc' => "Genotyping date if only year is known."),
+ 'experimenter' => array('req' => FALSE, 'width' => 10, 'desc' => "Person who conducted genotyping. It should match 'contact_name' in the Contact sheet. Multiple names can be added with a semicolon (;) in between."),
+ 'dye_color' => array('req' => FALSE, 'width' => 10, 'desc' => "Dye color used for genotyping."),
+ 'comments' => array('req' => FALSE, 'width' => 10, 'desc' => "Any comments on the specific genotype (of a specific sample with a specific marker)."),
+ );
+
+ // Adds labels.
+ $headers['clone_id']['label'] = 'clone_ID';
+ $headers['sample_id']['label'] = 'sample_ID';
+ $headers['storage_id']['label'] = 'storage_ID';
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['genotyping'] = -1;
+ $cvterms['SITE_CV']['clone'] = -1;
+ $cvterms['SITE_CV']['clone_of'] = -1;
+ $cvterms['SITE_CV']['sample'] = -1;
+ $cvterms['SITE_CV']['sample_of'] = -1;
+ $cvterms['SITE_CV']['sample_id'] = -1;
+ $cvterms['SITE_CV']['storage_id'] = -1;
+ $cvterms['SITE_CV']['plot'] = -1;
+ $cvterms['SITE_CV']['row'] = -1;
+ $cvterms['SITE_CV']['position'] = -1;
+ $cvterms['SITE_CV']['pick_date'] = -1;
+ $cvterms['SITE_CV']['evaluation_date'] = -1;
+ $cvterms['SITE_CV']['collector'] = -1;
+ $cvterms['SITE_CV']['instrument'] = -1;
+ $cvterms['SITE_CV']['size_standard'] = -1;
+ $cvterms['SITE_CV']['dye_color'] = -1;
+ $cvterms['SITE_CV']['comments'] = -1;
+ $cvterms['SITE_CV']['data_year'] = -1;
+ $cvterms['sequence']['genetic_marker'] = -1;
+ $cvterms['sequence']['allele'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks dataset.
+ MCL_CHADO_DATASET::checkDataset($this, $line['dataset_name']);
+
+ // Checks organisms.
+ MCL_CHADO_ORGANISM::checkOrganism($this, $line['genus'], $line['species']);
+ MCL_CHADO_ORGANISM::checkOrganism($this, $line['marker_genus'], $line['marker_species']);
+
+ // Checks stock.
+ MCL_CHADO_STOCK::checkStock($this, $line['stock_name'], $line['genus'], $line['species']);
+
+ // Checks marker.
+ MCL_CHADO_FEATURE::checkFeature($this, $line['marker'], $line['marker_genus'], $line['marker_species'], $this->cvterms['sequence']['genetic_marker']);
+
+ // Checks experimenter for contacts.
+ MCL_CHADO_CONTACT::checkContact($this, $line['experimenter'], '[;,]');
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Gets the dataset.
+ $dataset = MCL_CHADO_DATASET::getDataset($line['dataset']);
+
+ // Gets the organims.
+ $organism = MCL_CHADO_ORGANISM::getOrganism($line['genus'], $line['species']);
+
+ // Gets the stock.
+ $stock = MCL_CHADO_STOCK::getStock($line['stock_name'], $line['genus'], $line['species']);
+
+ // Gets the marker.
+ $marker = MCL_CHADO_FEATURE::getFeature($line['marker'], $line['marker_genus'], $line['marker_species'], $this->cvterms['sequence']['genetic_marker']);
+
+ while (FALSE) {
+
+ // Creates uniquename and description for genotype.
+ $description = '';
+ $uniquename = $marker->getUniquename() . '_' . $description;
+
+ // Adds a genotype.
+ $genotype = MCL_CHADO_GENOTYPE::addGenotype($this, $uniquename, $this->cvterms['sequence']['allele'], $description);
+
+ // Adds a sample.
+ $sample = NULL;
+// $sample = MCL_CHADO_STOCK::addStock($this, $line['sample_id'], '', $organism->getOrganismID(), $this->cvterms['SITE_CV']['sample']);
+
+ // Adds a nd_eperiment.
+ $nd_experiment = MCL_CHADO_ND_EXPERIMENT::addNdExperiment($this, $this->cvterms['SITE_CV']['genotyping'], 0, $this->cvterms['SITE_CV']['sample_id'], $sample->getStockID());
+
+ // Adds clone properties.
+ if ($clone) {
+ $clone->addProp($this, 'SITE_CV', 'storage_id', $line['storage_id']);
+ $clone->addProp($this, 'SITE_CV', 'plot', $line['plot']);
+ $clone->addProp($this, 'SITE_CV', 'row', $line['row']);
+ $clone->addProp($this, 'SITE_CV', 'position', $line['position']);
+ }
+
+ // Adds sample properties.
+ $sample->addProp($this, 'SITE_CV', 'storage_id', $line['storage_id']);
+ $sample->addProp($this, 'SITE_CV', 'plot', $line['plot']);
+ $sample->addProp($this, 'SITE_CV', 'row', $line['row']);
+ $sample->addProp($this, 'SITE_CV', 'position', $line['position']);
+ $sample->addProp($this, 'SITE_CV', 'collector', $line['collector']);
+ $sample->addProp($this, 'SITE_CV', 'collection_date', $line['collection_date']);
+
+ // Adds properties.
+ $nd_experiment->addProp($this, 'SITE_CV', 'genotyping_date', $line['genotyping_date']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'instrument', $line['instrument']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'size_standard', $line['size_standard']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'data_year', $line['data_year']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'dye_color', $line['dye_color']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'comments', $line['comments']);
+
+ // Adds a stock.
+ $nd_experiment->addStock($this, $sample);
+
+ // Adds evaluators.
+ $nd_experiment->addContact($this, $line['experimenter'], "[;]");
+
+ // Adds a genotype.
+ $nd_experiment->addGenotype($this, $genotype);
+
+ // Adds a genotype for marker.
+ $marker->addGenotype($this, $genotype);
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_genotype_snp.class.inc b/includes/class/template/module/mcl_template_genotype_snp.class.inc
new file mode 100644
index 0000000..7495c97
--- /dev/null
+++ b/includes/class/template/module/mcl_template_genotype_snp.class.inc
@@ -0,0 +1,69 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for genotype-snp sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'dataset_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the genotyping dataset. It should match a dataset_name in 'Dataset' sheet."),
+ 'stock_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the stock genotyped. It should match an 'stock_namme' of the 'Stock' sheet."),
+ 'clone_id' => array('req' => FALSE, 'width' => 10, 'label' => 'clone_ID', 'desc' => "ID of a clone if known."),
+ 'sample_id' => array('req' => TRUE, 'width' => 10, 'label' => 'sample_ID', 'desc' => "ID of a sample. Normally it is the same as ID unless the user want to keep tract of genotype of a specific sample."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['clone'] = -1;
+ $cvterms['SITE_CV']['sample'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_image.class.inc b/includes/class/template/module/mcl_template_image.class.inc
new file mode 100644
index 0000000..5e7a62d
--- /dev/null
+++ b/includes/class/template/module/mcl_template_image.class.inc
@@ -0,0 +1,74 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for field book sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'file_name' => array('req' => TRUE,'width' => 10, 'desc' => "Name of the image file."),
+ 'image_type' => array('req' => TRUE,'width' => 10, 'desc' => "The type of the image file."),
+ 'file_legend' => array('req' => TRUE,'width' => 10, 'desc' => "Legend of the image file."),
+ 'comments' => array('req' => TRUE,'width' => 10, 'desc' => "Any comments for the image file."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['photo_provider'] = -1;
+ $cvterms['SITE_CV']['legend'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+
+
+
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_library.class.inc b/includes/class/template/module/mcl_template_library.class.inc
new file mode 100644
index 0000000..dc84d7a
--- /dev/null
+++ b/includes/class/template/module/mcl_template_library.class.inc
@@ -0,0 +1,97 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for library sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'library_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the library (or SNP chip name)."),
+ 'type' => array('req' => TRUE, 'width' => 10, 'desc' => "Type of the library ('SNP_chip' for the SNP chip data)."),
+ 'pi' => array('req' => FALSE, 'width' => 10, 'desc' => "PI of the project."),
+ 'description' => array('req' => FALSE, 'width' => 10, 'desc' => "Description of the library."),
+ 'reference' => array('req' => FALSE, 'width' => 10, 'desc' => "pub_id for any reference."),
+ );
+
+ // Adds labels.
+ $headers['pi']['label'] = 'PI';
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['SNP_chip'] = -1;
+ $cvterms['SITE_CV']['description'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks type.
+ MCL_CHADO_CVTERM::checkCvterm($this, 'SITE_CV', $line['type']);
+
+ // Checks PI.
+ MCL_CHADO_CONTACT::checkContact($this, $line['pi']);
+
+ // Checks references.
+ MCL_CHADO_PUB::checkPub($this, $line['reference'], '[;,]');
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Adds a library.
+ $type_id = MCL_CHADO_CVTERM::getCvterm('SITE_CV', $line['type']);
+ $library = MCL_CHADO_LIBRARY::addLibrary($this, $line['library_name'], $type_id);
+ if ($library) {
+
+ // Adds properties.
+ $library->addProp($this, 'SITE_CV', 'description', $line['description']);
+
+ // Adds PI.
+ $library->addContact($this, $line['pi']);
+
+ // Adds references.
+ $library->addReference($this, $line['reference'], "[,;]");
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_map.class.inc b/includes/class/template/module/mcl_template_map.class.inc
new file mode 100644
index 0000000..745374c
--- /dev/null
+++ b/includes/class/template/module/mcl_template_map.class.inc
@@ -0,0 +1,127 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for map sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'map_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the map given by the database curator - follow each database's naming convention."),
+ 'genus' => array('req' => TRUE, 'width' => 10, 'desc' => "Genus of the mapping population."),
+ 'species' => array('req' => TRUE, 'width' => 10, 'desc' => "species of the mapping population. Multiple species can be entered with ';' in between for the mapping populations from inter-specific crosses."),
+ 'map_unit' => array('req' => TRUE, 'width' => 10, 'desc' => "cM, bp, etc."),
+ 'analysis_method' => array('req' => FALSE, 'width' => 10, 'desc' => "Analysis method for the mapping."),
+ 'software' => array('req' => FALSE, 'width' => 10, 'desc' => "Software used for map construction."),
+ 'map_type' => array('req' => FALSE, 'width' => 10, 'desc' => "genetic, physical, cytogenetic, sequence."),
+ 'population_type' => array('req' => FALSE, 'width' => 10, 'desc' => "F2, BC1, RIL, etc."),
+ 'population_size' => array('req' => FALSE, 'width' => 10, 'desc' => "Size of population."),
+ 'population_name' => array('req' => FALSE, 'width' => 10, 'desc' => "Name of the mapping population. It should match 'stock_name' column of the Stock sheet."),
+ 'source_url' => array('req' => FALSE, 'width' => 10, 'desc' => "Map data source website."),
+ 'comments' => array('req' => FALSE, 'width' => 10, 'desc' => "Any comments for the map."),
+ 'genome_group' => array('req' => FALSE, 'width' => 10, 'desc' => "Specific genome groups if available (eg. A, D etc for cotton)."),
+ 'contact' => array('req' => FALSE, 'width' => 10, 'desc' => "Contact person for the map."),
+ 'reference' => array('req' => FALSE, 'width' => 10, 'desc' => "pub_id of the reference."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['alias'] = -1;
+ $cvterms['SITE_CV']['analysis_method'] = -1;
+ $cvterms['SITE_CV']['software'] = -1;
+ $cvterms['SITE_CV']['map_type'] = -1;
+ $cvterms['SITE_CV']['population_type'] = -1;
+ $cvterms['SITE_CV']['population_size'] = -1;
+ $cvterms['SITE_CV']['source_url'] = -1;
+ $cvterms['SITE_CV']['comments'] = -1;
+ $cvterms['SITE_CV']['genome_group'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks organism for map.
+ MCL_CHADO_ORGANISM::checkOrganism($this, $line['genus'], $line['species'], '[;,]');
+
+ // Checks map_unit.
+ MCL_CHADO_FEATUREMAP::checkMapUnit($this, $line['map_unit']);
+
+ // Checks contacts.
+ MCL_CHADO_CONTACT::checkContact($this, $line['contact'], '[;,]');
+
+ // Checks references.
+ MCL_CHADO_PUB::checkPub($this, $line['reference'], '[;,]');
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Adds a map.
+ $map = MCL_CHADO_FEATUREMAP::addMap($this, $line['map_name'], $line['map_unit'], $line['description']);
+ if ($map) {
+
+ // Adds properties.
+ $map->addProp($this, 'SITE_CV', 'analysis_method', $line['analysis_method']);
+ $map->addProp($this, 'SITE_CV', 'software', $line['software']);
+ $map->addProp($this, 'SITE_CV', 'map_type', $line['map_type']);
+ $map->addProp($this, 'SITE_CV', 'population_type', $line['population_type']);
+ $map->addProp($this, 'SITE_CV', 'population_size', $line['population_size']);
+ $map->addProp($this, 'SITE_CV', 'source_url', $line['source_url']);
+ $map->addProp($this, 'SITE_CV', 'genome_group', $line['genome_group']);
+ $map->addProp($this, 'SITE_CV', 'comments', $line['comments']);
+
+ // Adds organisms.
+ $map->addOrganism($this, $line['genus'], $line['species'], "[,;]");
+
+ // Adds stocks.
+ $map->addStock($this, $line['population_name'], $line['genus'], $line['species'], "[,;]");
+
+ // Adds contacts.
+ $map->addContact($this, $line['contact'], "[,;]");
+
+ // Adds references.
+ $map->addReference($this, $line['references'], "[,;]");
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_map_position.class.inc b/includes/class/template/module/mcl_template_map_position.class.inc
new file mode 100644
index 0000000..aca893e
--- /dev/null
+++ b/includes/class/template/module/mcl_template_map_position.class.inc
@@ -0,0 +1,235 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for map_position sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'marker_qtl_mtl' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the marker, QTL or MTL. Please provide the detailr data in 'Marker', 'QTL', or 'MTL' sheet."),
+ 'locus_name' => array('req' => FALSE, 'width' => 10, 'desc' => "When a RFLP (eg. AA07) corresponds to more than one locus, the marker name (eg. AA07) is recorded in marker/qtl/mtl column and the specific name for each map position (eg. AA07A, AA07B) is recorded in this 'locus_name' column. Use AA07 as a marker name and the loci names as aliases for the marker name in 'Marker' Sheet. When a MTL is mapped to multiple locations, use the MTL_name in 'MTL' sheet in 'marker/qtl/mtl' column and the locus name of the specific map position in 'locus_name'' colum."),
+ 'genus' => array('req' => TRUE, 'width' => 10, 'desc' => "The genus name of the organism from which the marker was developed."),
+ 'species' => array('req' => TRUE, 'width' => 10, 'desc' => "The species name of the organism from which the marker was developed. Enter 'sp.' to represent one unknown species, 'spp.' to represent multiple unknown species."),
+ 'map_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the genetic map."),
+ 'linkage_group' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the linkage group."),
+ 'linkage_group_order' => array('req' => FALSE, 'width' => 10, 'desc' => "The order of linkage groups for display. Some maps have linkage groups orders of which are not obvious such as G1V, G1G, G2V, etc."),
+ 'chr_name' => array('req' => FALSE, 'width' => 10, 'desc' => "Chromosome name for the linkage group when it\'s known (eg. At1, Dt1, etc in cotton)."),
+ 'chr_number' => array('req' => FALSE, 'width' => 10, 'desc' => "Chromosome number for the linkage group when it\'s known (eg. chr1, chr26, etc)."),
+ 'chromosome_arm' => array('req' => FALSE, 'width' => 10, 'desc' => "Name of the chromosome_arm for fish map."),
+ 'bin_name' => array('req' => FALSE, 'width' => 10, 'desc' => "Name of the bin if the locus is belongs to a bin. If a molecular marker belongs to multiple bins, list all of them in separate rows."),
+ 'start' => array('req' => FALSE, 'width' => 10, 'desc' => "The position of the locus (cM) or start position of the QTL."),
+ 'stop' => array('req' => FALSE, 'width' => 10, 'desc' => "The end position of the QTL or marker when a marker corresponds to a region in a genome."),
+ 'qtl_peak' => array('req' => FALSE, 'width' => 10, 'desc' => "Center position or the most likely position of the QTL."),
+ 'comments' => array('req' => FALSE, 'width' => 10, 'desc' => "Any comments for the map position."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['bin'] = -1;
+ $cvterms['SITE_CV']['start'] = -1;
+ $cvterms['SITE_CV']['stop'] = -1;
+ $cvterms['SITE_CV']['qtl_peak'] = -1;
+ $cvterms['SITE_CV']['comments'] = -1;
+ $cvterms['SITE_CV']['chr_name'] = -1;
+ $cvterms['SITE_CV']['chr_number'] = -1;
+ $cvterms['sequence']['marker_locus'] = -1;
+ $cvterms['sequence']['genetic_marker'] = -1;
+ $cvterms['sequence']['qtl'] = -1;
+ $cvterms['sequence']['heritable_phenotypic_marker'] = -1;
+ $cvterms['sequence']['linkage_group'] = -1;
+ $cvterms['sequence']['chromosome_arm'] = -1;
+ $cvterms['relationship']['contained_in'] = -1;
+ $cvterms['relationship']['instance_of'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks organisms.
+ MCL_CHADO_ORGANISM::checkOrganism($this, $line['genus'], $line['species']);
+
+ // Checks map.
+ MCL_CHADO_FEATUREMAP::checkMap($this, $line['map_name']);
+
+ // Checks marker_qtl_mtl. It must be generic marker, MTL or QTL.
+ $organism = MCL_CHADO_ORGANISM::getOrganism($line['genus'], $line['species']);
+ $marker_qtl_mtl = $line['marker_qtl_mtl'];
+ $args = array(
+ 'uniquename' => $marker_qtl_mtl,
+ 'organism_id' => $organism->getOrganismID(),
+ 'type_id' => $this->cvterms['sequence']['genetic_marker'],
+ );
+ $feature = MCL_CHADO_FEATURE::byKey($args);
+ if (!$feature) {
+
+ $args['type_id'] = $this->cvterms['sequence']['qtl'];
+ $feature = MCL_CHADO_FEATURE::byKey($args);
+ if (!$feature) {
+
+ $args['type_id'] = $this->cvterms['sequence']['heritable_phenotypic_marker'];
+ $feature = MCL_CHADO_FEATURE::byKey($args);
+ if (!$feature) {
+ $this->updateMsg('E', "Error - $marker_qtl_mtl is not 'Marker, 'QTL' or 'MTL'");
+ }
+ }
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Gets the organism_id.
+ $organism = MCL_CHADO_ORGANISM::getOrganism($line['genus'], $line['species']);
+ $organism_id = $organism->getorganismID();
+
+ // Gets the feature. It must be marker, QTL or MTL.
+ $marker_qtl_mtl = $line['marker_qtl_mtl'];
+ $args = array(
+ 'uniquename' => $marker_qtl_mtl,
+ 'organism_id' => $organism_id,
+ 'type_id' => $marker,
+ );
+ $feature = MCL_CHADO_FEATURE::byKey($args);
+ if (!$feature) {
+ $args['type_id'] = $this->cvterms['sequence']['qtl'];
+ $feature = MCL_CHADO_FEATURE::byKey($args);
+ if (!$feature) {
+ $args['type_id'] = $this->cvterms['sequence']['heritable_phenotypic_marker'];
+ $feature = MCL_CHADO_FEATURE::byKey($args);
+ }
+ }
+
+ // Adds a locus if this is a genetic marker. If locus name is empty,
+ // use $marker_qtl_mtl.
+ if ($feature->getTypeID() == $this->cvterms['sequence']['genetic_marker']) {
+ $locus_name = ($line['locus_name']) ? $line['locus_name'] : $marker_qtl_mtl;
+ $locus = MCL_CHADO_FEATURE::addFeature($this, $locus_name, $locus_name, $this->cvterms['sequence']['marker_locus'], $organism_id);
+ if ($locus) {
+
+ // Adds a relationship.
+ $bin->addRelatedFeature($this, $feature, $this->cvterms['relationship']['instance_of']);
+ }
+ }
+
+ // Gets the map.
+ $map = MCL_CHADO_FEATUREMAP::byKey(array('name' => $line['map_name']));
+
+ // Adds a linkage group.
+ $linkage_group = $link['linkage_group'];
+
+ // Gets organism ID for a linkage group.
+ $organism_id_lg = MCL_VAR::getValueByName('ORGANISM_ID');
+
+ // Adds a linkage group.
+ $uniquename = $map->getName() . '.' . $linkage_group;
+ $linkage_group = MCL_CHADO_FEATURE::addFeature($this, $uniquename, $linkage_group, $this->cvterms['sequence']['linkage_group'], $organism_id);
+
+ // Adds properties.
+ $linkage_group->addProp($this, 'SITE_CV', 'chr_name', $line['chr_name']);
+ $linkage_group->addProp($this, 'SITE_CV', 'chr_number', $line['chr_number']);
+
+ // Adds a chromosome arm
+ $chromosome_arm_name = $line['chromosome_arm'];
+ if ($chromosome_arm_name) {
+ $chromosome_arm = MCL_CHADO_FEATURE::addFeature($this, $chromosome_arm_name, $chromosome_arm_name, $this->cvterms['sequence']['chromosome_arm'], $organism_id);
+ if ($chromosome_arm) {
+
+ // Adds a relationship.
+ $feature->addRelatedFeature($this, $chromosome_arm, $this->cvterms['relationship']['contained_in']);
+ }
+ }
+
+ // Adds a bin.
+ $bin_name = $line['bin_name'];
+ if ($bin_name) {
+ $uniquename = $map->getName() . '.' . $bin_name;
+ $bin = MCL_CHADO_FEATURE::addFeature($this, $uniquename, '', $chromosome_arm_name, $this->cvterms['SITE_CV']['bin'], $organism_id);
+ if ($bin) {
+
+ // Adds a relationship.
+ if ($locus) {
+ $locus->addRelatedFeature($this, $bin, $this->cvterms['relationship']['contained_in']);
+ }
+ else {
+ $feature->addRelatedFeature($this, $bin, $this->cvterms['relationship']['contained_in']);
+ }
+ }
+ }
+
+ // Adds a featurepos if the linkage_group and any of start, stop or qtl_peak exist.
+ $start = $line['start'];
+ $stop = $line['stop'];
+ $qtl_peak = $line['qtl_peak'];
+ $data = trim($start.$stop.$qtl_peak);
+ if ($data && $linkage_group) {
+
+ // Adds a featurepos.
+ $featurepos = MCL_CHADO_FEATUREPOS::addFeaturepos($this, $feature, $map, $linkage_group);
+ if ($featurepos) {
+
+ // Adds properties.
+ $featurepos->addProp($this, 'SITE_CV', 'start', $line['start']);
+ $featurepos->addProp($this, 'SITE_CV', 'stop', $line['stop']);
+ $featurepos->addProp($this, 'SITE_CV', 'qtl_peak', $line['qtl_peak']);
+ $featurepos->addProp($this, 'SITE_CV', 'comments', $line['comments']);
+
+
+ // Adds a featurepos if the linkage_group, the bin and either start or stop exist.
+ $data = trim($start.$stop);
+ if ($data && $linkage_group && $bin) {
+
+ // Adds a featurepos.
+ $featurepos = MCL_CHADO_FEATUREPOS::addFeaturepos($this, $bin, $map, $linkage_group);
+ if ($featurepos) {
+
+ // Adds properties.
+ $featurepos->addProp($this, 'SITE_CV', 'start', $line['start']);
+ $featurepos->addProp($this, 'SITE_CV', 'stop', $line['stop']);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_marker.class.inc b/includes/class/template/module/mcl_template_marker.class.inc
new file mode 100644
index 0000000..da65716
--- /dev/null
+++ b/includes/class/template/module/mcl_template_marker.class.inc
@@ -0,0 +1,250 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for marker sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'marker_name' => array('req' => TRUE, 'width' => 10, 'desc' =>"Name of the marker."),
+ 'marker_type' => array('req' => FALSE, 'width' => 10, 'desc' =>"Marker type such as SSR, RFLP, RAPD, STS, SCAR, overgo probe and Isozyme. Refer to the available marker_type page for each database."),
+ 'genus' => array('req' => TRUE, 'width' => 10, 'desc' =>"The genus name of the organism from which the marker was developed."),
+ 'species' => array('req' => TRUE, 'width' => 10, 'desc' =>"The species name of the organism from which the marker was developed. Enter 'sp.' to represent one unknown species, 'spp.' to represent multiple unknown species."),
+ 'alias' => array('req' => FALSE, 'width' => 10, 'desc' =>"Other names used for the marker. Multiple aliases, separated by a semicolon (;), can be added."),
+ 'marker_sequence' => array('req' => FALSE, 'width' => 10, 'desc' =>"Sequence of the marker when available. For SNP, it should be in the format of 5'flanking sequence[A/T] 3'flanking sequence."),
+ 'gb_id' => array('req' => FALSE, 'width' => 10, 'desc' =>"Associated GenBank ID of the marker or the source of the marker (eg. EST)."),
+ 'dbsnp_id' => array('req' => FALSE, 'width' => 10, 'desc' =>"Associated dbSNP_ID. #ss number should be used."),
+ 'five_prime_flanking_seq' => array('req' => FALSE, 'width' => 10, 'desc' =>"5' flanking sequence of SNP or Indel."),
+ 'three_prime_flanking_seq' => array('req' => FALSE, 'width' => 10, 'desc' =>"3' flanking sequence of SNP or Indel."),
+ 'shared_species' => array('req' => FALSE, 'width' => 10, 'desc' =>"Species names of organisms that have been found to have the same SNP. If there are more than one other species, using ';' to separate."),
+ 'repeat_motif' => array('req' => FALSE, 'width' => 10, 'desc' =>"Repeat motif for SSR markers."),
+ 'snp_chip_name' => array('req' => FALSE, 'width' => 10, 'desc' => "SNP chip name when SNPs belong to a chip (the name should match 'name' in Library sheet."),
+ 'snp_chip_id' => array('req' => FALSE, 'width' => 10, 'desc' => "SNP chip ID if there is a specific ID for the specific SNP chip entered in 'SNP_chip_ID'."),
+ 'restriction_enzyme' => array('req' => FALSE, 'width' => 10, 'desc' =>"Restriction Enzyme used for CAPS marker or other markers that use restriction enzymes."),
+ 'product_length' => array('req' => FALSE, 'width' => 10, 'desc' =>"The PCR product length from the source species of the marker."),
+ 'max_length' => array('req' => FALSE, 'width' => 10, 'desc' =>"The maximum product size that have been observed."),
+ 'min_length' => array('req' => FALSE, 'width' => 10, 'desc' =>"The minimum product size that have been observed."),
+ 'is_codominant' => array('req' => FALSE, 'width' => 10, 'desc' =>"Yes if the marker is codominant, No otherwise."),
+ 'pcr_condition' => array('req' => FALSE, 'width' => 10, 'desc' =>"PCR condition for PCR-based markers."),
+ 'screening_method' => array('req' => FALSE, 'width' => 10, 'desc' =>"Gel type, % etc (eg. 2% agarose) for PCR product visualization and any other screening methods for other types of markers."),
+ 'monomorphic_population' => array('req' => FALSE, 'width' => 10, 'desc' =>"The name of the mapping population of which the marker was monomorphic."),
+ 'source_marker_name' => array('req' => FALSE, 'width' => 10, 'desc' =>"The name of the marker from which the marker is generated (STS, SSR or SCAR markers are often generated from other markers). The detail of the source marker should be given in a separate row."),
+ 'source_description' => array('req' => FALSE, 'width' => 10, 'desc' =>"Whether the marker was developed from the sequence of EST, BAC, cDNA, genomic clone, or WGS."),
+ 'indel_seq' => array('req' => FALSE, 'width' => 10, 'desc' =>"sequences of indel (eg. ATT)."),
+ 'alleles' => array('req' => FALSE, 'width' => 10, 'desc' =>"Alleles for the SNP marker (eg. A/T)."),
+ 'gel_picture_file_name' => array('req' => FALSE, 'width' => 10, 'desc' =>"File name of the gel picture if available."),
+ 'gel_picture_legend' => array('req' => FALSE, 'width' => 10, 'desc' =>"Legend of the gel picture if available."),
+ 'comments' => array('req' => FALSE, 'width' => 10, 'desc' =>"Any comments about the marker."),
+ 'variety' => array('req' => FALSE, 'width' => 10, 'desc' =>"The variety from which the marker was developed. It should match a 'stock_name' in the Stock sheet."),
+ 'image' => array('req' => FALSE, 'width' => 10, 'desc' =>"Image_ID of any associated image (Detailed info in 'Image' sheet.) Multiple images, separated by comma, can be added."),
+ 'contact' => array('req' => FALSE, 'width' => 10, 'desc' =>"Contact person for the marker (Please provide the contact info of these researchers in 'Contact' sheet)."),
+ 'reference' => array('req' => FALSE, 'width' => 10, 'desc' =>"Reference where the marker is originally described (pub_id), Multiple references, separated by comma, can be added."),
+ );
+
+ // Adds labels.
+ $headers['gb_id']['label'] = 'GB_ID';
+ $headers['dbsnp_id']['label'] = 'dbSNP_ID';
+ $headers['pcr_condition']['label'] = 'PCR_condition';
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['alias'] = -1;
+ $cvterms['SITE_CV']['marker_type'] = -1;
+ $cvterms['SITE_CV']['restriction_enzyme'] = -1;
+ $cvterms['SITE_CV']['product_length'] = -1;
+ $cvterms['SITE_CV']['max_length'] = -1;
+ $cvterms['SITE_CV']['min_length'] = -1;
+ $cvterms['SITE_CV']['is_codominant'] = -1;
+ $cvterms['SITE_CV']['repeat_motif'] = -1;
+ $cvterms['SITE_CV']['source'] = -1;
+ $cvterms['SITE_CV']['pcr_condition'] = -1;
+ $cvterms['SITE_CV']['screening_method'] = -1;
+ $cvterms['SITE_CV']['monomorphic_population'] = -1;
+ $cvterms['SITE_CV']['filename'] = -1;
+ $cvterms['SITE_CV']['indel_seq'] = -1;
+ $cvterms['SITE_CV']['legend'] = -1;
+ $cvterms['SITE_CV']['comments'] = -1;
+ $cvterms['SITE_CV']['SNP_chip'] = -1;
+ $cvterms['sequence']['genetic_marker'] = -1;
+ $cvterms['sequence']['primer'] = -1;
+ $cvterms['sequence']['probe'] = -1;
+ $cvterms['sequence']['associated_with'] = -1;
+ $cvterms['sequence']['five_prime_flanking_region'] = -1;
+ $cvterms['sequence']['three_prime_flanking_region'] = -1;
+ $cvterms['sequence']['allele'] = -1;
+ $cvterms['sequence']['SNP'] = -1;
+ $cvterms['relationship']['adjacent_to'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks db.
+ MCL_CHADO_DB::checkDB($this, 'dbSNP');
+ MCL_CHADO_DB::checkDB($this, 'DB:genbank');
+
+ // Checks organism.
+ MCL_CHADO_ORGANISM::checkOrganism($this, $line['genus'], $line['species']);
+
+ // Checks SNP_chip_name.
+// MCL_CHADO_LIBRARY::checkLibrary($this, $line['snp_chip']);
+
+ // Checks contacts.
+ MCL_CHADO_CONTACT::checkContact($this, $line['contact'], '[;,]');
+
+ // Checks images.
+ MCL_CHADO_IMAGE::checkImage($this, $line['image'], '[;,]');
+
+ // Checks references.
+ MCL_CHADO_PUB::checkPub($this, $line['reference'], '[;,]');
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Gets the organism.
+ $organism = MCL_CHADO_ORGANISM::getOrganism($line['genus'], $line['species']);
+
+ // Adds a marker.
+ $marker = MCL_CHADO_FEATURE::addFeature($this, $line['marker_name'], $line['marker_name'], $this->cvterms['sequence']['genetic_marker'], $organism->getOrganismID());
+ if ($marker) {
+
+ // Updates feature.residues.
+ $marker_sequence = $line['marker_sequence'];
+ $gb_id = $line['gb_id'];
+ $five_prime_flanking_seq = $line['five_prime_flanking_seq'];
+ $three_prime_flanking_seq = $line['three_prime_flanking_seq'];
+ $alleles = $line['alleles'];
+
+ // Sets the marker_sequence to the residues.
+ $residues = '';
+ if ($marker_sequence) {
+ $residues = $marker_sequence;
+ }
+
+ // Gets the sequence from GenBank.
+ else if ($gb_id) {
+ $residues = '';
+ }
+
+ // Concatenates five_prime_flanking_seq, alleles and three_prime_flanking_seq.
+ else if ($five_prime_flanking_seq && $alleles && $three_prime_flanking_seq) {
+ $residues = $five_prime_flanking_seq . $alleles . $three_prime_flanking_seq;
+ }
+ if ($residues) {
+ $marker->setResidues($residues);
+ $marker->update();
+ }
+
+ // Adds properties.
+ $marker->addProp($this, 'SITE_CV', 'marker_type', $line['marker_type']);
+ $marker->addProp($this, 'SITE_CV', 'repeat_motif', $line['repeat_motif']);
+ $marker->addProp($this, 'SITE_CV', 'restriction_enzyme', $line['restriction_enzyme']);
+ $marker->addProp($this, 'SITE_CV', 'product_length', $line['product_length']);
+ $marker->addProp($this, 'SITE_CV', 'max_length', $line['max_length']);
+ $marker->addProp($this, 'SITE_CV', 'min_length', $line['min_length']);
+ $marker->addProp($this, 'SITE_CV', 'is_codominant', $line['is_codominant']);
+ $marker->addProp($this, 'SITE_CV', 'pcr_condition', $line['pcr_condition']);
+ $marker->addProp($this, 'SITE_CV', 'screening_method', $line['screening_method']);
+ $marker->addProp($this, 'SITE_CV', 'monomorphic_population', $line['monomorphic_population']);
+ $marker->addProp($this, 'SITE_CV', 'source', $line['source']);
+ $marker->addProp($this, 'SITE_CV', 'filename', $line['filename']);
+ $marker->addProp($this, 'SITE_CV', 'indel_seq', $line['indel_seq']);
+ $marker->addProp($this, 'SITE_CV', 'legend', $line['legend']);
+ $marker->addProp($this, 'SITE_CV', 'comments', $line['comments']);
+
+ // Adds prime flanking sequences.
+ $marker->addProp($this, 'sequence', 'five_prime_flanking_region', $line['five_prime_flanking_seq']);
+ $marker->addProp($this, 'sequence', 'three_prime_flanking_region', $line['three_prime_flanking_seq']);
+
+ // Adds alleles.
+ $type = ($line['marker_type'] == 'snp') ? 'SNP' : 'allele';
+ $marker->addProp($this, 'SITE_CV', $type, $line['alleles']);
+
+ // Adds aliases.
+ $marker->addAlias($this, $this->cvterms['SITE_CV']['alias'], $line['alias'], "[;,]");
+
+ // Adds gb_id (accession).
+ $db = MCL_CHADO_DB::getDB('DB:genbank');
+ $marker->addDBXref($this, $db->getDbID(), $line['gb_id'], "[;,]");
+
+ // Adds dbsnp_id.
+ $db = MCL_CHADO_DB::getDB('dbSNP');
+ $marker->addDBXref($this, $db->getDbID(), $line['dbsnp_id'], "[;,]");
+
+ // Adds varieties.
+ $marker->addStock($this, $line['variety'], $line['genus'], $line['species'], "[;,]");
+
+ // Adds contacts.
+ $marker->addContact($this, $line['contact'], "[;,]");
+
+ // Adds images.
+ $marker->addImage($this, $line['image'], "[;,]");
+
+ // Creates and adds snp_chip_id.
+ $library = MCL_CHADO_LIBRARY::getLibrary($line['snp_chip_name'], $this->cvterms['SITE_CV']['SNP_chip']);
+ if ($library) {
+
+ // Adds snp_chip_id as a synonym.
+ $synonym = MCL_CHADO_SYNONYM::addSynonym($this, $line['snp_chip_id'], $this->cvterms['SITE_CV']['SNP_chip']);
+
+ // Adds the synonym to marker and library.
+ if ($synonym) {
+ $marker->addSynonym($this, $synonym);
+ $library->addSynonym($this, $synonym);
+ }
+ }
+
+ // Adds references.
+ $marker->addReference($this, $line['reference'], "[;,]");
+
+ // Adds primer sequences.
+ $marker->addSequence($this, $line, '~primer', $this->cvterms['sequence']['primer'], $this->cvterms['relationship']['adjacent_to']);
+
+ // Adds probe sequences.
+ $marker->addSequence($this, $line, '~probe', $this->cvterms['sequence']['probe'], $this->cvterms['sequence']['associated_with']);
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_mtl.class.inc b/includes/class/template/module/mcl_template_mtl.class.inc
new file mode 100644
index 0000000..7ae9044
--- /dev/null
+++ b/includes/class/template/module/mcl_template_mtl.class.inc
@@ -0,0 +1,144 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for MTL sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'mtl_name' => array('req' => TRUE, 'width' => 10, 'label' => 'MTL_name', 'desc' => "Trait locus name given by curators."),
+ 'genus' => array('req' => TRUE, 'width' => 10, 'desc' => "The genus of the phenotyping material."),
+ 'species' => array('req' => TRUE, 'width' => 10, 'desc' => "The species of the phenotyping material."),
+ 'trait_name' => array('req' => FALSE, 'width' => 10, 'desc' => "Descriptive name for trait, it should be one of the crop trait ontology and should match a term in 'Trait' sheet."),
+ 'trait_descriptor_set' => array('req' => FALSE, 'width' => 10, 'desc' => "Name of the crop trait ontology. A site-wide crop trait ontology can be specified in the loader."),
+ 'gb_id' => array('req' => FALSE, 'width' => 10, 'label' => 'GB_ID', 'desc' => "Associated genbank ID if available."),
+ 'alias' => array('req' => FALSE, 'width' => 10, 'desc' => "Other names used for the trait. Multiple aliases, separated by comma, can be added."),
+ 'screening_method' => array('req' => FALSE, 'width' => 10, 'desc' => "Any specific method for the phenotypic inspection."),
+ 'description' => array('req' => FALSE, 'width' => 10, 'desc' => "Desctiption for the trait. The more detail, the better. You can describe the phenotype of the various cultivar and provide the pictures."),
+ 'published_symbol' => array('req' => FALSE, 'width' => 10, 'desc' => "Published symbol for the MTL."),
+ 'colocalized_marker' => array('req' => FALSE, 'width' => 10, 'desc' => "Molecular marker that colocalizes with the MTL."),
+ 'neighboring_marker' => array('req' => FALSE, 'width' => 10, 'desc' => "Molecular marker that is mapped near MTL. Multiple markers can be added, separated by a semicolon (;)."),
+ 'contact' => array('req' => FALSE, 'width' => 10, 'desc' => "Contact person for the MTL. It should match 'contact_name' in Contact sheet."),
+ 'image' => array('req' => FALSE, 'width' => 10, 'desc' => "Image_ID of any associated image (Detailed info in 'Image' sheet.) Multiple images, separated by comma, can be added."),
+ 'reference' => array('req' => FALSE, 'width' => 10, 'desc' => "pub_id for the reference that describes MTL. Multiple references, separated by comma, can be added."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['alias'] = -1;
+ $cvterms['SITE_CV']['screening_method'] = -1;
+ $cvterms['SITE_CV']['description'] = -1;
+ $cvterms['SITE_CV']['published_symbol'] = -1;
+ $cvterms['sequence']['genetic_marker'] = -1;
+ $cvterms['sequence']['heritable_phenotypic_marker'] = -1;
+ $cvterms['relationship']['located_in'] = -1;
+ $cvterms['relationship']['adjacent_to'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks DB for DB:genbank.
+ MCL_CHADO_DB::checkDB($this, 'DB:genbank');
+
+ // Checks organism.
+ MCL_CHADO_ORGANISM::checkOrganism($this, $line['genus'], $line['species']);
+
+ // Checks trait_descriptor_set and trait_name.
+ MCL_CHADO_CVTERM::checkCvterm($this, $line['trait_descriptor_set'], $line['trait_name']);
+
+ // Checks colocalized_markers.
+ MCL_CHADO_FEATURE::checkFeature($this, $line['neighboring_marker'], $line['genus'], $line['species'], $this->cvterms['sequence']['genetic_marker'], '[;,]');
+
+ // Checks neighboring_markers.
+ MCL_CHADO_FEATURE::checkFeature($this, $line['neighboring_marker'], $line['genus'], $line['species'], $this->cvterms['sequence']['genetic_marker'], '[;,]');
+
+ // Checks images.
+ MCL_CHADO_IMAGE::checkImage($this, $line['image'], '[;,]');
+
+ // Checks references.
+ MCL_CHADO_PUB::checkPub($this, $line['reference'], '[;,]');
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Gets the organism.
+ $organism = MCL_CHADO_ORGANISM::getOrganism($line['genus'], $line['species']);
+
+ // Adds a MTL.
+ $mtl = MCL_CHADO_FEATURE::addFeature($this, $line['mtl_name'], $line['trait_name'], $this->cvterms['sequence']['heritable_phenotypic_marker'], $organism->getOrganismID());
+ if ($mtl) {
+
+ // Adds properties.
+ $mtl->addProp($this, 'SITE_CV', 'alias', $line['alias']);
+ $mtl->addProp($this, 'SITE_CV', 'screening_method', $line['screening_method']);
+ $mtl->addProp($this, 'SITE_CV', 'description', $line['description']);
+ $mtl->addProp($this, 'SITE_CV', 'published_symbol', $line['published_symbol']);
+
+ // Adds colocalized_markers.
+ $mtl->addRelatedFeatures($this, $line['colocalized_marker'], $this->cvterms['sequence']['genetic_marker'], $this->cvterms['relationship']['adjacent_to'], "[,;]");
+
+ // Adds neighboring_markers.
+ $mtl->addRelatedFeatures($this, $line['neighboring_marker'], $this->cvterms['sequence']['genetic_marker'], $this->cvterms['relationship']['located_in'], "[,;]");
+
+ // Adds dbxref.
+ $db = MCL_CHADO_DB::getDB('DB:genbank');
+ $mtl->addDBXref($this, $db->getDbID(), $line['gb_id'], "[,;]");
+
+ /// Adds a trait.
+ $mtl->addTrait($this, $line['trait_descriptor_set'], $line['trait_name']);
+
+ // Adds contacts.
+ $mtl->addContact($this, $line['contact'], "[,;]");
+
+ // Adds images.
+ $mtl->addImage($this, $line['image'], "[,;]");
+
+ // Adds references.
+ $mtl->addReference($this, $line['reference'], "[,;]");
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_phenotype.class.inc b/includes/class/template/module/mcl_template_phenotype.class.inc
new file mode 100644
index 0000000..da81395
--- /dev/null
+++ b/includes/class/template/module/mcl_template_phenotype.class.inc
@@ -0,0 +1,281 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for phenotype sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'dataset_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the phenotyping dataset. It should match a 'dataset_name' column entry in the 'Dataset' sheet."),
+ 'stock_name' => array('req' => TRUE, 'width' => 10, 'desc' => "ID of the stock that has been phenotyped. It should match a 'stock_name' column entry in the 'Stock' sheet."),
+ 'genus' => array('req' => TRUE, 'width' => 10, 'desc' => ""),
+ 'species' => array('req' => TRUE, 'width' => 10, 'desc' => ""),
+ 'sample_id' => array('req' => TRUE, 'width' => 10, 'desc' => "The ID of the smallest sample or sub-sample that was tested (Each row should have unique sample_ID). If there is no unique sample ID, users can concatenate a set of columns that gives a unique phenotypic value and those columns become required fields. For example, if a combination of dataset_name, ID, phenotyping_date is unique for the specific phenotype, those three can be concatenated with '_' in between."),
+ 'clone_id' => array('req' => FALSE, 'width' => 10, 'desc' => "ID of a spefic clone if available (eg. individual tree)."),
+ 'evaluator' => array('req' => FALSE, 'width' => 10, 'desc' => "Person who did the phenotyping. Multiple person can be entered with ';' in between. It should match 'contact_name' of the Contact sheet."),
+ 'site_name' => array('req' => FALSE, 'width' => 10, 'desc' => "Site information where the stock for the phenotyping is planted. It should match 'site_name' in the 'Site' sheet."),
+ 'rep' => array('req' => FALSE, 'width' => 10, 'desc' => "Any repetition number."),
+ 'rootstock' => array('req' => FALSE, 'width' => 10, 'desc' => "Name of tje rootstock if the plant are grafted to a rootstock. It should match an 'stock_name' column of the 'Stock' sheet."),
+ 'plot' => array('req' => FALSE, 'width' => 10, 'desc' => "Plot name."),
+ 'row' => array('req' => FALSE, 'width' => 10, 'desc' => "Row."),
+ 'position' => array('req' => FALSE, 'width' => 10, 'desc' => "Position of the plant."),
+ 'plant_date' => array('req' => FALSE, 'width' => 10, 'desc' => "Date of the planting."),
+ 'data_year' => array('req' => FALSE, 'width' => 10, 'desc' => "Phenotyping date if only year is known."),
+ 'evaluation_date' => array('req' => FALSE, 'width' => 10, 'desc' => "Date of phenotype evaluation."),
+ 'pick_date' => array('req' => FALSE, 'width' => 10, 'desc' => "Date of the sample collection if the collection is done on a different date than the phenotype evaluation."),
+ 'fiber_pkg' => array('req' => FALSE, 'width' => 10, 'desc' => "Group of samples for phenotyping, can contain samples from multiple germplasm."),
+ 'storage_time' => array('req' => FALSE, 'width' => 10, 'desc' => "Time between collection and phenotyping."),
+ 'storage_regime' => array('req' => FALSE, 'width' => 10, 'desc' => "The condition of sample storage between the collection and phenotyping."),
+ 'comments' => array('req' => FALSE, 'width' => 10, 'desc' => "Any comments for the phenotyping."),
+ );
+
+ // Adds labels.
+ $headers['sample_id']['label'] = 'sample_ID';
+ $headers['clone_id']['label'] = 'clone_ID';
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['phenotyping'] = -1;
+ $cvterms['SITE_CV']['nd_geolocation_id'] = -1;
+ $cvterms['SITE_CV']['sample'] = -1;
+ $cvterms['SITE_CV']['sample_of'] = -1;
+ $cvterms['SITE_CV']['clone'] = -1;
+ $cvterms['SITE_CV']['clone_of'] = -1;
+ $cvterms['SITE_CV']['clone_id'] = -1;
+ $cvterms['SITE_CV']['plot'] = -1;
+ $cvterms['SITE_CV']['row'] = -1;
+ $cvterms['SITE_CV']['position'] = -1;
+ $cvterms['SITE_CV']['plant_date'] = -1;
+ $cvterms['SITE_CV']['pick_date'] = -1;
+ $cvterms['SITE_CV']['evaluation_date'] = -1;
+ $cvterms['SITE_CV']['storage_time'] = -1;
+ $cvterms['SITE_CV']['storage_regime'] = -1;
+ $cvterms['SITE_CV']['fiber_pkg'] = -1;
+ $cvterms['SITE_CV']['comments'] = -1;
+ $cvterms['SITE_CV']['trait_descriptor'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks dataset.
+ MCL_CHADO_DATASET::checkDataset($this, $line['dataset_name']);
+
+ // Checks organisms.
+ MCL_CHADO_ORGANISM::checkOrganism($this, $line['genus'], $line['species']);
+
+ // Checks stock.
+ MCL_CHADO_STOCK::checkStock($this, $line['stock_name'], $line['genus'], $line['species']);
+
+ // Checks rootstock.
+ MCL_CHADO_STOCK::checkStock($this, $line['rootstock'], $line['genus'], $line['species']);
+
+ // Checks evaluator for contact.
+ MCL_CHADO_CONTACT::checkContact($this, $line['evaluator'], '[;,]');
+
+ // Checks site.
+ MCL_CHADO_LOCATION::checkSite($this, $line['site_name']);
+
+ // Checks phenotypic descriptor.
+ $this->_checkDescriptors($line, $line['dataset_name']);
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Checks the data column. Skip this line if no data presents.
+ if ($this->isEmptyRow($line, '^#')) {
+ return TRUE;
+ }
+
+ // Gets the organims.
+ $organism = MCL_CHADO_ORGANISM::getOrganism($line['genus'], $line['species']);
+
+ // Gets the stock.
+ $args = array(
+ 'uniquename' => $line['stock_name'],
+ 'organism_id' => $organism->getOrganismID(),
+ );
+ $stock = MCL_CHADO_STOCK::byKey($args);
+ if ($stock) {
+
+ // Adds sample.
+ $sample = MCL_CHADO_STOCK::addStock($this, $line['sample_id'], '', $organism->getOrganismID(), $this->cvterms['SITE_CV']['sample']);
+ if (!$sample) {
+ return FALSE;
+ }
+
+ // Adds clone.
+ $clone = MCL_CHADO_STOCK::addStock($this, $line['clone_id'], '', $organism->getOrganismID(), $this->cvterms['SITE_CV']['clone']);
+
+ // Adds relationships between stock, sample and clone.
+ if ($clone) {
+ $clone->addRelatedStock($this, $stock, $this->cvterms['SITE_CV']['clone_of']);
+ $sample->addRelatedStock($this, $clone, $this->cvterms['SITE_CV']['sample_of']);
+ }
+ $sample->addRelatedStock($this, $stock, $this->cvterms['SITE_CV']['sample_of']);
+
+ // Gets rootstock_id.
+ $rootstock = MCL_CHADO_STOCK::getStock($line['rootstock'], $line['genus'], $line['species']);
+ $rootstock_id = '';
+ if ($rootstock) {
+ $rootstock_id = $rootstock->getStockID();
+ }
+
+ // Gets nd_geolocation_id.
+ $nd_geolocation_id = MCL_CHADO_LOCATION::getLocationIDBySite($line['site_name']);
+
+ // Adds clone properties.
+ if ($clone) {
+ $clone->addProp($this, 'SITE_CV', 'rootstock_id', $rootstock_id);
+ $clone->addProp($this, 'SITE_CV', 'nd_geolocation_id', $nd_geolocation_id);
+ $clone->addProp($this, 'SITE_CV', 'clone_id', $line['clone_id']);
+ $clone->addProp($this, 'SITE_CV', 'rep', $line['rep']);
+ $clone->addProp($this, 'SITE_CV', 'plot', $line['plot']);
+ $clone->addProp($this, 'SITE_CV', 'row', $line['row']);
+ $clone->addProp($this, 'SITE_CV', 'position', $line['position']);
+ $clone->addProp($this, 'SITE_CV', 'plant_date', $line['plant_date']);
+ }
+
+ // Adds sample properties.
+ $sample->addProp($this, 'SITE_CV', 'rootstock_id', $rootstock_id);
+ $sample->addProp($this, 'SITE_CV', 'nd_geolocation_id', $nd_geolocation_id);
+ $sample->addProp($this, 'SITE_CV', 'clone_id', $line['clone_id']);
+ $sample->addProp($this, 'SITE_CV', 'rep', $line['rep']);
+ $sample->addProp($this, 'SITE_CV', 'plot', $line['plot']);
+ $sample->addProp($this, 'SITE_CV', 'row', $line['row']);
+ $sample->addProp($this, 'SITE_CV', 'position', $line['position']);
+ $sample->addProp($this, 'SITE_CV', 'plant_date', $line['plant_date']);
+ $sample->addProp($this, 'SITE_CV', 'pick_date', $line['pick_date']);
+ $sample->addProp($this, 'SITE_CV', 'storage_time', $line['storage_time']);
+ $sample->addProp($this, 'SITE_CV', 'fiber_pkg', $line['fiber_pkg']);
+ $sample->addProp($this, 'SITE_CV', 'storage_regime', $line['storage_regime']);
+ $sample->addProp($this, 'SITE_CV', 'comments', $line['comments']);
+
+ // Gets phenotyping data.
+ foreach ($this->descriptors as $descriptor => $cvterm_id) {
+
+ // Skips if no data present.
+ if (!$line[$descriptor]) {
+ continue;
+ }
+
+ // Adds a phenotype.
+ $uniquename = $descriptor . '_' . $line[$descriptor];
+ $phenotype = MCL_CHADO_PHENOTYPE::addPhenotype($this, $uniquename, $cvterm_id, $line[$descriptor]);
+
+ // Adds a nd_experiment.
+ $nd_experiment = MCL_CHADO_ND_EXPERIMENT::addNdExperiment($this, $this->cvterms['SITE_CV']['phenotyping'], $nd_geolocation_id, $cvterm_id, $sample->getStockID());
+
+ // Adds properties.
+ $nd_experiment->addProp($this, 'SITE_CV', 'data_year', $line['data_year']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'evaluation_date', $line['evaluation_date']);
+
+ // Adds evaluators.
+ $nd_experiment->addContact($this, $line['evaluator'], "[;]");
+
+ // Adds a stock.
+ $nd_experiment->addStock($this, $sample, $sample->getTypeID());
+
+ // Adds a dataset.
+ $nd_experiment->addDataset($this, $line['dataset_name']);
+
+ // Adds a phenotype.
+ $nd_experiment->addPhenotype($this, $phenotype);
+ }
+ }
+ }
+
+ /**
+ * Checks trait descriptors. Look for the descritpors for this dataset.
+ * If found, skip. Otherwise, keep them in $this->descriptors.
+ *
+ * @param array $line
+ * @param string $dataset_name
+ */
+ private function _checkDescriptors($line, $dataset_name) {
+
+ // Gets the project ID and check for trait_descriptor.
+ $dataset = MCL_CHADO_DATASET::getDataset($dataset_name);
+ $project_id = $dataset->getProjectID();
+ $cv_name = $dataset->getProp($this, 'SITE_CV', 'trait_descriptor');
+ if (!$cv_name) {
+ $this->updateMsg('E', "$dataset_name does not have trait_descriptor as a project property");
+ return;
+ }
+
+ // Skips if the descriptors has been checked for this dataset.
+ if (array_key_exists($project_id, $this->descriptors)) {
+ return;
+ }
+
+ // Go through headers stord in the line array.
+ $descriptors = array();
+ $err_flag = FALSE;
+ foreach ($line as $column => $value) {
+ if (preg_match("/^#[A-Za-z]/", $column)) {
+
+ $cvterm_name = str_replace('#', '', $column);
+ $cvterm = MCL_CHADO_CVTERM::getCvterm($cv_name, $cvterm_name);
+ if ($cvterm) {
+ $descriptors[$column] = $cvterm->getCvtermID();
+ }
+ else {
+ $err_flag = TRUE;
+ $this->updateMsg('E', "$cvterm_name not found in cvterm");
+ }
+ }
+ }
+
+ // Updates $this->descriptor array and job property if no error found.
+ if (!$err_flag) {
+ $this->descriptors[$project_id] = $descriptors;
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_progeny.class.inc b/includes/class/template/module/mcl_template_progeny.class.inc
new file mode 100644
index 0000000..28b5027
--- /dev/null
+++ b/includes/class/template/module/mcl_template_progeny.class.inc
@@ -0,0 +1,91 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for field book sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'progeny_name' => array('req' => TRUE, 'width' => 14, 'desc' => ""),
+ 'alias' => array('req' => FALSE, 'width' => 14, 'desc' => "Record all the aliases for the cross here. The format is 'Alias type1:Alias1; Alias type2:Alias2'. When there is no specific type for an alias, just write the aliases without the specific type. (eg. Breeder:LG98-942; Institution:4321;2-F04-01)."),
+ 'genus' => array('req' => TRUE, 'width' => 10, 'desc' => ""),
+ 'species' => array('req' => TRUE, 'width' => 10, 'desc' => "When only the genus is known, write 'sp.' in the species."),
+ 'dataset_name' => array('req' => TRUE, 'width' => 14, 'desc' => ""),
+ 'cross_number' => array('req' => TRUE, 'width' => 10, 'desc' => "Specific ID of a cross that generated the progeny; Must also be found in the Cross table."),
+ 'description' => array('req' => TRUE, 'width' => 14, 'desc' => "Any other descriptive data about the selection or seedling."),
+ 'advanced_to_2nd' => array('req' => TRUE, 'width' => 10, 'desc' => "Yes if it is advanced to 2nd phase, No otherwise. Leave it empty if the selection decision is yet to be made."),
+ 'advanced_to_3rd' => array('req' => TRUE, 'width' => 10, 'desc' => "Yes if it is advanced to 3rd phase, No otherwise."),
+ 'advanced_to_4th' => array('req' => TRUE, 'width' => 10, 'desc' => "Yes if it is advanced to 4th phase, No otherwise."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['progeny'] = -1;
+ $cvterms['SITE_CV']['cross_number'] = -1;
+ $cvterms['SITE_CV']['is_a_maternal_parent_of'] = -1;
+ $cvterms['SITE_CV']['is_a_paternal_parent_of'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks organism.
+ MCL_CHADO_ORGANISM::checkOrganism($this, $line['genus'], $line['species']);
+
+ // Checks cross_number. If cross_number is not empty, check dataset_name.
+ MCL_CHADO_ND_EXPERIMENT::checkCrossNumber($this, $line['dataset_name'], $line['cross_number']);
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Gets the stock.
+ $stock = NULL;
+ if ($stock) {
+ // Adds a progeny.
+ $stock->addProgeny($this, $line['dataset_name'], $line['cross_number']);
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_qtl.class.inc b/includes/class/template/module/mcl_template_qtl.class.inc
new file mode 100644
index 0000000..9a8b492
--- /dev/null
+++ b/includes/class/template/module/mcl_template_qtl.class.inc
@@ -0,0 +1,184 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for QTL sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'dataset_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the QTL trait study, the dataset_name should exist in 'dataset_name' column of the 'Dataset' sheet."),
+ 'qtl_label' => array('req' => TRUE, 'width' => 10, 'desc' => "Official unique label of QTL given by the curator. Follow each database's naming convention."),
+ 'published_symbol' => array('req' => FALSE, 'width' => 10, 'desc' => "Published Symbol for the QTL."),
+ 'genus' => array('req' => TRUE, 'width' => 10, 'desc' => "The genus of the phenotyping material."),
+ 'species' => array('req' => TRUE, 'width' => 10, 'desc' => "The species of the phenotyping material."),
+ 'trait_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Descriptive name for trait, it should be one of the crop trait ontology and should match a term in 'Trait' sheet."),
+ 'trait_descriptor_set' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the crop trait ontology (entered by the curator who loads the data into the database)."),
+ 'alias' => array('req' => FALSE, 'width' => 10, 'desc' => "Other names for the trait, multiple aliases, separated by a semicolon (;) can be added."),
+ 'r2' => array('req' => FALSE, 'width' => 10, 'desc' => "Fraction of the total variation explained by the QTLs."),
+ 'lod' => array('req' => FALSE, 'width' => 10, 'desc' => "QTL Likelihood of odds."),
+ 'bayes_factor' => array('req' => FALSE, 'width' => 10, 'desc' => "Bayes factor."),
+ 'additive_effect' => array('req' => FALSE, 'width' => 10, 'desc' => "The average phenotype effect of substituting a q allele for a Q allele."),
+ 'dominance_effect' => array('req' => FALSE, 'width' => 10, 'desc' => "The deviation of the heterozygote phenotype from the mean of the homozygotes."),
+ 'additivity_dominance_ratio' => array('req' => FALSE, 'width' => 10, 'desc' => "The average phenotype effect of substituting a q allele for a Q allele dominance effect The deviation of the heterozygote phenotype from the mean of the homozygotes."),
+ 'direction' => array('req' => FALSE, 'width' => 10, 'desc' => " The direction of additive effect on the phenotype."),
+ 'colocalized_marker' => array('req' => FALSE, 'width' => 10, 'desc' => "Marker that are mapped within the interval defined by the QTL. Multiple markers can be added, separated by a semicolon (;)."),
+ 'neighboring_marker' => array('req' => FALSE, 'width' => 10, 'desc' => "Marker that is mapped in the nearest flanking position outside the interval defined by the QTL. Used to estimate QTL position if no appropriate colocalized markers are found. Multiple markers can be added, separated by a semicolon (;)."),
+ 'screening_method' => array('req' => FALSE, 'width' => 10, 'desc' => "Any specific method for the phenotypic inspection."),
+ 'comments' => array('req' => FALSE, 'width' => 10, 'desc' => "Any comments."),
+ 'mean' => array('req' => FALSE, 'width' => 10, 'desc' => "Mean value of the phenotype (if one QTL has multiple mean values based on the condition and/or population, enter them in QTL_trait_Data sheet."),
+ 'p_value' => array('req' => FALSE, 'width' => 10, 'desc' => "p-value."),
+ 'kw_score' => array('req' => FALSE, 'width' => 10, 'desc' => "kw score."),
+ 'variance' => array('req' => FALSE, 'width' => 10, 'desc' => "variance."),
+ 'population_low_value' => array('req' => FALSE, 'width' => 10, 'desc' => "Lowest phenotypic value."),
+ 'population_high_value' => array('req' => FALSE, 'width' => 10, 'desc' => "Maximum phenotypic value."),
+ 'reference' => array('req' => FALSE, 'width' => 10, 'desc' => "pub_id of the QTL paper."),
+ );
+
+ // Adds labels.
+ $headers['qtl_label']['label'] = 'QTL_label';
+ $headers['r2']['label'] = 'R2';
+ $headers['lod']['label'] = 'LOD';
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['alias'] = -1;
+ $cvterms['SITE_CV']['published_symbol'] = -1;
+ $cvterms['SITE_CV']['r2'] = -1;
+ $cvterms['SITE_CV']['lod'] = -1;
+ $cvterms['SITE_CV']['additive_effect'] = -1;
+ $cvterms['SITE_CV']['dominance_effect'] = -1;
+ $cvterms['SITE_CV']['additivity_dominance_ratio'] = -1;
+ $cvterms['SITE_CV']['direction'] = -1;
+ $cvterms['SITE_CV']['screening_method'] = -1;
+ $cvterms['SITE_CV']['clone'] = -1;
+ $cvterms['SITE_CV']['source'] = -1;
+ $cvterms['SITE_CV']['bayes_factor'] = -1;
+ $cvterms['SITE_CV']['p_value'] = -1;
+ $cvterms['SITE_CV']['kw_score'] = -1;
+ $cvterms['SITE_CV']['comments'] = -1;
+ $cvterms['SITE_CV']['population_low_value'] = -1;
+ $cvterms['SITE_CV']['population_high_value'] = -1;
+ $cvterms['sequence']['genetic_marker'] = -1;
+ $cvterms['sequence']['qtl'] = -1;
+ $cvterms['relationship']['located_in'] = -1;
+ $cvterms['relationship']['adjacent_to'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks dataset.
+ MCL_CHADO_DATASET::checkDataset($this, $line['dataset_name']);
+
+ // Checks organism.
+ MCL_CHADO_ORGANISM::checkOrganism($this, $line['genus'], $line['species']);
+
+ // Checks trait_descriptor_set and trait_name.
+ MCL_CHADO_CVTERM::checkCvterm($this, $line['trait_descriptor_set'], $line['trait_name']);
+
+ // Checks colocalized_markers.
+ MCL_CHADO_FEATURE::checkFeature($this, $line['colocalized_marker'], $line['genus'], $line['species'], $this->cvterms['sequence']['genetic_marker'], '[;,]');
+
+ // Checks neighboring_markers.
+ MCL_CHADO_FEATURE::checkFeature($this, $line['neighboring_marker'], $line['genus'], $line['species'], $this->cvterms['sequence']['genetic_marker'], '[;,]');
+
+ // Checks references.
+ MCL_CHADO_PUB::checkPub($this, $line['reference'], '[;,]');
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Gets the organism.
+ $organism = MCL_CHADO_ORGANISM::getOrganism($line['genus'], $line['species']);
+
+ // Adds or gets QTL.
+ $qtl = MCL_CHADO_FEATURE::addFeature($this, $line['qtl_label'], $line['trait_name'], $this->cvterms['sequence']['qtl'], $organism->getOrganismID());
+ if ($qtl) {
+
+ // Adds properties.
+ $qtl->addProp($this, 'SITE_CV', 'published_symbol', $line['published_symbol']);
+ $qtl->addProp($this, 'SITE_CV', 'r2', $line['r2']);
+ $qtl->addProp($this, 'SITE_CV', 'lod', $line['lod']);
+ $qtl->addProp($this, 'SITE_CV', 'additive_effect', $line['additive_effect']);
+ $qtl->addProp($this, 'SITE_CV', 'dominance_effect', $line['dominance_effect']);
+ $qtl->addProp($this, 'SITE_CV', 'additivity_dominance_ratio', $line['additivity_dominance_ratio']);
+ $qtl->addProp($this, 'SITE_CV', 'direction', $line['direction']);
+ $qtl->addProp($this, 'SITE_CV', 'screening_method', $line['screening_method']);
+ $qtl->addProp($this, 'SITE_CV', 'comments', $line['comments']);
+ $qtl->addProp($this, 'SITE_CV', 'mean', $line['mean']);
+ $qtl->addProp($this, 'SITE_CV', 'bayes_factor', $line['bayes_factor']);
+ $qtl->addProp($this, 'SITE_CV', 'p_value', $line['p_value']);
+ $qtl->addProp($this, 'SITE_CV', 'kw_score', $line['kw_score']);
+ $qtl->addProp($this, 'SITE_CV', 'variance', $line['variance']);
+ $qtl->addProp($this, 'SITE_CV', 'population_low_value', $line['population_low_value']);
+ $qtl->addProp($this, 'SITE_CV', 'population_high_value', $line['population_high_value']);
+
+ /// Adds trait.
+ $qtl->addTrait($this, $line['trait_descriptor_set'], $line['trait_name']);
+
+ // Adds alias.
+ $qtl->addAlias($this, $this->cvterms['SITE_CV']['alias'], $line['alias'], "[,;]");
+
+ // Adds dataset.
+ $qtl->addDataset($this, $line['dataset_name']);
+
+ // Adds colocalized_markers.
+ $qtl->addRelatedFeatures($this, $line['colocalized_marker'], $this->cvterms['sequence']['genetic_marker'], $this->cvterms['relationship']['adjacent_to'], "[,;]");
+
+ // Adds neighboring_markers.
+ $qtl->addRelatedFeatures($this, $line['neighboring_marker'], $this->cvterms['sequence']['genetic_marker'], $this->cvterms['relationship']['located_in'], "[,;]");
+
+ // Adds stocks.
+ $qtl->addStock($this, $line['source'], $line['genus'], $line['species'], "[,;]");
+
+ // Adds references.
+ $qtl->addReference($this, $line['reference'], "[,;]");
+ }
+ else {
+ $this->updateMsg('E', "Error : cannot get/add " . $line['qtl_label']);
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_qtl_trait_data.class.inc b/includes/class/template/module/mcl_template_qtl_trait_data.class.inc
new file mode 100644
index 0000000..06cfb0f
--- /dev/null
+++ b/includes/class/template/module/mcl_template_qtl_trait_data.class.inc
@@ -0,0 +1,161 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for field book sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $dataset_name_desc = "
+name of the QTL trait study, the dataset_name should exist in 'dataset_name' column of the 'Dataset' sheet.
+ A-B-C-D system
+ A: common name of species (scientific name if not available and genus name if cross-species)
+ B: trait_name (usually an article report multiple QTL for a trait)
+ C: Last name of the corresponding author
+ D: publish year";
+
+ // Sets the headers.
+ $headers = array(
+ 'dataset_name' => array('req' => TRUE, 'width' => 10, 'desc' => $dataset_name_desc),
+ 'stock_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the population or parent of the population, The name should exist in the 'stock_name' column of the 'Stock' sheet."),
+ 'genus' => array('req' => TRUE, 'width' => 10, 'desc' => "Genus to which the stock belongs to."),
+ 'species' => array('req' => TRUE, 'width' => 10, 'desc' => "Species name. Enter 'sp.' to represent one unknown species, 'spp.' to represent multiple unknown species."),
+ 'descriptor' => array('req' => TRUE, 'width' => 10, 'desc' => "Name of the trait. It should exist in 'trait_name' column of the 'Trait' sheet and 'QTL' sheet."),
+ 'trait_descriptor_set' => array('req' => TRUE, 'width' => 20, 'desc' => "The name of the crop trait ontology that is stored in cv table of chado (eg. 'rosaceae_trait_ontology' for GDR, 'cotton_trait_ontology' for cotton). In Main Lab, we develop crop trait ontology for Rosaceae, cool season food legumes, cotton and citrus, and map them to the Plant Trait Ontology."),
+ 'site_name' => array('req' => FALSE, 'width' => 10, 'desc' => "Location/environment where the plant was grown. Site_name should exist in 'site_name' column of the 'Site' sheet. If the phenotypic measurement has bee done in multiple years, create multiple site_code even if it is done in the same location."),
+ 'mean' => array('req' => TRUE, 'width' => 10, 'desc' => "Mean value of the traits for each parent and progeny."),
+ 'standard_deviation' => array('req' => FALSE, 'width' => 10, 'desc' => ""),
+ 'coefficient_of_variation' => array('req' => FALSE, 'width' => 10, 'desc' => ""),
+ 'skewness' => array('req' => FALSE, 'width' => 10, 'desc' => ""),
+ 'h2' => array('req' => FALSE, 'width' => 10, 'desc' => ""),
+ 'cl_90' => array('req' => FALSE, 'width' => 10, 'desc' => ""),
+ 'comments' => array('req' => FALSE, 'width' => 10, 'desc' => ""),
+ 'reference' => array('req' => FALSE, 'width' => 10, 'desc' => ""),
+ );
+
+ // Adds labels.
+ $headers['cl_90']['label'] = 'Cl_90';
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['phenotyping'] = -1;
+ $cvterms['SITE_CV']['statistical'] = -1;
+ $cvterms['SITE_CV']['standard_deviation'] = -1;
+ $cvterms['SITE_CV']['coefficient_of_variation'] = -1;
+ $cvterms['SITE_CV']['skewness'] = -1;
+ $cvterms['SITE_CV']['h2'] = -1;
+ $cvterms['SITE_CV']['cl_90'] = -1;
+ $cvterms['SITE_CV']['comments'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks dataset.
+ MCL_CHADO_DATASET::checkDataset($this, $line['dataset_name']);
+
+ // Cehcks descriptor.
+ MCL_CHADO_CVTERM::checkCvterm($this, $line['trait_descriptor_set'], $line['descriptor']);
+
+ // Checks organism.
+ MCL_CHADO_ORGANISM::checkOrganism($this, $line['genus'], $line['species']);
+
+ // Checks stock.
+ MCL_CHADO_STOCK::checkStock($this, $line['stock_name'], $line['genus'], $line['species']);
+
+ // Checks site.
+ MCL_CHADO_LOCATION::checkSite($this, $line['site_name']);
+
+ // Checks references.
+ MCL_CHADO_PUB::checkPub($this, $line['reference'], '[;,]');
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Gets the descriptor.
+ $descriptor = MCL_CHADO_CVTERM::getCvterm($line['trait_descriptor_set'], $line['descriptor']);
+
+ // Gets the organims.
+ $organism = MCL_CHADO_ORGANISM::getOrganism($line['genus'], $line['species']);
+
+ // Gets the stock.
+ $args = array(
+ 'uniquename' => $line['stock_name'],
+ 'organism_id' => $organism->getOrganismID(),
+ );
+ $stock = MCL_CHADO_STOCK::byKey($args);
+
+ // Gets nd_geolocation_id.
+ $nd_geolocation_id = MCL_CHADO_LOCATION::getLocationIDBySite($line['site_name']);
+
+ // Adds a phenotype (mean).
+ $uniquename = $line['descriptor'] . '_' . $line['mean'];
+ $phenotype = MCL_CHADO_PHENOTYPE::addPhenotype($this, $uniquename, $descriptor->getCvtermID(), $line['mean']);
+
+ // Adds a nd_experiment.
+ $value = $line['dataset_name'] . '_' . $line['site_name'] . '_' . $line['stock_name'] . '_' . $descriptor->getCvtermID();
+ $nd_experiment = MCL_CHADO_ND_EXPERIMENT::addNdExperiment($this, $this->cvterms['SITE_CV']['statistical'], $nd_geolocation_id, $this->cvterms['SITE_CV']['statistical'], $value);
+
+ // Adds properties.
+ $nd_experiment->addProp($this, 'SITE_CV', 'standard_deviation', $line['standard_deviation']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'coefficient_of_variation', $line['coefficient_of_variation']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'skewness', $line['skewness']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'h2', $line['h2']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'cl_90', $line['cl_90']);
+ $nd_experiment->addProp($this, 'SITE_CV', 'comments', $line['comments']);
+
+ // Adds a phenotype.
+ $nd_experiment->addPhenotype($this, $phenotype);
+
+ // Adds a stock.
+ $nd_experiment->addStock($this, $stock, $stock->getTypeID());
+
+ // Adds a dataset.
+ $nd_experiment->addDataset($this, $line['dataset_name']);
+
+ // Adds references.
+ $nd_experiment->addReference($this, $line['references'], "[,;]");
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_site.class.inc b/includes/class/template/module/mcl_template_site.class.inc
new file mode 100644
index 0000000..7311f2e
--- /dev/null
+++ b/includes/class/template/module/mcl_template_site.class.inc
@@ -0,0 +1,110 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for site sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'site_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Curator-assigned name of the site."),
+ 'latitude' => array('req' => FALSE, 'width' => 10, 'desc' => "The decimal latitude coordinate of the georeference, using positive and negative sign to indicate N and S, respectively."),
+ 'longitude' => array('req' => FALSE, 'width' => 10, 'desc' => "The decimal longitude coordinate of the georeference, using positive and negative sign to indicate E and W, respectively."),
+ 'altitude' => array('req' => FALSE, 'width' => 10, 'desc' => "The altitude (elevation) of the location in meters. If the altitude is only known as a range, this is the average, and altitude_dev will hold half of the width of the range."),
+ 'geodetic_datum' => array('req' => FALSE, 'width' => 10, 'desc' => "The geodetic system on which the geo-reference coordinates are based. For geo-references measured between 1984 and 2010, this will typically be WGS84."),
+ 'type' => array('req' => FALSE, 'width' => 10, 'desc' => "'orchard', 'nursery' or any other types of location."),
+ 'country' => array('req' => FALSE, 'width' => 10, 'desc' => "Country where the site belongs to."),
+ 'state' => array('req' => FALSE, 'width' => 10, 'desc' => "State where the site belongs to."),
+ 'region' => array('req' => FALSE, 'width' => 10, 'desc' => "Region where the site belongs to."),
+ 'address' => array('req' => FALSE, 'width' => 10, 'desc' => "The entire address except the country."),
+ 'comments' => array('req' => FALSE, 'width' => 10, 'desc' => "Any further comments on the site."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['type'] = -1;
+ $cvterms['SITE_CV']['country'] = -1;
+ $cvterms['SITE_CV']['state'] = -1;
+ $cvterms['SITE_CV']['region'] = -1;
+ $cvterms['SITE_CV']['address'] = -1;
+ $cvterms['SITE_CV']['comments'] = -1;
+ $cvterms['SITE_CV']['site_code'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+ // Checks data here ...
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Adds a location.
+ $loc_info = array();
+ if ($line['latitude']) {
+ $loc_info['latitude'] = $line['latitude'];
+ }
+ if ($line['longitude']) {
+ $loc_info['longitude'] = $line['longitude'];
+ }
+ if ($line['altitude']) {
+ $loc_info['altitude'] = $line['altitude'];
+ }
+ if ($line['geodetic_datum']) {
+ $loc_info['geodetic_datum'] = $line['geodetic_datum'];
+ }
+ $location = MCL_CHADO_LOCATION::addLocation($this, $line['site_name'], $loc_info);
+ if ($location) {
+
+ // Adds properties.
+ $location->addProp($this, 'SITE_CV', 'type', $line['type']);
+ $location->addProp($this, 'SITE_CV', 'country', $line['country']);
+ $location->addProp($this, 'SITE_CV', 'state', $line['state']);
+ $location->addProp($this, 'SITE_CV', 'region', $line['region']);
+ $location->addProp($this, 'SITE_CV', 'address', $line['address']);
+ $location->addProp($this, 'SITE_CV', 'country', $line['country']);
+ $location->addProp($this, 'SITE_CV', 'comments', $line['comments']);
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_stock.class.inc b/includes/class/template/module/mcl_template_stock.class.inc
new file mode 100644
index 0000000..1734b14
--- /dev/null
+++ b/includes/class/template/module/mcl_template_stock.class.inc
@@ -0,0 +1,202 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for stock sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {
+ $headers = array(
+ 'stock_name' => array('req' => TRUE, 'width' => 10, 'desc' => "Primary ID or name of stock. The most important ID or name (unique and stable at least within the breeding program) should be in this column. For mapping population, follow the naming convention of each database."),
+ 'germplasm_type' => array('req' => TRUE, 'width' => 10, 'desc' => "Select from the three choices (cultivar, breeding/research material, or wild/unimproved) for an individual germplasm or 'population' for a group of individual."),
+ 'genus' => array('req' => TRUE, 'width' => 10, 'desc' => "Genus to which the stock belongs to."),
+ 'species' => array('req' => TRUE, 'width' => 10, 'desc' => "Species name. Enter 'sp.' to represent one unknown species, 'spp.' to represent multiple unknown species."),
+ 'grin_id' => array('req' => FALSE, 'width' => 10, 'desc' => "Accession ID (ACID) in the GRIN database, if it is known."),
+ 'subspecies' => array('req' => FALSE, 'width' => 10, 'desc' => "Subspecies name."),
+ 'description' => array('req' => FALSE, 'width' => 10, 'desc' => "Stock_name for the pollen parent of this entry. This stock_name must also have its own record in this table (it should be entered before being listed as a parent)."),
+ 'secondary_id' => array('req' => FALSE, 'width' => 10, 'desc' => "Alternate ID or name that is commonly used to refer to the entry."),
+ 'paternal_parent' => array('req' => FALSE, 'width' => 10, 'desc' => "Stock_name for the pollen parent of this entry. This stock_name must also have its own record in this table (it should be entered before being listed as a parent)."),
+ 'maternal_parent' => array('req' => FALSE, 'width' => 10, 'desc' => "Stock_name for the seed parent of this entry. This stock_name must also have its own record in this table (it should be entered before being listed as a parent)."),
+ 'mutation_parent' => array('req' => FALSE, 'width' => 10, 'desc' => "Stock_name of the mutaion parent. This stock_name must also have its own record in this table (it should be entered before being listed as a parent)."),
+ 'selfing_parent' => array('req' => FALSE, 'width' => 10, 'desc' => "Stock_name of the selfing parent. This stock_name must also have its own record in this table (it should be entered before being listed as a parent)."),
+ 'alias' => array('req' => FALSE, 'width' => 10, 'desc' => "A concatenation of all other less commonly used names or designations for the entry. the aliases. The format is 'Alias type1:Alias1; Alias type2:Alias2'. When there is no specific type for aliases, just write the aliases without the specific type. (eg. Collector:98HT-227; Site:W6 21306; ABC-1; 21306) The format is 'Alias type1:Alias1; Alias type2:Alias2'. When there is no specific type for an alias, just write the aliases without the specific type. (eg. Collector:98HT-227; Site:W6 21306; ABC-1; 21306)."),
+ 'cultivar' => array('req' => FALSE, 'width' => 10, 'desc' => "Cultivar name if It is a named, cultivated variety."),
+ 'pedigree' => array('req' => FALSE, 'width' => 10, 'desc' => "Any additional pedigree information: When the exact parents are not known, or any additional information beyond just parents (eg. Red-fruit sport of Jonathan, Pyrus sp. X Cydonia sp., etc)."),
+ 'origin' => array('req' => FALSE, 'width' => 10, 'desc' => "The original country for the variety (especially for wild variety)."),
+ 'population_size' => array('req' => FALSE, 'width' => 10, 'desc' => "Only for type 'population'."),
+ 'germplasm_center' => array('req' => FALSE, 'width' => 10, 'desc' => "Stock center or lab where the stock is distributed. Otherwise, provide the details of the contact person in contact column (from whom the material can be obtained) in the 'Contact' sheet."),
+// 'contact' => array('req' => FALSE, 'width' => 10, 'desc' => "Contact person for the variety from whom the variety can be obtained. It should match 'contact_name' in 'Contact' sheet."),
+ 'description' => array('req' => FALSE, 'width' => 10, 'desc' => "any description for the stock."),
+ 'comments' => array('req' => FALSE, 'width' => 10, 'desc' => "Any comments on the stock."),
+ 'image' => array('req' => FALSE, 'width' => 10, 'desc' => "Image_ID of any associated image (Detailed info in 'Image' sheet.) Multiple images, separated by comma, can be added."),
+ 'reference' => array('req' => FALSE, 'width' => 10, 'desc' => "pub_id if any publication is associated with the stock."),
+ );
+
+ // Adds labels.
+ $headers['grin_id']['label'] = 'GRIN_ID';
+ $headers['secondary_id']['label'] = 'secondary_ID';
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['alias'] = -1;
+ $cvterms['SITE_CV']['germplasm_center'] = -1;
+ $cvterms['SITE_CV']['variety'] = -1;
+ $cvterms['SITE_CV']['cultivar'] = -1;
+ $cvterms['SITE_CV']['breeding_research_material'] = -1;
+ $cvterms['SITE_CV']['wild_unimproved'] = -1;
+ $cvterms['SITE_CV']['tbd'] = -1;
+ $cvterms['SITE_CV']['landrace'] = -1;
+ $cvterms['SITE_CV']['germplasm'] = -1;
+ $cvterms['SITE_CV']['population'] = -1;
+ $cvterms['SITE_CV']['species'] = -1;
+ $cvterms['SITE_CV']['is_a_maternal_parent_of'] = -1;
+ $cvterms['SITE_CV']['is_a_paternal_parent_of'] = -1;
+ $cvterms['SITE_CV']['is_a_mutation_parent_of'] = -1;
+ $cvterms['SITE_CV']['is_a_selfing_parent_of'] = -1;
+ $cvterms['SITE_CV']['maternal_parent'] = -1;
+ $cvterms['SITE_CV']['paternal_parent'] = -1;
+ $cvterms['SITE_CV']['mutation_parent'] = -1;
+ $cvterms['SITE_CV']['selfing_parent'] = -1;
+ $cvterms['SITE_CV']['pedigree'] = -1;
+ $cvterms['SITE_CV']['description'] = -1;
+ $cvterms['SITE_CV']['origin'] = -1;
+ $cvterms['SITE_CV']['comments'] = -1;
+ $cvterms['SITE_CV']['population_size'] = -1;
+ $cvterms['SITE_CV']['subspecies'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks DB for GRIN Taxonomy.
+ MCL_CHADO_DB::checkDB($this, 'GRIN Taxonomy');
+
+ // Checks organism.
+ MCL_CHADO_ORGANISM::checkOrganism($this, $line['genus'], $line['species']);
+
+ // Checks germplasm type.
+ MCL_CHADO_STOCK::checkType($this, $line['germplasm_type']);
+
+ // Checks aliases.
+ MCL_CHADO_STOCK::checkAlias($this, $line['alias'], '[;,]');
+
+ // Checks contacts.
+// MCL_CHADO_CONTACT::checkContact($this, $line['contact'], '[;,]');
+
+ // Checks images.
+ MCL_CHADO_IMAGE::checkImage($this, $line['image'], '[;,]');
+
+ // Checks references.
+ MCL_CHADO_PUB::checkPub($this, $line['reference'], '[;,]');
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Gets the organism.
+ $organism = MCL_CHADO_ORGANISM::getOrganism($line['genus'], $line['species']);
+ $organism_id = $organism->getOrganismID();
+
+ // Gets type_id.
+ $type_id = $this->cvterms['SITE_CV'][strtolower($line['germplasm_type'])];
+
+ // Updates name.
+ $name = ($line['secondary_id']) ? $line['secondary_id'] : '';
+
+ // Adds a stock.
+ $stock = MCL_CHADO_STOCK::addStock($this, $line['stock_name'], $name, $organism_id, $type_id, $name);
+ if ($stock) {
+
+ // Gets db.
+ $db = MCL_CHADO_DB::getDB('GRIN Taxonomy');
+
+ // Adds a dbxref.
+ $dbxref = MCL_CHADO_DBXREF::addDBXref($this, $db->getDbID(), $line['grin_id']);
+ if ($dbxref) {
+
+ // Adds dbxref to stock_dbxref table.
+ $stock->addDBXref($this, $dbxref);
+
+ // Updates stock.dbxref_id.
+ $stock->setDbxrefID($dbxref->getDbxrefID());
+ $stock->update();
+ }
+
+ // Adds properties.
+ $stock->addProp($this, 'SITE_CV', 'secondary_id', $line['secondary_id']);
+ $stock->addProp($this, 'SITE_CV', 'description', $line['description']);
+ $stock->addProp($this, 'SITE_CV', 'cultivar', $line['cultivar']);
+ $stock->addProp($this, 'SITE_CV', 'pedigree', $line['pedigree']);
+ $stock->addProp($this, 'SITE_CV', 'origin', $line['origin']);
+ $stock->addProp($this, 'SITE_CV', 'population_size', $line['population_size']);
+ $stock->addProp($this, 'SITE_CV', 'subspecies', $line['subspecies']);
+ $stock->addProp($this, 'SITE_CV', 'germplasm_center', $line['germplasm_center']);
+ $stock->addProp($this, 'SITE_CV', 'comments', $line['comments']);
+
+ // Adds aliases.
+ $stock->addAlias($this, $line['alias'], "[,;]");
+
+ // Adds parents.
+ $stock->addParent($this, $line['paternal_parent'], $organism_id, $this->cvterms['SITE_CV']['is_a_maternal_parent_of']);
+ $stock->addParent($this, $line['maternal_parent'], $organism_id, $this->cvterms['SITE_CV']['is_a_paternal_parent_of']);
+ $stock->addParent($this, $line['mutation_parent'], $organism_id, $this->cvterms['SITE_CV']['is_a_mutation_parent_of']);
+ $stock->addParent($this, $line['selfing_parent'], $organism_id, $this->cvterms['SITE_CV']['is_a_selfing_parent_of']);
+
+ //Adds contacts.
+// $stock->addContact($this, $line['contact'], "[,;]");
+
+ // Adds images.
+ $stock->addImage($this, $line['image'], "[,;]");
+
+ // Adds references.
+ $stock->addReference($this, $line['reference'], "[,;]");
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/class/template/module/mcl_template_trait.class.inc b/includes/class/template/module/mcl_template_trait.class.inc
new file mode 100644
index 0000000..771b3a5
--- /dev/null
+++ b/includes/class/template/module/mcl_template_trait.class.inc
@@ -0,0 +1,104 @@
+getMemberArr());
+ }
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineDescription()
+ */
+ public function defineDescription() {
+ $desc = 'The description for trait sheet';
+ return $desc;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineHeaders()
+ */
+ public function defineHeaders() {;
+ $headers = array(
+ 'trait_name' => array('req' => TRUE, 'width' => 20, 'desc' => "Trait ontology term for the database or crop. QTLs, MTLs and phenotypic descriptors used in breeding programs can be associated with trait names."),
+ 'trait_descriptor_set' => array('req' => TRUE, 'width' => 20, 'desc' => "The name of the crop trait ontology that is stored in cv table of chado (eg. 'rosaceae_trait_ontology' for GDR, 'cotton_trait_ontology' for cotton). In Main Lab, we develop crop trait ontology for Rosaceae, cool season food legumes, cotton and citrus, and map them to the Plant Trait Ontology."),
+ 'trait_category' => array('req' => FALSE, 'width' => 20, 'desc' => "The root term of the Plant Tait Ontology for the trait name. Choose one from the list (biochemical trait | growth and development trait | anatomy and morphology trait | quality trait | stature or vigor trait | sterility or fertility trait | stress trait | yield trait)."),
+ 'abbreviation' => array('req' => FALSE, 'width' => 14, 'desc' => "Abbreviation of the trait ontology term (trait_name)."),
+ 'definition' => array('req' => FALSE, 'width' => 50, 'desc' => "Definition of trait ontology term (trait_name)."),
+ );
+ return $headers;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::defineCvterms()
+ */
+ public function defineCvterms() {
+ $cvterms = array();
+ $cvterms['SITE_CV']['abbreviation'] = -1;
+ $cvterms['relationship']['is_a'] = -1;
+ return $cvterms;
+ }
+
+ /**
+ * @see MCL_TEMPLATE::runErrorCheckDataLine()
+ */
+ public function runErrorCheckDataLine($line) {
+
+ // Checks DB.
+ MCL_CHADO_DB::checkDB($this, MCL_VAR::getValueByName('SITE_DB'));
+
+ // Checks trait_descriptor_set
+ MCL_CHADO_CV::checkCV($this, $line['trait_descriptor_set']);
+
+ // Checks for trait_category.
+ MCL_CHADO_TRAIT::checkCategory($this, $line['trait_category'], $line['trait_descriptor_set']);
+ }
+
+ /**
+ * @see MCL_TEMPLATE::uploadDataLine()
+ */
+ public function uploadDataLine($line) {
+
+ // Gets db.
+ $db = MCL_CHADO_DB::getDB(MCL_VAR::getValueByName('SITE_DB'));
+
+ // Gets trait_descriptor_set.
+ $cv = MCL_CHADO_CV::getCV($line['trait_descriptor_set']);
+
+ // Adds a trait.
+ $trait = MCL_CHADO_TRAIT::addTrait($this, $db->getName(), $cv->getName(), $line['trait_name'], $line['definition']);
+ if ($trait) {
+
+ // Adds properties.
+ $trait->addProp($this, 'SITE_CV', 'abbreviation', $line['abbreviation']);
+
+ // Adds categories.
+ $trait->addCategory($this, $cv->getName(), $line['trait_category'], $this->cvterms['relationship']['is_a']);
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/form/mcl.drush.form.inc b/includes/form/mcl.drush.form.inc
new file mode 100644
index 0000000..7aec617
--- /dev/null
+++ b/includes/form/mcl.drush.form.inc
@@ -0,0 +1,135 @@
+ 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'Drush commands',
+ );
+ $form['drush']['note'] = array(
+ '#markup' => '
',
+ );
+
+ // Lists drush commands to be shown to users.
+ $cmds = array(
+ 'uploading' => array('mcl-upload-data', 'mcl-rerun-job'),
+ 'job' => array('mcl-list-jobs','mcl-job-info','mcl-delete-job'),
+ );
+
+ // Gets all drush commands for MCL.
+ $info = mcl_drush_command();
+ $collapsed = FALSE;
+ foreach ($cmds as $type => $list) {
+ foreach ($list as $cmd) {
+ $form['drush'][$cmd] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => $collapsed,
+ '#collapsible' => TRUE,
+ '#title' => $cmd,
+ );
+ if (!$collapsed) {
+ $collapsed = TRUE;
+ }
+ $form['drush'][$cmd]['table'] = array(
+ '#markup' => _get_mcl_drush_cmd_details($info[$cmd]),
+ );
+ }
+ }
+
+ // Sets form properties.
+ $form['#prefix'] = '';
+ $form['#suffix'] = '
';
+ return $form;
+}
+
+/**
+ * Returns the details of the drush command.
+ *
+ * @param array $info
+ *
+ * @return string
+ */
+function _get_mcl_drush_cmd_details($info) {
+
+ // Populates the table with the details.
+ $rows = array();
+ _get_mcl_drush_cmd_details_helper($rows, $info, 'text', 'description');
+ _get_mcl_drush_cmd_details_helper($rows, $info, 'array', 'arguments');
+ _get_mcl_drush_cmd_details_helper($rows, $info, 'array', 'options');
+ _get_mcl_drush_cmd_details_helper($rows, $info, 'array', 'examples');
+ $table_vars = array(
+ 'header' => array(),
+ 'rows' => $rows,
+ 'attributes' => array('style' => 'width:90%'),
+ );
+ return theme('table', $table_vars);
+}
+
+/**
+ * Populates $row with the command information.
+ *
+ * @param array $rows
+ * @param string $type
+ * @param string $tag
+ * @param array $info
+ *
+ * @return array
+ */
+function _get_mcl_drush_cmd_details_helper(&$rows, $info, $type, $tag) {
+ if (array_key_exists($tag, $info)) {
+ if ($type == 'text') {
+ $rows[] = array(ucfirst($tag), $info[$tag]);
+ }
+ else if ($type == 'array') {
+ $items = array();
+ foreach ($info[$tag] as $key => $val) {
+ $items[] = "$key : $val";
+ }
+ $rows[] = array(ucfirst($tag), implode('
', $items));
+ }
+ }
+}
+
+/**
+ * Ajax function which returns the form via ajax.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_drush_form_ajax_callback($form, $form_state) {
+ return $form;
+}
+
+/**
+ * Validates the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_drush_form_validate($form, &$form_state) {}
+
+/**
+ * Submits the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_drush_form_submit($form, &$form_state) {}
diff --git a/includes/form/mcl.form.inc b/includes/form/mcl.form.inc
new file mode 100644
index 0000000..483ac48
--- /dev/null
+++ b/includes/form/mcl.form.inc
@@ -0,0 +1,86 @@
+ 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'Mainlab Chado Loader',
+ );
+
+ // Descriptions of MCL.
+ $desc_drush = '';
+ if (in_array('administrator', $user->roles)) {
+ $desc_drush = "
Click 'Drush commands to see the list of drush commands that available for MCL.";
+ }
+
+ $desc = "
+ MCL (Mainlab Chado Loader) is a module that enables a user to upload biological data to chado database schema. Users are required to transfer their biological data into various types of data template files. MCL, then, uploads these data template files into a chado schema.
+
+ Click 'Templates to see the list of templates that MCL currently supports.
+
Click 'Upload Data to upload your data or see status of your currently uploaing jobs.
+ $desc_drush
+ ";
+ $form['mcl']['desc'] = array(
+ '#markup' => $desc,
+ );
+
+ // Lists of the page links.
+ $items = array();
+ $items[] = l('Templates', '/mcl/template_list');
+ $items[] = l('Upload Data', '/mcl/upload_data');
+
+ // Adds the link to the list of drush commands.
+ if (user_access('admin_mcl')) {
+ $items[] = l('Drush commands', '/mcl/drush');
+ }
+ $form['mcl']['page_link'] = array(
+ '#markup' => theme('item_list', array('items' => $items)),
+ );
+
+ // Sets form properties.
+ $form['#prefix'] = '';
+ $form['#suffix'] = '
';
+ return $form;
+}
+
+/**
+ * Ajax function which returns the form via ajax.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_form_ajax_callback($form, $form_state) {
+ return $form;
+}
+
+/**
+ * Validates the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_form_validate($form, &$form_state) {}
+
+/**
+ * Submits the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_form_submit($form, &$form_state) {}
diff --git a/includes/form/mcl.job_view.form.inc b/includes/form/mcl.job_view.form.inc
new file mode 100644
index 0000000..0c98081
--- /dev/null
+++ b/includes/form/mcl.job_view.form.inc
@@ -0,0 +1,411 @@
+ $user->uid));
+
+ // Creates a form.
+ $form = array();
+ $form['#tree'] = TRUE;
+
+ // Adds job details.
+ $form['job_view'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'Job Details',
+ );
+
+ if ($job_id) {
+
+ // Saves job ID.
+ $form['job_id'] = array(
+ '#type' => 'value',
+ '#value' => $job_id,
+ );
+
+ // Gets MCL_JOB_UPLOAD.
+ $mcl_job = MCL_JOB_UPLOAD::byKey(array('job_id' => $job_id));
+ if ($mcl_job) {
+
+ // Adds the table for job details.
+ $form['job_view']['details'] = array(
+ '#markup' => _mcl_get_detail_table($mcl_job),
+ );
+
+ // Adds re-run.
+ $form['job_re_run'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'Re-Run Job',
+ );
+ $form['job_re_run']['upload_file'] = array(
+ '#type' => 'managed_file',
+ '#title' => 'Data template file',
+ '#description' => "Please provide a data template file.",
+ '#upload_location' => $mcl_user->getUserDirURL(),
+ '#required' => TRUE,
+ '#progress_indicator' => 'bar',
+ '#upload_validators' => array(
+ 'file_validate_extensions' => array('xls xlsx zip csv'),
+ ),
+ );
+ $form['job_re_run']['rerun_btn'] = array(
+ '#type' => 'submit',
+ '#name' => 'rerun_btn',
+ '#value' => 'Re-Run the Job',
+ );
+
+ // Gets all logs.
+ $all_logs = _mcl_get_all_logs($mcl_job);
+
+ // Adds the log fieldsets.
+ $log_types = array('E', 'N', 'W', 'D');
+ foreach ($log_types as $log_type) {
+ if (array_key_exists($log_type, $all_logs)) {
+ _mcl_add_logs($form, $mcl_job, $log_type, $all_logs[$log_type]);
+ }
+ }
+ }
+ else {
+ $form['job_view']['error'] = array(
+ '#markup' => "Error : Could not find job for $job_id",
+ );
+ }
+ }
+ else {
+ $form['job_view']['error'] = array(
+ '#markup' => "Error : Please specify job ID.",
+ );
+ }
+
+ // Adds the link to 'data upload' page.
+ $form['link_upload_page'] = array(
+ '#markup' => "",
+ );
+
+ // Sets form properties.
+ $form['#prefix'] = '';
+ $form['#suffix'] = '
';
+ return $form;
+}
+
+/**
+ * Returns all logs in an array.
+ *
+ * @param MCL_JOB_UPLOAD $mcl_job
+ *
+ * @return array
+ */
+function _mcl_get_all_logs(MCL_JOB_UPLOAD $mcl_job) {
+ $all_logs = array();
+
+ // Gets the path to the public folder.
+ $public_path = drupal_realpath('public://');
+ $public_url = file_create_url('public://');
+
+ // Adds log files (Warning / Errror / Dup-Data) in recent directory.
+ $recent_dir = $mcl_job->getRecentLogDir('recent');
+ $objects = scandir($recent_dir);
+ foreach ($objects as $object) {
+ if ($object === '.' or $object === '..') {
+ continue;
+ }
+ if (is_dir("$recent_dir/$object")) {
+ preg_match("/(\d+)-([A-Z])/", $object, $matches);
+ $status_int = $matches[1];
+ $type = $matches[2];
+
+ // Skips new data log.
+ if ($type == 'N') {
+ continue;
+ }
+
+ // Initialzes the array.
+ if (!array_key_exists($type, $all_logs)) {
+ $all_logs[$type] = array();
+ }
+
+ $files = file_scan_directory("$recent_dir/$object", "/\.log$/");
+ $log_files = array();
+ foreach ($files as $filepath => $file) {
+ preg_match("/-([A-Za-z\_]+)\.log$/", $filepath, $matches2);
+ $key = $matches2[1];
+ $log_files []= array(
+ 'key' => $key,
+ 'filepath' => $filepath,
+ 'url' => "$public_url/" . str_replace($public_path, '', $filepath),
+ );
+ }
+
+ // Adds log files.
+ if (!empty($log_files)) {
+ $all_logs[$type][$status_int] = $log_files;
+ }
+ }
+
+ // Adds log files.
+ if (!empty($log_files)) {
+ $all_logs[$type][$status_int] = $log_files;
+ }
+ }
+
+ // Adds log file for new data.
+ // Gets log (new data) files in 'new_data' directory.
+ $new_data_dir = $mcl_job->getNewDataLogDir('new_data');
+ $files = file_scan_directory($new_data_dir, "/\.log$/");
+ $log_files = array();
+ krsort($files);
+ foreach ($files as $filepath => $file) {
+ preg_match("/([A-Za-z\-\_]+)-(\d+-\d+-\d+)-(\d+-\d+-\d+)\.log$/", $filepath, $matches);
+ $key = $matches[1];
+ $date = $matches[2];
+ $time = $matches[3];
+ $log_files []= array(
+ 'key' => $key,
+ 'date' => "$date $time",
+ 'filepath' => $filepath,
+ 'url' => "$public_url/" . str_replace($public_path, '', $filepath),
+ );
+ }
+
+
+ // Adds log files.
+ if (!empty($log_files)) {
+
+ // Sort by date-time.
+ usort($log_files, "_mcl_cmp_log");
+ $all_logs['N']['40'] = $log_files;
+ }
+ return $all_logs;
+}
+
+/**
+ * Comparison function for sorting array.
+ *
+ * @param associ array $a
+ * @param associ array $b
+ *
+ * @return boolean
+ */
+function _mcl_cmp_log($a, $b) {
+ return strcmp($b['date'], $a['date']);
+}
+
+/**
+ * Adds the error logs to the form.
+ *
+ * @param array $form
+ * @param MCL_JOB $mcl_job
+ * @param string $type
+ * @param array $logs
+ */
+function _mcl_add_logs(&$form, MCL_JOB $mcl_job, $log_type, $logs) {
+ $id_form = 'log_' . $log_type;
+ $id_viewer = 'id_log_viewer_' . $log_type;
+ $id_table = 'id_table_' . $log_type;
+ $id_anchor = 'anchor_' . $log_type;
+ $title = $mcl_job->getMessageType($log_type) . ' Logs';
+
+ // Adds the anchor.
+ $form[$id_anchor] = array(
+ '#markup' => "",
+ );
+
+ // Adds the log form.
+ $form[$id_form] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => ($log_type != 'E'),
+ '#collapsible' => TRUE,
+ '#title' => $title,
+ );
+
+ // Creates a table for each status.
+ $table = '';
+ $total_row = 0;
+ foreach ($logs as $status_int => $log_files) {
+ $total_row += 2;
+
+ // Populates the rows.
+ $rows = array();
+ foreach ($log_files as $log_file) {
+ $total_row++;
+ $url = $log_file['url'];
+
+ // Adds the link to view if the size of the log file is less than
+ // 15 MB (15000000 B).
+ $filepath = $log_file['filepath'];
+ $link_view = 'N/A';
+ if (file_exists($filepath) && filesize($filepath) < 15000000) {
+ $link_view = "view";
+ }
+ $row = array(
+ $log_file['key'],
+ l('download', $url, array('query' => array('downlaod' => 1))),
+ $link_view,
+ );
+ if ($log_type == 'N') {
+ $row []= $log_file['date'];
+ }
+ $rows []= $row;
+ }
+
+ // Table variables.
+ $column_name = 'Template Name';
+ if ($status_int == 20) {
+ $column_name = 'Type';
+ }
+
+ // Adds headers.
+ $headers = array(
+ $column_name,
+ array('data' => 'Download', 'style' => 'width:30px;'),
+ array('data' => 'View', 'style' => 'width:28px;'),
+ );
+ if ($log_type == 'N') {
+ $headers []= array('data' => 'Uploaded Date', 'style' => 'width:175px;');
+ }
+
+ // Sets table properties.
+ $table_width = 'width:330px;';
+ if ($log_type == 'N') {
+ $table_width = 'width:470px;';
+ }
+
+ // Creates a talbe.
+ $table_vars = array(
+ 'header' => $headers,
+ 'rows' => $rows,
+ 'empty' => 'No logs',
+ 'attributes' => array('style' => $table_width),
+ );
+
+ // Adds the caption.
+ $caption = "Status = $status_int (" . $mcl_job->trStatusIntToLabel($status_int) . ')';
+ if (!preg_match("/[ND]/", $log_type)) {
+ $table_vars['caption'] = "$caption";
+ }
+ $table .= theme('table', $table_vars);
+ }
+
+ // Creates two horizontal div and show log tale on the left and log
+ // viewer on the right.
+ $div = "
+
+
Please click view on the table.
+
+ $table
+
";
+
+ // Adds to the error logs.
+ $form[$id_form]['table'] = array(
+ '#markup' => $div,
+ );
+}
+
+/**
+ * Adds the job info. table.
+ *
+ * @parma MCL_JOB_UPLOAD $mcl_job
+ *
+ */
+function _mcl_get_detail_table(MCL_JOB_UPLOAD $mcl_job) {
+ global $base_url;
+ global $base_root;
+
+ // Adds the link to the uploaded file.
+ $mcl_file = $mcl_job->getMCLFile();
+ $link_template = l('download', 'mcl/download_file/' . $mcl_file->getFileID());
+
+ // Adds the link to download all log files in zip.
+ $link_log = l('download all', 'mcl/download_log/' . $mcl_job->getJobID());
+
+ // Gets the compete date.
+ $complete_date = $mcl_job->getCompleteDate();
+ if (!$complete_date) {
+ $complete_date = 'N/A';
+ }
+
+ // Adds job information.
+ $rows = array();
+ $rows []= array(array('data' => 'Job ID', 'style' => 'width:150px;'), $mcl_job->getJobID());
+ $rows []= array('Name', $mcl_job->getName());
+ $rows []= array('Status', $mcl_job->getStatusLabel());
+ $rows []= array('Data Template File', $link_template);
+ $rows []= array('Submit Date', $mcl_job->getSubmitDate());
+ $rows []= array('Complete Date', $complete_date);
+// $rows []= array('Log Files', $link_log);
+
+ // Table variables.
+ $table_vars = array(
+ 'header' => NULL,
+ 'rows' => $rows,
+ 'attributes' => array('style' => 'max-width:550px;'),
+ );
+ return theme('table', $table_vars);
+}
+
+/**
+ * Ajax function which returns the form via ajax.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_job_view_form_ajax_callback($form, $form_state) {
+ return $form;
+}
+
+/**
+ * Validates the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_job_view_form_validate($form, &$form_state) {}
+
+/**
+ * Submits the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_job_view_form_submit($form, &$form_state) {
+ global $user;
+
+ // Gets MCL_USER.
+ $mcl_user = MCL_USER::byKey(array('user_id' => $user->uid));
+ $user_name = $mcl_user->getName();
+ $user_dir = $mcl_user->getUserDir();
+
+ // Gets job_id.
+ $job_id = $form['job_id']['#value'];
+
+ // Gets the re-uploading file.
+ $drupal_file = file_load($form_state['values']['job_re_run']['upload_file']);
+
+ // Moves the file to the user temp space.
+ $dest_filepath = "$user_dir/tmp/" . $drupal_file->filename;
+ $target_filepath = drupal_realpath($drupal_file->uri);
+ $cmd = "mv $target_filepath $dest_filepath";
+ exec($cmd);
+
+ // Removes file form manage_file table.
+ db_delete('file_managed')
+ ->condition('fid', $drupal_file->fid, '=')
+ ->execute();
+
+ // Submits the re-uploading job.
+ $cmd = "drush mcl-rerun-job $job_id $dest_filepath --move_input &";
+ exec($cmd);
+}
diff --git a/includes/form/mcl.template.form.inc b/includes/form/mcl.template.form.inc
new file mode 100644
index 0000000..c8a316f
--- /dev/null
+++ b/includes/form/mcl.template.form.inc
@@ -0,0 +1,128 @@
+ 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'Data Template',
+ );
+
+ // Gets the information about the template.
+ _get_mcl_template_table($form, $template_id);
+
+ // Sets form properties.
+ $form['#prefix'] = '';
+ $form['#suffix'] = '
';
+ return $form;
+}
+
+/**
+ * Returns a list of all data templates in a table.
+ *
+ * @return string
+ */
+function _get_mcl_template_table(&$form, $template_id) {
+
+
+ // $template_id is empty.
+ if (!$template_id) {
+ $form['template']['table'] = array(
+ '#markup' => "",
+ );
+ return;
+ }
+
+ // Gets MCL_TEMPLATE.
+ $mcl_template = MCL_TEMPLATE::getTemplatebyID($template_id);
+
+ // No template found for $template_id.
+ if (!$mcl_template) {
+ $form['template']['table'] = array(
+ '#markup' => "Could not found a template for the template ID ($template_id). Plese select a different template in
this page ",
+ );
+ return;
+ }
+
+ // Gets the template information.
+ $rows = array();
+ $rows []= array(array('data' => 'Template Type', 'style' => 'width:90px;'), $mcl_template->getTemplateType());
+ $rows []= array('Template', $mcl_template->getTemplate());
+ $rows []= array(' ', "download");
+ $table_vars = array(
+ 'header' => NULL,
+ 'rows' => $rows,
+ 'attributes' => array('style' => 'width:40%'),
+ );
+ $form['template']['info'] = array(
+ '#markup' => theme('table', $table_vars),
+ );
+
+ // The header columns of the template.
+ $form['template']['headers'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => TRUE,
+ '#title' => "Headers",
+ );
+ $form['template']['headers']['table'] = array(
+ '#markup' => $mcl_template->getHeaderTable(),
+ );
+
+ // The cvterms of the template.
+ $form['template']['cvterms'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => TRUE,
+ '#collapsible' => TRUE,
+ '#title' => "cvterms",
+ );
+ $form['template']['cvterms']['table'] = array(
+ '#markup' => $mcl_template->getCvtermTable(),
+ );
+
+ // Table Footer.
+ $form['template']['footer'] = array(
+ '#markup' => "",
+ );
+}
+
+/**
+ * Ajax function which returns the form via ajax.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_template_form_ajax_callback($form, $form_state) {
+ return $form;
+}
+
+/**
+ * Validates the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_template_form_validate($form, &$form_state) {}
+
+/**
+ * Submits the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_template_form_submit($form, &$form_state) {}
diff --git a/includes/form/mcl.template_list.form.inc b/includes/form/mcl.template_list.form.inc
new file mode 100644
index 0000000..0389b80
--- /dev/null
+++ b/includes/form/mcl.template_list.form.inc
@@ -0,0 +1,123 @@
+ 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => FALSE,
+ '#title' => 'MCL Data Template List',
+ );
+
+ // Template description.
+ $form['template_list']['desc'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => TRUE,
+ '#collapsible' => TRUE,
+ '#title' => 'Template Description',
+ );
+ $form['template_list']['desc']['text'] = array(
+ '#markup' => MCL_TEMPLATE::getProperties(),
+ );
+
+ // Template list.
+ $form['template_list']['table'] = array(
+ '#markup' => _mcl_get_template_table(),
+ );
+
+ // Sets form properties.
+ $form['#prefix'] = '';
+ $form['#suffix'] = '
';
+ return $form;
+}
+
+/**
+ * Returns a list of all data templates in a table.
+ *
+ * @return string
+ */
+function _mcl_get_template_table() {
+
+ // Headers.
+ $headers = array(
+ array('data' => 'Template Type', 'style' => 'width:25%'),
+ 'Template', 'Details', 'Download');
+
+ // Data templates.
+ $rows = array();
+ $mcl_templates = MCL_TEMPLATE::getTemplates();
+ foreach ($mcl_templates as $mcl_template) {
+ $template_type = $mcl_template->getTemplateType();
+ $template = $mcl_template->getTemplate();
+ $template_id = $mcl_template->getTemplateID();
+ $tmpl = MCL_TEMPLATE::getTemplateByID($template_id);
+
+ // Checks if class has been defined.
+ $link_details = 'Not Defined';
+ $link_download = 'N/A';
+ if ($tmpl) {
+ $link_details = "view";
+ $link_download = "download";
+ }
+
+ // Populates rows.
+ $row = array(
+ $mcl_template->getTemplateType(),
+ $mcl_template->getTemplate(),
+ $link_details,
+ $link_download,
+ );
+ $rows []= $row;
+ }
+
+ // Table variables.
+ $table_vars = array(
+ 'header' => $headers,
+ 'rows' => $rows,
+ 'empty' => 'No Data Template',
+ 'attributes' => array('style' => 'width:100%'),
+ );
+
+ // Table Footer.
+ $footer = "";
+ return theme('table', $table_vars) . $footer;
+}
+
+/**
+ * Ajax function which returns the form via ajax.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_template_list_form_ajax_callback($form, $form_state) {
+ return $form;
+}
+
+/**
+ * Validates the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_template_list_form_validate($form, &$form_state) {}
+
+/**
+ * Submits the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_template_list_form_submit($form, &$form_state) {}
diff --git a/includes/form/mcl.upload_data.form.inc b/includes/form/mcl.upload_data.form.inc
new file mode 100644
index 0000000..e112568
--- /dev/null
+++ b/includes/form/mcl.upload_data.form.inc
@@ -0,0 +1,246 @@
+ 'fieldset',
+ '#collapsed' => TRUE,
+ '#collapsible' => TRUE,
+ '#title' => 'Uploading Data',
+ );
+
+ // Gets MCL_USER.
+ $mcl_user = MCL_USER::byKey(array('user_id' => $user->uid));
+ if (!$mcl_user) {
+ $form['upload_data']['#collapsed'] = FALSE;
+ $form['upload_data']['err'] = array(
+ '#markup' => "You don't have the permission to upload data. Please ask site manager to get the permission.",
+ );
+ }
+ else {
+
+ // Upload Data.
+ $desc = "MCL data uploading phases.
+ Phase 1 : checks syntax errors.
+ It checks syntax errors such as missing columns, missing data on required columns, miss-spelled
+ column name and so on.
+ Phase 2 : checks data errors.
+ The data errors are the errors on data in database. For instance, genus and species are
+ listed in stock data template. MCL checks if organism_id for these genus and species
+ exists in organism table. If not found, it throws an error and it adds an appropriate error
+ message to the error log file.
+ Phase 3 : uploads data templates.
+ After checking errors, it finally starts uploading data template into chado schema.
+ During the uploading phases, MCL creates several different types of log files and stores in the
+ job directory. MCL seizes the process if it finds an error and ask a user to fix the data. The
+ user goes though the all log files to find the errors and fix them. After fixing the error,
+ the user come back to the \"Upload Job\" page to re-upload the fixed data file. Then, perform
+ re-run job.
+ ";
+ $form['upload_data']['desc'] = array(
+ '#markup' => $desc,
+ );
+
+ // Adds the job table.
+ $form['job_list'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => FALSE,
+ '#collapsible' => TRUE,
+ '#title' => 'Uploading Job List',
+ );
+ $form['job_list']['job_table'] = array(
+ '#markup' => _mcl_get_uploading_job_table(),
+ );
+
+ // Adds the add form.
+ _mcl_get_add_job_form($form, $mcl_user);
+ }
+
+ $form['home_link'] = array(
+ '#markup' => "",
+ );
+
+ // Sets form properties.
+ $form['#prefix'] = '';
+ $form['#suffix'] = '
';
+ return $form;
+}
+
+/**
+ * Returns a list of all uploading jobs in a table.
+ *
+ * @return string
+ */
+function _mcl_get_uploading_job_table() {
+ global $user;
+
+ // Sets the headers.
+ $headers = array(
+ array('data' => 'Job ID', 'style' => 'width:50px'),
+ array('data' => 'Status', 'style' => 'width:60px'),
+ array('data' => 'Name', 'style' => ''),
+ array('data' => 'Submit Date', 'style' => 'width:120px'),
+ array('data' => 'Details', 'style' => 'width:40px'),
+ array('data' => 'Action', 'style' => 'width:40px'),
+ );
+
+ // Gets all jobs.
+ $mcl_jobs = MCL_JOB::getJobsByUser($user->uid);
+ $rows = array();
+ foreach ($mcl_jobs as $mcl_job) {
+ $job_id = $mcl_job->getJobID();
+
+ // Creates 'Delete' link.
+ $confirm_attr = array(
+ 'attributes' => array(
+ 'id' => 'delete_job_' . $job_id,
+ 'class' => array('use-ajax', 'mcl-confirm'),
+ )
+ );
+ $delete_link = l('delete', "mcl/delete_job/$job_id", $confirm_attr);
+
+ // Adds the row.
+ $row = array(
+ $job_id,
+ $mcl_job->getStatusLabel(),
+ $mcl_job->getName(),
+ $mcl_job->getSubmitDate(),
+ l('view', "/mcl/job_view/$job_id"),
+ $delete_link,
+ );
+ $rows []= $row;
+ }
+
+ // Gets the upload_job information.
+ $table_vars = array(
+ 'header' => $headers,
+ 'rows' => $rows,
+ 'empty' => t("You don't have any uploading job."),
+ 'attributes' => array(),
+ );
+ return theme('table', $table_vars);
+}
+
+/**
+ * Adds form elements for adding a job.
+ *
+ * @param array $form
+ * @param MCL_USER $mcl_user
+ */
+function _mcl_get_add_job_form(&$form, MCL_USER $mcl_user) {
+ global $user;
+
+ // Adds a add_upload_job form.
+ $form['add_upload_job'] = array(
+ '#type' => 'fieldset',
+ '#collapsed' => TRUE,
+ '#collapsible' => TRUE,
+ '#title' => 'Add Upload Job',
+ );
+ $form['add_upload_job']['name'] = array(
+ '#type' => 'textfield',
+ '#title' => 'Job Name',
+ '#description' => "Please specify the name of a job.",
+ '#required' => TRUE,
+ );
+ $form['add_upload_job']['upload_file'] = array(
+ '#type' => 'managed_file',
+ '#title' => 'Data template file',
+ '#description' => "Please provide a data template file.",
+ '#upload_location' => $mcl_user->getUserDirURL(),
+ '#required' => TRUE,
+ '#progress_indicator' => 'bar',
+ '#upload_validators' => array(
+ 'file_validate_extensions' => array('xls xlsx zip csv'),
+ ),
+ );
+ $form['add_upload_job']['add_btn'] = array(
+ '#type' => 'submit',
+ '#name' => 'add_btn',
+ '#value' => 'Add a uploading job',
+ );
+}
+
+/**
+ * Ajax function which returns the form via ajax.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_upload_data_form_ajax_callback($form, $form_state) {
+ return $form;
+}
+
+/**
+ * Validates the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_upload_data_form_validate($form, &$form_state) {
+ global $user;
+
+ // Checks job name for duplication.
+ $name = trim($form_state['values']['add_upload_job']['name']);
+ $mcl_job = MCL_JOB::byKey(array('name' => $name, 'user_id' => $user->uid));
+ if ($mcl_job) {
+ form_set_error('add_upload_job][name', t("The job name '$name' exists. Please change the name of the job."));
+ }
+}
+
+/**
+ * Submits the form.
+ *
+ * @param $form
+ * @param $form_state
+ */
+function mcl_upload_data_form_submit($form, &$form_state) {
+ global $user;
+
+ // Gets MCL_USER.
+ $mcl_user = MCL_USER::byKey(array('user_id' => $user->uid));
+ $user_name = $mcl_user->getName();
+ $user_dir = $mcl_user->getUserDir();
+
+ // Gets the job info.
+ $job_name = trim($form_state['values']['add_upload_job']['name']);
+ $drupal_file = file_load($form_state['values']['add_upload_job']['upload_file']);
+
+ // Create the user temp directory.
+ $user_tmp_dir = "$user_dir/tmp";
+ mcl_create_dir($user_tmp_dir);
+
+ // Moves the file to the user temp directory.
+ $dest_filepath = "$user_tmp_dir/" . $drupal_file->filename;
+ $target_filepath = drupal_realpath($drupal_file->uri);
+ $cmd = "mv $target_filepath $dest_filepath";
+ exec($cmd);
+
+ // Removes the uploaded file.
+ //file_delete($drupal_file);
+ db_delete('file_managed')
+ ->condition('fid', $drupal_file->fid, '=')
+ ->execute();
+
+ // Submits a job.
+ $cmd = "drush mcl-upload-data $user_name $dest_filepath " .
+ " --working_dir=" . $mcl_user->getUserDir() .
+ " --job_name=\"$job_name\" --move_input &";
+ exec($cmd);
+}
diff --git a/includes/mcl.inc b/includes/mcl.inc
new file mode 100644
index 0000000..6a619a6
--- /dev/null
+++ b/includes/mcl.inc
@@ -0,0 +1,207 @@
+' . t("The working directory, $working_dir, does not exist or is not writeable by the web server.") . '';
+// }
+ if ($issues) {
+ drupal_set_message($issues);
+ }
+}
+
+/**
+ * Prints the message on screen.
+ *
+ * @param string $msg
+ * @param integer $indent
+ */
+function mcl_print($msg, $indent = 0, $line_feed = 1, $period_flag = TRUE) {
+
+ // Adds indents.
+ $space = str_repeat(' ', $indent * 4);
+
+ // Adds new lines.
+ $new_lines = str_repeat("\n", $line_feed);
+
+ // Adds a period.
+ $period = ($period_flag) ? '.' : '';
+ print $space . $msg . $period . $new_lines;
+}
+
+/**
+ * Empties a dirctory
+ *
+ * @param string $dir
+ *
+ * @return boolean
+ */
+function mcl_empty_dir($dir) {
+ if (mcl_remove_dir($dir)) {
+ return mcl_create_dir($dir);
+ }
+ return FALSE;
+}
+
+/**
+ * Creates a dirctory
+ *
+ * @param string $dir
+ *
+ * @return boolean
+ */
+function mcl_create_dir($dir) {
+
+ // Creates a dirctory.
+ if(!file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
+ drupal_set_message("Cannot create directory : $dir");
+ watchdog('mcl', "Fail to create directory: %dir.", array('%dir' => $dir), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * Removes all files and sub-diretories.
+ *
+ * @param $target_dir
+ *
+ * @return boolean TRUE|FALSE
+ */
+function mcl_remove_dir($target_dir) {
+
+ if (is_dir($target_dir)) {
+
+ // Gets the files in the target directory.
+ $objects = scandir($target_dir);
+ foreach ($objects as $object) {
+
+ // Ignores the . and .. objects
+ if ($object == "." or $object == "..") {
+ continue;
+ }
+
+ // If the object is another directory then recurse.
+ if (filetype($target_dir . "/" . $object) == "dir") {
+ mcl_remove_dir($target_dir . "/" . $object);
+ }
+ // Otherwise delete the file.
+ else {
+ unlink($target_dir . "/" . $object);
+ }
+ }
+ reset($objects);
+
+ // Finaly, removes the directory.
+ return rmdir($target_dir);
+ }
+ return false;
+}
+
+/**
+ * Returns MCL public folder URL.
+ *
+ * @return string
+ */
+function mcl_get_public_URL() {
+ return file_create_url('public://') . '/mcl';
+}
+
+/**
+ * Returns MCL public folder URL.
+ *
+ * @param string $filepath
+ *
+ * @return string
+ */
+function mcl_get_rel_filepath($filepath) {
+
+ // Gets the relative path to the file.
+ $mcl_file_dir = mcl_get_config_setting('mcl_file_dir');
+ return str_replace($mcl_file_dir, '', $filepath);
+}
+
+/**
+ * Returns the all files under the provided directory.
+ *
+ * @param string $pattern
+ *
+ * @return array of string
+ */
+function mcl_retrive_files($target_dir, $pattern) {
+ $dir = new RecursiveDirectoryIterator($target_dir);
+ $ite = new RecursiveIteratorIterator($dir);
+ $files = new RegexIterator($ite, $pattern, RegexIterator::GET_MATCH);
+ $file_list = array();
+ foreach($files as $file) {
+ $file_list = array_merge($file_list, $file);
+ }
+ return $file_list;
+}
+
+/**
+ * Download all log files.
+ */
+function mcl_download_log($job_id) {
+
+ // Gets MCL_UPLOAD_JOB.
+ $mcl_job = MCL_JOB_UPLOAD::byKey(array('job_id' => $job_id));
+ $log_root_dir = dirname($mcl_job->getLogDir());
+
+ // Sets zip path and name.
+ $filename = "mcl-$job_id-" . date("Y-m-d-G-i-s") . '.zip';
+ $filepath = file_directory_temp() . "/$filename";
+
+ // Zips the folder.
+ $cmd = "cd $log_root_dir;zip -rq $filepath logs";
+ exec("which zip", $output, $return_var);
+ if ($return_var) {
+ drupal_set_message("Failed to zip the folder");
+
+// return FALSE;
+ }
+
+ // Attaches the zip file.
+ header("Content-Type: text/plain");
+ header("Content-Disposition: attachment; filename=$filename");
+ readfile($filepath);
+ exit();
+}
+
+/**
+ * Download a file.
+ *
+ * @param integer $file_id
+ */
+function mcl_download_file($file_id) {
+
+ // Gets MCL_FILE and the filepath
+ $mcl_file = MCL_FILE::byKey(array('file_id' => $file_id));
+ $filepath = $mcl_file->getFilepath();
+ $filename = basename($filepath);
+ if (!file_exists($filepath)) {
+ drupal_set_message("Error : $filepath not found");
+ drupal_goto();
+ }
+ else {
+
+ // Attaches the file.
+ header("Content-Type: text/plain");
+ header("Content-Disposition: attachment; filename=$filename");
+ header('Content-Length: ' . filesize($filepath));
+ readfile($filepath);
+ exit();
+ }
+}
diff --git a/mcl.drush.inc b/mcl.drush.inc
new file mode 100644
index 0000000..e2de3d2
--- /dev/null
+++ b/mcl.drush.inc
@@ -0,0 +1,843 @@
+ t('Dumps a database schema.'),
+ 'arguments' => array(
+ 'schema' => t('The schema name.'),
+ ),
+ 'examples' => array(
+ 'Standard example' => 'drush mcl-dump-schema [schema]',
+ ),
+ 'aliases' => array('mcl-dump'),
+ );
+ $items['mcl-run'] = array(
+ 'description' => t('Runs job in mcl_job table.'),
+ 'examples' => array(
+ 'Standard example' => 'drush mcl-run',
+ ),
+ );
+ $items['mcl-upload-data'] = array(
+ 'description' => t('Uploads data file.'),
+ 'arguments' => array(
+ 'username' => t('Drupal user name.'),
+ 'filepath' => t('The filename of the uploading file with path.'),
+ ),
+ 'options' => array(
+ 'working_dir' => t('Specifies the working directory.'),
+ 'job_name' => t('Specifies the name of a job.'),
+ 'move_input' => t('Moves the input file to the file folder in the job directory.'),
+ ),
+ 'examples' => array(
+ 'Standard example' => 'drush mcl-upload-data [username] [filepath] --working_dir=/yourpath',
+ ),
+ );
+ $items['mcl-rerun-job'] = array(
+ 'description' => t('Re-Run the uploading job.'),
+ 'arguments' => array(
+ 'job_id' => t('The job ID.'),
+ 'filepath' => t('The filename of the uploading file with path.'),
+ ),
+ 'options' => array(
+ 'force' => t('Forces to re-run the passed steps.'),
+ 'move_input' => t('Moves the input file to the file folder in the job directory.'),
+ 'status' => t('The status to start with.'),
+ 'working_dir' => t('Specifies the working directory.'),
+ ),
+ 'examples' => array(
+ 'Standard example' => 'drush mcl-rerun-job [job_id] [filepath] --status=0 --force --working_dir=/yourpath',
+ ),
+ );
+ $items['mcl-get-template'] = array(
+ 'description' => t('Generates a template in Excel format.'),
+ 'arguments' => array(
+ 'template' => t('The template name.'),
+ ),
+ 'examples' => array(
+ 'Standard example' => 'drush mcl-get-template [template]',
+ ),
+ );
+ $items['mcl-submit-uploading-job'] = array(
+ 'description' => t('Submits a uploading job.'),
+ 'arguments' => array(
+ 'username' => t('Drupal user name.'),
+ 'filepath' => t('The filename of the uploading file with path.'),
+ ),
+ 'options' => array(
+ 'working_dir' => t('Specify the working directory.'),
+ 'move_input' => t('Moves the input file to the file folder in the job directory.'),
+ ),
+ 'examples' => array(
+ 'Standard example' => 'drush mcl-submit-uploading-job [username] [filepath] --working_dir=/your_path',
+ ),
+ );
+ $items['mcl-list-jobs'] = array(
+ 'description' => t('Views a list of your jobs.'),
+ 'arguments' => array(
+ 'username' => t('Drupal user name.'),
+ ),
+ 'examples' => array(
+ 'Standard example' => 'drush mcl-list-jobs [username]',
+ ),
+ );
+ $items['mcl-job-info'] = array(
+ 'description' => t('Shows the information about a job.'),
+ 'arguments' => array(
+ 'job_id' => t('The Job ID.'),
+ ),
+ 'examples' => array(
+ 'Standard example' => 'drush mcl-job-info [job_id]',
+ ),
+ );
+ $items['mcl-delete-job'] = array(
+ 'description' => t('Deletes a job.'),
+ 'arguments' => array(
+ 'job_id' => t('The Job ID of the job to be deleted.'),
+ ),
+ 'examples' => array(
+ 'Standard example' => 'drush mcl-delete-job [job_id]',
+ ),
+ );
+ $items['mcl-generate-class'] = array(
+ 'description' => t('Generate class files.'),
+ 'arguments' => array(
+ 'module' => t('The target module.'),
+ 'schema' => t('The schema name.'),
+ 'dump_file' => t('Postgresql dump file.'),
+ 'table_file' => t('The list of tables.'),
+ ),
+ 'options' => array(
+ 'namespace' => t('Specifies the namespace.'),
+ 'overwrite' => t('Overwrite all class files in the class directory.'),
+ 'working_dir' => t('Specifies the working directory.'),
+ 'class_dir' => t('Specifies the class directory.'),
+ ),
+ 'examples' => array(
+ 'Standard example' => 'drush mcl-generate-class [module] [schema] [dump_file] [table_file] --working_dir=/yourpath',
+ ),
+ );
+ return $items;
+}
+
+/**
+ * Callback for dump-schema command.
+ *
+ * @param string $schema
+ */
+function drush_mcl_dump_schema($schema) {
+
+ // Checks arguments
+ if (!$schema) {
+ mcl_print("ERROR: please provide a name of schema", 1);
+ exit;
+ }
+
+ // Sets the target file.
+ $target_file = drupal_get_path('module', 'mcl') . "/drupal7.$schema.sql";
+
+ // Sets the command line.
+ $cmd = "pg_dump -U postgres -h localhost --no-owner --schema=$schema --schema-only drupal7 > $target_file";
+ mcl_print("Execute the following command:", 1);
+ mcl_print(">$cmd", 2);
+ exec($cmd);
+ mcl_print("DONE", 1, 3);
+}
+
+/**
+ * Callback for mcl-run command.
+ */
+function drush_mcl_run() {
+
+ // Shows job type if specifed.
+ mcl_print("Running uploading job in queue.", 1, 2);
+
+ // Launches jobs.
+ $manager = new MCL_JOB_MANAGER();
+ $manager->processJobs('upload');
+ mcl_print("DONE", 1, 3);
+}
+
+/**
+ * Callback for mcl-rerun-job command.
+ *
+ * @param string $job_id
+ * @param string $filepath
+ */
+function drush_mcl_rerun_job($job_id, $filepath) {
+
+ // Checks arguments.
+ $args = array(
+ 'job_id' => $job_id,
+ );
+ if ($filepath) {
+ $args['filepath'] = $filepath;
+ }
+ if (!mcl_check_arguments($args)) {
+ mcl_print("Error : Please check arguments", 1, 3);
+ exit;
+ }
+
+ // Gets MCL_JOB_UPLOAD.
+ $mcl_job = MCL_JOB_UPLOAD::byKey(array('job_id' => $job_id));
+
+ // Checks the status option.
+ $status = drush_get_option('status');
+ if ($status) {
+ if (is_numeric($status)) {
+
+ // Sets the status.
+ $mcl_job->setStatus($status);
+ }
+ else {
+ mcl_print("Error : The status ($status) is not numeric", 1, 3);
+ exit;
+ }
+ }
+
+ // Checks the force option.
+ $force = drush_get_option('force');
+ $force = ($force) ? TRUE : FALSE;
+ $mcl_job->setForce($force);
+
+ // Check the move_input option.
+ $move_input = drush_get_option('move_input');
+ $move_input = ($move_input) ? TRUE : FALSE;
+
+ // Checks the working_dir option.
+ $working_dir = drush_get_option('working_dir');
+ if ($working_dir) {
+ if (!mcl_check_working_dir($working_dir)) {
+ exit;
+ }
+ $mcl_job->changeWorkingDir($working_dir);
+ }
+
+ // Overwrites the input file.
+ if ($filepath) {
+
+ // Gets the new filepath.
+ $file_dir = $mcl_job->getJobDir() . '/files';
+ $new_filepath = $file_dir . '/' . basename($filepath);
+
+ // Set the new filepath.
+ $file_id = $mcl_job->getParamByKey('file_id');
+ $mcl_file = MCL_FILE::byKey(array('file_id' => $file_id));
+ $mcl_file->setFilepath($new_filepath);
+ $mcl_file->update();
+
+ // Copies it over.
+ $cmd = ($move_input) ? "mv $filepath $new_filepath" : "cp $filepath $new_filepath";
+ exec($cmd, $return_var);
+ print "$cmd\n";
+ if (!empty($return_var)) {
+ mcl_print("Fail to overwrite the file", 1, 2);
+ mcl_print($cmd, 1, 3);
+ exit;
+ }
+ }
+
+ // Sets the status to be 0 if
+ // - status is negative.
+ // - filepath is not empty.
+ if ($mcl_job->getStatus() < 0 || $filepath) {
+ $mcl_job->setStatus(0);
+ }
+
+ // Updates all changes of the job properties.
+ $mcl_job->update();
+
+ // Launches the job.
+ mcl_print("Re-running the job ($job_id)", 1, 2);
+ $manager = new MCL_JOB_MANAGER();
+ $status = $manager->processJob($mcl_job);
+ if ($status) {
+ mcl_print("DONE : The uploading job was completed without an error.", 1, 4);
+
+ // Sets the complete date if it has no date. Keep the first one.
+ $complete_date = $mcl_job->getCompleteDate();
+ if (!$complete_date) {
+ $mcl_job->setCompleteDate(date("Y-m-d G:i:s"));
+ $mcl_job->update();
+ }
+ }
+ else {
+ $job_id = $mcl_job->getJobID();
+ $opt_working_dir = '--working_dir=' . $mcl_job->getWorkingDir();
+ mcl_print("DONE : The job (Job ID = $job_id) was completed with some errors", 1, 2);
+ mcl_print("Please fix the errors and re-run this job", 2, 2);
+ mcl_print(">drush mcl-rerun-job $job_id $filepath $opt_working_dir", 2, 4, FALSE);
+ }
+}
+
+/**
+ * Callback for list jobs.
+ *
+ * @param string $username
+ */
+function drush_mcl_list_jobs($username) {
+
+ // Checks arguments.
+ $args = array(
+ 'username' => $username,
+ );
+ if (!mcl_check_arguments($args)) {
+ mcl_print("Error : Please check arguments", 1, 3);
+ exit;
+ }
+
+ // Gets MCL_USER.
+ $mcl_user = MCL_USER::byKey(array('name' => $username));
+
+ // Gets all jobs that belong to this user.
+ $manager = new MCL_JOB_MANAGER();
+ $jobs = $manager->getJobs(array('user_id' => $mcl_user->getUserID()));
+ $job_list = '';
+ foreach ($jobs as $job) {
+ $job_id = $job->getJobID();
+ $name = $job->getName();
+ $status = $job->getStatus();
+ $job_list .= "\t[$job_id] $name at $status\n";
+ }
+
+ // Print out the job list.
+ if ($job_list) {
+ mcl_print("List jobs for $username", 1);
+ mcl_print("==================================", 1);
+ mcl_print($job_list, 1);
+ mcl_print("----------------------------------", 1, 3);
+ }
+ else {
+ mcl_print("No job found for $username", 1, 3);
+ }
+}
+
+/**
+ * Callback for job info.
+ *
+ * @param string $job_id
+ */
+function drush_mcl_job_info($job_id) {
+
+ // Checks arguments.
+ $args = array(
+ 'job_id' => $job_id,
+ );
+ if (!mcl_check_arguments($args)) {
+ mcl_print("Error : Please check arguments", 1, 3);
+ exit;
+ }
+
+ // Gets MCL_JOB.
+ $mcl_job = MCL_JOB_UPLOAD::byKey(array('job_id' => $job_id));
+
+ // Gets and shows the job information.
+ $info = $mcl_job->getJobInfo();
+ mcl_print("Job Information", 1, 2);
+ foreach ($info as $key => $value) {
+ printf("%s : %s\n", $key, $value);
+ }
+ print "\n\n\n";
+}
+
+/**
+ * Callback for delete a job.
+ */
+function drush_mcl_delete_job($job_id) {
+
+ // Checks arguments.
+ $args = array(
+ 'job_id' => $job_id,
+ );
+ if (!mcl_check_arguments($args)) {
+ mcl_print("Error : Please check arguments", 1, 3);
+ exit;
+ }
+
+ // Gets MCL_JOB.
+ $mcl_job = MCL_JOB::byKey(array('job_id' => $job_id));
+ if ($mcl_job->delete()) {
+ $msg = "Job has been deleted";
+ }
+ else {
+ $msg = "Fail to delete the job";
+ }
+ mcl_print($msg, 1, 3);
+}
+
+/**
+ * Callback for uploading cvterms from an Excel file.
+ *
+ * @param string $template
+ *
+ * @return boolean
+ */
+function drush_mcl_get_template($template) {
+
+ // Checks arguments.
+ if ($template) {
+ $mcl_template = MCL_TEMPLATE::byKey(array('template' => $template));
+ if (!$mcl_template) {
+ mcl_print("Error : template ($template) have not been defined", 1, 3);
+ exit;
+ }
+ }
+ else {
+ mcl_print("Error : Please check arguments", 1, 3);
+ exit;
+ }
+
+ // Sets the file path.
+ $filepath = getcwd();
+
+ // Gets MCL_TEMPLATE.
+ $args = array(
+ 'template_id' => $mcl_template->getTemplateID(),
+ 'type' => 'cmd',
+ 'filepath' => $filepath,
+ );
+ if (mcl_download_template_excel($args)) {
+ mcl_print("\n\nTemplate file has been created in ($filepath)", 1, 3);
+ }
+ else {
+ mcl_print("Error : Failed to generate template file", 1, 3);
+ }
+}
+
+/**
+ * Callback for submitting a uploading job.
+ *
+ * @param string $username
+ * @param string $filepath
+ */
+function drush_mcl_submit_uploading_job($username, $filepath) {
+
+ // Checks arguments.
+ $args = array(
+ 'username' => $username,
+ 'filepath' => $filepath,
+ );
+ if (!mcl_check_arguments($args)) {
+ mcl_print("Error : Please check arguments", 1, 3);
+ exit;
+ }
+
+ // Checks the working_dir_dir option.
+ $working_dir = drush_get_option('working_dir');
+ if ($working_dir) {
+ if (!file_exists($working_dir)) {
+ mcl_print("Error : The working directory ($working_dir) dose not exist", 1, 3);
+ exit;
+ }
+ }
+
+ // Gets the job_name option.
+ $job_name = drush_get_option('job_name');
+
+ // Gets MCL_USER.
+ $mcl_user = MCL_USER::byKey(array('name' => $username));
+
+ // Prepares a uploading job.
+ $mcl_job = mcl_prepare_uploading_job($mcl_user, $filepath, $working_dir, $job_name, FALSE);
+ if ($mcl_job) {
+ mcl_print("Error : Failed to prepare a uploading job", 1, 3);
+ exit;
+ }
+
+ // Shows the message.
+ $msg = "\n\n\t=========================================" .
+ "\n\tUploading job has been submitted.\n\tThe notification email " .
+ "would be sent to\n\tthe following address shortly.\n\n" .
+ "\temail : " . $mcl_user->getMail() .
+ "\nJob ID : " . $mcl_job->getJobID() .
+ "\n\t-----------------------------------------\n\n\n\n\n";
+ print $msg;
+}
+
+/**
+ * Callback for uploading data file.
+ *
+ * @param string $username
+ * @param string $filepath
+ */
+function drush_mcl_upload_data($username, $filepath) {
+
+ // Checks arguments.
+ $args = array(
+ 'username' => $username,
+ 'filepath' => $filepath,
+ );
+ if (!mcl_check_arguments($args)) {
+ mcl_print("Error : Please check arguments", 1, 3);
+ exit;
+ }
+
+ // Checks the working_dir option.
+ $working_dir = drush_get_option('working_dir');
+ if (!mcl_check_working_dir($working_dir)) {
+ exit;
+ }
+
+ // Gets the job_name option.
+ $job_name = drush_get_option('job_name');
+
+ // Check the move_input option.
+ $move_input = drush_get_option('move_input');
+ $move_input = ($move_input) ? TRUE : FALSE;
+
+ // Gets MCL_USER.
+ $mcl_user = MCL_USER::byKey(array('name' => $username));
+
+ // Prepares a uploading job.
+ $mcl_job = mcl_prepare_uploading_job($mcl_user, $filepath, $move_input, $working_dir, $job_name);
+ if (!$mcl_job) {
+ mcl_print("Error : Failed to prepare a uploading job", 1, 3);
+ exit;
+ }
+
+ // Uploads the file.
+ $job_id = $mcl_job->getJobID();
+ $job_name = $mcl_job->getName();
+ mcl_print("Running $job_name (Job ID = $job_id)", 1, 2);
+ $manager = new MCL_JOB_MANAGER();
+ $status = $manager->processJob($mcl_job);
+ if ($status) {
+ mcl_print("\n\nDONE : The uploading job was completed without an error.", 1, 4);
+
+ // Sets the complete date if it has no date. Keep the first one.
+ $complete_date = $mcl_job->getCompleteDate();
+ if (!$complete_date) {
+ $mcl_job->setCompleteDate(date("Y-m-d G:i:s"));
+ $mcl_job->update();
+ }
+ }
+ else {
+ $job_id = $mcl_job->getJobID();
+ $opt_working_dir = ($working_dir) ? "--working_dir=$working_dir" : '';
+ $opt_move_input = ($move_input) ? '--move_input' : '';
+ mcl_print("DONE : The job (Job ID = $job_id) was completed with some errors", 1);
+ mcl_print("Please fix the errors and re-run this job ", 2, 2);
+
+ // Shows re-run command on screen.
+ $rerun_cmd = "drush mcl-rerun-job $job_id $filepath $opt_working_dir $opt_move_input";
+ mcl_print(">$rerun_cmd", 2, 4, FALSE);
+
+ // Saves the re-run command as job property.
+ $mcl_job->setPropByKey('rerun_cmd', $rerun_cmd);
+ $mcl_job->update();
+ }
+}
+
+/**
+ * Prepares for a uploading job.
+ *
+ * 1. Checks arguments.
+ * 2. Copies an input file to job folder.
+ *
+ * @param MCL_USER $mcl_user
+ * @param string $filepath
+ * @param boolean $move_input
+ * @param string $working_dir
+ * @param string $job_name
+ *
+ * @return MCL_JOB_UPLOAD
+ */
+function mcl_prepare_uploading_job(MCL_USER $mcl_user, $filepath, $move_input, $working_dir = '', $job_name = '') {
+ $mcl_job = NULL;
+
+ // Sets job directory to working directory.
+ $prop = array();
+ if ($working_dir) {
+ $prop['working_dir'] = $working_dir;
+ }
+
+ // Sets the job name.
+ $name = 'Uploading-Data-File';
+ if ($job_name) {
+ $name = $job_name;
+ }
+
+ // Prepares for a uploading job.
+ $transaction = db_transaction();
+ try {
+
+ // Creates a job for uploading data.
+ $details = array(
+ 'name' => $name,
+ 'type' => 'upload',
+ 'class_name' => 'MCL_JOB_UPLOAD',
+ 'status' => 0,
+ 'user_id' => $mcl_user->getUserID(),
+ 'submit_date' => date("Y-m-d G:i:s"),
+ 'prop' => json_encode($prop),
+ );
+ $mcl_job = new MCL_JOB_UPLOAD($details);
+ if ($mcl_job->insert()) {
+
+ // Moves the input file to 'file' folder in the job folder.
+ $filename = basename($filepath);
+ $new_filepath = $mcl_job->getFileDir() . "/$filename";
+ $cmd = ($move_input) ? "mv $filepath $new_filepath" : "cp $filepath $new_filepath";
+ mcl_print("Copying the input files", 1);
+ mcl_print("$cmd", 1, 2);
+ exec($cmd, $return_var);
+ if (!empty($return_var)) {
+ throw new Exception("Fail to copy file.\n\n$cmd\n\n");
+ }
+
+ // Adds the uploaded file to mcl_file.
+ $details = array(
+ 'filename' => $filename,
+ 'filepath' => $new_filepath,
+ 'uri' => '',
+ 'filesize' => filesize($new_filepath),
+ 'user_id' => $mcl_user->getUserID(),
+ 'job_id' => $mcl_job->getJobID(),
+ 'submit_date' => date("Y-m-d G:i:s"),
+ );
+ $upload_file = new MCL_FILE($details);
+ if ($upload_file->insert()) {
+
+ // Updates the job properties.
+ $mcl_job->setFileID($upload_file->getFileID());
+ if (!$mcl_job->update()) {
+ throw new Exception("Fail to update Job property.");
+ }
+ }
+ else {
+ throw new Exception("Fail to insert mcl_FILE.");
+ }
+ }
+ else {
+ throw new Exception("Fail to insert MCL_JOB.");
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ mcl_print("Error : " . $e->getMessage(), 1, 3);
+ watchdog('mcl', $e->getMessage(), array(), WATCHDOG_ERROR);
+ return array('flag' => FALSE);
+ }
+ return $mcl_job;
+}
+
+/**
+ * Callback for generating class files.
+ *
+ * @param string $module
+ * @param string $schema
+ * @param string $dump_file
+ * @param string $table_file
+ * @param string $namespace
+ *
+ */
+function drush_mcl_generate_class($module, $schema, $dump_file, $table_file) {
+
+ // Checks the working directory option.
+ $working_dir = drush_get_option('working_dir');
+ if ($working_dir) {
+ if (!file_exists($working_dir)) {
+ mcl_print("Error : The working directory does not exist", 1, 4);
+ exit;
+ }
+
+ // Updates the path for schema and table list files.
+ $dump_file = "$working_dir/$dump_file";
+ $table_file = "$working_dir/$table_file";
+ }
+ else {
+ mcl_print("Error : Please specify the working directory", 1, 4);
+ exit;
+ }
+
+ // Checks the class path directory option.
+ $class_dir = drush_get_option('class_dir');
+ if (!$class_dir) {
+
+ // Sets the default class directory.
+ $module_path = drupal_get_path('module', $module);
+ $class_dir = "$module_path/includes/class/$schema" . '_table_class';
+ }
+ if (!file_exists($class_dir)) {
+ mcl_print("The class directory does not exist", 1, 4);
+ exit;
+ }
+
+ // Checks the overwrite option.
+ $flag_overwrite = drush_get_option('overwrite');
+
+ // Checks arguments.
+ $args = array(
+ 'module' => $module,
+ 'dump_file' => $dump_file,
+ 'table_file' => $table_file,
+ );
+ if (!mcl_check_arguments($args)) {
+ mcl_print("Error : Please check arguments", 1, 3);
+ exit;
+ }
+
+ // Checks the namespace option.
+ $namespace = drush_get_option('namespace');
+
+ // Creates a tempolary directory and move the current class files.
+ $tmp_dir = "$working_dir/tmp";
+ mcl_create_dir($tmp_dir);
+
+ // Read the information of the tables in the schema.
+ $mcl_table_info = new MCL_TABLE_INFO($dump_file, $table_file);
+
+ // Generats claa files.
+ $writer = new MCL_TABLE_WRITER($mcl_table_info, $tmp_dir, $namespace);
+ if ($writer->generateClassFiles()) {
+
+ // Overwrites all the class files with newly generated ones.
+ if ($flag_overwrite) {
+ $cmd = "mv $tmp_dir/*.inc $class_dir; rmdir $tmp_dir";
+ exec($cmd);
+ mcl_print("The class files are generated to :", 1 , 1, FALSE);
+ mcl_print($class_dir, 1, 4);
+ }
+ else {
+ mcl_print("The class files are generated in to :", 1, 1, FALSE);
+ mcl_print($tmp_dir, 1, 1);
+ mcl_print("Please copy them over to the class directory", 1, 4);
+ }
+ }
+ else {
+ mcl_print("Failed to generate class files", 1, 4);
+ }
+}
+
+/**
+ * Checks working_dir directory.
+ *
+ * @param string $working_dir
+ *
+ * @return boolean
+ */
+function mcl_check_working_dir($working_dir) {
+
+ // Checks the working directory.
+ if ($working_dir) {
+
+ // Checks the existance.
+ if (!file_exists($working_dir)) {
+ mcl_print("Error : The working directory ($working_dir) dose not exist", 1, 3);
+ return FALSE;
+ }
+
+ // Checks for write permission.
+ if (!is_writable($working_dir)) {
+ mcl_print("Error : Cannot write on the working directory ($working_dir)", 1);
+ mcl_print("Please change the write permission of the directory", 1, 3);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/**
+ * Checks arguments.
+ *
+ * @param array $args
+ *
+ * @return boolean
+ */
+function mcl_check_arguments($args) {
+
+ // Checks the number of arugments.
+ $num_args = sizeof($args);
+ $count_args = 0;
+ foreach ($args as $key => $value) {
+ if (trim($value)) {
+ $count_args++;
+ }
+ }
+ if ($count_args != $num_args) {
+ mcl_print("Error : The number of arguments does not match", 1, 3);
+ return FALSE;
+ }
+
+ // Checks each type of argument.
+ foreach ($args as $key => $value) {
+
+ // Checks for empty value.
+ if (empty($value)) {
+ mcl_print("Error : $key is empty", 1, 3);
+ return FALSE;
+ }
+
+ // Checks for each type of argument.
+ if ($key == 'job_id') {
+
+ // Checks for an integer.
+ if (!preg_match("/^(\d+)$/", $value)) {
+ mcl_print("Error : $key must be an integer", 1, 3);
+ return FALSE;
+ }
+
+ // Checks for MCL_JOB.
+ $mcl_job = MCL_JOB::byKey(array('job_id' => $value));
+ if (!$mcl_job) {
+ mcl_print("Error : Job ID ($value) does not exist", 1, 3);
+ return FALSE;
+ }
+ }
+ else if ($key == 'username') {
+
+ // Checks for MCL_USER.
+ $mcl_user = MCL_USER::byKey(array('name' => $value));
+ if (!$mcl_user) {
+ mcl_print("Error : $value does not exist", 1, 3);
+ return FALSE;
+ }
+ }
+ else if (in_array($key, array('filepath', 'dump_file' ,'table_file'))) {
+
+ // Checks for filepath.
+ if (!file_exists($value)) {
+ mcl_print("Cannot find file", 1);
+ mcl_print("$value", 1, 2);
+ mcl_print("Please check file name or add full path to the filename", 1, 3);
+ return FALSE;
+ }
+ }
+ else if ($key == 'status') {
+
+ // Checks for an integer.
+ if (!preg_match("/^(\d+)$/", $value)) {
+ mcl_print("Error : $key must be an integer", 1, 3);
+ return FALSE;
+ }
+ }
+ else if ($key == 'module') {
+
+ // Checks if module exists.
+ if (!module_exists($value)) {
+ mcl_print("Error : The module ($value) does not exist", 1, 3);
+ return FALSE;
+ }
+ }
+ }
+ return TRUE;
+}
diff --git a/mcl.info b/mcl.info
new file mode 100644
index 0000000..8b91864
--- /dev/null
+++ b/mcl.info
@@ -0,0 +1,7 @@
+name = Mainlab Chado Loader
+description = PHP data uploader to chado schema for Mainlab
+package = Mainlab
+project = MCL
+core = 7.x
+version = 7.x-1.0
+configure = admin/mainlab_chado_loader
diff --git a/mcl.install b/mcl.install
new file mode 100644
index 0000000..aae5d8f
--- /dev/null
+++ b/mcl.install
@@ -0,0 +1,453 @@
+ array(
+ 'var_id' => array(
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ ),
+ 'name' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE,
+ ),
+ 'type' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE,
+ ),
+ 'value' => array(
+ 'type' => 'varchar',
+ 'length' => '1024',
+ ),
+ 'description' => array(
+ 'type' => 'text',
+ ),
+ ),
+ 'primary key' => array('var_id'),
+ 'unique keys' => array(
+ 'ukey_mcl_var_name' => array('name')
+ ),
+ );
+}
+
+/**
+ * Adds mcl_user table.
+ *
+ * @param $schema
+ */
+function mcl_add_table_mcl_user(&$schema) {
+ $schema['mcl_user'] = array(
+ 'fields' => array(
+ 'user_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ ),
+ 'name' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE,
+ ),
+ 'uid' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ ),
+ 'mail' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE,
+ ),
+ 'prop' => array(
+ 'type' => 'text',
+ 'not null' => FALSE,
+ ),
+ ),
+ 'primary key' => array('user_id'),
+ );
+}
+
+/**
+ * Adds mcl_template table.
+ *
+ * @param $schema
+ */
+function mcl_add_table_mcl_template(&$schema) {
+ $schema['mcl_template'] = array(
+ 'fields' => array(
+ 'template_id' => array(
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ ),
+ 'template' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE,
+ ),
+ 'template_type_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ ),
+ ),
+ 'primary key' => array('template_id'),
+ 'unique keys' => array(
+ 'ukey_mcl_template_template' => array('template')
+ ),
+ );
+}
+
+/**
+ * Adds template_type table.
+ *
+ * @param $schema
+ */
+function mcl_add_table_mcl_template_type(&$schema) {
+ $schema['mcl_template_type'] = array(
+ 'fields' => array(
+ 'template_type_id' => array(
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ ),
+ 'type' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE,
+ ),
+ 'rank' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ ),
+ ),
+ 'primary key' => array('template_type_id'),
+ 'unique keys' => array(
+ 'ukey_mcl_template_type' => array('type')
+ ),
+ );
+}
+
+/**
+ * Adds mcl_file table.
+ *
+ * @param $schema
+ */
+function mcl_add_table_mcl_file(&$schema) {
+ $schema['mcl_file'] = array(
+ 'fields' => array(
+ 'file_id' => array(
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ ),
+ 'type' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE,
+ ),
+ 'filename' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE,
+ ),
+ 'filepath' => array(
+ 'type' => 'varchar',
+ 'length' => '512',
+ 'not null' => TRUE,
+ ),
+ 'filesize' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'uri' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE,
+ ),
+ 'user_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ ),
+ 'job_id' => array(
+ 'type' => 'int',
+ ),
+ 'submit_date' => array(
+ 'type' => 'datetime',
+ 'mysql_type' => 'datetime', // The equivalent MySQL data type
+ 'pgsql_type' => 'timestamp without time zone', // The equivalent PostgreSQL data type
+ 'not null' => TRUE,
+ ),
+ 'prop' => array(
+ 'type' => 'text',
+ ),
+ ),
+ 'primary key' => array('file_id'),
+ );
+}
+
+/**
+ * Adds mcl_job table.
+ *
+ * @param $schema
+ */
+function mcl_add_table_mcl_job(&$schema) {
+ $schema['mcl_job'] = array(
+ 'fields' => array(
+ 'job_id' => array(
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ ),
+ 'name' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE,
+ ),
+ 'type' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ 'not null' => TRUE,
+ ),
+ 'class_name' => array(
+ 'type' => 'varchar',
+ 'length' => '255',
+ ),
+ 'status' => array(
+ 'type' => 'int',
+ ),
+ 'param' => array(
+ 'type' => 'text',
+ ),
+ 'prop' => array(
+ 'type' => 'text',
+ ),
+ 'user_id' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ ),
+ 'program_id' => array(
+ 'type' => 'int',
+ ),
+ 'submit_date' => array(
+ 'type' => 'datetime',
+ 'mysql_type' => 'datetime', // The equivalent MySQL data type
+ 'pgsql_type' => 'timestamp without time zone', // The equivalent PostgreSQL data type
+ 'not null' => TRUE,
+ ),
+ 'complete_date' => array(
+ 'type' => 'datetime',
+ 'mysql_type' => 'datetime', // The equivalent MySQL data type
+ 'pgsql_type' => 'timestamp without time zone', // The equivalent PostgreSQL data type
+ ),
+ ),
+ 'primary key' => array('job_id'),
+ );
+}
+
+/**
+ * Populates table with default values.
+ *
+ */
+function mcl_populate_table_defaults() {
+ $module_path = drupal_get_path('module', 'mcl');
+
+ // Includes .inc file.
+ require_once("$module_path/includes/mcl.inc");
+
+ // Registers autoloader.
+ require_once "$module_path/includes/class/mcl_class_loader.class.inc";
+ $bims_autoloader = new MCL_CLASS_LOADER($module_path);
+ $bims_autoloader->register();
+
+ // Populates mcl_var table.
+ mcl_populate_mcl_var();
+
+ // Populates mcl_template_type table.
+ mcl_populate_mcl_template_type();
+
+ // Populates mcl_template table.
+ mcl_populate_mcl_template();
+}
+
+/**
+ * Populates mcl_var table.
+ *
+ */
+function mcl_populate_mcl_var() {
+
+ // Gets null/default value.
+ $null_cvterm = MCL_CHADO_CVTERM::addNull();
+ $null_pub = MCL_CHADO_PUB::addNull();
+ $null_organism = MCL_CHADO_ORGANISM::addNull();
+ $na_location = MCL_CHADO_LOCATION::addNA();
+
+ // Adds MCL global variables.
+ $mcl_vars = array(
+ 'SITE_DB' => array('type' => 'SITE', 'value' => 'MAIN', 'desc' => 'The name of the site specific DB'),
+ 'SITE_CV' => array('type' => 'SITE', 'value' => 'MAIN', 'desc' => 'The name of the site specific CV'),
+ 'SITE_TRAIT_ONTOLOGY' => array('type' => 'SITE', 'value' => 'rosaceae_triat_ontology', 'desc' => 'CV.name for site specific trait ontology'),
+ 'CVTERM_ID' => array('type' => 'DEFAULT', 'value' => $null_cvterm->getCvtermID(), 'desc' => 'dummy cvterm ID. It is used for type_id of NULL pub.'),
+ 'PUB_ID' => array('type' => 'DEFAULT', 'value' => $null_pub->getPubID(), 'desc' => 'dummy pub ID. It is used for chado.cvterm_feature.pub_id.'),
+ 'ORGANISM_ID' => array('type' => 'DEFAULT', 'value' => $null_organism->getOrganismID(), 'desc' => 'dummy organism ID. It is used for organims ID of a linkage group.'),
+ 'ND_GEOLOCATION_ID' => array('type' => 'DEFAULT', 'value' => $na_location->getNdGeolocationID(), 'desc' => 'chado.nd_geolocation.nd_geolocation_id for "Not Available"'),
+ );
+
+ // Adds variables.
+ foreach ($mcl_vars as $name => $prop) {
+ if (!MCL_VAR::addVar($prop['type'], $name, $prop['value'], $prop['desc'])) {
+ print "\nError : Failed to add a variable.\n\n";
+ exit;
+ }
+ }
+}
+
+/**
+ * Populates mcl_template_type table.
+ *
+ */
+function mcl_populate_mcl_template_type() {
+
+ // Default template types.
+ $template_types = array(
+ 'DB',
+ 'CV',
+ 'CVTERM',
+ 'LIBRARY',
+ 'TRAIT',
+ 'CONTACT',
+ 'DATASET',
+ 'IMAGE',
+ 'DESCRIPTOR',
+ 'SITE',
+ 'STOCK',
+ 'PROGENY',
+ 'MARKER',
+ 'MTL',
+ 'QTL',
+ 'CROSS',
+ 'MAP',
+ 'MAP_POSITION',
+ 'FIELD_BOOK',
+ 'PHENOTYPE',
+ 'GENOTYPE',
+ );
+
+ // Adds template types.
+ $rank = 20;
+ foreach ($template_types as $template_type) {
+ $details = array(
+ 'type' => $template_type,
+ );
+ $mcl_template_type = MCL_TEMPLATE_TYPE::byKey($details);
+ if ($mcl_template_type) {
+ print "\n$template_type already existed.\n\n";
+ }
+ else {
+ $details['rank'] = $rank;
+ $mcl_template_type = new MCL_TEMPLATE_TYPE($details);
+ if (!$mcl_template_type->insert()) {
+ print "\nError : Failed to add a template type\n\n";
+ exit;
+ }
+ $rank += 10;
+ }
+ }
+}
+
+/**
+ * Populates mcl_template table.
+ *
+ */
+function mcl_populate_mcl_template() {
+
+ // Default templates.
+ $templates = array(
+ array('type' => 'DB', 'name' => 'db'),
+ array('type' => 'CV', 'name' => 'cv'),
+ array('type' => 'CVTERM', 'name' => 'cvterm'),
+ array('type' => 'LIBRARY', 'name' => 'library'),
+ array('type' => 'TRAIT', 'name' => 'trait'),
+ array('type' => 'DESCRIPTOR', 'name' => 'descriptor'),
+ array('type' => 'CONTACT', 'name' => 'contact'),
+ array('type' => 'DATASET', 'name' => 'dataset'),
+ array('type' => 'SITE', 'name' => 'site'),
+ array('type' => 'STOCK', 'name' => 'stock'),
+ array('type' => 'MTL', 'name' => 'mtl'),
+ array('type' => 'MARKER', 'name' => 'marker'),
+ array('type' => 'QTL', 'name' => 'qtl'),
+ array('type' => 'MTL', 'name' => 'mtl'),
+ array('type' => 'CROSS', 'name' => 'cross'),
+ array('type' => 'MAP', 'name' => 'map'),
+ array('type' => 'MAP_POSITION', 'name' => 'map_position'),
+ array('type' => 'PHENOTYPE', 'name' => 'qtl_trait_data'),
+ array('type' => 'PHENOTYPE', 'name' => 'phenotype'),
+ array('type' => 'GENOTYPE', 'name' => 'genotype'),
+ );
+
+ // Adds templates.
+ foreach ($templates as $template) {
+ $template_type = $template['type'];
+ $template_name = $template['name'];
+ if (!MCL_TEMPLATE::addTemplate($template_type, $template_name)) {
+ print "\nError : Failed to add a template ($template_type - $template_name)\n\n";
+ exit;
+ }
+ }
+}
+
+/**
+ * Update function defined below.
+ */
+/**
+ * .....
+ */
+function mcl_update_7007() {
+ $transaction = db_transaction();
+ try {
+ mcl_populate_table_defaults();
+ }
+ catch (\PDOException $e) {
+ $transaction->rollback();
+ $error = $e->getMessage();
+ throw new DrupalUpdateException($error);
+ }
+}
diff --git a/mcl.module b/mcl.module
new file mode 100644
index 0000000..9186243
--- /dev/null
+++ b/mcl.module
@@ -0,0 +1,377 @@
+register();
+
+ // Includes .inc file.
+ require_once("$module_path/includes/mcl.inc");
+
+ // Adds libraries.
+ drupal_add_library('system', 'drupal.ajax');
+ drupal_add_library('system', 'jquery');
+ drupal_add_library('system', 'jquery.form');
+ drupal_add_library('system', 'drupal.collapse');
+
+ // Adds javascript and css files.
+ drupal_add_js("$module_path/theme/js/mcl.js");
+ drupal_add_css("$module_path/theme/css/mcl.css");
+}
+
+/**
+ * Implementation of hook_permission().
+ */
+function mcl_permission() {
+ return array(
+ 'view_mcl' => array(
+ 'title' => t('View MCL'),
+ 'description' => t('Allow users to view MCL'),
+ ),
+ 'admin_mcl' => array(
+ 'title' => t('Administer MCL'),
+ 'description' => t('Allow users to perform administrative tasks for MCL'),
+ ),
+ );
+}
+
+/**
+ * Implementation of hook_access().
+ */
+function mcl_access($access_args) {
+ if (user_access($access_args)) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
+/*
+* Implementation of hook_theme().
+*/
+function mcl_theme () {
+ $template_path = drupal_get_path('module', 'mcl') . '/theme/templates';
+ return array();
+}
+
+/**
+ * Implementation of hook_cron().
+ */
+function mcl_cron() {}
+
+/**
+ * Implementation of hook_menu().
+ */
+function mcl_menu() {
+ $items = array();
+
+ // MCL ADMIN PAGES.
+ $weight = 0;
+ $items['admin/mcl'] = array(
+ 'title' => 'MCL',
+ 'description' => 'Admin page for Mainlab Chado Loader',
+ 'page callback' => 'mcl_admin_page',
+ 'access arguments' => array('admin_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/admin/mcl.admin.inc',
+ 'type' => MENU_NORMAL_ITEM,
+ );
+ $items['admin/mcl/template_type'] = array(
+ 'title' => 'Template Type',
+ 'description' => 'The data template types for MCL',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_admin_template_type_form'),
+ 'access arguments' => array('admin_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/admin/mcl.admin.template_type.inc',
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => $weight++,
+ );
+ $items['admin/mcl/template'] = array(
+ 'title' => 'Template',
+ 'description' => 'The data templates for MCL',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_admin_template_form'),
+ 'access arguments' => array('admin_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/admin/mcl.admin.template.inc',
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => $weight++,
+ );
+ $items['admin/mcl/user'] = array(
+ 'title' => 'User',
+ 'description' => 'Manage users for MCL',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_admin_user_form'),
+ 'access arguments' => array('admin_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/admin/mcl.admin.user.inc',
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => $weight++,
+ );
+ $items['admin/mcl/global_var'] = array(
+ 'title' => 'Variables',
+ 'description' => 'MCL global variables',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_admin_global_var_form'),
+ 'access arguments' => array('admin_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/admin/mcl.admin.global_var.inc',
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => $weight++,
+ );
+ $items['admin/mcl/global_var/edit'] = array(
+ 'title' => 'Variables',
+ 'description' => 'Edit MCL global variables',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_admin_global_var_edit_form', 4),
+ 'access arguments' => array('admin_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/admin/mcl.admin.global_var.inc',
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => $weight++,
+ );
+ $items['admin/mcl/config'] = array(
+ 'title' => 'Configuration',
+ 'description' => 'The configuration for MCL',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_admin_config_form'),
+ 'access arguments' => array('admin_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/admin/mcl.admin.config.inc',
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => $weight++,
+ );
+
+ // MCL PAGES.
+ $items['mcl'] = array(
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_form'),
+ 'access arguments' => array('view_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/form/mcl.form.inc',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['mcl/drush'] = array(
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_drush_form'),
+ 'access arguments' => array('view_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/form/mcl.drush.form.inc',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['mcl/upload_data'] = array(
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_upload_data_form'),
+ 'access arguments' => array('view_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/form/mcl.upload_data.form.inc',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['mcl/job_view'] = array(
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_job_view_form', 2),
+ 'access arguments' => array('view_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/form/mcl.job_view.form.inc',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['mcl/delete_job/%'] = array(
+ 'page callback' => 'mcl_delete_job',
+ 'page arguments' => array(2),
+ 'access arguments' => array('view_mcl'),
+ 'access callback' => 'mcl_access',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['mcl/template_list'] = array(
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_template_list_form'),
+ 'access arguments' => array('view_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/form/mcl.template_list.form.inc',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['mcl/template/view/%'] = array(
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('mcl_template_form', 3),
+ 'access arguments' => array('view_mcl'),
+ 'access callback' => 'mcl_access',
+ 'file' => '/includes/form/mcl.template.form.inc',
+ 'type' => MENU_CALLBACK,
+ );
+ $items['mcl/template/download'] = array(
+ 'page callback' => 'mcl_download_template',
+ 'page arguments' => array(3),
+ 'access arguments' => array('view_mcl'),
+ 'access callback' => 'mcl_access',
+ 'type' => MENU_CALLBACK,
+ );
+
+ // Download a file.
+ $items['mcl/download_file/%'] = array(
+ 'access arguments' => array('view_mcl'),
+ 'page callback' => 'mcl_download_file',
+ 'page arguments' => array(2),
+ 'access callback' => 'mcl_access',
+ 'type' => MENU_CALLBACK,
+ );
+
+ // Dowloading log files.
+ $items['mcl/download_log/%'] = array(
+ 'access arguments' => array('view_mcl'),
+ 'page callback' => 'mcl_download_log',
+ 'page arguments' => array(2),
+ 'access callback' => 'mcl_access',
+ 'type' => MENU_CALLBACK,
+ );
+ return $items;
+}
+
+/************************************************/
+/* MCL configuration setting */
+/************************************************/
+/**
+ * function for retreiving a MCL configuration setting.
+ *
+ * @param $setting
+ * The name of the configuration setting to retreive
+ */
+function mcl_get_config_setting($setting) {
+ switch($setting) {
+ case 'mcl_file_dir':
+ $default_mcl_file_dir = realpath('./') . '/' . variable_get('file_public_path', conf_path() . '/files');
+ return variable_get('mcl_file_dir', $default_mcl_file_dir);
+ break;
+ case 'mcl_working_dir':
+ $default_mcl_working_dir = realpath('./') . '/' . variable_get('file_public_path', conf_path() . '/files') . '/mcl';
+ return variable_get('mcl_working_dir', $default_mcl_working_dir);
+ break;
+ case 'mcl_working_url':
+ $default_mcl_working_url = realpath('./') . '/' . variable_get('file_public_path', conf_path() . '/files') . '/mcl/working';
+ return variable_get('mcl_working_url', $default_mcl_working_url);
+ break;
+ case 'mcl_library_dir':
+ $default_mcl_library_dir = realpath('./') . '/' . '/sites/all/libraries';
+ return variable_get('mcl_library_dir', $default_mcl_library_dir);
+ break;
+ }
+}
+
+/************************************************/
+/* CALLBACK FUNCTIONS */
+/************************************************/
+/**
+ * Delete a job.
+ */
+function mcl_delete_job($job_id) {
+
+ // Gets the MCL_JOB.
+ $mcl_job = MCL_JOB::byKey(array('job_id' => $job_id));
+ if ($mcl_job) {
+
+ // Deletes the job.
+ if ($mcl_job->delete()) {
+ drupal_set_message("The job ($job_id) has been deleted successfully.");
+ }
+ else {
+ drupal_set_message("Error : Failed to delete the job ($job_id).");
+ }
+ }
+ else {
+ drupal_set_message("Error : Cannot found a job for Job ID ($job_id).");
+ }
+ $commands = array();
+ print ajax_render($commands);
+}
+
+/**
+ * Generates a template in an Excel file for downloading.
+ */
+function mcl_download_template($template_id) {
+
+ // Generates template file in Excel format.
+ $args = array(
+ 'template_id' => $template_id,
+ 'type' => 'online',
+ );
+ mcl_download_template_excel($args);
+}
+
+/**
+ * Generates a template in an Excel file for downloading.
+ *
+ * @return boolean
+ */
+function mcl_download_template_excel($args) {
+
+ // Gets parameters.
+ $template_id = array_key_exists('template_id', $args) ? $args['template_id'] : '';
+ $version = array_key_exists('version', $args) ? $args['version'] : 'Excel2007';
+ $type = array_key_exists('type', $args) ? $args['type'] : 'online';
+ $filepath = array_key_exists('filepath', $args) ? $args['filepath'] : '';
+
+ // Returns if template ID is empty.
+ if (!$template_id) {
+ return FALSE;
+ }
+
+ // Gets the template.
+ $mcl_template = MCL_TEMPLATE::getTemplateByID($template_id);
+ $filename = 'mcl_template_' . $mcl_template->getTemplate() . '.xlsx';
+
+ // Gets template array for excel sheet.
+ $sheets = $mcl_template->getTemplateInfo();
+
+ // Creates MCL_EXCEL.
+ $details = array(
+ 'creator' => 'MAIN',
+ 'filename' => $filename,
+ 'filepath' => "$filepath/$filename",
+ 'version' => $version,
+ 'sheets' => $sheets,
+ );
+ $excel = new MCL_EXCEL($details);
+ $excel->create($type);
+ return TRUE;
+}
+
+/************************************************/
+/* EMAIL */
+/************************************************/
+/**
+ * Implements hook_mail().
+ */
+function mcl_mail($key, &$message, $params) {
+
+}
+
+ /************************************************/
+/* CONFIGURATIONS */
+/*************************************************/
+/**
+ * Checks the configuration.
+ */
+function mcl_check_setup() {
+
+ // Checks PHPExcel library.
+ // Checks PHPZip library.
+
+
+
+ $issues = '';
+ $is_ready = TRUE;
+}
\ No newline at end of file
diff --git a/schema/drupal7.chado.sql b/schema/drupal7.chado.sql
new file mode 100644
index 0000000..98b1ef5
--- /dev/null
+++ b/schema/drupal7.chado.sql
@@ -0,0 +1,23048 @@
+--
+-- PostgreSQL database dump
+--
+
+SET statement_timeout = 0;
+SET lock_timeout = 0;
+SET client_encoding = 'UTF8';
+SET standard_conforming_strings = on;
+SET check_function_bodies = false;
+SET client_min_messages = warning;
+
+--
+-- Name: chado; Type: SCHEMA; Schema: -; Owner: -
+--
+
+CREATE SCHEMA chado;
+
+
+SET search_path = chado, pg_catalog;
+
+--
+-- Name: feature_by_fx_type; Type: TYPE; Schema: chado; Owner: -
+--
+
+CREATE TYPE feature_by_fx_type AS (
+ feature_id integer,
+ depth integer
+);
+
+
+--
+-- Name: soi_type; Type: TYPE; Schema: chado; Owner: -
+--
+
+CREATE TYPE soi_type AS (
+ type_id integer,
+ subject_id integer,
+ object_id integer
+);
+
+
+--
+-- Name: _fill_cvtermpath4node(integer, integer, integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION _fill_cvtermpath4node(integer, integer, integer, integer, integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ origin alias for $1;
+ child_id alias for $2;
+ cvid alias for $3;
+ typeid alias for $4;
+ depth alias for $5;
+ cterm cvterm_relationship%ROWTYPE;
+ exist_c int;
+BEGIN
+ --- RAISE NOTICE 'depth=% root=%', depth,child_id;
+ --- not check type_id as it may be null and not very meaningful in cvtermpath when pathdistance > 1
+ SELECT INTO exist_c count(*) FROM cvtermpath WHERE cv_id = cvid AND object_id = origin AND subject_id = child_id AND pathdistance = depth;
+ IF (exist_c = 0) THEN
+ INSERT INTO cvtermpath (object_id, subject_id, cv_id, type_id, pathdistance) VALUES(origin, child_id, cvid, typeid, depth);
+ END IF;
+ FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = child_id LOOP
+ PERFORM _fill_cvtermpath4node(origin, cterm.subject_id, cvid, cterm.type_id, depth+1);
+ END LOOP;
+ RETURN 1;
+END;
+$_$;
+
+
+--
+-- Name: _fill_cvtermpath4node2detect_cycle(integer, integer, integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION _fill_cvtermpath4node2detect_cycle(integer, integer, integer, integer, integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ origin alias for $1;
+ child_id alias for $2;
+ cvid alias for $3;
+ typeid alias for $4;
+ depth alias for $5;
+ cterm cvterm_relationship%ROWTYPE;
+ exist_c int;
+ ccount int;
+ ecount int;
+ rtn int;
+BEGIN
+ EXECUTE 'SELECT * FROM tmpcvtermpath p1, tmpcvtermpath p2 WHERE p1.subject_id=p2.object_id AND p1.object_id=p2.subject_id AND p1.object_id = '|| origin || ' AND p2.subject_id = ' || child_id || 'AND ' || depth || '> 0';
+ GET DIAGNOSTICS ccount = ROW_COUNT;
+ IF (ccount > 0) THEN
+ --RAISE EXCEPTION 'FOUND CYCLE: node % on cycle path',origin;
+ RETURN origin;
+ END IF;
+ EXECUTE 'SELECT * FROM tmpcvtermpath WHERE cv_id = ' || cvid || ' AND object_id = ' || origin || ' AND subject_id = ' || child_id || ' AND ' || origin || '<>' || child_id;
+ GET DIAGNOSTICS ecount = ROW_COUNT;
+ IF (ecount > 0) THEN
+ --RAISE NOTICE 'FOUND TWICE (node), will check root obj % subj %',origin, child_id;
+ SELECT INTO rtn _fill_cvtermpath4root2detect_cycle(child_id, cvid);
+ IF (rtn > 0) THEN
+ RETURN rtn;
+ END IF;
+ END IF;
+ EXECUTE 'SELECT * FROM tmpcvtermpath WHERE cv_id = ' || cvid || ' AND object_id = ' || origin || ' AND subject_id = ' || child_id || ' AND pathdistance = ' || depth;
+ GET DIAGNOSTICS exist_c = ROW_COUNT;
+ IF (exist_c = 0) THEN
+ EXECUTE 'INSERT INTO tmpcvtermpath (object_id, subject_id, cv_id, type_id, pathdistance) VALUES(' || origin || ', ' || child_id || ', ' || cvid || ', ' || typeid || ', ' || depth || ')';
+ END IF;
+ FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = child_id LOOP
+ --RAISE NOTICE 'DOING for node, % %', origin, cterm.subject_id;
+ SELECT INTO rtn _fill_cvtermpath4node2detect_cycle(origin, cterm.subject_id, cvid, cterm.type_id, depth+1);
+ IF (rtn > 0) THEN
+ RETURN rtn;
+ END IF;
+ END LOOP;
+ RETURN 0;
+END;
+$_$;
+
+
+--
+-- Name: _fill_cvtermpath4root(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION _fill_cvtermpath4root(integer, integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ rootid alias for $1;
+ cvid alias for $2;
+ ttype int;
+ cterm cvterm_relationship%ROWTYPE;
+ child cvterm_relationship%ROWTYPE;
+BEGIN
+ SELECT INTO ttype cvterm_id FROM cvterm WHERE (name = 'isa' OR name = 'is_a');
+ PERFORM _fill_cvtermpath4node(rootid, rootid, cvid, ttype, 0);
+ FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = rootid LOOP
+ PERFORM _fill_cvtermpath4root(cterm.subject_id, cvid);
+ -- RAISE NOTICE 'DONE for term, %', cterm.subject_id;
+ END LOOP;
+ RETURN 1;
+END;
+$_$;
+
+
+--
+-- Name: _fill_cvtermpath4root2detect_cycle(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION _fill_cvtermpath4root2detect_cycle(integer, integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ rootid alias for $1;
+ cvid alias for $2;
+ ttype int;
+ ccount int;
+ cterm cvterm_relationship%ROWTYPE;
+ child cvterm_relationship%ROWTYPE;
+ rtn int;
+BEGIN
+ SELECT INTO ttype cvterm_id FROM cvterm WHERE (name = 'isa' OR name = 'is_a');
+ SELECT INTO rtn _fill_cvtermpath4node2detect_cycle(rootid, rootid, cvid, ttype, 0);
+ IF (rtn > 0) THEN
+ RETURN rtn;
+ END IF;
+ FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = rootid LOOP
+ EXECUTE 'SELECT * FROM tmpcvtermpath p1, tmpcvtermpath p2 WHERE p1.subject_id=p2.object_id AND p1.object_id=p2.subject_id AND p1.object_id=' || rootid || ' AND p1.subject_id=' || cterm.subject_id;
+ GET DIAGNOSTICS ccount = ROW_COUNT;
+ IF (ccount > 0) THEN
+ --RAISE NOTICE 'FOUND TWICE (root), will check root obj % subj %',rootid,cterm.subject_id;
+ SELECT INTO rtn _fill_cvtermpath4node2detect_cycle(rootid, cterm.subject_id, cvid, ttype, 0);
+ IF (rtn > 0) THEN
+ RETURN rtn;
+ END IF;
+ ELSE
+ SELECT INTO rtn _fill_cvtermpath4root2detect_cycle(cterm.subject_id, cvid);
+ IF (rtn > 0) THEN
+ RETURN rtn;
+ END IF;
+ END IF;
+ END LOOP;
+ RETURN 0;
+END;
+$_$;
+
+
+--
+-- Name: _fill_cvtermpath4soi(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION _fill_cvtermpath4soi(integer, integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ rootid alias for $1;
+ cvid alias for $2;
+ ttype int;
+ cterm soi_type%ROWTYPE;
+BEGIN
+ SELECT INTO ttype cvterm_id FROM cvterm WHERE name = 'isa';
+ --RAISE NOTICE 'got ttype %',ttype;
+ PERFORM _fill_cvtermpath4soinode(rootid, rootid, cvid, ttype, 0);
+ FOR cterm IN SELECT tmp_type AS type_id, subject_id FROM tmpcvtr WHERE object_id = rootid LOOP
+ PERFORM _fill_cvtermpath4soi(cterm.subject_id, cvid);
+ END LOOP;
+ RETURN 1;
+END;
+$_$;
+
+
+--
+-- Name: _fill_cvtermpath4soinode(integer, integer, integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION _fill_cvtermpath4soinode(integer, integer, integer, integer, integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ origin alias for $1;
+ child_id alias for $2;
+ cvid alias for $3;
+ typeid alias for $4;
+ depth alias for $5;
+ cterm soi_type%ROWTYPE;
+ exist_c int;
+BEGIN
+ --RAISE NOTICE 'depth=% o=%, root=%, cv=%, t=%', depth,origin,child_id,cvid,typeid;
+ SELECT INTO exist_c count(*) FROM cvtermpath WHERE cv_id = cvid AND object_id = origin AND subject_id = child_id AND pathdistance = depth;
+ --- longest path
+ IF (exist_c > 0) THEN
+ UPDATE cvtermpath SET pathdistance = depth WHERE cv_id = cvid AND object_id = origin AND subject_id = child_id;
+ ELSE
+ INSERT INTO cvtermpath (object_id, subject_id, cv_id, type_id, pathdistance) VALUES(origin, child_id, cvid, typeid, depth);
+ END IF;
+ FOR cterm IN SELECT tmp_type AS type_id, subject_id FROM tmpcvtr WHERE object_id = child_id LOOP
+ PERFORM _fill_cvtermpath4soinode(origin, cterm.subject_id, cvid, cterm.type_id, depth+1);
+ END LOOP;
+ RETURN 1;
+END;
+$_$;
+
+
+SET default_tablespace = '';
+
+SET default_with_oids = false;
+
+--
+-- Name: cvtermpath; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cvtermpath (
+ cvtermpath_id integer NOT NULL,
+ type_id integer,
+ subject_id integer NOT NULL,
+ object_id integer NOT NULL,
+ cv_id integer NOT NULL,
+ pathdistance integer
+);
+
+
+--
+-- Name: TABLE cvtermpath; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE cvtermpath IS 'The reflexive transitive closure of
+the cvterm_relationship relation.';
+
+
+--
+-- Name: COLUMN cvtermpath.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvtermpath.type_id IS 'The relationship type that
+this is a closure over. If null, then this is a closure over ALL
+relationship types. If non-null, then this references a relationship
+cvterm - note that the closure will apply to both this relationship
+AND the OBO_REL:is_a (subclass) relationship.';
+
+
+--
+-- Name: COLUMN cvtermpath.cv_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvtermpath.cv_id IS 'Closures will mostly be within
+one cv. If the closure of a relationship traverses a cv, then this
+refers to the cv of the object_id cvterm.';
+
+
+--
+-- Name: COLUMN cvtermpath.pathdistance; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvtermpath.pathdistance IS 'The number of steps
+required to get from the subject cvterm to the object cvterm, counting
+from zero (reflexive relationship).';
+
+
+--
+-- Name: _get_all_object_ids(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION _get_all_object_ids(integer) RETURNS SETOF cvtermpath
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ leaf alias for $1;
+ cterm cvtermpath%ROWTYPE;
+ cterm2 cvtermpath%ROWTYPE;
+BEGIN
+ FOR cterm IN SELECT * FROM cvterm_relationship WHERE subject_id = leaf LOOP
+ RETURN NEXT cterm;
+ FOR cterm2 IN SELECT * FROM _get_all_object_ids(cterm.object_id) LOOP
+ RETURN NEXT cterm2;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: _get_all_subject_ids(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION _get_all_subject_ids(integer) RETURNS SETOF cvtermpath
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ root alias for $1;
+ cterm cvtermpath%ROWTYPE;
+ cterm2 cvtermpath%ROWTYPE;
+BEGIN
+ FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = root LOOP
+ RETURN NEXT cterm;
+ FOR cterm2 IN SELECT * FROM _get_all_subject_ids(cterm.subject_id) LOOP
+ RETURN NEXT cterm2;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: boxquery(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION boxquery(integer, integer) RETURNS box
+ LANGUAGE sql IMMUTABLE
+ AS $_$SELECT box (create_point($1, $2), create_point($1, $2))$_$;
+
+
+--
+-- Name: boxquery(integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION boxquery(integer, integer, integer) RETURNS box
+ LANGUAGE sql IMMUTABLE
+ AS $_$SELECT box (create_point($1, $2), create_point($1, $3))$_$;
+
+
+--
+-- Name: boxrange(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION boxrange(integer, integer) RETURNS box
+ LANGUAGE sql IMMUTABLE
+ AS $_$SELECT box (create_point(0, $1), create_point($2,500000000))$_$;
+
+
+--
+-- Name: boxrange(integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION boxrange(integer, integer, integer) RETURNS box
+ LANGUAGE sql IMMUTABLE
+ AS $_$SELECT box (create_point($1, $2), create_point($1,$3))$_$;
+
+
+--
+-- Name: bt_sort_genotype(character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION bt_sort_genotype(genotype character varying) RETURNS character varying
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ arr varchar [];
+ BEGIN
+ if genotype != '' then
+ arr = string_to_array(genotype, '|');
+ arr = array(SELECT * FROM unnest(arr) ORDER BY 1);
+ genotype = array_to_string(arr, '|') || '|';
+ end if;
+ return genotype;
+ END;
+$$;
+
+
+--
+-- Name: complement_residues(text); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION complement_residues(text) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT (translate($1,
+ 'acgtrymkswhbvdnxACGTRYMKSWHBVDNX',
+ 'tgcayrkmswdvbhnxTGCAYRKMSWDVBHNX'))$_$;
+
+
+--
+-- Name: concat_pair(text, text); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION concat_pair(text, text) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT $1 || $2$_$;
+
+
+--
+-- Name: create_point(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION create_point(integer, integer) RETURNS point
+ LANGUAGE sql
+ AS $_$SELECT point ($1, $2)$_$;
+
+
+--
+-- Name: create_soi(); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION create_soi() RETURNS integer
+ LANGUAGE plpgsql
+ AS $$
+DECLARE
+ parent soi_type%ROWTYPE;
+ isa_id cvterm.cvterm_id%TYPE;
+ soi_term TEXT := 'soi';
+ soi_def TEXT := 'ontology of SO feature instantiated in database';
+ soi_cvid INTEGER;
+ soiterm_id INTEGER;
+ pcount INTEGER;
+ count INTEGER := 0;
+ cquery TEXT;
+BEGIN
+ SELECT INTO isa_id cvterm_id FROM cvterm WHERE name = 'isa';
+ SELECT INTO soi_cvid cv_id FROM cv WHERE name = soi_term;
+ IF (soi_cvid > 0) THEN
+ DELETE FROM cvtermpath WHERE cv_id = soi_cvid;
+ DELETE FROM cvterm WHERE cv_id = soi_cvid;
+ ELSE
+ INSERT INTO cv (name, definition) VALUES(soi_term, soi_def);
+ END IF;
+ SELECT INTO soi_cvid cv_id FROM cv WHERE name = soi_term;
+ INSERT INTO cvterm (name, cv_id) VALUES(soi_term, soi_cvid);
+ SELECT INTO soiterm_id cvterm_id FROM cvterm WHERE name = soi_term;
+ CREATE TEMP TABLE tmpcvtr (tmp_type INT, type_id INT, subject_id INT, object_id INT);
+ CREATE UNIQUE INDEX u_tmpcvtr ON tmpcvtr(subject_id, object_id);
+ INSERT INTO tmpcvtr (tmp_type, type_id, subject_id, object_id)
+ SELECT DISTINCT isa_id, soiterm_id, f.type_id, soiterm_id FROM feature f, cvterm t
+ WHERE f.type_id = t.cvterm_id AND f.type_id > 0;
+ EXECUTE 'select * from tmpcvtr where type_id = ' || soiterm_id || ';';
+ get diagnostics pcount = row_count;
+ raise notice 'all types in feature %',pcount;
+--- do it hard way, delete any child feature type from above (NOT IN clause did not work)
+ FOR parent IN SELECT DISTINCT 0, t.cvterm_id, 0 FROM feature c, feature_relationship fr, cvterm t
+ WHERE t.cvterm_id = c.type_id AND c.feature_id = fr.subject_id LOOP
+ DELETE FROM tmpcvtr WHERE type_id = soiterm_id and object_id = soiterm_id
+ AND subject_id = parent.subject_id;
+ END LOOP;
+ EXECUTE 'select * from tmpcvtr where type_id = ' || soiterm_id || ';';
+ get diagnostics pcount = row_count;
+ raise notice 'all types in feature after delete child %',pcount;
+ --- create feature type relationship (store in tmpcvtr)
+ CREATE TEMP TABLE tmproot (cv_id INTEGER not null, cvterm_id INTEGER not null, status INTEGER DEFAULT 0);
+ cquery := 'SELECT * FROM tmproot tmp WHERE tmp.status = 0;';
+ ---temp use tmpcvtr to hold instantiated SO relationship for speed
+ ---use soterm_id as type_id, will delete from tmpcvtr
+ ---us tmproot for this as well
+ INSERT INTO tmproot (cv_id, cvterm_id, status) SELECT DISTINCT soi_cvid, c.subject_id, 0 FROM tmpcvtr c
+ WHERE c.object_id = soiterm_id;
+ EXECUTE cquery;
+ GET DIAGNOSTICS pcount = ROW_COUNT;
+ WHILE (pcount > 0) LOOP
+ RAISE NOTICE 'num child temp (to be inserted) in tmpcvtr: %',pcount;
+ INSERT INTO tmpcvtr (tmp_type, type_id, subject_id, object_id)
+ SELECT DISTINCT fr.type_id, soiterm_id, c.type_id, p.cvterm_id FROM feature c, feature_relationship fr,
+ tmproot p, feature pf, cvterm t WHERE c.feature_id = fr.subject_id AND fr.object_id = pf.feature_id
+ AND p.cvterm_id = pf.type_id AND t.cvterm_id = c.type_id AND p.status = 0;
+ UPDATE tmproot SET status = 1 WHERE status = 0;
+ INSERT INTO tmproot (cv_id, cvterm_id, status)
+ SELECT DISTINCT soi_cvid, c.type_id, 0 FROM feature c, feature_relationship fr,
+ tmproot tmp, feature p, cvterm t WHERE c.feature_id = fr.subject_id AND fr.object_id = p.feature_id
+ AND tmp.cvterm_id = p.type_id AND t.cvterm_id = c.type_id AND tmp.status = 1;
+ UPDATE tmproot SET status = 2 WHERE status = 1;
+ EXECUTE cquery;
+ GET DIAGNOSTICS pcount = ROW_COUNT;
+ END LOOP;
+ DELETE FROM tmproot;
+ ---get transitive closure for soi
+ PERFORM _fill_cvtermpath4soi(soiterm_id, soi_cvid);
+ DROP TABLE tmpcvtr;
+ DROP TABLE tmproot;
+ RETURN 1;
+END;
+$$;
+
+
+--
+-- Name: feature; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature (
+ feature_id integer NOT NULL,
+ dbxref_id integer,
+ organism_id integer NOT NULL,
+ name character varying(255),
+ uniquename text NOT NULL,
+ residues text,
+ seqlen integer,
+ md5checksum character(32),
+ type_id integer NOT NULL,
+ is_analysis boolean DEFAULT false NOT NULL,
+ is_obsolete boolean DEFAULT false NOT NULL,
+ timeaccessioned timestamp without time zone DEFAULT now() NOT NULL,
+ timelastmodified timestamp without time zone DEFAULT now() NOT NULL
+);
+ALTER TABLE ONLY feature ALTER COLUMN residues SET STORAGE EXTERNAL;
+
+
+--
+-- Name: TABLE feature; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature IS 'A feature is a biological sequence or a
+section of a biological sequence, or a collection of such
+sections. Examples include genes, exons, transcripts, regulatory
+regions, polypeptides, protein domains, chromosome sequences, sequence
+variations, cross-genome match regions such as hits and HSPs and so
+on; see the Sequence Ontology for more. The combination of
+organism_id, uniquename and type_id should be unique.';
+
+
+--
+-- Name: COLUMN feature.dbxref_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.dbxref_id IS 'An optional primary chado.stable
+identifier for this feature. Secondary identifiers and external
+dbxrefs go in the table feature_dbxref.';
+
+
+--
+-- Name: COLUMN feature.organism_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.organism_id IS 'The organism to which this feature
+belongs. This column is mandatory.';
+
+
+--
+-- Name: COLUMN feature.name; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.name IS 'The optional human-readable common name for
+a feature, for display purposes.';
+
+
+--
+-- Name: COLUMN feature.uniquename; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.uniquename IS 'The unique name for a feature; may
+not be necessarily be particularly human-readable, although this is
+preferred. This name must be unique for this type of feature within
+this organism.';
+
+
+--
+-- Name: COLUMN feature.residues; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.residues IS 'A sequence of alphabetic characters
+representing biological residues (nucleic acids, amino acids). This
+column does not need to be manifested for all features; it is optional
+for features such as exons where the residues can be derived from the
+featureloc. It is recommended that the value for this column be
+manifested for features which may may non-contiguous sublocations (e.g.
+transcripts), since derivation at query time is non-trivial. For
+expressed sequence, the DNA sequence should be used rather than the
+RNA sequence. The default storage method for the residues column is
+EXTERNAL, which will store it uncompressed to make substring operations
+faster.';
+
+
+--
+-- Name: COLUMN feature.seqlen; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.seqlen IS 'The length of the residue feature. See
+column:residues. This column is partially redundant with the residues
+column, and also with featureloc. This column is required because the
+location may be unknown and the residue sequence may not be
+manifested, yet it may be desirable to store and query the length of
+the feature. The seqlen should always be manifested where the length
+of the sequence is known.';
+
+
+--
+-- Name: COLUMN feature.md5checksum; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.md5checksum IS 'The 32-character checksum of the sequence,
+calculated using the MD5 algorithm. This is practically guaranteed to
+be unique for any feature. This column thus acts as a unique
+identifier on the mathematical sequence.';
+
+
+--
+-- Name: COLUMN feature.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.type_id IS 'A required reference to a table:cvterm
+giving the feature type. This will typically be a Sequence Ontology
+identifier. This column is thus used to subclass the feature table.';
+
+
+--
+-- Name: COLUMN feature.is_analysis; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.is_analysis IS 'Boolean indicating whether this
+feature is annotated or the result of an automated analysis. Analysis
+results also use the companalysis module. Note that the dividing line
+between analysis and annotation may be fuzzy, this should be determined on
+a per-project basis in a consistent manner. One requirement is that
+there should only be one non-analysis version of each wild-type gene
+feature in a genome, whereas the same gene feature can be predicted
+multiple times in different analyses.';
+
+
+--
+-- Name: COLUMN feature.is_obsolete; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.is_obsolete IS 'Boolean indicating whether this
+feature has been obsoleted. Some chado instances may choose to simply
+remove the feature altogether, others may choose to keep an obsolete
+row in the table.';
+
+
+--
+-- Name: COLUMN feature.timeaccessioned; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.timeaccessioned IS 'For handling object
+accession or modification timestamps (as opposed to database auditing data,
+handled elsewhere). The expectation is that these fields would be
+available to software interacting with chado.';
+
+
+--
+-- Name: COLUMN feature.timelastmodified; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature.timelastmodified IS 'For handling object
+accession or modification timestamps (as opposed to database auditing data,
+handled elsewhere). The expectation is that these fields would be
+available to software interacting with chado.';
+
+
+--
+-- Name: feature_disjoint_from(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION feature_disjoint_from(integer) RETURNS SETOF feature
+ LANGUAGE sql
+ AS $_$SELECT feature.*
+ FROM feature
+ INNER JOIN featureloc AS x ON (x.feature_id=feature.feature_id)
+ INNER JOIN featureloc AS y ON (y.feature_id = $1)
+ WHERE
+ x.srcfeature_id = y.srcfeature_id AND
+ ( x.fmax < y.fmin OR x.fmin > y.fmax ) $_$;
+
+
+--
+-- Name: feature_overlaps(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION feature_overlaps(integer) RETURNS SETOF feature
+ LANGUAGE sql
+ AS $_$SELECT feature.*
+ FROM feature
+ INNER JOIN featureloc AS x ON (x.feature_id=feature.feature_id)
+ INNER JOIN featureloc AS y ON (y.feature_id = $1)
+ WHERE
+ x.srcfeature_id = y.srcfeature_id AND
+ ( x.fmax >= y.fmin AND x.fmin <= y.fmax ) $_$;
+
+
+--
+-- Name: featureloc; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featureloc (
+ featureloc_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ srcfeature_id integer,
+ fmin integer,
+ is_fmin_partial boolean DEFAULT false NOT NULL,
+ fmax integer,
+ is_fmax_partial boolean DEFAULT false NOT NULL,
+ strand smallint,
+ phase integer,
+ residue_info text,
+ locgroup integer DEFAULT 0 NOT NULL,
+ rank integer DEFAULT 0 NOT NULL,
+ CONSTRAINT featureloc_c2 CHECK ((fmin <= fmax))
+);
+
+
+--
+-- Name: TABLE featureloc; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE featureloc IS 'The location of a feature relative to
+another feature. Important: interbase coordinates are used. This is
+vital as it allows us to represent zero-length features e.g. splice
+sites, insertion points without an awkward fuzzy system. Features
+typically have exactly ONE location, but this need not be the
+case. Some features may not be localized (e.g. a gene that has been
+characterized genetically but no sequence or molecular information is
+available). Note on multiple locations: Each feature can have 0 or
+more locations. Multiple locations do NOT indicate non-contiguous
+locations (if a feature such as a transcript has a non-contiguous
+location, then the subfeatures such as exons should always be
+manifested). Instead, multiple featurelocs for a feature designate
+alternate locations or grouped locations; for instance, a feature
+designating a blast hit or hsp will have two locations, one on the
+query feature, one on the subject feature. Features representing
+sequence variation could have alternate locations instantiated on a
+feature on the mutant strain. The column:rank is used to
+differentiate these different locations. Reflexive locations should
+never be stored - this is for -proper- (i.e. non-self) locations only; nothing should be located relative to itself.';
+
+
+--
+-- Name: COLUMN featureloc.feature_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureloc.feature_id IS 'The feature that is being located. Any feature can have zero or more featurelocs.';
+
+
+--
+-- Name: COLUMN featureloc.srcfeature_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureloc.srcfeature_id IS 'The source feature which this location is relative to. Every location is relative to another feature (however, this column is nullable, because the srcfeature may not be known). All locations are -proper- that is, nothing should be located relative to itself. No cycles are allowed in the featureloc graph.';
+
+
+--
+-- Name: COLUMN featureloc.fmin; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureloc.fmin IS 'The leftmost/minimal boundary in the linear range represented by the featureloc. Sometimes (e.g. in Bioperl) this is called -start- although this is confusing because it does not necessarily represent the 5-prime coordinate. Important: This is space-based (interbase) coordinates, counting from zero. To convert this to the leftmost position in a base-oriented system (eg GFF, Bioperl), add 1 to fmin.';
+
+
+--
+-- Name: COLUMN featureloc.is_fmin_partial; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureloc.is_fmin_partial IS 'This is typically
+false, but may be true if the value for column:fmin is inaccurate or
+the leftmost part of the range is unknown/unbounded.';
+
+
+--
+-- Name: COLUMN featureloc.fmax; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureloc.fmax IS 'The rightmost/maximal boundary in the linear range represented by the featureloc. Sometimes (e.g. in bioperl) this is called -end- although this is confusing because it does not necessarily represent the 3-prime coordinate. Important: This is space-based (interbase) coordinates, counting from zero. No conversion is required to go from fmax to the rightmost coordinate in a base-oriented system that counts from 1 (e.g. GFF, Bioperl).';
+
+
+--
+-- Name: COLUMN featureloc.is_fmax_partial; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureloc.is_fmax_partial IS 'This is typically
+false, but may be true if the value for column:fmax is inaccurate or
+the rightmost part of the range is unknown/unbounded.';
+
+
+--
+-- Name: COLUMN featureloc.strand; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureloc.strand IS 'The orientation/directionality of the
+location. Should be 0, -1 or +1.';
+
+
+--
+-- Name: COLUMN featureloc.phase; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureloc.phase IS 'Phase of translation with
+respect to srcfeature_id.
+Values are 0, 1, 2. It may not be possible to manifest this column for
+some features such as exons, because the phase is dependant on the
+spliceform (the same exon can appear in multiple spliceforms). This column is mostly useful for predicted exons and CDSs.';
+
+
+--
+-- Name: COLUMN featureloc.residue_info; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureloc.residue_info IS 'Alternative residues,
+when these differ from feature.residues. For instance, a SNP feature
+located on a wild and mutant protein would have different alternative residues.
+for alignment/similarity features, the alternative residues is used to
+represent the alignment string (CIGAR format). Note on variation
+features; even if we do not want to instantiate a mutant
+chromosome/contig feature, we can still represent a SNP etc with 2
+locations, one (rank 0) on the genome, the other (rank 1) would have
+most fields null, except for alternative residues.';
+
+
+--
+-- Name: COLUMN featureloc.locgroup; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureloc.locgroup IS 'This is used to manifest redundant,
+derivable extra locations for a feature. The default locgroup=0 is
+used for the DIRECT location of a feature. Important: most Chado users may
+never use featurelocs WITH logroup > 0. Transitively derived locations
+are indicated with locgroup > 0. For example, the position of an exon on
+a BAC and in global chromosome coordinates. This column is used to
+differentiate these groupings of locations. The default locgroup 0
+is used for the main or primary location, from which the others can be
+derived via coordinate transformations. Another example of redundant
+locations is storing ORF coordinates relative to both transcript and
+genome. Redundant locations open the possibility of the database
+getting into inconsistent states; this schema gives us the flexibility
+of both warehouse instantiations with redundant locations (easier for
+querying) and management instantiations with no redundant
+locations. An example of using both locgroup and rank: imagine a
+feature indicating a conserved region between the chromosomes of two
+different species. We may want to keep redundant locations on both
+contigs and chromosomes. We would thus have 4 locations for the single
+conserved region feature - two distinct locgroups (contig level and
+chromosome level) and two distinct ranks (for the two species).';
+
+
+--
+-- Name: COLUMN featureloc.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureloc.rank IS 'Used when a feature has >1
+location, otherwise the default rank 0 is used. Some features (e.g.
+blast hits and HSPs) have two locations - one on the query and one on
+the subject. Rank is used to differentiate these. Rank=0 is always
+used for the query, Rank=1 for the subject. For multiple alignments,
+assignment of rank is arbitrary. Rank is also used for
+sequence_variant features, such as SNPs. Rank=0 indicates the wildtype
+(or baseline) feature, Rank=1 indicates the mutant (or compared) feature.';
+
+
+--
+-- Name: feature_subalignments(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION feature_subalignments(integer) RETURNS SETOF featureloc
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ return_data featureloc%ROWTYPE;
+ f_id ALIAS FOR $1;
+ feature_data feature%rowtype;
+ featureloc_data featureloc%rowtype;
+ s text;
+ fmin integer;
+ slen integer;
+BEGIN
+ --RAISE NOTICE 'feature_id is %', featureloc_data.feature_id;
+ SELECT INTO feature_data * FROM feature WHERE feature_id = f_id;
+ FOR featureloc_data IN SELECT * FROM featureloc WHERE feature_id = f_id LOOP
+ --RAISE NOTICE 'fmin is %', featureloc_data.fmin;
+ return_data.feature_id = f_id;
+ return_data.srcfeature_id = featureloc_data.srcfeature_id;
+ return_data.is_fmin_partial = featureloc_data.is_fmin_partial;
+ return_data.is_fmax_partial = featureloc_data.is_fmax_partial;
+ return_data.strand = featureloc_data.strand;
+ return_data.phase = featureloc_data.phase;
+ return_data.residue_info = featureloc_data.residue_info;
+ return_data.locgroup = featureloc_data.locgroup;
+ return_data.rank = featureloc_data.rank;
+ s = feature_data.residues;
+ fmin = featureloc_data.fmin;
+ slen = char_length(s);
+ WHILE char_length(s) LOOP
+ --RAISE NOTICE 'residues is %', s;
+ --trim off leading match
+ s = trim(leading '|ATCGNatcgn' from s);
+ --if leading match detected
+ IF slen > char_length(s) THEN
+ return_data.fmin = fmin;
+ return_data.fmax = featureloc_data.fmin + (slen - char_length(s));
+ --if the string started with a match, return it,
+ --otherwise, trim the gaps first (ie do not return this iteration)
+ RETURN NEXT return_data;
+ END IF;
+ --trim off leading gap
+ s = trim(leading '-' from s);
+ fmin = featureloc_data.fmin + (slen - char_length(s));
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: featureloc_slice(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION featureloc_slice(integer, integer) RETURNS SETOF featureloc
+ LANGUAGE sql
+ AS $_$SELECT * from featureloc where boxquery($1, $2) @ boxrange(fmin,fmax)$_$;
+
+
+--
+-- Name: featureloc_slice(integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION featureloc_slice(integer, integer, integer) RETURNS SETOF featureloc
+ LANGUAGE sql
+ AS $_$SELECT *
+ FROM featureloc
+ WHERE boxquery($1, $2, $3) && boxrange(srcfeature_id,fmin,fmax)$_$;
+
+
+--
+-- Name: featureloc_slice(character varying, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION featureloc_slice(character varying, integer, integer) RETURNS SETOF featureloc
+ LANGUAGE sql
+ AS $_$SELECT featureloc.*
+ FROM featureloc
+ INNER JOIN feature AS srcf ON (srcf.feature_id = featureloc.srcfeature_id)
+ WHERE boxquery($2, $3) @ boxrange(fmin,fmax)
+ AND srcf.name = $1 $_$;
+
+
+--
+-- Name: featureslice(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION featureslice(integer, integer) RETURNS SETOF featureloc
+ LANGUAGE sql
+ AS $_$SELECT * from featureloc where boxquery($1, $2) @ boxrange(fmin,fmax)$_$;
+
+
+--
+-- Name: fill_cvtermpath(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION fill_cvtermpath(integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ cvid alias for $1;
+ root cvterm%ROWTYPE;
+BEGIN
+ DELETE FROM cvtermpath WHERE cv_id = cvid;
+ FOR root IN SELECT DISTINCT t.* from cvterm t LEFT JOIN cvterm_relationship r ON (t.cvterm_id = r.subject_id) INNER JOIN cvterm_relationship r2 ON (t.cvterm_id = r2.object_id) WHERE t.cv_id = cvid AND r.subject_id is null LOOP
+ PERFORM _fill_cvtermpath4root(root.cvterm_id, root.cv_id);
+ END LOOP;
+ RETURN 1;
+END;
+$_$;
+
+
+--
+-- Name: fill_cvtermpath(character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION fill_cvtermpath(character varying) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ cvname alias for $1;
+ cv_id int;
+ rtn int;
+BEGIN
+ SELECT INTO cv_id cv.cv_id from cv WHERE cv.name = cvname;
+ SELECT INTO rtn fill_cvtermpath(cv_id);
+ RETURN rtn;
+END;
+$_$;
+
+
+--
+-- Name: get_all_object_ids(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_all_object_ids(integer) RETURNS SETOF cvtermpath
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ leaf alias for $1;
+ cterm cvtermpath%ROWTYPE;
+ exist_c int;
+BEGIN
+ SELECT INTO exist_c count(*) FROM cvtermpath WHERE object_id = leaf and pathdistance <= 0;
+ IF (exist_c > 0) THEN
+ FOR cterm IN SELECT * FROM cvtermpath WHERE subject_id = leaf AND pathdistance > 0 LOOP
+ RETURN NEXT cterm;
+ END LOOP;
+ ELSE
+ FOR cterm IN SELECT * FROM _get_all_object_ids(leaf) LOOP
+ RETURN NEXT cterm;
+ END LOOP;
+ END IF;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_all_subject_ids(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_all_subject_ids(integer) RETURNS SETOF cvtermpath
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ root alias for $1;
+ cterm cvtermpath%ROWTYPE;
+ exist_c int;
+BEGIN
+ SELECT INTO exist_c count(*) FROM cvtermpath WHERE object_id = root and pathdistance <= 0;
+ IF (exist_c > 0) THEN
+ FOR cterm IN SELECT * FROM cvtermpath WHERE object_id = root and pathdistance > 0 LOOP
+ RETURN NEXT cterm;
+ END LOOP;
+ ELSE
+ FOR cterm IN SELECT * FROM _get_all_subject_ids(root) LOOP
+ RETURN NEXT cterm;
+ END LOOP;
+ END IF;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_cv_id_for_feature(); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_cv_id_for_feature() RETURNS integer
+ LANGUAGE sql
+ AS $$SELECT cv_id FROM cv WHERE name='sequence'$$;
+
+
+--
+-- Name: get_cv_id_for_feature_relationsgip(); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_cv_id_for_feature_relationsgip() RETURNS integer
+ LANGUAGE sql
+ AS $$SELECT cv_id FROM cv WHERE name='relationship'$$;
+
+
+--
+-- Name: get_cv_id_for_featureprop(); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_cv_id_for_featureprop() RETURNS integer
+ LANGUAGE sql
+ AS $$SELECT cv_id FROM cv WHERE name='feature_property'$$;
+
+
+--
+-- Name: get_cycle_cvterm_id(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_cycle_cvterm_id(integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ cvid alias for $1;
+ root cvterm%ROWTYPE;
+ rtn int;
+BEGIN
+ CREATE TEMP TABLE tmpcvtermpath(object_id int, subject_id int, cv_id int, type_id int, pathdistance int);
+ CREATE INDEX tmp_cvtpath1 ON tmpcvtermpath(object_id, subject_id);
+ FOR root IN SELECT DISTINCT t.* from cvterm t LEFT JOIN cvterm_relationship r ON (t.cvterm_id = r.subject_id) INNER JOIN cvterm_relationship r2 ON (t.cvterm_id = r2.object_id) WHERE t.cv_id = cvid AND r.subject_id is null LOOP
+ SELECT INTO rtn _fill_cvtermpath4root2detect_cycle(root.cvterm_id, root.cv_id);
+ IF (rtn > 0) THEN
+ DROP TABLE tmpcvtermpath;
+ RETURN rtn;
+ END IF;
+ END LOOP;
+ DROP TABLE tmpcvtermpath;
+ RETURN 0;
+END;
+$_$;
+
+
+--
+-- Name: get_cycle_cvterm_id(character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_cycle_cvterm_id(character varying) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ cvname alias for $1;
+ cv_id int;
+ rtn int;
+BEGIN
+ SELECT INTO cv_id cv.cv_id from cv WHERE cv.name = cvname;
+ SELECT INTO rtn get_cycle_cvterm_id(cv_id);
+ RETURN rtn;
+END;
+$_$;
+
+
+--
+-- Name: get_cycle_cvterm_id(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_cycle_cvterm_id(integer, integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ cvid alias for $1;
+ rootid alias for $2;
+ rtn int;
+BEGIN
+ CREATE TEMP TABLE tmpcvtermpath(object_id int, subject_id int, cv_id int, type_id int, pathdistance int);
+ CREATE INDEX tmp_cvtpath1 ON tmpcvtermpath(object_id, subject_id);
+ SELECT INTO rtn _fill_cvtermpath4root2detect_cycle(rootid, cvid);
+ IF (rtn > 0) THEN
+ DROP TABLE tmpcvtermpath;
+ RETURN rtn;
+ END IF;
+ DROP TABLE tmpcvtermpath;
+ RETURN 0;
+END;
+$_$;
+
+
+--
+-- Name: get_cycle_cvterm_ids(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_cycle_cvterm_ids(integer) RETURNS SETOF integer
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ cvid alias for $1;
+ root cvterm%ROWTYPE;
+ rtn int;
+BEGIN
+ FOR root IN SELECT DISTINCT t.* from cvterm t WHERE cv_id = cvid LOOP
+ SELECT INTO rtn get_cycle_cvterm_id(cvid,root.cvterm_id);
+ IF (rtn > 0) THEN
+ RETURN NEXT rtn;
+ END IF;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_feature_id(character varying, character varying, character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_id(character varying, character varying, character varying) RETURNS integer
+ LANGUAGE sql
+ AS $_$
+ SELECT feature_id
+ FROM feature
+ WHERE uniquename=$1
+ AND type_id=get_feature_type_id($2)
+ AND organism_id=get_organism_id($3)
+ $_$;
+
+
+--
+-- Name: get_feature_ids(text); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_ids(text) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ sql alias for $1;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+ myrc3 feature_by_fx_type%ROWTYPE;
+BEGIN
+ FOR myrc IN EXECUTE sql LOOP
+ RETURN NEXT myrc;
+ FOR myrc2 IN SELECT * FROM get_up_feature_ids(myrc.feature_id) LOOP
+ RETURN NEXT myrc2;
+ END LOOP;
+ FOR myrc3 IN SELECT * FROM get_sub_feature_ids(myrc.feature_id) LOOP
+ RETURN NEXT myrc3;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_feature_ids_by_child_count(character varying, character varying, integer, character varying, character); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_ids_by_child_count(character varying, character varying, integer, character varying, character) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ ptype alias for $1;
+ ctype alias for $2;
+ ccount alias for $3;
+ operator alias for $4;
+ is_an alias for $5;
+ query TEXT;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type %ROWTYPE;
+BEGIN
+ query := 'SELECT DISTINCT f.feature_id
+ FROM feature f INNER join (select count(*) as c, p.feature_id FROM feature p
+ INNER join cvterm pt ON (p.type_id = pt.cvterm_id) INNER join feature_relationship fr
+ ON (p.feature_id = fr.object_id) INNER join feature c ON (c.feature_id = fr.subject_id)
+ INNER join cvterm ct ON (c.type_id = ct.cvterm_id)
+ WHERE pt.name = ' || quote_literal(ptype) || ' AND ct.name = ' || quote_literal(ctype)
+ || ' AND p.is_analysis = ' || quote_literal(is_an) || ' group by p.feature_id) as cq
+ ON (cq.feature_id = f.feature_id) WHERE cq.c ' || operator || ccount || ';';
+ ---RAISE NOTICE '%', query;
+ FOR myrc IN SELECT * FROM get_feature_ids(query) LOOP
+ RETURN NEXT myrc;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_feature_ids_by_ont(character varying, character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_ids_by_ont(character varying, character varying) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ aspect alias for $1;
+ term alias for $2;
+ query TEXT;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ query := 'SELECT DISTINCT fcvt.feature_id
+ FROM feature_cvterm fcvt, cv, cvterm t WHERE cv.cv_id = t.cv_id AND
+ t.cvterm_id = fcvt.cvterm_id AND cv.name = ' || quote_literal(aspect) ||
+ ' AND t.name = ' || quote_literal(term) || ';';
+ IF (STRPOS(term, '%') > 0) THEN
+ query := 'SELECT DISTINCT fcvt.feature_id
+ FROM feature_cvterm fcvt, cv, cvterm t WHERE cv.cv_id = t.cv_id AND
+ t.cvterm_id = fcvt.cvterm_id AND cv.name = ' || quote_literal(aspect) ||
+ ' AND t.name like ' || quote_literal(term) || ';';
+ END IF;
+ FOR myrc IN SELECT * FROM get_feature_ids(query) LOOP
+ RETURN NEXT myrc;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_feature_ids_by_ont_root(character varying, character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_ids_by_ont_root(character varying, character varying) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ aspect alias for $1;
+ term alias for $2;
+ query TEXT;
+ subquery TEXT;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ subquery := 'SELECT t.cvterm_id FROM cv, cvterm t WHERE cv.cv_id = t.cv_id
+ AND cv.name = ' || quote_literal(aspect) || ' AND t.name = ' || quote_literal(term) || ';';
+ IF (STRPOS(term, '%') > 0) THEN
+ subquery := 'SELECT t.cvterm_id FROM cv, cvterm t WHERE cv.cv_id = t.cv_id
+ AND cv.name = ' || quote_literal(aspect) || ' AND t.name like ' || quote_literal(term) || ';';
+ END IF;
+ query := 'SELECT DISTINCT fcvt.feature_id
+ FROM feature_cvterm fcvt INNER JOIN (SELECT cvterm_id FROM get_it_sub_cvterm_ids(' || quote_literal(subquery) || ')) AS ont ON (fcvt.cvterm_id = ont.cvterm_id);';
+ FOR myrc IN SELECT * FROM get_feature_ids(query) LOOP
+ RETURN NEXT myrc;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_feature_ids_by_property(character varying, character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_ids_by_property(character varying, character varying) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ p_type alias for $1;
+ p_val alias for $2;
+ query TEXT;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ query := 'SELECT DISTINCT fprop.feature_id
+ FROM featureprop fprop, cvterm t WHERE t.cvterm_id = fprop.type_id AND t.name = ' ||
+ quote_literal(p_type) || ' AND fprop.value = ' || quote_literal(p_val) || ';';
+ IF (STRPOS(p_val, '%') > 0) THEN
+ query := 'SELECT DISTINCT fprop.feature_id
+ FROM featureprop fprop, cvterm t WHERE t.cvterm_id = fprop.type_id AND t.name = ' ||
+ quote_literal(p_type) || ' AND fprop.value like ' || quote_literal(p_val) || ';';
+ END IF;
+ FOR myrc IN SELECT * FROM get_feature_ids(query) LOOP
+ RETURN NEXT myrc;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_feature_ids_by_propval(character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_ids_by_propval(character varying) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ p_val alias for $1;
+ query TEXT;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ query := 'SELECT DISTINCT fprop.feature_id
+ FROM featureprop fprop WHERE fprop.value = ' || quote_literal(p_val) || ';';
+ IF (STRPOS(p_val, '%') > 0) THEN
+ query := 'SELECT DISTINCT fprop.feature_id
+ FROM featureprop fprop WHERE fprop.value like ' || quote_literal(p_val) || ';';
+ END IF;
+ FOR myrc IN SELECT * FROM get_feature_ids(query) LOOP
+ RETURN NEXT myrc;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_feature_ids_by_type(character varying, character); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_ids_by_type(character varying, character) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ gtype alias for $1;
+ is_an alias for $2;
+ query TEXT;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ query := 'SELECT DISTINCT f.feature_id
+ FROM feature f, cvterm t WHERE t.cvterm_id = f.type_id AND t.name = ' || quote_literal(gtype) ||
+ ' AND f.is_analysis = ' || quote_literal(is_an) || ';';
+ IF (STRPOS(gtype, '%') > 0) THEN
+ query := 'SELECT DISTINCT f.feature_id
+ FROM feature f, cvterm t WHERE t.cvterm_id = f.type_id AND t.name like '
+ || quote_literal(gtype) || ' AND f.is_analysis = ' || quote_literal(is_an) || ';';
+ END IF;
+ FOR myrc IN SELECT * FROM get_feature_ids(query) LOOP
+ RETURN NEXT myrc;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_feature_ids_by_type_name(character varying, text, character); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_ids_by_type_name(character varying, text, character) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ gtype alias for $1;
+ name alias for $2;
+ is_an alias for $3;
+ query TEXT;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ query := 'SELECT DISTINCT f.feature_id
+ FROM feature f INNER join cvterm t ON (f.type_id = t.cvterm_id)
+ WHERE t.name = ' || quote_literal(gtype) || ' AND (f.uniquename = ' || quote_literal(name)
+ || ' OR f.name = ' || quote_literal(name) || ') AND f.is_analysis = ' || quote_literal(is_an) || ';';
+ IF (STRPOS(name, '%') > 0) THEN
+ query := 'SELECT DISTINCT f.feature_id
+ FROM feature f INNER join cvterm t ON (f.type_id = t.cvterm_id)
+ WHERE t.name = ' || quote_literal(gtype) || ' AND (f.uniquename like ' || quote_literal(name)
+ || ' OR f.name like ' || quote_literal(name) || ') AND f.is_analysis = ' || quote_literal(is_an) || ';';
+ END IF;
+ FOR myrc IN SELECT * FROM get_feature_ids(query) LOOP
+ RETURN NEXT myrc;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_feature_ids_by_type_src(character varying, text, character); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_ids_by_type_src(character varying, text, character) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ gtype alias for $1;
+ src alias for $2;
+ is_an alias for $3;
+ query TEXT;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ query := 'SELECT DISTINCT f.feature_id
+ FROM feature f INNER join cvterm t ON (f.type_id = t.cvterm_id) INNER join featureloc fl
+ ON (f.feature_id = fl.feature_id) INNER join feature src ON (src.feature_id = fl.srcfeature_id)
+ WHERE t.name = ' || quote_literal(gtype) || ' AND src.uniquename = ' || quote_literal(src)
+ || ' AND f.is_analysis = ' || quote_literal(is_an) || ';';
+ IF (STRPOS(gtype, '%') > 0) THEN
+ query := 'SELECT DISTINCT f.feature_id
+ FROM feature f INNER join cvterm t ON (f.type_id = t.cvterm_id) INNER join featureloc fl
+ ON (f.feature_id = fl.feature_id) INNER join feature src ON (src.feature_id = fl.srcfeature_id)
+ WHERE t.name like ' || quote_literal(gtype) || ' AND src.uniquename = ' || quote_literal(src)
+ || ' AND f.is_analysis = ' || quote_literal(is_an) || ';';
+ END IF;
+ FOR myrc IN SELECT * FROM get_feature_ids(query) LOOP
+ RETURN NEXT myrc;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_feature_relationship_type_id(character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_relationship_type_id(character varying) RETURNS integer
+ LANGUAGE sql
+ AS $_$
+ SELECT cvterm_id
+ FROM cv INNER JOIN cvterm USING (cv_id)
+ WHERE cvterm.name=$1 AND cv.name='relationship'
+ $_$;
+
+
+--
+-- Name: get_feature_type_id(character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_feature_type_id(character varying) RETURNS integer
+ LANGUAGE sql
+ AS $_$
+ SELECT cvterm_id
+ FROM cv INNER JOIN cvterm USING (cv_id)
+ WHERE cvterm.name=$1 AND cv.name='sequence'
+ $_$;
+
+
+--
+-- Name: get_featureprop_type_id(character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_featureprop_type_id(character varying) RETURNS integer
+ LANGUAGE sql
+ AS $_$
+ SELECT cvterm_id
+ FROM cv INNER JOIN cvterm USING (cv_id)
+ WHERE cvterm.name=$1 AND cv.name='feature_property'
+ $_$;
+
+
+--
+-- Name: get_graph_above(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_graph_above(integer) RETURNS SETOF cvtermpath
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ leaf alias for $1;
+ cterm cvtermpath%ROWTYPE;
+ cterm2 cvtermpath%ROWTYPE;
+BEGIN
+ FOR cterm IN SELECT * FROM cvterm_relationship WHERE subject_id = leaf LOOP
+ RETURN NEXT cterm;
+ FOR cterm2 IN SELECT * FROM get_all_object_ids(cterm.object_id) LOOP
+ RETURN NEXT cterm2;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_graph_below(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_graph_below(integer) RETURNS SETOF cvtermpath
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ root alias for $1;
+ cterm cvtermpath%ROWTYPE;
+ cterm2 cvtermpath%ROWTYPE;
+BEGIN
+ FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = root LOOP
+ RETURN NEXT cterm;
+ FOR cterm2 IN SELECT * FROM get_all_subject_ids(cterm.subject_id) LOOP
+ RETURN NEXT cterm2;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: cvterm; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cvterm (
+ cvterm_id integer NOT NULL,
+ cv_id integer NOT NULL,
+ name character varying(1024) NOT NULL,
+ definition text,
+ dbxref_id integer NOT NULL,
+ is_obsolete integer DEFAULT 0 NOT NULL,
+ is_relationshiptype integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cvterm; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE cvterm IS 'A term, class, universal or type within an
+ontology or controlled vocabulary. This table is also used for
+relations and properties. cvterms constitute nodes in the graph
+defined by the collection of cvterms and cvterm_relationships.';
+
+
+--
+-- Name: COLUMN cvterm.cv_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvterm.cv_id IS 'The cv or ontology or namespace to which
+this cvterm belongs.';
+
+
+--
+-- Name: COLUMN cvterm.name; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvterm.name IS 'A concise human-readable name or
+label for the cvterm. Uniquely identifies a cvterm within a cv.';
+
+
+--
+-- Name: COLUMN cvterm.definition; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvterm.definition IS 'A human-readable text
+definition.';
+
+
+--
+-- Name: COLUMN cvterm.dbxref_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvterm.dbxref_id IS 'Primary identifier dbxref - The
+unique global OBO identifier for this cvterm. Note that a cvterm may
+have multiple secondary dbxrefs - see also table: cvterm_dbxref.';
+
+
+--
+-- Name: COLUMN cvterm.is_obsolete; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvterm.is_obsolete IS 'Boolean 0=false,1=true; see
+GO documentation for details of obsoletion. Note that two terms with
+different primary dbxrefs may exist if one is obsolete.';
+
+
+--
+-- Name: COLUMN cvterm.is_relationshiptype; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvterm.is_relationshiptype IS 'Boolean
+0=false,1=true relations or relationship types (also known as Typedefs
+in OBO format, or as properties or slots) form a cv/ontology in
+themselves. We use this flag to indicate whether this cvterm is an
+actual term/class/universal or a relation. Relations may be drawn from
+the OBO Relations ontology, but are not exclusively drawn from there.';
+
+
+--
+-- Name: get_it_sub_cvterm_ids(text); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_it_sub_cvterm_ids(text) RETURNS SETOF cvterm
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ query alias for $1;
+ cterm cvterm%ROWTYPE;
+ cterm2 cvterm%ROWTYPE;
+BEGIN
+ FOR cterm IN EXECUTE query LOOP
+ RETURN NEXT cterm;
+ FOR cterm2 IN SELECT subject_id as cvterm_id FROM get_all_subject_ids(cterm.cvterm_id) LOOP
+ RETURN NEXT cterm2;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_organism_id(character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_organism_id(character varying) RETURNS integer
+ LANGUAGE sql
+ AS $_$
+SELECT organism_id
+ FROM organism
+ WHERE genus=substring($1,1,position(' ' IN $1)-1)
+ AND species=substring($1,position(' ' IN $1)+1)
+ $_$;
+
+
+--
+-- Name: get_organism_id(character varying, character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_organism_id(character varying, character varying) RETURNS integer
+ LANGUAGE sql
+ AS $_$
+ SELECT organism_id
+ FROM organism
+ WHERE genus=$1
+ AND species=$2
+ $_$;
+
+
+--
+-- Name: get_organism_id_abbrev(character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_organism_id_abbrev(character varying) RETURNS integer
+ LANGUAGE sql
+ AS $_$
+SELECT organism_id
+ FROM organism
+ WHERE substr(genus,1,1)=substring($1,1,1)
+ AND species=substring($1,position(' ' IN $1)+1)
+ $_$;
+
+
+--
+-- Name: get_sub_feature_ids(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_sub_feature_ids(integer) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ root alias for $1;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ FOR myrc IN SELECT DISTINCT subject_id AS feature_id FROM feature_relationship WHERE object_id = root LOOP
+ RETURN NEXT myrc;
+ FOR myrc2 IN SELECT * FROM get_sub_feature_ids(myrc.feature_id) LOOP
+ RETURN NEXT myrc2;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_sub_feature_ids(text); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_sub_feature_ids(text) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ sql alias for $1;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ FOR myrc IN EXECUTE sql LOOP
+ FOR myrc2 IN SELECT * FROM get_sub_feature_ids(myrc.feature_id) LOOP
+ RETURN NEXT myrc2;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_sub_feature_ids(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_sub_feature_ids(integer, integer) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ root alias for $1;
+ depth alias for $2;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ FOR myrc IN SELECT DISTINCT subject_id AS feature_id, depth FROM feature_relationship WHERE object_id = root LOOP
+ RETURN NEXT myrc;
+ FOR myrc2 IN SELECT * FROM get_sub_feature_ids(myrc.feature_id,depth+1) LOOP
+ RETURN NEXT myrc2;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_sub_feature_ids_by_type_src(character varying, text, character); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_sub_feature_ids_by_type_src(character varying, text, character) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ gtype alias for $1;
+ src alias for $2;
+ is_an alias for $3;
+ query text;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ query := 'SELECT DISTINCT f.feature_id FROM feature f INNER join cvterm t ON (f.type_id = t.cvterm_id)
+ INNER join featureloc fl
+ ON (f.feature_id = fl.feature_id) INNER join feature src ON (src.feature_id = fl.srcfeature_id)
+ WHERE t.name = ' || quote_literal(gtype) || ' AND src.uniquename = ' || quote_literal(src)
+ || ' AND f.is_analysis = ' || quote_literal(is_an) || ';';
+ IF (STRPOS(gtype, '%') > 0) THEN
+ query := 'SELECT DISTINCT f.feature_id FROM feature f INNER join cvterm t ON (f.type_id = t.cvterm_id)
+ INNER join featureloc fl
+ ON (f.feature_id = fl.feature_id) INNER join feature src ON (src.feature_id = fl.srcfeature_id)
+ WHERE t.name like ' || quote_literal(gtype) || ' AND src.uniquename = ' || quote_literal(src)
+ || ' AND f.is_analysis = ' || quote_literal(is_an) || ';';
+ END IF;
+ FOR myrc IN SELECT * FROM get_sub_feature_ids(query) LOOP
+ RETURN NEXT myrc;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_up_feature_ids(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_up_feature_ids(integer) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ leaf alias for $1;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ FOR myrc IN SELECT DISTINCT object_id AS feature_id FROM feature_relationship WHERE subject_id = leaf LOOP
+ RETURN NEXT myrc;
+ FOR myrc2 IN SELECT * FROM get_up_feature_ids(myrc.feature_id) LOOP
+ RETURN NEXT myrc2;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_up_feature_ids(text); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_up_feature_ids(text) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ sql alias for $1;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ FOR myrc IN EXECUTE sql LOOP
+ FOR myrc2 IN SELECT * FROM get_up_feature_ids(myrc.feature_id) LOOP
+ RETURN NEXT myrc2;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: get_up_feature_ids(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION get_up_feature_ids(integer, integer) RETURNS SETOF feature_by_fx_type
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ leaf alias for $1;
+ depth alias for $2;
+ myrc feature_by_fx_type%ROWTYPE;
+ myrc2 feature_by_fx_type%ROWTYPE;
+BEGIN
+ FOR myrc IN SELECT DISTINCT object_id AS feature_id, depth FROM feature_relationship WHERE subject_id = leaf LOOP
+ RETURN NEXT myrc;
+ FOR myrc2 IN SELECT * FROM get_up_feature_ids(myrc.feature_id,depth+1) LOOP
+ RETURN NEXT myrc2;
+ END LOOP;
+ END LOOP;
+ RETURN;
+END;
+$_$;
+
+
+--
+-- Name: gffattstring(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION gffattstring(integer) RETURNS character varying
+ LANGUAGE plpgsql
+ AS $_$DECLARE
+ return_string varchar;
+ f_id ALIAS FOR $1;
+ atts_view gffatts%ROWTYPE;
+ feature_row feature%ROWTYPE;
+ name varchar;
+ uniquename varchar;
+ parent varchar;
+ escape_loc int;
+BEGIN
+ --Get name from feature.name
+ --Get ID from feature.uniquename
+ SELECT INTO feature_row * FROM feature WHERE feature_id = f_id;
+ name = feature_row.name;
+ return_string = 'ID=' || feature_row.uniquename;
+ IF name IS NOT NULL AND name != ''
+ THEN
+ return_string = return_string ||';' || 'Name=' || name;
+ END IF;
+ --Get Parent from feature_relationship
+ SELECT INTO feature_row * FROM feature f, feature_relationship fr
+ WHERE fr.subject_id = f_id AND fr.object_id = f.feature_id;
+ IF FOUND
+ THEN
+ return_string = return_string||';'||'Parent='||feature_row.uniquename;
+ END IF;
+ FOR atts_view IN SELECT * FROM gff3atts WHERE feature_id = f_id LOOP
+ escape_loc = position(';' in atts_view.attribute);
+ IF escape_loc > 0 THEN
+ atts_view.attribute = replace(atts_view.attribute, ';', '%3B');
+ END IF;
+ return_string = return_string || ';'
+ || atts_view.type || '='
+ || atts_view.attribute;
+ END LOOP;
+ RETURN return_string;
+END;
+$_$;
+
+
+--
+-- Name: db; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE db (
+ db_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ description character varying(255),
+ urlprefix character varying(255),
+ url character varying(255)
+);
+
+
+--
+-- Name: TABLE db; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE db IS 'A database authority. Typical databases in
+bioinformatics are FlyBase, GO, UniProt, NCBI, MGI, etc. The authority
+is generally known by this shortened form, which is unique within the
+bioinformatics and biomedical realm. To Do - add support for URIs,
+URNs (e.g. LSIDs). We can do this by treating the URL as a URI -
+however, some applications may expect this to be resolvable - to be
+decided.';
+
+
+--
+-- Name: dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE dbxref (
+ dbxref_id integer NOT NULL,
+ db_id integer NOT NULL,
+ accession character varying(255) NOT NULL,
+ version character varying(255) DEFAULT ''::character varying NOT NULL,
+ description text
+);
+
+
+--
+-- Name: TABLE dbxref; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE dbxref IS 'A unique, global, chado. stable identifier. Not necessarily an external reference - can reference data items inside the particular chado instance being used. Typically a row in a table can be uniquely identified with a primary identifier (called dbxref_id); a table may also have secondary identifiers (in a linking table _dbxref). A dbxref is generally written as : or as ::.';
+
+
+--
+-- Name: COLUMN dbxref.accession; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN dbxref.accession IS 'The local part of the identifier. Guaranteed by the db authority to be unique for that db.';
+
+
+--
+-- Name: feature_cvterm; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_cvterm (
+ feature_cvterm_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ pub_id integer NOT NULL,
+ is_not boolean DEFAULT false NOT NULL,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_cvterm; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_cvterm IS 'Associate a term from a cv with a feature, for example, GO annotation.';
+
+
+--
+-- Name: COLUMN feature_cvterm.pub_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_cvterm.pub_id IS 'Provenance for the annotation. Each annotation should have a single primary chado.tion (which may be of the appropriate type for computational analyses) where more details can be found. Additional provenance dbxrefs can be attached using feature_cvterm_dbxref.';
+
+
+--
+-- Name: COLUMN feature_cvterm.is_not; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_cvterm.is_not IS 'If this is set to true, then this annotation is interpreted as a NEGATIVE annotation - i.e. the feature does NOT have the specified function, process, component, part, etc. See GO docs for more details.';
+
+
+--
+-- Name: feature_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_dbxref (
+ feature_dbxref_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ dbxref_id integer NOT NULL,
+ is_current boolean DEFAULT true NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_dbxref; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_dbxref IS 'Links a feature to dbxrefs. This is for secondary identifiers; primary identifiers should use feature.dbxref_id.';
+
+
+--
+-- Name: COLUMN feature_dbxref.is_current; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_dbxref.is_current IS 'True if this secondary dbxref is the most up to date accession in the corresponding db. Retired accessions should set this field to false';
+
+
+--
+-- Name: feature_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_pub (
+ feature_pub_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_pub IS 'Provenance. Linking table between features and chado.tions that mention them.';
+
+
+--
+-- Name: feature_synonym; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_synonym (
+ feature_synonym_id integer NOT NULL,
+ synonym_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ pub_id integer NOT NULL,
+ is_current boolean DEFAULT false NOT NULL,
+ is_internal boolean DEFAULT false NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_synonym; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_synonym IS 'Linking table between feature and synonym.';
+
+
+--
+-- Name: COLUMN feature_synonym.pub_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_synonym.pub_id IS 'The pub_id link is for relating the usage of a given synonym to the chado.tion in which it was used.';
+
+
+--
+-- Name: COLUMN feature_synonym.is_current; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_synonym.is_current IS 'The is_current boolean indicates whether the linked synonym is the current -official- symbol for the linked feature.';
+
+
+--
+-- Name: COLUMN feature_synonym.is_internal; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_synonym.is_internal IS 'Typically a synonym exists so that somebody querying the db with an obsolete name can find the object theyre looking for (under its current name. If the synonym has been used chado.y and deliberately (e.g. in a paper), it may also be listed in reports as a synonym. If the synonym was not used deliberately (e.g. there was a typo which went chado., then the is_internal boolean may be set to -true- so that it is known that the synonym is -internal- and should be queryable but should not be listed in reports as a valid synonym.';
+
+
+--
+-- Name: featureprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featureprop (
+ featureprop_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE featureprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE featureprop IS 'A feature can have any number of slot-value property tags attached to it. This is an alternative to hardcoding a list of columns in the relational schema, and is completely extensible.';
+
+
+--
+-- Name: COLUMN featureprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureprop.type_id IS 'The name of the
+property/slot is a cvterm. The meaning of the property is defined in
+that cvterm. Certain property types will only apply to certain feature
+types (e.g. the anticodon property will only apply to tRNA features) ;
+the types here come from the sequence feature property ontology.';
+
+
+--
+-- Name: COLUMN featureprop.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureprop.value IS 'The value of the property, represented as text. Numeric values are converted to their text representation. This is less efficient than using native database types, but is easier to query.';
+
+
+--
+-- Name: COLUMN featureprop.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featureprop.rank IS 'Property-Value ordering. Any
+feature can have multiple values for any particular property type -
+these are ordered in a list using rank, counting from zero. For
+properties that are single-valued rather than multi-valued, the
+default 0 value should be used';
+
+
+--
+-- Name: pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE pub (
+ pub_id integer NOT NULL,
+ title text,
+ volumetitle text,
+ volume character varying(255),
+ series_name character varying(255),
+ issue character varying(255),
+ pyear character varying(255),
+ pages character varying(255),
+ miniref character varying(255),
+ uniquename text NOT NULL,
+ type_id integer NOT NULL,
+ is_obsolete boolean DEFAULT false,
+ publisher character varying(255),
+ pubplace character varying(255)
+);
+
+
+--
+-- Name: TABLE pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE pub IS 'A documented provenance artefact - chado.tions,
+documents, personal communication.';
+
+
+--
+-- Name: COLUMN pub.title; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN pub.title IS 'Descriptive general heading.';
+
+
+--
+-- Name: COLUMN pub.volumetitle; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN pub.volumetitle IS 'Title of part if one of a series.';
+
+
+--
+-- Name: COLUMN pub.series_name; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN pub.series_name IS 'Full name of (journal) series.';
+
+
+--
+-- Name: COLUMN pub.pages; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN pub.pages IS 'Page number range[s], e.g. 457--459, viii + 664pp, lv--lvii.';
+
+
+--
+-- Name: COLUMN pub.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN pub.type_id IS 'The type of the chado.tion (book, journal, poem, graffiti, etc). Uses pub cv.';
+
+
+--
+-- Name: synonym; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE synonym (
+ synonym_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ type_id integer NOT NULL,
+ synonym_sgml character varying(255) NOT NULL
+);
+
+
+--
+-- Name: TABLE synonym; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE synonym IS 'A synonym for a feature. One feature can have multiple synonyms, and the same synonym can apply to multiple features.';
+
+
+--
+-- Name: COLUMN synonym.name; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN synonym.name IS 'The synonym itself. Should be human-readable machine-searchable ascii text.';
+
+
+--
+-- Name: COLUMN synonym.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN synonym.type_id IS 'Types would be symbol and fullname for now.';
+
+
+--
+-- Name: COLUMN synonym.synonym_sgml; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN synonym.synonym_sgml IS 'The fully specified synonym, with any non-ascii characters encoded in SGML.';
+
+
+--
+-- Name: gffatts; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW gffatts AS
+ SELECT fs.feature_id,
+ 'Ontology_term'::text AS type,
+ s.name AS attribute
+ FROM cvterm s,
+ feature_cvterm fs
+ WHERE (fs.cvterm_id = s.cvterm_id)
+UNION ALL
+ SELECT fs.feature_id,
+ 'Dbxref'::text AS type,
+ (((d.name)::text || ':'::text) || (s.accession)::text) AS attribute
+ FROM dbxref s,
+ feature_dbxref fs,
+ db d
+ WHERE ((fs.dbxref_id = s.dbxref_id) AND (s.db_id = d.db_id))
+UNION ALL
+ SELECT fs.feature_id,
+ 'Alias'::text AS type,
+ s.name AS attribute
+ FROM synonym s,
+ feature_synonym fs
+ WHERE (fs.synonym_id = s.synonym_id)
+UNION ALL
+ SELECT fp.feature_id,
+ cv.name AS type,
+ fp.value AS attribute
+ FROM featureprop fp,
+ cvterm cv
+ WHERE (fp.type_id = cv.cvterm_id)
+UNION ALL
+ SELECT fs.feature_id,
+ 'pub'::text AS type,
+ (((s.series_name)::text || ':'::text) || s.title) AS attribute
+ FROM pub s,
+ feature_pub fs
+ WHERE (fs.pub_id = s.pub_id);
+
+
+--
+-- Name: gfffeatureatts(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION gfffeatureatts(integer) RETURNS SETOF gffatts
+ LANGUAGE sql
+ AS $_$
+SELECT feature_id, 'cvterm' AS type, s.name AS attribute
+FROM cvterm s, feature_cvterm fs
+WHERE fs.feature_id= $1 AND fs.cvterm_id = s.cvterm_id
+UNION
+SELECT feature_id, 'dbxref' AS type, d.name || ':' || s.accession AS attribute
+FROM dbxref s, feature_dbxref fs, db d
+WHERE fs.feature_id= $1 AND fs.dbxref_id = s.dbxref_id AND s.db_id = d.db_id
+--UNION
+--SELECT feature_id, 'expression' AS type, s.description AS attribute
+--FROM expression s, feature_expression fs
+--WHERE fs.feature_id= $1 AND fs.expression_id = s.expression_id
+--UNION
+--SELECT fg.feature_id, 'genotype' AS type, g.uniquename||': '||g.description AS attribute
+--FROM gcontext g, feature_gcontext fg
+--WHERE fg.feature_id= $1 AND g.gcontext_id = fg.gcontext_id
+--UNION
+--SELECT feature_id, 'genotype' AS type, s.description AS attribute
+--FROM genotype s, feature_genotype fs
+--WHERE fs.feature_id= $1 AND fs.genotype_id = s.genotype_id
+--UNION
+--SELECT feature_id, 'phenotype' AS type, s.description AS attribute
+--FROM phenotype s, feature_phenotype fs
+--WHERE fs.feature_id= $1 AND fs.phenotype_id = s.phenotype_id
+UNION
+SELECT feature_id, 'synonym' AS type, s.name AS attribute
+FROM synonym s, feature_synonym fs
+WHERE fs.feature_id= $1 AND fs.synonym_id = s.synonym_id
+UNION
+SELECT fp.feature_id,cv.name,fp.value
+FROM featureprop fp, cvterm cv
+WHERE fp.feature_id= $1 AND fp.type_id = cv.cvterm_id
+UNION
+SELECT feature_id, 'pub' AS type, s.series_name || ':' || s.title AS attribute
+FROM pub s, feature_pub fs
+WHERE fs.feature_id= $1 AND fs.pub_id = s.pub_id
+$_$;
+
+
+--
+-- Name: order_exons(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION order_exons(integer) RETURNS void
+ LANGUAGE plpgsql
+ AS $_$
+ DECLARE
+ parent_type ALIAS FOR $1;
+ exon_id int;
+ part_of int;
+ exon_type int;
+ strand int;
+ arow RECORD;
+ order_by varchar;
+ rowcount int;
+ exon_count int;
+ ordered_exons int;
+ transcript_id int;
+ transcript_row feature%ROWTYPE;
+ BEGIN
+ SELECT INTO part_of cvterm_id FROM cvterm WHERE name='part_of'
+ AND cv_id IN (SELECT cv_id FROM cv WHERE name='relationship');
+ --SELECT INTO exon_type cvterm_id FROM cvterm WHERE name='exon'
+ -- AND cv_id IN (SELECT cv_id FROM cv WHERE name='sequence');
+ --RAISE NOTICE 'part_of %, exon %',part_of,exon_type;
+ FOR transcript_row IN
+ SELECT * FROM feature WHERE type_id = parent_type
+ LOOP
+ transcript_id = transcript_row.feature_id;
+ SELECT INTO rowcount count(*) FROM feature_relationship
+ WHERE object_id = transcript_id
+ AND rank = 0;
+ --Dont modify this transcript if there are already numbered exons or
+ --if there is only one exon
+ IF rowcount = 1 THEN
+ --RAISE NOTICE 'skipping transcript %, row count %',transcript_id,rowcount;
+ CONTINUE;
+ END IF;
+ --need to reverse the order if the strand is negative
+ SELECT INTO strand strand FROM featureloc WHERE feature_id=transcript_id;
+ IF strand > 0 THEN
+ order_by = 'fl.fmin';
+ ELSE
+ order_by = 'fl.fmax desc';
+ END IF;
+ exon_count = 0;
+ FOR arow IN EXECUTE
+ 'SELECT fr.*, fl.fmin, fl.fmax
+ FROM feature_relationship fr, featureloc fl
+ WHERE fr.object_id = '||transcript_id||'
+ AND fr.subject_id = fl.feature_id
+ AND fr.type_id = '||part_of||'
+ ORDER BY '||order_by
+ LOOP
+ --number the exons for a given transcript
+ UPDATE feature_relationship
+ SET rank = exon_count
+ WHERE feature_relationship_id = arow.feature_relationship_id;
+ exon_count = exon_count + 1;
+ END LOOP;
+ END LOOP;
+ END;
+$_$;
+
+
+--
+-- Name: phylonode_depth(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION phylonode_depth(integer) RETURNS double precision
+ LANGUAGE plpgsql
+ AS $_$DECLARE id ALIAS FOR $1;
+ DECLARE depth FLOAT := 0;
+ DECLARE curr_node phylonode%ROWTYPE;
+ BEGIN
+ SELECT INTO curr_node *
+ FROM phylonode
+ WHERE phylonode_id=id;
+ depth = depth + curr_node.distance;
+ IF curr_node.parent_phylonode_id IS NULL
+ THEN RETURN depth;
+ ELSE RETURN depth + phylonode_depth(curr_node.parent_phylonode_id);
+ END IF;
+ END
+$_$;
+
+
+--
+-- Name: phylonode_height(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION phylonode_height(integer) RETURNS double precision
+ LANGUAGE sql
+ AS $_$
+ SELECT coalesce(max(phylonode_height(phylonode_id) + distance), 0.0)
+ FROM phylonode
+ WHERE parent_phylonode_id = $1
+$_$;
+
+
+--
+-- Name: project_featureloc_up(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION project_featureloc_up(integer, integer) RETURNS featureloc
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE
+ in_featureloc_id alias for $1;
+ up_srcfeature_id alias for $2;
+ in_featureloc featureloc%ROWTYPE;
+ up_featureloc featureloc%ROWTYPE;
+ nu_featureloc featureloc%ROWTYPE;
+ nu_fmin INT;
+ nu_fmax INT;
+ nu_strand INT;
+BEGIN
+ SELECT INTO in_featureloc
+ featureloc.*
+ FROM featureloc
+ WHERE featureloc_id = in_featureloc_id;
+ SELECT INTO up_featureloc
+ up_fl.*
+ FROM featureloc AS in_fl
+ INNER JOIN featureloc AS up_fl
+ ON (in_fl.srcfeature_id = up_fl.feature_id)
+ WHERE
+ in_fl.featureloc_id = in_featureloc_id AND
+ up_fl.srcfeature_id = up_srcfeature_id;
+ IF up_featureloc.strand IS NULL
+ THEN RETURN NULL;
+ END IF;
+ IF up_featureloc.strand < 0
+ THEN
+ nu_fmin = project_point_up(in_featureloc.fmax,
+ up_featureloc.fmin,up_featureloc.fmax,-1);
+ nu_fmax = project_point_up(in_featureloc.fmin,
+ up_featureloc.fmin,up_featureloc.fmax,-1);
+ nu_strand = -in_featureloc.strand;
+ ELSE
+ nu_fmin = project_point_up(in_featureloc.fmin,
+ up_featureloc.fmin,up_featureloc.fmax,1);
+ nu_fmax = project_point_up(in_featureloc.fmax,
+ up_featureloc.fmin,up_featureloc.fmax,1);
+ nu_strand = in_featureloc.strand;
+ END IF;
+ in_featureloc.fmin = nu_fmin;
+ in_featureloc.fmax = nu_fmax;
+ in_featureloc.strand = nu_strand;
+ in_featureloc.srcfeature_id = up_featureloc.srcfeature_id;
+ RETURN in_featureloc;
+END
+$_$;
+
+
+--
+-- Name: project_point_down(integer, integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION project_point_down(integer, integer, integer, integer) RETURNS integer
+ LANGUAGE sql
+ AS $_$SELECT
+ CASE WHEN $4<0
+ THEN $3-$1
+ ELSE $1+$2
+ END AS p$_$;
+
+
+--
+-- Name: project_point_g2t(integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION project_point_g2t(integer, integer, integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$
+ DECLARE
+ in_p alias for $1;
+ srcf_id alias for $2;
+ t_id alias for $3;
+ e_floc featureloc%ROWTYPE;
+ out_p INT;
+ exon_cvterm_id INT;
+BEGIN
+ SELECT INTO exon_cvterm_id get_feature_type_id('exon');
+ SELECT INTO out_p
+ CASE
+ WHEN strand<0 THEN fmax-p
+ ELSE p-fmin
+ END AS p
+ FROM featureloc
+ INNER JOIN feature USING (feature_id)
+ INNER JOIN feature_relationship ON (feature.feature_id=subject_id)
+ WHERE
+ object_id = t_id AND
+ feature.type_id = exon_cvterm_id AND
+ featureloc.srcfeature_id = srcf_id AND
+ in_p >= fmin AND
+ in_p <= fmax;
+ RETURN in_featureloc;
+END
+$_$;
+
+
+--
+-- Name: project_point_up(integer, integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION project_point_up(integer, integer, integer, integer) RETURNS integer
+ LANGUAGE sql
+ AS $_$SELECT
+ CASE WHEN $4<0
+ THEN $3-$1 -- rev strand
+ ELSE $1-$2 -- fwd strand
+ END AS p$_$;
+
+
+--
+-- Name: reverse_complement(text); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION reverse_complement(text) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT reverse_string(complement_residues($1))$_$;
+
+
+--
+-- Name: reverse_string(text); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION reverse_string(text) RETURNS text
+ LANGUAGE plpgsql
+ AS $_$
+ DECLARE
+ reversed_string TEXT;
+ incoming ALIAS FOR $1;
+ BEGIN
+ reversed_string = '';
+ FOR i IN REVERSE char_length(incoming)..1 loop
+ reversed_string = reversed_string || substring(incoming FROM i FOR 1);
+ END loop;
+ RETURN reversed_string;
+END$_$;
+
+
+--
+-- Name: share_exons(); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION share_exons() RETURNS void
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ BEGIN
+ CREATE temporary TABLE shared_exons AS
+ SELECT gene.feature_id as gene_feature_id
+ , gene.uniquename as gene_uniquename
+ , transcript1.uniquename as transcript1
+ , exon1.feature_id as exon1_feature_id
+ , exon1.uniquename as exon1_uniquename
+ , transcript2.uniquename as transcript2
+ , exon2.feature_id as exon2_feature_id
+ , exon2.uniquename as exon2_uniquename
+ , exon1_loc.fmin
+ , exon1_loc.fmax
+ FROM feature gene
+ JOIN cvterm gene_type ON gene.type_id = gene_type.cvterm_id
+ JOIN cv gene_type_cv USING (cv_id)
+ JOIN feature_relationship gene_transcript1 ON gene.feature_id = gene_transcript1.object_id
+ JOIN feature transcript1 ON gene_transcript1.subject_id = transcript1.feature_id
+ JOIN cvterm transcript1_type ON transcript1.type_id = transcript1_type.cvterm_id
+ JOIN cv transcript1_type_cv ON transcript1_type.cv_id = transcript1_type_cv.cv_id
+ JOIN feature_relationship transcript1_exon1 ON transcript1_exon1.object_id = transcript1.feature_id
+ JOIN feature exon1 ON transcript1_exon1.subject_id = exon1.feature_id
+ JOIN cvterm exon1_type ON exon1.type_id = exon1_type.cvterm_id
+ JOIN cv exon1_type_cv ON exon1_type.cv_id = exon1_type_cv.cv_id
+ JOIN featureloc exon1_loc ON exon1_loc.feature_id = exon1.feature_id
+ JOIN feature_relationship gene_transcript2 ON gene.feature_id = gene_transcript2.object_id
+ JOIN feature transcript2 ON gene_transcript2.subject_id = transcript2.feature_id
+ JOIN cvterm transcript2_type ON transcript2.type_id = transcript2_type.cvterm_id
+ JOIN cv transcript2_type_cv ON transcript2_type.cv_id = transcript2_type_cv.cv_id
+ JOIN feature_relationship transcript2_exon2 ON transcript2_exon2.object_id = transcript2.feature_id
+ JOIN feature exon2 ON transcript2_exon2.subject_id = exon2.feature_id
+ JOIN cvterm exon2_type ON exon2.type_id = exon2_type.cvterm_id
+ JOIN cv exon2_type_cv ON exon2_type.cv_id = exon2_type_cv.cv_id
+ JOIN featureloc exon2_loc ON exon2_loc.feature_id = exon2.feature_id
+ WHERE gene_type_cv.name = 'sequence'
+ AND gene_type.name = 'gene'
+ AND transcript1_type_cv.name = 'sequence'
+ AND transcript1_type.name = 'mRNA'
+ AND transcript2_type_cv.name = 'sequence'
+ AND transcript2_type.name = 'mRNA'
+ AND exon1_type_cv.name = 'sequence'
+ AND exon1_type.name = 'exon'
+ AND exon2_type_cv.name = 'sequence'
+ AND exon2_type.name = 'exon'
+ AND exon1.feature_id < exon2.feature_id
+ AND exon1_loc.rank = 0
+ AND exon2_loc.rank = 0
+ AND exon1_loc.fmin = exon2_loc.fmin
+ AND exon1_loc.fmax = exon2_loc.fmax
+ ;
+ /* Choose one of the shared exons to be the canonical representative.
+ We pick the one with the smallest feature_id.
+ */
+ CREATE temporary TABLE canonical_exon_representatives AS
+ SELECT gene_feature_id, min(exon1_feature_id) AS canonical_feature_id, fmin
+ FROM shared_exons
+ GROUP BY gene_feature_id,fmin
+ ;
+ CREATE temporary TABLE exon_replacements AS
+ SELECT DISTINCT shared_exons.exon2_feature_id AS actual_feature_id
+ , canonical_exon_representatives.canonical_feature_id
+ , canonical_exon_representatives.fmin
+ FROM shared_exons
+ JOIN canonical_exon_representatives USING (gene_feature_id)
+ WHERE shared_exons.exon2_feature_id <> canonical_exon_representatives.canonical_feature_id
+ AND shared_exons.fmin = canonical_exon_representatives.fmin
+ ;
+ UPDATE feature_relationship
+ SET subject_id = (
+ SELECT canonical_feature_id
+ FROM exon_replacements
+ WHERE feature_relationship.subject_id = exon_replacements.actual_feature_id)
+ WHERE subject_id IN (
+ SELECT actual_feature_id FROM exon_replacements
+ );
+ UPDATE feature_relationship
+ SET object_id = (
+ SELECT canonical_feature_id
+ FROM exon_replacements
+ WHERE feature_relationship.subject_id = exon_replacements.actual_feature_id)
+ WHERE object_id IN (
+ SELECT actual_feature_id FROM exon_replacements
+ );
+ UPDATE feature
+ SET is_obsolete = true
+ WHERE feature_id IN (
+ SELECT actual_feature_id FROM exon_replacements
+ );
+ END;
+$$;
+
+
+--
+-- Name: store_analysis(character varying, character varying, character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION store_analysis(character varying, character varying, character varying) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$DECLARE
+ v_program ALIAS FOR $1;
+ v_programversion ALIAS FOR $2;
+ v_sourcename ALIAS FOR $3;
+ pkval INTEGER;
+ BEGIN
+ SELECT INTO pkval analysis_id
+ FROM analysis
+ WHERE program=v_program AND
+ programversion=v_programversion AND
+ sourcename=v_sourcename;
+ IF NOT FOUND THEN
+ INSERT INTO analysis
+ (program,programversion,sourcename)
+ VALUES
+ (v_program,v_programversion,v_sourcename);
+ RETURN currval('analysis_analysis_id_seq');
+ END IF;
+ RETURN pkval;
+ END;
+$_$;
+
+
+--
+-- Name: store_db(character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION store_db(character varying) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$DECLARE
+ v_name ALIAS FOR $1;
+ v_db_id INTEGER;
+ BEGIN
+ SELECT INTO v_db_id db_id
+ FROM db
+ WHERE name=v_name;
+ IF NOT FOUND THEN
+ INSERT INTO db
+ (name)
+ VALUES
+ (v_name);
+ RETURN currval('db_db_id_seq');
+ END IF;
+ RETURN v_db_id;
+ END;
+$_$;
+
+
+--
+-- Name: store_dbxref(character varying, character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION store_dbxref(character varying, character varying) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$DECLARE
+ v_dbname ALIAS FOR $1;
+ v_accession ALIAS FOR $1;
+ v_db_id INTEGER;
+ v_dbxref_id INTEGER;
+ BEGIN
+ SELECT INTO v_db_id
+ store_db(v_dbname);
+ SELECT INTO v_dbxref_id dbxref_id
+ FROM dbxref
+ WHERE db_id=v_db_id AND
+ accession=v_accession;
+ IF NOT FOUND THEN
+ INSERT INTO dbxref
+ (db_id,accession)
+ VALUES
+ (v_db_id,v_accession);
+ RETURN currval('dbxref_dbxref_id_seq');
+ END IF;
+ RETURN v_dbxref_id;
+ END;
+$_$;
+
+
+--
+-- Name: store_feature(integer, integer, integer, integer, integer, integer, character varying, character varying, integer, boolean); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION store_feature(integer, integer, integer, integer, integer, integer, character varying, character varying, integer, boolean) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$DECLARE
+ v_srcfeature_id ALIAS FOR $1;
+ v_fmin ALIAS FOR $2;
+ v_fmax ALIAS FOR $3;
+ v_strand ALIAS FOR $4;
+ v_dbxref_id ALIAS FOR $5;
+ v_organism_id ALIAS FOR $6;
+ v_name ALIAS FOR $7;
+ v_uniquename ALIAS FOR $8;
+ v_type_id ALIAS FOR $9;
+ v_is_analysis ALIAS FOR $10;
+ v_feature_id INT;
+ v_featureloc_id INT;
+ BEGIN
+ IF v_dbxref_id IS NULL THEN
+ SELECT INTO v_feature_id feature_id
+ FROM feature
+ WHERE uniquename=v_uniquename AND
+ organism_id=v_organism_id AND
+ type_id=v_type_id;
+ ELSE
+ SELECT INTO v_feature_id feature_id
+ FROM feature
+ WHERE dbxref_id=v_dbxref_id;
+ END IF;
+ IF NOT FOUND THEN
+ INSERT INTO feature
+ ( dbxref_id ,
+ organism_id ,
+ name ,
+ uniquename ,
+ type_id ,
+ is_analysis )
+ VALUES
+ ( v_dbxref_id ,
+ v_organism_id ,
+ v_name ,
+ v_uniquename ,
+ v_type_id ,
+ v_is_analysis );
+ v_feature_id = currval('feature_feature_id_seq');
+ ELSE
+ UPDATE feature SET
+ dbxref_id = v_dbxref_id ,
+ organism_id = v_organism_id ,
+ name = v_name ,
+ uniquename = v_uniquename ,
+ type_id = v_type_id ,
+ is_analysis = v_is_analysis
+ WHERE
+ feature_id=v_feature_id;
+ END IF;
+ PERFORM store_featureloc(v_feature_id,
+ v_srcfeature_id,
+ v_fmin,
+ v_fmax,
+ v_strand,
+ 0,
+ 0);
+ RETURN v_feature_id;
+ END;
+$_$;
+
+
+--
+-- Name: store_feature_synonym(integer, character varying, integer, boolean, boolean, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION store_feature_synonym(integer, character varying, integer, boolean, boolean, integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$DECLARE
+ v_feature_id ALIAS FOR $1;
+ v_syn ALIAS FOR $2;
+ v_type_id ALIAS FOR $3;
+ v_is_current ALIAS FOR $4;
+ v_is_internal ALIAS FOR $5;
+ v_pub_id ALIAS FOR $6;
+ v_synonym_id INT;
+ v_feature_synonym_id INT;
+ BEGIN
+ IF v_feature_id IS NULL THEN RAISE EXCEPTION 'feature_id cannot be null';
+ END IF;
+ SELECT INTO v_synonym_id synonym_id
+ FROM synonym
+ WHERE name=v_syn AND
+ type_id=v_type_id;
+ IF NOT FOUND THEN
+ INSERT INTO synonym
+ ( name,
+ synonym_sgml,
+ type_id)
+ VALUES
+ ( v_syn,
+ v_syn,
+ v_type_id);
+ v_synonym_id = currval('synonym_synonym_id_seq');
+ END IF;
+ SELECT INTO v_feature_synonym_id feature_synonym_id
+ FROM feature_synonym
+ WHERE feature_id=v_feature_id AND
+ synonym_id=v_synonym_id AND
+ pub_id=v_pub_id;
+ IF NOT FOUND THEN
+ INSERT INTO feature_synonym
+ ( feature_id,
+ synonym_id,
+ pub_id,
+ is_current,
+ is_internal)
+ VALUES
+ ( v_feature_id,
+ v_synonym_id,
+ v_pub_id,
+ v_is_current,
+ v_is_internal);
+ v_feature_synonym_id = currval('feature_synonym_feature_synonym_id_seq');
+ ELSE
+ UPDATE feature_synonym
+ SET is_current=v_is_current, is_internal=v_is_internal
+ WHERE feature_synonym_id=v_feature_synonym_id;
+ END IF;
+ RETURN v_feature_synonym_id;
+ END;
+$_$;
+
+
+--
+-- Name: store_featureloc(integer, integer, integer, integer, integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION store_featureloc(integer, integer, integer, integer, integer, integer, integer) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$DECLARE
+ v_feature_id ALIAS FOR $1;
+ v_srcfeature_id ALIAS FOR $2;
+ v_fmin ALIAS FOR $3;
+ v_fmax ALIAS FOR $4;
+ v_strand ALIAS FOR $5;
+ v_rank ALIAS FOR $6;
+ v_locgroup ALIAS FOR $7;
+ v_featureloc_id INT;
+ BEGIN
+ IF v_feature_id IS NULL THEN RAISE EXCEPTION 'feature_id cannot be null';
+ END IF;
+ SELECT INTO v_featureloc_id featureloc_id
+ FROM featureloc
+ WHERE feature_id=v_feature_id AND
+ rank=v_rank AND
+ locgroup=v_locgroup;
+ IF NOT FOUND THEN
+ INSERT INTO featureloc
+ ( feature_id,
+ srcfeature_id,
+ fmin,
+ fmax,
+ strand,
+ rank,
+ locgroup)
+ VALUES
+ ( v_feature_id,
+ v_srcfeature_id,
+ v_fmin,
+ v_fmax,
+ v_strand,
+ v_rank,
+ v_locgroup);
+ v_featureloc_id = currval('featureloc_featureloc_id_seq');
+ ELSE
+ UPDATE featureloc SET
+ feature_id = v_feature_id,
+ srcfeature_id = v_srcfeature_id,
+ fmin = v_fmin,
+ fmax = v_fmax,
+ strand = v_strand,
+ rank = v_rank,
+ locgroup = v_locgroup
+ WHERE
+ featureloc_id=v_featureloc_id;
+ END IF;
+ RETURN v_featureloc_id;
+ END;
+$_$;
+
+
+--
+-- Name: store_organism(character varying, character varying, character varying); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION store_organism(character varying, character varying, character varying) RETURNS integer
+ LANGUAGE plpgsql
+ AS $_$DECLARE
+ v_genus ALIAS FOR $1;
+ v_species ALIAS FOR $2;
+ v_common_name ALIAS FOR $3;
+ v_organism_id INTEGER;
+ BEGIN
+ SELECT INTO v_organism_id organism_id
+ FROM organism
+ WHERE genus=v_genus AND
+ species=v_species;
+ IF NOT FOUND THEN
+ INSERT INTO organism
+ (genus,species,common_name)
+ VALUES
+ (v_genus,v_species,v_common_name);
+ RETURN currval('organism_organism_id_seq');
+ ELSE
+ UPDATE organism
+ SET common_name=v_common_name
+ WHERE organism_id = v_organism_id;
+ END IF;
+ RETURN v_organism_id;
+ END;
+$_$;
+
+
+--
+-- Name: subsequence(integer, integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION subsequence(integer, integer, integer, integer) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT
+ CASE WHEN $4<0
+ THEN reverse_complement(substring(srcf.residues,$2+1,($3-$2)))
+ ELSE substring(residues,$2+1,($3-$2))
+ END AS residues
+ FROM feature AS srcf
+ WHERE
+ srcf.feature_id=$1$_$;
+
+
+--
+-- Name: subsequence_by_feature(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION subsequence_by_feature(integer) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT subsequence_by_feature($1,0,0)$_$;
+
+
+--
+-- Name: subsequence_by_feature(integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION subsequence_by_feature(integer, integer, integer) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT
+ CASE WHEN strand<0
+ THEN reverse_complement(substring(srcf.residues,fmin+1,(fmax-fmin)))
+ ELSE substring(srcf.residues,fmin+1,(fmax-fmin))
+ END AS residues
+ FROM feature AS srcf
+ INNER JOIN featureloc ON (srcf.feature_id=featureloc.srcfeature_id)
+ WHERE
+ featureloc.feature_id=$1 AND
+ featureloc.rank=$2 AND
+ featureloc.locgroup=$3$_$;
+
+
+--
+-- Name: subsequence_by_featureloc(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION subsequence_by_featureloc(integer) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT
+ CASE WHEN strand<0
+ THEN reverse_complement(substring(srcf.residues,fmin+1,(fmax-fmin)))
+ ELSE substring(srcf.residues,fmin+1,(fmax-fmin))
+ END AS residues
+ FROM feature AS srcf
+ INNER JOIN featureloc ON (srcf.feature_id=featureloc.srcfeature_id)
+ WHERE
+ featureloc_id=$1$_$;
+
+
+--
+-- Name: subsequence_by_subfeatures(integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION subsequence_by_subfeatures(integer) RETURNS text
+ LANGUAGE sql
+ AS $_$
+SELECT subsequence_by_subfeatures($1,get_feature_relationship_type_id('part_of'),0,0)
+$_$;
+
+
+--
+-- Name: subsequence_by_subfeatures(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION subsequence_by_subfeatures(integer, integer) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT subsequence_by_subfeatures($1,$2,0,0)$_$;
+
+
+--
+-- Name: subsequence_by_subfeatures(integer, integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION subsequence_by_subfeatures(integer, integer, integer, integer) RETURNS text
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE v_feature_id ALIAS FOR $1;
+DECLARE v_rtype_id ALIAS FOR $2;
+DECLARE v_rank ALIAS FOR $3;
+DECLARE v_locgroup ALIAS FOR $4;
+DECLARE subseq TEXT;
+DECLARE seqrow RECORD;
+BEGIN
+ subseq = '';
+ FOR seqrow IN
+ SELECT
+ CASE WHEN strand<0
+ THEN reverse_complement(substring(srcf.residues,fmin+1,(fmax-fmin)))
+ ELSE substring(srcf.residues,fmin+1,(fmax-fmin))
+ END AS residues
+ FROM feature AS srcf
+ INNER JOIN featureloc ON (srcf.feature_id=featureloc.srcfeature_id)
+ INNER JOIN feature_relationship AS fr
+ ON (fr.subject_id=featureloc.feature_id)
+ WHERE
+ fr.object_id=v_feature_id AND
+ fr.type_id=v_rtype_id AND
+ featureloc.rank=v_rank AND
+ featureloc.locgroup=v_locgroup
+ ORDER BY fr.rank
+ LOOP
+ subseq = subseq || seqrow.residues;
+ END LOOP;
+ RETURN subseq;
+END
+$_$;
+
+
+--
+-- Name: subsequence_by_typed_subfeatures(integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION subsequence_by_typed_subfeatures(integer, integer) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT subsequence_by_typed_subfeatures($1,$2,0,0)$_$;
+
+
+--
+-- Name: subsequence_by_typed_subfeatures(integer, integer, integer, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION subsequence_by_typed_subfeatures(integer, integer, integer, integer) RETURNS text
+ LANGUAGE plpgsql
+ AS $_$
+DECLARE v_feature_id ALIAS FOR $1;
+DECLARE v_ftype_id ALIAS FOR $2;
+DECLARE v_rank ALIAS FOR $3;
+DECLARE v_locgroup ALIAS FOR $4;
+DECLARE subseq TEXT;
+DECLARE seqrow RECORD;
+BEGIN
+ subseq = '';
+ FOR seqrow IN
+ SELECT
+ CASE WHEN strand<0
+ THEN reverse_complement(substring(srcf.residues,fmin+1,(fmax-fmin)))
+ ELSE substring(srcf.residues,fmin+1,(fmax-fmin))
+ END AS residues
+ FROM feature AS srcf
+ INNER JOIN featureloc ON (srcf.feature_id=featureloc.srcfeature_id)
+ INNER JOIN feature AS subf ON (subf.feature_id=featureloc.feature_id)
+ INNER JOIN feature_relationship AS fr ON (fr.subject_id=subf.feature_id)
+ WHERE
+ fr.object_id=v_feature_id AND
+ subf.type_id=v_ftype_id AND
+ featureloc.rank=v_rank AND
+ featureloc.locgroup=v_locgroup
+ ORDER BY fr.rank
+ LOOP
+ subseq = subseq || seqrow.residues;
+ END LOOP;
+ RETURN subseq;
+END
+$_$;
+
+
+--
+-- Name: translate_codon(text, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION translate_codon(text, integer) RETURNS character
+ LANGUAGE sql
+ AS $_$SELECT aa FROM genetic_code.gencode_codon_aa WHERE codon=$1 AND gencode_id=$2$_$;
+
+
+--
+-- Name: translate_dna(text); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION translate_dna(text) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT translate_dna($1,1)$_$;
+
+
+--
+-- Name: translate_dna(text, integer); Type: FUNCTION; Schema: chado; Owner: -
+--
+
+CREATE FUNCTION translate_dna(text, integer) RETURNS text
+ LANGUAGE plpgsql
+ AS $_$
+ DECLARE
+ dnaseq ALIAS FOR $1;
+ gcode ALIAS FOR $2;
+ translation TEXT;
+ dnaseqlen INT;
+ codon CHAR(3);
+ aa CHAR(1);
+ i INT;
+ BEGIN
+ translation = '';
+ dnaseqlen = char_length(dnaseq);
+ i=1;
+ WHILE i+1 < dnaseqlen loop
+ codon = substring(dnaseq,i,3);
+ aa = translate_codon(codon,gcode);
+ translation = translation || aa;
+ i = i+3;
+ END loop;
+ RETURN translation;
+END$_$;
+
+
+--
+-- Name: concat(text); Type: AGGREGATE; Schema: chado; Owner: -
+--
+
+CREATE AGGREGATE concat(text) (
+ SFUNC = concat_pair,
+ STYPE = text,
+ INITCOND = ''
+);
+
+
+--
+-- Name: acquisition; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE acquisition (
+ acquisition_id integer NOT NULL,
+ assay_id integer NOT NULL,
+ protocol_id integer,
+ channel_id integer,
+ acquisitiondate timestamp without time zone DEFAULT now(),
+ name text,
+ uri text
+);
+
+
+--
+-- Name: TABLE acquisition; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE acquisition IS 'This represents the scanning of hybridized material. The output of this process is typically a digital image of an array.';
+
+
+--
+-- Name: acquisition_acquisition_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE acquisition_acquisition_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: acquisition_acquisition_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE acquisition_acquisition_id_seq OWNED BY acquisition.acquisition_id;
+
+
+--
+-- Name: acquisition_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE acquisition_relationship (
+ acquisition_relationship_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ type_id integer NOT NULL,
+ object_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE acquisition_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE acquisition_relationship IS 'Multiple monochrome images may be merged to form a multi-color image. Red-green images of 2-channel hybridizations are an example of this.';
+
+
+--
+-- Name: acquisition_relationship_acquisition_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE acquisition_relationship_acquisition_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: acquisition_relationship_acquisition_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE acquisition_relationship_acquisition_relationship_id_seq OWNED BY acquisition_relationship.acquisition_relationship_id;
+
+
+--
+-- Name: acquisitionprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE acquisitionprop (
+ acquisitionprop_id integer NOT NULL,
+ acquisition_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE acquisitionprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE acquisitionprop IS 'Parameters associated with image acquisition.';
+
+
+--
+-- Name: acquisitionprop_acquisitionprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE acquisitionprop_acquisitionprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: acquisitionprop_acquisitionprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE acquisitionprop_acquisitionprop_id_seq OWNED BY acquisitionprop.acquisitionprop_id;
+
+
+--
+-- Name: all_feature_names; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW all_feature_names AS
+ SELECT feature.feature_id,
+ ("substring"(feature.uniquename, 0, 255))::character varying(255) AS name,
+ feature.organism_id
+ FROM feature
+UNION
+ SELECT feature.feature_id,
+ feature.name,
+ feature.organism_id
+ FROM feature
+ WHERE (feature.name IS NOT NULL)
+UNION
+ SELECT fs.feature_id,
+ s.name,
+ f.organism_id
+ FROM feature_synonym fs,
+ synonym s,
+ feature f
+ WHERE ((fs.synonym_id = s.synonym_id) AND (fs.feature_id = f.feature_id))
+UNION
+ SELECT fp.feature_id,
+ ("substring"(fp.value, 0, 255))::character varying(255) AS name,
+ f.organism_id
+ FROM featureprop fp,
+ feature f
+ WHERE (f.feature_id = fp.feature_id)
+UNION
+ SELECT fd.feature_id,
+ d.accession AS name,
+ f.organism_id
+ FROM feature_dbxref fd,
+ dbxref d,
+ feature f
+ WHERE ((fd.dbxref_id = d.dbxref_id) AND (fd.feature_id = f.feature_id));
+
+
+--
+-- Name: analysis_organism; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE analysis_organism (
+ analysis_id integer NOT NULL,
+ organism_id integer NOT NULL
+);
+
+
+--
+-- Name: analysisfeatureprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE analysisfeatureprop (
+ analysisfeatureprop_id integer NOT NULL,
+ analysisfeature_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer NOT NULL
+);
+
+
+--
+-- Name: analysisfeatureprop_analysisfeatureprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE analysisfeatureprop_analysisfeatureprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: analysisfeatureprop_analysisfeatureprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE analysisfeatureprop_analysisfeatureprop_id_seq OWNED BY analysisfeatureprop.analysisfeatureprop_id;
+
+
+--
+-- Name: analysisprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE analysisprop (
+ analysisprop_id integer NOT NULL,
+ analysis_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: analysisprop_analysisprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE analysisprop_analysisprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: analysisprop_analysisprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE analysisprop_analysisprop_id_seq OWNED BY analysisprop.analysisprop_id;
+
+
+--
+-- Name: arraydesign; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE arraydesign (
+ arraydesign_id integer NOT NULL,
+ manufacturer_id integer NOT NULL,
+ platformtype_id integer NOT NULL,
+ substratetype_id integer,
+ protocol_id integer,
+ dbxref_id integer,
+ name text NOT NULL,
+ version text,
+ description text,
+ array_dimensions text,
+ element_dimensions text,
+ num_of_elements integer,
+ num_array_columns integer,
+ num_array_rows integer,
+ num_grid_columns integer,
+ num_grid_rows integer,
+ num_sub_columns integer,
+ num_sub_rows integer
+);
+
+
+--
+-- Name: TABLE arraydesign; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE arraydesign IS 'General properties about an array.
+An array is a template used to generate physical slides, etc. It
+contains layout information, as well as global array properties, such
+as material (glass, nylon) and spot dimensions (in rows/columns).';
+
+
+--
+-- Name: arraydesign_arraydesign_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE arraydesign_arraydesign_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: arraydesign_arraydesign_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE arraydesign_arraydesign_id_seq OWNED BY arraydesign.arraydesign_id;
+
+
+--
+-- Name: arraydesignprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE arraydesignprop (
+ arraydesignprop_id integer NOT NULL,
+ arraydesign_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE arraydesignprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE arraydesignprop IS 'Extra array design properties that are not accounted for in arraydesign.';
+
+
+--
+-- Name: arraydesignprop_arraydesignprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE arraydesignprop_arraydesignprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: arraydesignprop_arraydesignprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE arraydesignprop_arraydesignprop_id_seq OWNED BY arraydesignprop.arraydesignprop_id;
+
+
+--
+-- Name: assay; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE assay (
+ assay_id integer NOT NULL,
+ arraydesign_id integer NOT NULL,
+ protocol_id integer,
+ assaydate timestamp without time zone DEFAULT now(),
+ arrayidentifier text,
+ arraybatchidentifier text,
+ operator_id integer NOT NULL,
+ dbxref_id integer,
+ name text,
+ description text
+);
+
+
+--
+-- Name: TABLE assay; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE assay IS 'An assay consists of a physical instance of
+an array, combined with the conditions used to create the array
+(protocols, technician information). The assay can be thought of as a hybridization.';
+
+
+--
+-- Name: assay_assay_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE assay_assay_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: assay_assay_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE assay_assay_id_seq OWNED BY assay.assay_id;
+
+
+--
+-- Name: assay_biomaterial; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE assay_biomaterial (
+ assay_biomaterial_id integer NOT NULL,
+ assay_id integer NOT NULL,
+ biomaterial_id integer NOT NULL,
+ channel_id integer,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE assay_biomaterial; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE assay_biomaterial IS 'A biomaterial can be hybridized many times (technical replicates), or combined with other biomaterials in a single hybridization (for two-channel arrays).';
+
+
+--
+-- Name: assay_biomaterial_assay_biomaterial_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE assay_biomaterial_assay_biomaterial_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: assay_biomaterial_assay_biomaterial_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE assay_biomaterial_assay_biomaterial_id_seq OWNED BY assay_biomaterial.assay_biomaterial_id;
+
+
+--
+-- Name: assay_project; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE assay_project (
+ assay_project_id integer NOT NULL,
+ assay_id integer NOT NULL,
+ project_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE assay_project; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE assay_project IS 'Link assays to projects.';
+
+
+--
+-- Name: assay_project_assay_project_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE assay_project_assay_project_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: assay_project_assay_project_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE assay_project_assay_project_id_seq OWNED BY assay_project.assay_project_id;
+
+
+--
+-- Name: assayprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE assayprop (
+ assayprop_id integer NOT NULL,
+ assay_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE assayprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE assayprop IS 'Extra assay properties that are not accounted for in assay.';
+
+
+--
+-- Name: assayprop_assayprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE assayprop_assayprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: assayprop_assayprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE assayprop_assayprop_id_seq OWNED BY assayprop.assayprop_id;
+
+
+--
+-- Name: biomaterial; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE biomaterial (
+ biomaterial_id integer NOT NULL,
+ taxon_id integer,
+ biosourceprovider_id integer,
+ dbxref_id integer,
+ name text,
+ description text
+);
+
+
+--
+-- Name: TABLE biomaterial; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE biomaterial IS 'A biomaterial represents the MAGE concept of BioSource, BioSample, and LabeledExtract. It is essentially some biological material (tissue, cells, serum) that may have been processed. Processed biomaterials should be traceable back to raw biomaterials via the biomaterialrelationship table.';
+
+
+--
+-- Name: biomaterial_biomaterial_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE biomaterial_biomaterial_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: biomaterial_biomaterial_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE biomaterial_biomaterial_id_seq OWNED BY biomaterial.biomaterial_id;
+
+
+--
+-- Name: biomaterial_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE biomaterial_dbxref (
+ biomaterial_dbxref_id integer NOT NULL,
+ biomaterial_id integer NOT NULL,
+ dbxref_id integer NOT NULL
+);
+
+
+--
+-- Name: biomaterial_dbxref_biomaterial_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE biomaterial_dbxref_biomaterial_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: biomaterial_dbxref_biomaterial_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE biomaterial_dbxref_biomaterial_dbxref_id_seq OWNED BY biomaterial_dbxref.biomaterial_dbxref_id;
+
+
+--
+-- Name: biomaterial_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE biomaterial_relationship (
+ biomaterial_relationship_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ type_id integer NOT NULL,
+ object_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE biomaterial_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE biomaterial_relationship IS 'Relate biomaterials to one another. This is a way to track a series of treatments or material splits/merges, for instance.';
+
+
+--
+-- Name: biomaterial_relationship_biomaterial_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE biomaterial_relationship_biomaterial_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: biomaterial_relationship_biomaterial_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE biomaterial_relationship_biomaterial_relationship_id_seq OWNED BY biomaterial_relationship.biomaterial_relationship_id;
+
+
+--
+-- Name: biomaterial_treatment; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE biomaterial_treatment (
+ biomaterial_treatment_id integer NOT NULL,
+ biomaterial_id integer NOT NULL,
+ treatment_id integer NOT NULL,
+ unittype_id integer,
+ value real,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE biomaterial_treatment; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE biomaterial_treatment IS 'Link biomaterials to treatments. Treatments have an order of operations (rank), and associated measurements (unittype_id, value).';
+
+
+--
+-- Name: biomaterial_treatment_biomaterial_treatment_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE biomaterial_treatment_biomaterial_treatment_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: biomaterial_treatment_biomaterial_treatment_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE biomaterial_treatment_biomaterial_treatment_id_seq OWNED BY biomaterial_treatment.biomaterial_treatment_id;
+
+
+--
+-- Name: biomaterialprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE biomaterialprop (
+ biomaterialprop_id integer NOT NULL,
+ biomaterial_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE biomaterialprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE biomaterialprop IS 'Extra biomaterial properties that are not accounted for in biomaterial.';
+
+
+--
+-- Name: biomaterialprop_biomaterialprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE biomaterialprop_biomaterialprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: biomaterialprop_biomaterialprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE biomaterialprop_biomaterialprop_id_seq OWNED BY biomaterialprop.biomaterialprop_id;
+
+
+--
+-- Name: blast_hit_data; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE blast_hit_data (
+ analysisfeature_id integer NOT NULL,
+ analysis_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ db_id integer NOT NULL,
+ hit_num integer NOT NULL,
+ hit_name character varying(1025),
+ hit_url text,
+ hit_description text,
+ hit_organism character varying(1025),
+ blast_org_id integer,
+ hit_accession character varying(255),
+ hit_best_eval double precision,
+ hit_best_score double precision,
+ hit_pid double precision
+);
+
+
+--
+-- Name: blast_organisms; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE blast_organisms (
+ blast_org_id integer NOT NULL,
+ blast_org_name character varying(1025)
+);
+
+
+--
+-- Name: blast_organisms_blast_org_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE blast_organisms_blast_org_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: blast_organisms_blast_org_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE blast_organisms_blast_org_id_seq OWNED BY blast_organisms.blast_org_id;
+
+
+--
+-- Name: cell_line; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cell_line (
+ cell_line_id integer NOT NULL,
+ name character varying(255),
+ uniquename character varying(255) NOT NULL,
+ organism_id integer NOT NULL,
+ timeaccessioned timestamp without time zone DEFAULT now() NOT NULL,
+ timelastmodified timestamp without time zone DEFAULT now() NOT NULL
+);
+
+
+--
+-- Name: cell_line_cell_line_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cell_line_cell_line_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cell_line_cell_line_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cell_line_cell_line_id_seq OWNED BY cell_line.cell_line_id;
+
+
+--
+-- Name: cell_line_cvterm; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cell_line_cvterm (
+ cell_line_cvterm_id integer NOT NULL,
+ cell_line_id integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ pub_id integer NOT NULL,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: cell_line_cvterm_cell_line_cvterm_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cell_line_cvterm_cell_line_cvterm_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cell_line_cvterm_cell_line_cvterm_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cell_line_cvterm_cell_line_cvterm_id_seq OWNED BY cell_line_cvterm.cell_line_cvterm_id;
+
+
+--
+-- Name: cell_line_cvtermprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cell_line_cvtermprop (
+ cell_line_cvtermprop_id integer NOT NULL,
+ cell_line_cvterm_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: cell_line_cvtermprop_cell_line_cvtermprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cell_line_cvtermprop_cell_line_cvtermprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cell_line_cvtermprop_cell_line_cvtermprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cell_line_cvtermprop_cell_line_cvtermprop_id_seq OWNED BY cell_line_cvtermprop.cell_line_cvtermprop_id;
+
+
+--
+-- Name: cell_line_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cell_line_dbxref (
+ cell_line_dbxref_id integer NOT NULL,
+ cell_line_id integer NOT NULL,
+ dbxref_id integer NOT NULL,
+ is_current boolean DEFAULT true NOT NULL
+);
+
+
+--
+-- Name: cell_line_dbxref_cell_line_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cell_line_dbxref_cell_line_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cell_line_dbxref_cell_line_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cell_line_dbxref_cell_line_dbxref_id_seq OWNED BY cell_line_dbxref.cell_line_dbxref_id;
+
+
+--
+-- Name: cell_line_feature; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cell_line_feature (
+ cell_line_feature_id integer NOT NULL,
+ cell_line_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: cell_line_feature_cell_line_feature_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cell_line_feature_cell_line_feature_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cell_line_feature_cell_line_feature_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cell_line_feature_cell_line_feature_id_seq OWNED BY cell_line_feature.cell_line_feature_id;
+
+
+--
+-- Name: cell_line_library; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cell_line_library (
+ cell_line_library_id integer NOT NULL,
+ cell_line_id integer NOT NULL,
+ library_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: cell_line_library_cell_line_library_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cell_line_library_cell_line_library_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cell_line_library_cell_line_library_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cell_line_library_cell_line_library_id_seq OWNED BY cell_line_library.cell_line_library_id;
+
+
+--
+-- Name: cell_line_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cell_line_pub (
+ cell_line_pub_id integer NOT NULL,
+ cell_line_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: cell_line_pub_cell_line_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cell_line_pub_cell_line_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cell_line_pub_cell_line_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cell_line_pub_cell_line_pub_id_seq OWNED BY cell_line_pub.cell_line_pub_id;
+
+
+--
+-- Name: cell_line_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cell_line_relationship (
+ cell_line_relationship_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ object_id integer NOT NULL,
+ type_id integer NOT NULL
+);
+
+
+--
+-- Name: cell_line_relationship_cell_line_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cell_line_relationship_cell_line_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cell_line_relationship_cell_line_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cell_line_relationship_cell_line_relationship_id_seq OWNED BY cell_line_relationship.cell_line_relationship_id;
+
+
+--
+-- Name: cell_line_synonym; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cell_line_synonym (
+ cell_line_synonym_id integer NOT NULL,
+ cell_line_id integer NOT NULL,
+ synonym_id integer NOT NULL,
+ pub_id integer NOT NULL,
+ is_current boolean DEFAULT false NOT NULL,
+ is_internal boolean DEFAULT false NOT NULL
+);
+
+
+--
+-- Name: cell_line_synonym_cell_line_synonym_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cell_line_synonym_cell_line_synonym_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cell_line_synonym_cell_line_synonym_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cell_line_synonym_cell_line_synonym_id_seq OWNED BY cell_line_synonym.cell_line_synonym_id;
+
+
+--
+-- Name: cell_lineprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cell_lineprop (
+ cell_lineprop_id integer NOT NULL,
+ cell_line_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: cell_lineprop_cell_lineprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cell_lineprop_cell_lineprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cell_lineprop_cell_lineprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cell_lineprop_cell_lineprop_id_seq OWNED BY cell_lineprop.cell_lineprop_id;
+
+
+--
+-- Name: cell_lineprop_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cell_lineprop_pub (
+ cell_lineprop_pub_id integer NOT NULL,
+ cell_lineprop_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: cell_lineprop_pub_cell_lineprop_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cell_lineprop_pub_cell_lineprop_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cell_lineprop_pub_cell_lineprop_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cell_lineprop_pub_cell_lineprop_pub_id_seq OWNED BY cell_lineprop_pub.cell_lineprop_pub_id;
+
+
+--
+-- Name: chado_search_diversity_search; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE chado_search_diversity_search (
+ feature_id integer,
+ marker_uniquename text,
+ marker_organism_id integer,
+ genotype_id integer,
+ genotype text,
+ allele character varying(255),
+ project_id integer,
+ project_name character varying(255),
+ stock_id integer,
+ stock_uniquename text,
+ organism_id integer,
+ organism character varying(510)
+);
+
+
+--
+-- Name: chado_search_gene_search; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE chado_search_gene_search (
+ feature_id integer,
+ name character varying(255),
+ uniquename text,
+ feature_type character varying(1025),
+ organism_id integer,
+ organism character varying(510),
+ analysis_id integer,
+ analysis_name character varying(255),
+ srcfeature_id integer,
+ landmark character varying(255),
+ fmin integer,
+ fmax integer,
+ location character varying(510),
+ genome character varying(255)
+);
+
+
+--
+-- Name: chado_search_germplasm_search; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE chado_search_germplasm_search (
+ stock_id integer,
+ name character varying(255),
+ uniquename text,
+ organism_id integer,
+ organism character varying(255),
+ genome text,
+ db character varying(255),
+ accession character varying(255),
+ urlprefix character varying(255),
+ alias text
+);
+
+
+--
+-- Name: chado_search_haplotype_block_search; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE chado_search_haplotype_block_search (
+ hb_feature_id integer,
+ haplotype_block text,
+ organism_id integer,
+ organism character varying(510),
+ analysis_id integer,
+ genome character varying(255),
+ landmark character varying(255),
+ fmin integer,
+ fmax integer
+);
+
+
+--
+-- Name: chado_search_marker_search; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE chado_search_marker_search (
+ marker_feature_id integer,
+ marker_uniquename text,
+ marker_name character varying(255),
+ seq_feature_id integer,
+ seq_uniquename text,
+ organism_id integer,
+ organism character varying(510),
+ featuremap_id integer,
+ map_name character varying(255),
+ mapped_organism_id integer,
+ mapped_organism character varying(510),
+ lg_uniquename text,
+ marker_type text,
+ start real,
+ stop real,
+ landmark_feature_id integer,
+ landmark character varying(255),
+ landmark_organism character varying(510),
+ fmin integer,
+ fmax integer,
+ location character varying(510),
+ alias text,
+ synonym text
+);
+
+
+--
+-- Name: chado_search_sequence_search; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE chado_search_sequence_search (
+ feature_id integer,
+ name character varying(255),
+ uniquename text,
+ feature_type character varying(1025),
+ organism_id integer,
+ organism character varying(510),
+ analysis_id integer,
+ analysis_name character varying(255),
+ srcfeature_id integer,
+ landmark character varying(255),
+ fmin integer,
+ fmax integer,
+ location character varying(510)
+);
+
+
+--
+-- Name: chadoprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE chadoprop (
+ chadoprop_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE chadoprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE chadoprop IS 'This table is different from other prop tables in the database, as it is for storing information about the database itself, like schema version';
+
+
+--
+-- Name: COLUMN chadoprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN chadoprop.type_id IS 'The name of the property or slot is a cvterm. The meaning of the property is defined in that cvterm.';
+
+
+--
+-- Name: COLUMN chadoprop.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN chadoprop.value IS 'The value of the property, represented as text. Numeric values are converted to their text representation.';
+
+
+--
+-- Name: COLUMN chadoprop.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN chadoprop.rank IS 'Property-Value ordering. Any
+ cv can have multiple values for any particular property type -
+ these are ordered in a list using rank, counting from zero. For
+ properties that are single-valued rather than multi-valued, the
+ default 0 value should be used.';
+
+
+--
+-- Name: chadoprop_chadoprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE chadoprop_chadoprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: chadoprop_chadoprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE chadoprop_chadoprop_id_seq OWNED BY chadoprop.chadoprop_id;
+
+
+--
+-- Name: channel; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE channel (
+ channel_id integer NOT NULL,
+ name text NOT NULL,
+ definition text NOT NULL
+);
+
+
+--
+-- Name: TABLE channel; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE channel IS 'Different array platforms can record signals from one or more channels (cDNA arrays typically use two CCD, but Affymetrix uses only one).';
+
+
+--
+-- Name: channel_channel_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE channel_channel_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: channel_channel_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE channel_channel_id_seq OWNED BY channel.channel_id;
+
+
+--
+-- Name: common_ancestor_cvterm; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW common_ancestor_cvterm AS
+ SELECT p1.subject_id AS cvterm1_id,
+ p2.subject_id AS cvterm2_id,
+ p1.object_id AS ancestor_cvterm_id,
+ p1.pathdistance AS pathdistance1,
+ p2.pathdistance AS pathdistance2,
+ (p1.pathdistance + p2.pathdistance) AS total_pathdistance
+ FROM cvtermpath p1,
+ cvtermpath p2
+ WHERE (p1.object_id = p2.object_id);
+
+
+--
+-- Name: VIEW common_ancestor_cvterm; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW common_ancestor_cvterm IS 'The common ancestor of any
+two terms is the intersection of both terms ancestors. Two terms can
+have multiple common ancestors. Use total_pathdistance to get the
+least common ancestor';
+
+
+--
+-- Name: common_descendant_cvterm; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW common_descendant_cvterm AS
+ SELECT p1.object_id AS cvterm1_id,
+ p2.object_id AS cvterm2_id,
+ p1.subject_id AS ancestor_cvterm_id,
+ p1.pathdistance AS pathdistance1,
+ p2.pathdistance AS pathdistance2,
+ (p1.pathdistance + p2.pathdistance) AS total_pathdistance
+ FROM cvtermpath p1,
+ cvtermpath p2
+ WHERE (p1.subject_id = p2.subject_id);
+
+
+--
+-- Name: VIEW common_descendant_cvterm; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW common_descendant_cvterm IS 'The common descendant of
+any two terms is the intersection of both terms descendants. Two terms
+can have multiple common descendants. Use total_pathdistance to get
+the least common ancestor';
+
+
+--
+-- Name: contact; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE contact (
+ contact_id integer NOT NULL,
+ type_id integer,
+ name character varying(255) NOT NULL,
+ description character varying(255)
+);
+
+
+--
+-- Name: TABLE contact; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE contact IS 'Model persons, institutes, groups, organizations, etc.';
+
+
+--
+-- Name: COLUMN contact.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN contact.type_id IS 'What type of contact is this? E.g. "person", "lab".';
+
+
+--
+-- Name: contact_contact_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE contact_contact_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: contact_contact_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE contact_contact_id_seq OWNED BY contact.contact_id;
+
+
+--
+-- Name: contact_image; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE contact_image (
+ contact_image_id integer NOT NULL,
+ contact_id integer NOT NULL,
+ eimage_id integer NOT NULL,
+ type_id integer NOT NULL
+);
+
+
+--
+-- Name: contact_image_contact_image_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE contact_image_contact_image_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: contact_image_contact_image_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE contact_image_contact_image_id_seq OWNED BY contact_image.contact_image_id;
+
+
+--
+-- Name: contact_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE contact_relationship (
+ contact_relationship_id integer NOT NULL,
+ type_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ object_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE contact_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE contact_relationship IS 'Model relationships between contacts';
+
+
+--
+-- Name: COLUMN contact_relationship.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN contact_relationship.type_id IS 'Relationship type between subject and object. This is a cvterm, typically from the OBO relationship ontology, although other relationship types are allowed.';
+
+
+--
+-- Name: COLUMN contact_relationship.subject_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN contact_relationship.subject_id IS 'The subject of the subj-predicate-obj sentence. In a DAG, this corresponds to the child node.';
+
+
+--
+-- Name: COLUMN contact_relationship.object_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN contact_relationship.object_id IS 'The object of the subj-predicate-obj sentence. In a DAG, this corresponds to the parent node.';
+
+
+--
+-- Name: contact_relationship_contact_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE contact_relationship_contact_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: contact_relationship_contact_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE contact_relationship_contact_relationship_id_seq OWNED BY contact_relationship.contact_relationship_id;
+
+
+--
+-- Name: contactprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE contactprop (
+ contactprop_id integer NOT NULL,
+ contact_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: contactprop_contactprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE contactprop_contactprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: contactprop_contactprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE contactprop_contactprop_id_seq OWNED BY contactprop.contactprop_id;
+
+
+--
+-- Name: content_type_chado_analysis_unigene; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE content_type_chado_analysis_unigene (
+ vid integer DEFAULT 0 NOT NULL,
+ nid integer DEFAULT 0 NOT NULL,
+ CONSTRAINT content_type_chado_analysis_unigene_nid_check CHECK ((nid >= 0)),
+ CONSTRAINT content_type_chado_analysis_unigene_vid_check CHECK ((vid >= 0))
+);
+
+
+--
+-- Name: control; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE control (
+ control_id integer NOT NULL,
+ type_id integer NOT NULL,
+ assay_id integer NOT NULL,
+ tableinfo_id integer NOT NULL,
+ row_id integer NOT NULL,
+ name text,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: control_control_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE control_control_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: control_control_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE control_control_id_seq OWNED BY control.control_id;
+
+
+--
+-- Name: cv; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cv (
+ cv_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ definition text
+);
+
+
+--
+-- Name: TABLE cv; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE cv IS 'A controlled vocabulary or ontology. A cv is
+composed of cvterms (AKA terms, classes, types, universals - relations
+and properties are also stored in cvterm) and the relationships
+between them.';
+
+
+--
+-- Name: COLUMN cv.name; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cv.name IS 'The name of the ontology. This
+corresponds to the obo-format -namespace-. cv names uniquely identify
+the cv. In OBO file format, the cv.name is known as the namespace.';
+
+
+--
+-- Name: COLUMN cv.definition; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cv.definition IS 'A text description of the criteria for
+membership of this ontology.';
+
+
+--
+-- Name: cv_cv_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cv_cv_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cv_cv_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cv_cv_id_seq OWNED BY cv.cv_id;
+
+
+--
+-- Name: cv_cvterm_count; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW cv_cvterm_count AS
+ SELECT cv.name,
+ count(*) AS num_terms_excl_obs
+ FROM (cv
+ JOIN cvterm USING (cv_id))
+ WHERE (cvterm.is_obsolete = 0)
+ GROUP BY cv.name;
+
+
+--
+-- Name: VIEW cv_cvterm_count; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW cv_cvterm_count IS 'per-cv terms counts (excludes obsoletes)';
+
+
+--
+-- Name: cv_cvterm_count_with_obs; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW cv_cvterm_count_with_obs AS
+ SELECT cv.name,
+ count(*) AS num_terms_incl_obs
+ FROM (cv
+ JOIN cvterm USING (cv_id))
+ GROUP BY cv.name;
+
+
+--
+-- Name: VIEW cv_cvterm_count_with_obs; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW cv_cvterm_count_with_obs IS 'per-cv terms counts (includes obsoletes)';
+
+
+--
+-- Name: cvterm_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cvterm_relationship (
+ cvterm_relationship_id integer NOT NULL,
+ type_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ object_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE cvterm_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE cvterm_relationship IS 'A relationship linking two
+cvterms. Each cvterm_relationship constitutes an edge in the graph
+defined by the collection of cvterms and cvterm_relationships. The
+meaning of the cvterm_relationship depends on the definition of the
+cvterm R refered to by type_id. However, in general the definitions
+are such that the statement "all SUBJs REL some OBJ" is true. The
+cvterm_relationship statement is about the subject, not the
+object. For example "insect wing part_of thorax".';
+
+
+--
+-- Name: COLUMN cvterm_relationship.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvterm_relationship.type_id IS 'The nature of the
+relationship between subject and object. Note that relations are also
+housed in the cvterm table, typically from the OBO relationship
+ontology, although other relationship types are allowed.';
+
+
+--
+-- Name: COLUMN cvterm_relationship.subject_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvterm_relationship.subject_id IS 'The subject of
+the subj-predicate-obj sentence. The cvterm_relationship is about the
+subject. In a graph, this typically corresponds to the child node.';
+
+
+--
+-- Name: COLUMN cvterm_relationship.object_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvterm_relationship.object_id IS 'The object of the
+subj-predicate-obj sentence. The cvterm_relationship refers to the
+object. In a graph, this typically corresponds to the parent node.';
+
+
+--
+-- Name: cv_leaf; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW cv_leaf AS
+ SELECT cvterm.cv_id,
+ cvterm.cvterm_id
+ FROM cvterm
+ WHERE (NOT (cvterm.cvterm_id IN ( SELECT cvterm_relationship.object_id
+ FROM cvterm_relationship)));
+
+
+--
+-- Name: VIEW cv_leaf; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW cv_leaf IS 'the leaves of a cv are the set of terms
+which have no children (terms that are not the object of a
+relation). All cvs will have at least 1 leaf';
+
+
+--
+-- Name: cv_link_count; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW cv_link_count AS
+ SELECT cv.name AS cv_name,
+ relation.name AS relation_name,
+ relation_cv.name AS relation_cv_name,
+ count(*) AS num_links
+ FROM ((((cv
+ JOIN cvterm ON ((cvterm.cv_id = cv.cv_id)))
+ JOIN cvterm_relationship ON ((cvterm.cvterm_id = cvterm_relationship.subject_id)))
+ JOIN cvterm relation ON ((cvterm_relationship.type_id = relation.cvterm_id)))
+ JOIN cv relation_cv ON ((relation.cv_id = relation_cv.cv_id)))
+ GROUP BY cv.name, relation.name, relation_cv.name;
+
+
+--
+-- Name: VIEW cv_link_count; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW cv_link_count IS 'per-cv summary of number of
+links (cvterm_relationships) broken down by
+relationship_type. num_links is the total # of links of the specified
+type in which the subject_id of the link is in the named cv';
+
+
+--
+-- Name: cv_path_count; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW cv_path_count AS
+ SELECT cv.name AS cv_name,
+ relation.name AS relation_name,
+ relation_cv.name AS relation_cv_name,
+ count(*) AS num_paths
+ FROM ((((cv
+ JOIN cvterm ON ((cvterm.cv_id = cv.cv_id)))
+ JOIN cvtermpath ON ((cvterm.cvterm_id = cvtermpath.subject_id)))
+ JOIN cvterm relation ON ((cvtermpath.type_id = relation.cvterm_id)))
+ JOIN cv relation_cv ON ((relation.cv_id = relation_cv.cv_id)))
+ GROUP BY cv.name, relation.name, relation_cv.name;
+
+
+--
+-- Name: VIEW cv_path_count; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW cv_path_count IS 'per-cv summary of number of
+paths (cvtermpaths) broken down by relationship_type. num_paths is the
+total # of paths of the specified type in which the subject_id of the
+path is in the named cv. See also: cv_distinct_relations';
+
+
+--
+-- Name: cv_root; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW cv_root AS
+ SELECT cvterm.cv_id,
+ cvterm.cvterm_id AS root_cvterm_id
+ FROM cvterm
+ WHERE ((NOT (cvterm.cvterm_id IN ( SELECT cvterm_relationship.subject_id
+ FROM cvterm_relationship))) AND (cvterm.is_obsolete = 0));
+
+
+--
+-- Name: VIEW cv_root; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW cv_root IS 'the roots of a cv are the set of terms
+which have no parents (terms that are not the subject of a
+relation). Most cvs will have a single root, some may have >1. All
+will have at least 1';
+
+
+--
+-- Name: cv_root_mview; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cv_root_mview (
+ name character varying(1024),
+ cvterm_id integer,
+ cv_id integer,
+ cv_name character varying(255)
+);
+
+
+--
+-- Name: cvprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cvprop (
+ cvprop_id integer NOT NULL,
+ cv_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cvprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE cvprop IS 'Additional extensible properties can be attached to a cv using this table. A notable example would be the cv version';
+
+
+--
+-- Name: COLUMN cvprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvprop.type_id IS 'The name of the property or slot is a cvterm. The meaning of the property is defined in that cvterm.';
+
+
+--
+-- Name: COLUMN cvprop.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvprop.value IS 'The value of the property, represented as text. Numeric values are converted to their text representation.';
+
+
+--
+-- Name: COLUMN cvprop.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvprop.rank IS 'Property-Value ordering. Any
+ cv can have multiple values for any particular property type -
+ these are ordered in a list using rank, counting from zero. For
+ properties that are single-valued rather than multi-valued, the
+ default 0 value should be used.';
+
+
+--
+-- Name: cvprop_cvprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cvprop_cvprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cvprop_cvprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cvprop_cvprop_id_seq OWNED BY cvprop.cvprop_id;
+
+
+--
+-- Name: cvterm_cvterm_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cvterm_cvterm_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cvterm_cvterm_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cvterm_cvterm_id_seq OWNED BY cvterm.cvterm_id;
+
+
+--
+-- Name: cvterm_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cvterm_dbxref (
+ cvterm_dbxref_id integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ dbxref_id integer NOT NULL,
+ is_for_definition integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cvterm_dbxref; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE cvterm_dbxref IS 'In addition to the primary
+identifier (cvterm.dbxref_id) a cvterm can have zero or more secondary
+identifiers/dbxrefs, which may refer to records in external
+databases. The exact semantics of cvterm_dbxref are not fixed. For
+example: the dbxref could be a pubmed ID that is pertinent to the
+cvterm, or it could be an equivalent or similar term in another
+ontology. For example, GO cvterms are typically linked to InterPro
+IDs, even though the nature of the relationship between them is
+largely one of statistical association. The dbxref may be have data
+records attached in the same database instance, or it could be a
+"hanging" dbxref pointing to some external database. NOTE: If the
+desired objective is to link two cvterms together, and the nature of
+the relation is known and holds for all instances of the subject
+cvterm then consider instead using cvterm_relationship together with a
+well-defined relation.';
+
+
+--
+-- Name: COLUMN cvterm_dbxref.is_for_definition; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvterm_dbxref.is_for_definition IS 'A
+cvterm.definition should be supported by one or more references. If
+this column is true, the dbxref is not for a term in an external database -
+it is a dbxref for provenance information for the definition.';
+
+
+--
+-- Name: cvterm_dbxref_cvterm_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cvterm_dbxref_cvterm_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cvterm_dbxref_cvterm_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cvterm_dbxref_cvterm_dbxref_id_seq OWNED BY cvterm_dbxref.cvterm_dbxref_id;
+
+
+--
+-- Name: cvterm_relationship_cvterm_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cvterm_relationship_cvterm_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cvterm_relationship_cvterm_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cvterm_relationship_cvterm_relationship_id_seq OWNED BY cvterm_relationship.cvterm_relationship_id;
+
+
+--
+-- Name: cvtermpath_cvtermpath_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cvtermpath_cvtermpath_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cvtermpath_cvtermpath_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cvtermpath_cvtermpath_id_seq OWNED BY cvtermpath.cvtermpath_id;
+
+
+--
+-- Name: cvtermprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cvtermprop (
+ cvtermprop_id integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text DEFAULT ''::text NOT NULL,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cvtermprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE cvtermprop IS 'Additional extensible properties can be attached to a cvterm using this table. Corresponds to -AnnotationProperty- in W3C OWL format.';
+
+
+--
+-- Name: COLUMN cvtermprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvtermprop.type_id IS 'The name of the property or slot is a cvterm. The meaning of the property is defined in that cvterm.';
+
+
+--
+-- Name: COLUMN cvtermprop.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvtermprop.value IS 'The value of the property, represented as text. Numeric values are converted to their text representation.';
+
+
+--
+-- Name: COLUMN cvtermprop.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvtermprop.rank IS 'Property-Value ordering. Any
+cvterm can have multiple values for any particular property type -
+these are ordered in a list using rank, counting from zero. For
+properties that are single-valued rather than multi-valued, the
+default 0 value should be used.';
+
+
+--
+-- Name: cvtermprop_cvtermprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cvtermprop_cvtermprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cvtermprop_cvtermprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cvtermprop_cvtermprop_id_seq OWNED BY cvtermprop.cvtermprop_id;
+
+
+--
+-- Name: cvtermsynonym; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE cvtermsynonym (
+ cvtermsynonym_id integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ synonym character varying(1024) NOT NULL,
+ type_id integer
+);
+
+
+--
+-- Name: TABLE cvtermsynonym; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE cvtermsynonym IS 'A cvterm actually represents a
+distinct class or concept. A concept can be refered to by different
+phrases or names. In addition to the primary name (cvterm.name) there
+can be a number of alternative aliases or synonyms. For example, "T
+cell" as a synonym for "T lymphocyte".';
+
+
+--
+-- Name: COLUMN cvtermsynonym.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN cvtermsynonym.type_id IS 'A synonym can be exact,
+narrower, or broader than.';
+
+
+--
+-- Name: cvtermsynonym_cvtermsynonym_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE cvtermsynonym_cvtermsynonym_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: cvtermsynonym_cvtermsynonym_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE cvtermsynonym_cvtermsynonym_id_seq OWNED BY cvtermsynonym.cvtermsynonym_id;
+
+
+--
+-- Name: db_db_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE db_db_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: db_db_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE db_db_id_seq OWNED BY db.db_id;
+
+
+--
+-- Name: db_dbxref_count; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW db_dbxref_count AS
+ SELECT db.name,
+ count(*) AS num_dbxrefs
+ FROM (db
+ JOIN dbxref USING (db_id))
+ GROUP BY db.name;
+
+
+--
+-- Name: VIEW db_dbxref_count; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW db_dbxref_count IS 'per-db dbxref counts';
+
+
+--
+-- Name: dbxref_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE dbxref_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: dbxref_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE dbxref_dbxref_id_seq OWNED BY dbxref.dbxref_id;
+
+
+--
+-- Name: dbxrefprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE dbxrefprop (
+ dbxrefprop_id integer NOT NULL,
+ dbxref_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text DEFAULT ''::text NOT NULL,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE dbxrefprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE dbxrefprop IS 'Metadata about a dbxref. Note that this is not defined in the dbxref module, as it depends on the cvterm table. This table has a structure analagous to cvtermprop.';
+
+
+--
+-- Name: dbxrefprop_dbxrefprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE dbxrefprop_dbxrefprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: dbxrefprop_dbxrefprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE dbxrefprop_dbxrefprop_id_seq OWNED BY dbxrefprop.dbxrefprop_id;
+
+
+--
+-- Name: dfeatureloc; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW dfeatureloc AS
+ SELECT featureloc.featureloc_id,
+ featureloc.feature_id,
+ featureloc.srcfeature_id,
+ featureloc.fmin AS nbeg,
+ featureloc.is_fmin_partial AS is_nbeg_partial,
+ featureloc.fmax AS nend,
+ featureloc.is_fmax_partial AS is_nend_partial,
+ featureloc.strand,
+ featureloc.phase,
+ featureloc.residue_info,
+ featureloc.locgroup,
+ featureloc.rank
+ FROM featureloc
+ WHERE ((featureloc.strand < 0) OR (featureloc.phase < 0))
+UNION
+ SELECT featureloc.featureloc_id,
+ featureloc.feature_id,
+ featureloc.srcfeature_id,
+ featureloc.fmax AS nbeg,
+ featureloc.is_fmax_partial AS is_nbeg_partial,
+ featureloc.fmin AS nend,
+ featureloc.is_fmin_partial AS is_nend_partial,
+ featureloc.strand,
+ featureloc.phase,
+ featureloc.residue_info,
+ featureloc.locgroup,
+ featureloc.rank
+ FROM featureloc
+ WHERE (((featureloc.strand IS NULL) OR (featureloc.strand >= 0)) OR (featureloc.phase >= 0));
+
+
+--
+-- Name: eimage; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE eimage (
+ eimage_id integer NOT NULL,
+ eimage_data text,
+ eimage_type character varying(255) NOT NULL,
+ image_uri character varying(255)
+);
+
+
+--
+-- Name: COLUMN eimage.eimage_data; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN eimage.eimage_data IS 'We expect images in eimage_data (e.g. JPEGs) to be uuencoded.';
+
+
+--
+-- Name: COLUMN eimage.eimage_type; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN eimage.eimage_type IS 'Describes the type of data in eimage_data.';
+
+
+--
+-- Name: eimage_eimage_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE eimage_eimage_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: eimage_eimage_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE eimage_eimage_id_seq OWNED BY eimage.eimage_id;
+
+
+--
+-- Name: eimageprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE eimageprop (
+ eimageprop_id integer NOT NULL,
+ eimage_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0
+);
+
+
+--
+-- Name: eimageprop_eimageprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE eimageprop_eimageprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: eimageprop_eimageprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE eimageprop_eimageprop_id_seq OWNED BY eimageprop.eimageprop_id;
+
+
+--
+-- Name: element; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE element (
+ element_id integer NOT NULL,
+ feature_id integer,
+ arraydesign_id integer NOT NULL,
+ type_id integer,
+ dbxref_id integer
+);
+
+
+--
+-- Name: TABLE element; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE element IS 'Represents a feature of the array. This is typically a region of the array coated or bound to DNA.';
+
+
+--
+-- Name: element_element_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE element_element_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: element_element_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE element_element_id_seq OWNED BY element.element_id;
+
+
+--
+-- Name: element_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE element_relationship (
+ element_relationship_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ type_id integer NOT NULL,
+ object_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE element_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE element_relationship IS 'Sometimes we want to combine measurements from multiple elements to get a composite value. Affymetrix combines many probes to form a probeset measurement, for instance.';
+
+
+--
+-- Name: element_relationship_element_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE element_relationship_element_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: element_relationship_element_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE element_relationship_element_relationship_id_seq OWNED BY element_relationship.element_relationship_id;
+
+
+--
+-- Name: elementresult; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE elementresult (
+ elementresult_id integer NOT NULL,
+ element_id integer NOT NULL,
+ quantification_id integer NOT NULL,
+ signal double precision NOT NULL
+);
+
+
+--
+-- Name: TABLE elementresult; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE elementresult IS 'An element on an array produces a measurement when hybridized to a biomaterial (traceable through quantification_id). This is the base data from which tables that actually contain data inherit.';
+
+
+--
+-- Name: elementresult_elementresult_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE elementresult_elementresult_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: elementresult_elementresult_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE elementresult_elementresult_id_seq OWNED BY elementresult.elementresult_id;
+
+
+--
+-- Name: elementresult_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE elementresult_relationship (
+ elementresult_relationship_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ type_id integer NOT NULL,
+ object_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE elementresult_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE elementresult_relationship IS 'Sometimes we want to combine measurements from multiple elements to get a composite value. Affymetrix combines many probes to form a probeset measurement, for instance.';
+
+
+--
+-- Name: elementresult_relationship_elementresult_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE elementresult_relationship_elementresult_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: elementresult_relationship_elementresult_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE elementresult_relationship_elementresult_relationship_id_seq OWNED BY elementresult_relationship.elementresult_relationship_id;
+
+
+--
+-- Name: environment; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE environment (
+ environment_id integer NOT NULL,
+ uniquename text NOT NULL,
+ description text
+);
+
+
+--
+-- Name: TABLE environment; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE environment IS 'The environmental component of a phenotype description.';
+
+
+--
+-- Name: environment_cvterm; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE environment_cvterm (
+ environment_cvterm_id integer NOT NULL,
+ environment_id integer NOT NULL,
+ cvterm_id integer NOT NULL
+);
+
+
+--
+-- Name: environment_cvterm_environment_cvterm_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE environment_cvterm_environment_cvterm_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: environment_cvterm_environment_cvterm_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE environment_cvterm_environment_cvterm_id_seq OWNED BY environment_cvterm.environment_cvterm_id;
+
+
+--
+-- Name: environment_environment_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE environment_environment_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: environment_environment_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE environment_environment_id_seq OWNED BY environment.environment_id;
+
+
+--
+-- Name: expression; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE expression (
+ expression_id integer NOT NULL,
+ uniquename text NOT NULL,
+ md5checksum character(32),
+ description text
+);
+
+
+--
+-- Name: TABLE expression; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE expression IS 'The expression table is essentially a bridge table.';
+
+
+--
+-- Name: expression_cvterm; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE expression_cvterm (
+ expression_cvterm_id integer NOT NULL,
+ expression_id integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ rank integer DEFAULT 0 NOT NULL,
+ cvterm_type_id integer NOT NULL
+);
+
+
+--
+-- Name: expression_cvterm_expression_cvterm_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE expression_cvterm_expression_cvterm_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: expression_cvterm_expression_cvterm_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE expression_cvterm_expression_cvterm_id_seq OWNED BY expression_cvterm.expression_cvterm_id;
+
+
+--
+-- Name: expression_cvtermprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE expression_cvtermprop (
+ expression_cvtermprop_id integer NOT NULL,
+ expression_cvterm_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE expression_cvtermprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE expression_cvtermprop IS 'Extensible properties for
+expression to cvterm associations. Examples: qualifiers.';
+
+
+--
+-- Name: COLUMN expression_cvtermprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN expression_cvtermprop.type_id IS 'The name of the
+property/slot is a cvterm. The meaning of the property is defined in
+that cvterm. For example, cvterms may come from the FlyBase miscellaneous cv.';
+
+
+--
+-- Name: COLUMN expression_cvtermprop.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN expression_cvtermprop.value IS 'The value of the
+property, represented as text. Numeric values are converted to their
+text representation. This is less efficient than using native database
+types, but is easier to query.';
+
+
+--
+-- Name: COLUMN expression_cvtermprop.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN expression_cvtermprop.rank IS 'Property-Value
+ordering. Any expression_cvterm can have multiple values for any particular
+property type - these are ordered in a list using rank, counting from
+zero. For properties that are single-valued rather than multi-valued,
+the default 0 value should be used.';
+
+
+--
+-- Name: expression_cvtermprop_expression_cvtermprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE expression_cvtermprop_expression_cvtermprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: expression_cvtermprop_expression_cvtermprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE expression_cvtermprop_expression_cvtermprop_id_seq OWNED BY expression_cvtermprop.expression_cvtermprop_id;
+
+
+--
+-- Name: expression_expression_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE expression_expression_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: expression_expression_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE expression_expression_id_seq OWNED BY expression.expression_id;
+
+
+--
+-- Name: expression_image; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE expression_image (
+ expression_image_id integer NOT NULL,
+ expression_id integer NOT NULL,
+ eimage_id integer NOT NULL
+);
+
+
+--
+-- Name: expression_image_expression_image_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE expression_image_expression_image_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: expression_image_expression_image_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE expression_image_expression_image_id_seq OWNED BY expression_image.expression_image_id;
+
+
+--
+-- Name: expression_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE expression_pub (
+ expression_pub_id integer NOT NULL,
+ expression_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: expression_pub_expression_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE expression_pub_expression_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: expression_pub_expression_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE expression_pub_expression_pub_id_seq OWNED BY expression_pub.expression_pub_id;
+
+
+--
+-- Name: expressionprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE expressionprop (
+ expressionprop_id integer NOT NULL,
+ expression_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: expressionprop_expressionprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE expressionprop_expressionprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: expressionprop_expressionprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE expressionprop_expressionprop_id_seq OWNED BY expressionprop.expressionprop_id;
+
+
+--
+-- Name: f_type; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW f_type AS
+ SELECT f.feature_id,
+ f.name,
+ f.dbxref_id,
+ c.name AS type,
+ f.residues,
+ f.seqlen,
+ f.md5checksum,
+ f.type_id,
+ f.timeaccessioned,
+ f.timelastmodified
+ FROM feature f,
+ cvterm c
+ WHERE (f.type_id = c.cvterm_id);
+
+
+--
+-- Name: f_loc; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW f_loc AS
+ SELECT f.feature_id,
+ f.name,
+ f.dbxref_id,
+ fl.nbeg,
+ fl.nend,
+ fl.strand
+ FROM dfeatureloc fl,
+ f_type f
+ WHERE (f.feature_id = fl.feature_id);
+
+
+--
+-- Name: feature_contact; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_contact (
+ feature_contact_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ contact_id integer NOT NULL
+);
+
+
+--
+-- Name: feature_contact_feature_contact_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_contact_feature_contact_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_contact_feature_contact_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_contact_feature_contact_id_seq OWNED BY feature_contact.feature_contact_id;
+
+
+--
+-- Name: feature_contains; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW feature_contains AS
+ SELECT x.feature_id AS subject_id,
+ y.feature_id AS object_id
+ FROM featureloc x,
+ featureloc y
+ WHERE ((x.srcfeature_id = y.srcfeature_id) AND ((y.fmin >= x.fmin) AND (y.fmin <= x.fmax)));
+
+
+--
+-- Name: VIEW feature_contains; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW feature_contains IS 'subject intervals contains (or is
+same as) object interval. transitive,reflexive';
+
+
+--
+-- Name: feature_cvterm_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_cvterm_dbxref (
+ feature_cvterm_dbxref_id integer NOT NULL,
+ feature_cvterm_id integer NOT NULL,
+ dbxref_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_cvterm_dbxref; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_cvterm_dbxref IS 'Additional dbxrefs for an association. Rows in the feature_cvterm table may be backed up by dbxrefs. For example, a feature_cvterm association that was inferred via a protein-protein interaction may be backed by by refering to the dbxref for the alternate protein. Corresponds to the WITH column in a GO gene association file (but can also be used for other analagous associations). See http://www.geneontology.org/doc/GO.annotation.shtml#file for more details.';
+
+
+--
+-- Name: feature_cvterm_dbxref_feature_cvterm_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_cvterm_dbxref_feature_cvterm_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_cvterm_dbxref_feature_cvterm_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_cvterm_dbxref_feature_cvterm_dbxref_id_seq OWNED BY feature_cvterm_dbxref.feature_cvterm_dbxref_id;
+
+
+--
+-- Name: feature_cvterm_feature_cvterm_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_cvterm_feature_cvterm_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_cvterm_feature_cvterm_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_cvterm_feature_cvterm_id_seq OWNED BY feature_cvterm.feature_cvterm_id;
+
+
+--
+-- Name: feature_cvterm_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_cvterm_pub (
+ feature_cvterm_pub_id integer NOT NULL,
+ feature_cvterm_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_cvterm_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_cvterm_pub IS 'Secondary pubs for an
+association. Each feature_cvterm association is supported by a single
+primary publication. Additional secondary pubs can be added using this
+linking table (in a GO gene association file, these corresponding to
+any IDs after the pipe symbol in the publications column.';
+
+
+--
+-- Name: feature_cvterm_pub_feature_cvterm_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_cvterm_pub_feature_cvterm_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_cvterm_pub_feature_cvterm_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_cvterm_pub_feature_cvterm_pub_id_seq OWNED BY feature_cvterm_pub.feature_cvterm_pub_id;
+
+
+--
+-- Name: feature_cvtermprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_cvtermprop (
+ feature_cvtermprop_id integer NOT NULL,
+ feature_cvterm_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_cvtermprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_cvtermprop IS 'Extensible properties for
+feature to cvterm associations. Examples: GO evidence codes;
+qualifiers; metadata such as the date on which the entry was curated
+and the source of the association. See the featureprop table for
+meanings of type_id, value and rank.';
+
+
+--
+-- Name: COLUMN feature_cvtermprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_cvtermprop.type_id IS 'The name of the
+property/slot is a cvterm. The meaning of the property is defined in
+that cvterm. cvterms may come from the OBO evidence code cv.';
+
+
+--
+-- Name: COLUMN feature_cvtermprop.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_cvtermprop.value IS 'The value of the
+property, represented as text. Numeric values are converted to their
+text representation. This is less efficient than using native database
+types, but is easier to query.';
+
+
+--
+-- Name: COLUMN feature_cvtermprop.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_cvtermprop.rank IS 'Property-Value
+ordering. Any feature_cvterm can have multiple values for any particular
+property type - these are ordered in a list using rank, counting from
+zero. For properties that are single-valued rather than multi-valued,
+the default 0 value should be used.';
+
+
+--
+-- Name: feature_cvtermprop_feature_cvtermprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_cvtermprop_feature_cvtermprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_cvtermprop_feature_cvtermprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_cvtermprop_feature_cvtermprop_id_seq OWNED BY feature_cvtermprop.feature_cvtermprop_id;
+
+
+--
+-- Name: feature_dbxref_feature_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_dbxref_feature_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_dbxref_feature_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_dbxref_feature_dbxref_id_seq OWNED BY feature_dbxref.feature_dbxref_id;
+
+
+--
+-- Name: feature_difference; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW feature_difference AS
+ SELECT x.feature_id AS subject_id,
+ y.feature_id AS object_id,
+ x.strand AS srcfeature_id,
+ x.srcfeature_id AS fmin,
+ x.fmin AS fmax,
+ y.fmin AS strand
+ FROM featureloc x,
+ featureloc y
+ WHERE ((x.srcfeature_id = y.srcfeature_id) AND ((x.fmin < y.fmin) AND (x.fmax >= y.fmax)))
+UNION
+ SELECT x.feature_id AS subject_id,
+ y.feature_id AS object_id,
+ x.strand AS srcfeature_id,
+ x.srcfeature_id AS fmin,
+ y.fmax,
+ x.fmax AS strand
+ FROM featureloc x,
+ featureloc y
+ WHERE ((x.srcfeature_id = y.srcfeature_id) AND ((x.fmax > y.fmax) AND (x.fmin <= y.fmin)));
+
+
+--
+-- Name: VIEW feature_difference; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW feature_difference IS 'size of gap between two features. must be abutting or disjoint';
+
+
+--
+-- Name: feature_disjoint; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW feature_disjoint AS
+ SELECT x.feature_id AS subject_id,
+ y.feature_id AS object_id
+ FROM featureloc x,
+ featureloc y
+ WHERE ((x.srcfeature_id = y.srcfeature_id) AND ((x.fmax < y.fmin) AND (x.fmin > y.fmax)));
+
+
+--
+-- Name: VIEW feature_disjoint; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW feature_disjoint IS 'featurelocs do not meet. symmetric';
+
+
+--
+-- Name: feature_distance; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW feature_distance AS
+ SELECT x.feature_id AS subject_id,
+ y.feature_id AS object_id,
+ x.srcfeature_id,
+ x.strand AS subject_strand,
+ y.strand AS object_strand,
+ CASE
+ WHEN (x.fmax <= y.fmin) THEN (x.fmax - y.fmin)
+ ELSE (y.fmax - x.fmin)
+ END AS distance
+ FROM featureloc x,
+ featureloc y
+ WHERE ((x.srcfeature_id = y.srcfeature_id) AND ((x.fmax <= y.fmin) OR (x.fmin >= y.fmax)));
+
+
+--
+-- Name: feature_expression; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_expression (
+ feature_expression_id integer NOT NULL,
+ expression_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: feature_expression_feature_expression_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_expression_feature_expression_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_expression_feature_expression_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_expression_feature_expression_id_seq OWNED BY feature_expression.feature_expression_id;
+
+
+--
+-- Name: feature_expressionprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_expressionprop (
+ feature_expressionprop_id integer NOT NULL,
+ feature_expression_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_expressionprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_expressionprop IS 'Extensible properties for
+feature_expression (comments, for example). Modeled on feature_cvtermprop.';
+
+
+--
+-- Name: feature_expressionprop_feature_expressionprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_expressionprop_feature_expressionprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_expressionprop_feature_expressionprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_expressionprop_feature_expressionprop_id_seq OWNED BY feature_expressionprop.feature_expressionprop_id;
+
+
+--
+-- Name: feature_feature_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_feature_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_feature_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_feature_id_seq OWNED BY feature.feature_id;
+
+
+--
+-- Name: feature_genotype; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_genotype (
+ feature_genotype_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ genotype_id integer NOT NULL,
+ chromosome_id integer,
+ rank integer NOT NULL,
+ cgroup integer NOT NULL,
+ cvterm_id integer NOT NULL
+);
+
+
+--
+-- Name: COLUMN feature_genotype.chromosome_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_genotype.chromosome_id IS 'A feature of SO type "chromosome".';
+
+
+--
+-- Name: COLUMN feature_genotype.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_genotype.rank IS 'rank can be used for
+n-ploid organisms or to preserve order.';
+
+
+--
+-- Name: COLUMN feature_genotype.cgroup; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_genotype.cgroup IS 'Spatially distinguishable
+group. group can be used for distinguishing the chromosomal groups,
+for example (RNAi products and so on can be treated as different
+groups, as they do not fall on a particular chromosome).';
+
+
+--
+-- Name: feature_genotype_feature_genotype_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_genotype_feature_genotype_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_genotype_feature_genotype_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_genotype_feature_genotype_id_seq OWNED BY feature_genotype.feature_genotype_id;
+
+
+--
+-- Name: feature_image; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_image (
+ feature_image_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ eimage_id integer NOT NULL
+);
+
+
+--
+-- Name: feature_image_feature_image_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_image_feature_image_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_image_feature_image_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_image_feature_image_id_seq OWNED BY feature_image.feature_image_id;
+
+
+--
+-- Name: feature_intersection; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW feature_intersection AS
+ SELECT x.feature_id AS subject_id,
+ y.feature_id AS object_id,
+ x.srcfeature_id,
+ x.strand AS subject_strand,
+ y.strand AS object_strand,
+ CASE
+ WHEN (x.fmin < y.fmin) THEN y.fmin
+ ELSE x.fmin
+ END AS fmin,
+ CASE
+ WHEN (x.fmax > y.fmax) THEN y.fmax
+ ELSE x.fmax
+ END AS fmax
+ FROM featureloc x,
+ featureloc y
+ WHERE ((x.srcfeature_id = y.srcfeature_id) AND ((x.fmax >= y.fmin) AND (x.fmin <= y.fmax)));
+
+
+--
+-- Name: VIEW feature_intersection; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW feature_intersection IS 'set-intersection on interval defined by featureloc. featurelocs must meet';
+
+
+--
+-- Name: feature_meets; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW feature_meets AS
+ SELECT x.feature_id AS subject_id,
+ y.feature_id AS object_id
+ FROM featureloc x,
+ featureloc y
+ WHERE ((x.srcfeature_id = y.srcfeature_id) AND ((x.fmax >= y.fmin) AND (x.fmin <= y.fmax)));
+
+
+--
+-- Name: VIEW feature_meets; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW feature_meets IS 'intervals have at least one
+interbase point in common (ie overlap OR abut). symmetric,reflexive';
+
+
+--
+-- Name: feature_meets_on_same_strand; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW feature_meets_on_same_strand AS
+ SELECT x.feature_id AS subject_id,
+ y.feature_id AS object_id
+ FROM featureloc x,
+ featureloc y
+ WHERE (((x.srcfeature_id = y.srcfeature_id) AND (x.strand = y.strand)) AND ((x.fmax >= y.fmin) AND (x.fmin <= y.fmax)));
+
+
+--
+-- Name: VIEW feature_meets_on_same_strand; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW feature_meets_on_same_strand IS 'as feature_meets, but
+featurelocs must be on the same strand. symmetric,reflexive';
+
+
+--
+-- Name: feature_phenotype; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_phenotype (
+ feature_phenotype_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ phenotype_id integer NOT NULL
+);
+
+
+--
+-- Name: feature_phenotype_feature_phenotype_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_phenotype_feature_phenotype_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_phenotype_feature_phenotype_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_phenotype_feature_phenotype_id_seq OWNED BY feature_phenotype.feature_phenotype_id;
+
+
+--
+-- Name: feature_project; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_project (
+ feature_project_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ project_id integer NOT NULL
+);
+
+
+--
+-- Name: feature_project_feature_project_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_project_feature_project_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_project_feature_project_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_project_feature_project_id_seq OWNED BY feature_project.feature_project_id;
+
+
+--
+-- Name: feature_pub_feature_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_pub_feature_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_pub_feature_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_pub_feature_pub_id_seq OWNED BY feature_pub.feature_pub_id;
+
+
+--
+-- Name: feature_pubprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_pubprop (
+ feature_pubprop_id integer NOT NULL,
+ feature_pub_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_pubprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_pubprop IS 'Property or attribute of a feature_pub link.';
+
+
+--
+-- Name: feature_pubprop_feature_pubprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_pubprop_feature_pubprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_pubprop_feature_pubprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_pubprop_feature_pubprop_id_seq OWNED BY feature_pubprop.feature_pubprop_id;
+
+
+--
+-- Name: feature_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_relationship (
+ feature_relationship_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ object_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_relationship IS 'Features can be arranged in
+graphs, e.g. "exon part_of transcript part_of gene"; If type is
+thought of as a verb, the each arc or edge makes a statement
+[Subject Verb Object]. The object can also be thought of as parent
+(containing feature), and subject as child (contained feature or
+subfeature). We include the relationship rank/order, because even
+though most of the time we can order things implicitly by sequence
+coordinates, we can not always do this - e.g. transpliced genes. It is also
+useful for quickly getting implicit introns.';
+
+
+--
+-- Name: COLUMN feature_relationship.subject_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_relationship.subject_id IS 'The subject of the subj-predicate-obj sentence. This is typically the subfeature.';
+
+
+--
+-- Name: COLUMN feature_relationship.object_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_relationship.object_id IS 'The object of the subj-predicate-obj sentence. This is typically the container feature.';
+
+
+--
+-- Name: COLUMN feature_relationship.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_relationship.type_id IS 'Relationship type between subject and object. This is a cvterm, typically from the OBO relationship ontology, although other relationship types are allowed. The most common relationship type is OBO_REL:part_of. Valid relationship types are constrained by the Sequence Ontology.';
+
+
+--
+-- Name: COLUMN feature_relationship.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_relationship.value IS 'Additional notes or comments.';
+
+
+--
+-- Name: COLUMN feature_relationship.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_relationship.rank IS 'The ordering of subject features with respect to the object feature may be important (for example, exon ordering on a transcript - not always derivable if you take trans spliced genes into consideration). Rank is used to order these; starts from zero.';
+
+
+--
+-- Name: feature_relationship_feature_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_relationship_feature_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_relationship_feature_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_relationship_feature_relationship_id_seq OWNED BY feature_relationship.feature_relationship_id;
+
+
+--
+-- Name: feature_relationship_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_relationship_pub (
+ feature_relationship_pub_id integer NOT NULL,
+ feature_relationship_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_relationship_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_relationship_pub IS 'Provenance. Attach optional evidence to a feature_relationship in the form of a chado.tion.';
+
+
+--
+-- Name: feature_relationship_pub_feature_relationship_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_relationship_pub_feature_relationship_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_relationship_pub_feature_relationship_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_relationship_pub_feature_relationship_pub_id_seq OWNED BY feature_relationship_pub.feature_relationship_pub_id;
+
+
+--
+-- Name: feature_relationshipprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_relationshipprop (
+ feature_relationshipprop_id integer NOT NULL,
+ feature_relationship_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_relationshipprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_relationshipprop IS 'Extensible properties
+for feature_relationships. Analagous structure to featureprop. This
+table is largely optional and not used with a high frequency. Typical
+scenarios may be if one wishes to attach additional data to a
+feature_relationship - for example to say that the
+feature_relationship is only true in certain contexts.';
+
+
+--
+-- Name: COLUMN feature_relationshipprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_relationshipprop.type_id IS 'The name of the
+property/slot is a cvterm. The meaning of the property is defined in
+that cvterm. Currently there is no standard ontology for
+feature_relationship property types.';
+
+
+--
+-- Name: COLUMN feature_relationshipprop.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_relationshipprop.value IS 'The value of the
+property, represented as text. Numeric values are converted to their
+text representation. This is less efficient than using native database
+types, but is easier to query.';
+
+
+--
+-- Name: COLUMN feature_relationshipprop.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN feature_relationshipprop.rank IS 'Property-Value
+ordering. Any feature_relationship can have multiple values for any particular
+property type - these are ordered in a list using rank, counting from
+zero. For properties that are single-valued rather than multi-valued,
+the default 0 value should be used.';
+
+
+--
+-- Name: feature_relationshipprop_feature_relationshipprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_relationshipprop_feature_relationshipprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_relationshipprop_feature_relationshipprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_relationshipprop_feature_relationshipprop_id_seq OWNED BY feature_relationshipprop.feature_relationshipprop_id;
+
+
+--
+-- Name: feature_relationshipprop_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_relationshipprop_pub (
+ feature_relationshipprop_pub_id integer NOT NULL,
+ feature_relationshipprop_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE feature_relationshipprop_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE feature_relationshipprop_pub IS 'Provenance for feature_relationshipprop.';
+
+
+--
+-- Name: feature_relationshipprop_pub_feature_relationshipprop_pub_i_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_relationshipprop_pub_feature_relationshipprop_pub_i_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_relationshipprop_pub_feature_relationshipprop_pub_i_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_relationshipprop_pub_feature_relationshipprop_pub_i_seq OWNED BY feature_relationshipprop_pub.feature_relationshipprop_pub_id;
+
+
+--
+-- Name: feature_stock; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE feature_stock (
+ feature_stock_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ stock_id integer NOT NULL,
+ type_id integer
+);
+
+
+--
+-- Name: feature_stock_feature_stock_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_stock_feature_stock_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_stock_feature_stock_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_stock_feature_stock_id_seq OWNED BY feature_stock.feature_stock_id;
+
+
+--
+-- Name: feature_synonym_feature_synonym_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_synonym_feature_synonym_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: feature_synonym_feature_synonym_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE feature_synonym_feature_synonym_id_seq OWNED BY feature_synonym.feature_synonym_id;
+
+
+--
+-- Name: feature_union; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW feature_union AS
+ SELECT x.feature_id AS subject_id,
+ y.feature_id AS object_id,
+ x.srcfeature_id,
+ x.strand AS subject_strand,
+ y.strand AS object_strand,
+ CASE
+ WHEN (x.fmin < y.fmin) THEN x.fmin
+ ELSE y.fmin
+ END AS fmin,
+ CASE
+ WHEN (x.fmax > y.fmax) THEN x.fmax
+ ELSE y.fmax
+ END AS fmax
+ FROM featureloc x,
+ featureloc y
+ WHERE ((x.srcfeature_id = y.srcfeature_id) AND ((x.fmax >= y.fmin) AND (x.fmin <= y.fmax)));
+
+
+--
+-- Name: VIEW feature_union; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW feature_union IS 'set-union on interval defined by featureloc. featurelocs must meet';
+
+
+--
+-- Name: feature_uniquename_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE feature_uniquename_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featureloc_featureloc_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featureloc_featureloc_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featureloc_featureloc_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featureloc_featureloc_id_seq OWNED BY featureloc.featureloc_id;
+
+
+--
+-- Name: featureloc_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featureloc_pub (
+ featureloc_pub_id integer NOT NULL,
+ featureloc_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE featureloc_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE featureloc_pub IS 'Provenance of featureloc. Linking table between featurelocs and chado.tions that mention them.';
+
+
+--
+-- Name: featureloc_pub_featureloc_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featureloc_pub_featureloc_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featureloc_pub_featureloc_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featureloc_pub_featureloc_pub_id_seq OWNED BY featureloc_pub.featureloc_pub_id;
+
+
+--
+-- Name: featuremap; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featuremap (
+ featuremap_id integer NOT NULL,
+ name character varying(255),
+ description text,
+ unittype_id integer
+);
+
+
+--
+-- Name: featuremap_contact; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featuremap_contact (
+ featuremap_contact_id integer NOT NULL,
+ featuremap_id integer NOT NULL,
+ contact_id integer NOT NULL
+);
+
+
+--
+-- Name: featuremap_contact_featuremap_contact_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featuremap_contact_featuremap_contact_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featuremap_contact_featuremap_contact_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featuremap_contact_featuremap_contact_id_seq OWNED BY featuremap_contact.featuremap_contact_id;
+
+
+--
+-- Name: featuremap_dbxref_featuremap_dbxref_id; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featuremap_dbxref_featuremap_dbxref_id
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featuremap_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featuremap_dbxref (
+ featuremap_dbxref_id integer DEFAULT nextval('featuremap_dbxref_featuremap_dbxref_id'::regclass) NOT NULL,
+ featuremap_id integer NOT NULL,
+ dbxref_id integer NOT NULL,
+ is_current boolean DEFAULT true NOT NULL
+);
+
+
+--
+-- Name: featuremap_featuremap_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featuremap_featuremap_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featuremap_featuremap_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featuremap_featuremap_id_seq OWNED BY featuremap.featuremap_id;
+
+
+--
+-- Name: featuremap_organism; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featuremap_organism (
+ featuremap_organism_id integer NOT NULL,
+ featuremap_id integer NOT NULL,
+ organism_id integer NOT NULL
+);
+
+
+--
+-- Name: featuremap_organism_featuremap_organism_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featuremap_organism_featuremap_organism_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featuremap_organism_featuremap_organism_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featuremap_organism_featuremap_organism_id_seq OWNED BY featuremap_organism.featuremap_organism_id;
+
+
+--
+-- Name: featuremap_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featuremap_pub (
+ featuremap_pub_id integer NOT NULL,
+ featuremap_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: featuremap_pub_featuremap_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featuremap_pub_featuremap_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featuremap_pub_featuremap_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featuremap_pub_featuremap_pub_id_seq OWNED BY featuremap_pub.featuremap_pub_id;
+
+
+--
+-- Name: featuremap_stock; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featuremap_stock (
+ featuremap_stock_id integer NOT NULL,
+ featuremap_id integer NOT NULL,
+ stock_id integer NOT NULL
+);
+
+
+--
+-- Name: featuremap_stock_featuremap_stock_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featuremap_stock_featuremap_stock_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featuremap_stock_featuremap_stock_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featuremap_stock_featuremap_stock_id_seq OWNED BY featuremap_stock.featuremap_stock_id;
+
+
+--
+-- Name: featuremapprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featuremapprop (
+ featuremapprop_id integer NOT NULL,
+ featuremap_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: featuremapprop_featuremapprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featuremapprop_featuremapprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featuremapprop_featuremapprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featuremapprop_featuremapprop_id_seq OWNED BY featuremapprop.featuremapprop_id;
+
+
+--
+-- Name: featurepos; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featurepos (
+ featurepos_id integer NOT NULL,
+ featuremap_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ map_feature_id integer NOT NULL,
+ mappos double precision NOT NULL
+);
+
+
+--
+-- Name: COLUMN featurepos.map_feature_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featurepos.map_feature_id IS 'map_feature_id
+links to the feature (map) upon which the feature is being localized.';
+
+
+--
+-- Name: featurepos_featuremap_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featurepos_featuremap_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featurepos_featuremap_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featurepos_featuremap_id_seq OWNED BY featurepos.featuremap_id;
+
+
+--
+-- Name: featurepos_featurepos_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featurepos_featurepos_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featurepos_featurepos_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featurepos_featurepos_id_seq OWNED BY featurepos.featurepos_id;
+
+
+--
+-- Name: featureposprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featureposprop (
+ featureposprop_id integer NOT NULL,
+ featurepos_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: featureposprop_featureposprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featureposprop_featureposprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featureposprop_featureposprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featureposprop_featureposprop_id_seq OWNED BY featureposprop.featureposprop_id;
+
+
+--
+-- Name: featureprop_featureprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featureprop_featureprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featureprop_featureprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featureprop_featureprop_id_seq OWNED BY featureprop.featureprop_id;
+
+
+--
+-- Name: featureprop_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featureprop_pub (
+ featureprop_pub_id integer NOT NULL,
+ featureprop_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE featureprop_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE featureprop_pub IS 'Provenance. Any featureprop assignment can optionally be supported by a chado.tion.';
+
+
+--
+-- Name: featureprop_pub_featureprop_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featureprop_pub_featureprop_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featureprop_pub_featureprop_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featureprop_pub_featureprop_pub_id_seq OWNED BY featureprop_pub.featureprop_pub_id;
+
+
+--
+-- Name: featurerange; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE featurerange (
+ featurerange_id integer NOT NULL,
+ featuremap_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ leftstartf_id integer NOT NULL,
+ leftendf_id integer,
+ rightstartf_id integer,
+ rightendf_id integer NOT NULL,
+ rangestr character varying(255)
+);
+
+
+--
+-- Name: TABLE featurerange; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE featurerange IS 'In cases where the start and end of a mapped feature is a range, leftendf and rightstartf are populated. leftstartf_id, leftendf_id, rightstartf_id, rightendf_id are the ids of features with respect to which the feature is being mapped. These may be cytological bands.';
+
+
+--
+-- Name: COLUMN featurerange.featuremap_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN featurerange.featuremap_id IS 'featuremap_id is the id of the feature being mapped.';
+
+
+--
+-- Name: featurerange_featurerange_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE featurerange_featurerange_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: featurerange_featurerange_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE featurerange_featurerange_id_seq OWNED BY featurerange.featurerange_id;
+
+
+--
+-- Name: featureset_meets; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW featureset_meets AS
+ SELECT x.object_id AS subject_id,
+ y.object_id
+ FROM ((feature_meets r
+ JOIN feature_relationship x ON ((r.subject_id = x.subject_id)))
+ JOIN feature_relationship y ON ((r.object_id = y.subject_id)));
+
+
+--
+-- Name: fp_key; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW fp_key AS
+ SELECT fp.feature_id,
+ c.name AS pkey,
+ fp.value
+ FROM featureprop fp,
+ cvterm c
+ WHERE (fp.featureprop_id = c.cvterm_id);
+
+
+--
+-- Name: genotype; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE genotype (
+ genotype_id integer NOT NULL,
+ name text,
+ uniquename text NOT NULL,
+ description character varying(255),
+ type_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE genotype; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE genotype IS 'Genetic context. A genotype is defined by a collection of features, mutations, balancers, deficiencies, haplotype blocks, or engineered constructs.';
+
+
+--
+-- Name: COLUMN genotype.name; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN genotype.name IS 'Optional alternative name for a genotype,
+for display purposes.';
+
+
+--
+-- Name: COLUMN genotype.uniquename; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN genotype.uniquename IS 'The unique name for a genotype;
+typically derived from the features making up the genotype.';
+
+
+--
+-- Name: genotype_genotype_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE genotype_genotype_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: genotype_genotype_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE genotype_genotype_id_seq OWNED BY genotype.genotype_id;
+
+
+--
+-- Name: genotypeprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE genotypeprop (
+ genotypeprop_id integer NOT NULL,
+ genotype_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: genotypeprop_genotypeprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE genotypeprop_genotypeprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: genotypeprop_genotypeprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE genotypeprop_genotypeprop_id_seq OWNED BY genotypeprop.genotypeprop_id;
+
+
+--
+-- Name: gff3atts; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW gff3atts AS
+ SELECT fs.feature_id,
+ 'Ontology_term'::text AS type,
+ CASE
+ WHEN ((db.name)::text ~~ '%Gene Ontology%'::text) THEN (('GO:'::text || (dbx.accession)::text))::character varying
+ WHEN ((db.name)::text ~~ 'Sequence Ontology%'::text) THEN (('SO:'::text || (dbx.accession)::text))::character varying
+ ELSE ((((db.name)::text || ':'::text) || (dbx.accession)::text))::character varying
+ END AS attribute
+ FROM cvterm s,
+ dbxref dbx,
+ feature_cvterm fs,
+ db
+ WHERE (((fs.cvterm_id = s.cvterm_id) AND (s.dbxref_id = dbx.dbxref_id)) AND (db.db_id = dbx.db_id))
+UNION ALL
+ SELECT fs.feature_id,
+ 'Dbxref'::text AS type,
+ (((d.name)::text || ':'::text) || (s.accession)::text) AS attribute
+ FROM dbxref s,
+ feature_dbxref fs,
+ db d
+ WHERE (((fs.dbxref_id = s.dbxref_id) AND (s.db_id = d.db_id)) AND ((d.name)::text <> 'GFF_source'::text))
+UNION ALL
+ SELECT f.feature_id,
+ 'Alias'::text AS type,
+ s.name AS attribute
+ FROM synonym s,
+ feature_synonym fs,
+ feature f
+ WHERE ((((fs.synonym_id = s.synonym_id) AND (f.feature_id = fs.feature_id)) AND ((f.name)::text <> (s.name)::text)) AND (f.uniquename <> (s.name)::text))
+UNION ALL
+ SELECT fp.feature_id,
+ cv.name AS type,
+ fp.value AS attribute
+ FROM featureprop fp,
+ cvterm cv
+ WHERE (fp.type_id = cv.cvterm_id)
+UNION ALL
+ SELECT fs.feature_id,
+ 'pub'::text AS type,
+ (((s.series_name)::text || ':'::text) || s.title) AS attribute
+ FROM pub s,
+ feature_pub fs
+ WHERE (fs.pub_id = s.pub_id)
+UNION ALL
+ SELECT fr.subject_id AS feature_id,
+ 'Parent'::text AS type,
+ parent.uniquename AS attribute
+ FROM feature_relationship fr,
+ feature parent
+ WHERE ((fr.object_id = parent.feature_id) AND (fr.type_id = ( SELECT cvterm.cvterm_id
+ FROM cvterm
+ WHERE (((cvterm.name)::text = 'part_of'::text) AND (cvterm.cv_id IN ( SELECT cv.cv_id
+ FROM cv
+ WHERE ((cv.name)::text = 'relationship'::text)))))))
+UNION ALL
+ SELECT fr.subject_id AS feature_id,
+ 'Derives_from'::text AS type,
+ parent.uniquename AS attribute
+ FROM feature_relationship fr,
+ feature parent
+ WHERE ((fr.object_id = parent.feature_id) AND (fr.type_id = ( SELECT cvterm.cvterm_id
+ FROM cvterm
+ WHERE (((cvterm.name)::text = 'derives_from'::text) AND (cvterm.cv_id IN ( SELECT cv.cv_id
+ FROM cv
+ WHERE ((cv.name)::text = 'relationship'::text)))))))
+UNION ALL
+ SELECT fl.feature_id,
+ 'Target'::text AS type,
+ (((((((target.name)::text || ' '::text) || (fl.fmin + 1)) || ' '::text) || fl.fmax) || ' '::text) || fl.strand) AS attribute
+ FROM featureloc fl,
+ feature target
+ WHERE ((fl.srcfeature_id = target.feature_id) AND (fl.rank <> 0))
+UNION ALL
+ SELECT feature.feature_id,
+ 'ID'::text AS type,
+ feature.uniquename AS attribute
+ FROM feature
+ WHERE (NOT (feature.type_id IN ( SELECT cvterm.cvterm_id
+ FROM cvterm
+ WHERE ((cvterm.name)::text = 'CDS'::text))))
+UNION ALL
+ SELECT feature.feature_id,
+ 'chado_feature_id'::text AS type,
+ (feature.feature_id)::character varying AS attribute
+ FROM feature
+UNION ALL
+ SELECT feature.feature_id,
+ 'Name'::text AS type,
+ feature.name AS attribute
+ FROM feature;
+
+
+--
+-- Name: go_count_analysis; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE go_count_analysis (
+ cvname character varying(255),
+ cvterm_id integer,
+ analysis_id integer,
+ organism_id integer,
+ feature_count integer
+);
+
+
+--
+-- Name: go_count_organism; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE go_count_organism (
+ cvname character varying(255),
+ cvterm_id integer,
+ organism_id integer,
+ feature_count integer
+);
+
+
+--
+-- Name: intron_combined_view; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW intron_combined_view AS
+ SELECT x1.feature_id AS exon1_id,
+ x2.feature_id AS exon2_id,
+ CASE
+ WHEN (l1.strand = (-1)) THEN l2.fmax
+ ELSE l1.fmax
+ END AS fmin,
+ CASE
+ WHEN (l1.strand = (-1)) THEN l1.fmin
+ ELSE l2.fmin
+ END AS fmax,
+ l1.strand,
+ l1.srcfeature_id,
+ r1.rank AS intron_rank,
+ r1.object_id AS transcript_id
+ FROM ((((((cvterm
+ JOIN feature x1 ON ((x1.type_id = cvterm.cvterm_id)))
+ JOIN feature_relationship r1 ON ((x1.feature_id = r1.subject_id)))
+ JOIN featureloc l1 ON ((x1.feature_id = l1.feature_id)))
+ JOIN feature x2 ON ((x2.type_id = cvterm.cvterm_id)))
+ JOIN feature_relationship r2 ON ((x2.feature_id = r2.subject_id)))
+ JOIN featureloc l2 ON ((x2.feature_id = l2.feature_id)))
+ WHERE ((((((((cvterm.name)::text = 'exon'::text) AND ((r2.rank - r1.rank) = 1)) AND (r1.object_id = r2.object_id)) AND (l1.strand = l2.strand)) AND (l1.srcfeature_id = l2.srcfeature_id)) AND (l1.locgroup = 0)) AND (l2.locgroup = 0));
+
+
+--
+-- Name: intronloc_view; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW intronloc_view AS
+ SELECT DISTINCT intron_combined_view.exon1_id,
+ intron_combined_view.exon2_id,
+ intron_combined_view.fmin,
+ intron_combined_view.fmax,
+ intron_combined_view.strand,
+ intron_combined_view.srcfeature_id
+ FROM intron_combined_view;
+
+
+--
+-- Name: kegg_by_organism; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE kegg_by_organism (
+ analysis_name character varying(255),
+ analysis_id integer,
+ organism_id integer
+);
+
+
+--
+-- Name: library; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE library (
+ library_id integer NOT NULL,
+ organism_id integer NOT NULL,
+ name character varying(255),
+ uniquename text NOT NULL,
+ type_id integer NOT NULL,
+ is_obsolete integer DEFAULT 0 NOT NULL,
+ timeaccessioned timestamp without time zone DEFAULT now() NOT NULL,
+ timelastmodified timestamp without time zone DEFAULT now() NOT NULL
+);
+
+
+--
+-- Name: COLUMN library.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN library.type_id IS 'The type_id foreign key links
+to a controlled vocabulary of library types. Examples of this would be: "cDNA_library" or "genomic_library"';
+
+
+--
+-- Name: library_contact; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE library_contact (
+ library_contact_id integer NOT NULL,
+ library_id integer NOT NULL,
+ contact_id integer NOT NULL
+);
+
+
+--
+-- Name: library_contact_library_contact_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE library_contact_library_contact_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: library_contact_library_contact_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE library_contact_library_contact_id_seq OWNED BY library_contact.library_contact_id;
+
+
+--
+-- Name: library_cvterm; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE library_cvterm (
+ library_cvterm_id integer NOT NULL,
+ library_id integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE library_cvterm; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE library_cvterm IS 'The table library_cvterm links a library to controlled vocabularies which describe the library. For instance, there might be a link to the anatomy cv for "head" or "testes" for a head or testes library.';
+
+
+--
+-- Name: library_cvterm_library_cvterm_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE library_cvterm_library_cvterm_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: library_cvterm_library_cvterm_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE library_cvterm_library_cvterm_id_seq OWNED BY library_cvterm.library_cvterm_id;
+
+
+--
+-- Name: library_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE library_dbxref (
+ library_dbxref_id integer NOT NULL,
+ library_id integer NOT NULL,
+ dbxref_id integer NOT NULL,
+ is_current boolean DEFAULT true NOT NULL
+);
+
+
+--
+-- Name: library_dbxref_library_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE library_dbxref_library_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: library_dbxref_library_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE library_dbxref_library_dbxref_id_seq OWNED BY library_dbxref.library_dbxref_id;
+
+
+--
+-- Name: library_feature; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE library_feature (
+ library_feature_id integer NOT NULL,
+ library_id integer NOT NULL,
+ feature_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE library_feature; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE library_feature IS 'library_feature links a library to the clones which are contained in the library. Examples of such linked features might be "cDNA_clone" or "genomic_clone".';
+
+
+--
+-- Name: library_feature_library_feature_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE library_feature_library_feature_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: library_feature_library_feature_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE library_feature_library_feature_id_seq OWNED BY library_feature.library_feature_id;
+
+
+--
+-- Name: library_library_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE library_library_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: library_library_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE library_library_id_seq OWNED BY library.library_id;
+
+
+--
+-- Name: library_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE library_pub (
+ library_pub_id integer NOT NULL,
+ library_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: library_pub_library_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE library_pub_library_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: library_pub_library_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE library_pub_library_pub_id_seq OWNED BY library_pub.library_pub_id;
+
+
+--
+-- Name: library_stock; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE library_stock (
+ library_stock_id integer NOT NULL,
+ library_id integer NOT NULL,
+ stock_id integer NOT NULL
+);
+
+
+--
+-- Name: library_stock_library_stock_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE library_stock_library_stock_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: library_stock_library_stock_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE library_stock_library_stock_id_seq OWNED BY library_stock.library_stock_id;
+
+
+--
+-- Name: library_synonym; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE library_synonym (
+ library_synonym_id integer NOT NULL,
+ synonym_id integer NOT NULL,
+ library_id integer NOT NULL,
+ pub_id integer NOT NULL,
+ is_current boolean DEFAULT true NOT NULL,
+ is_internal boolean DEFAULT false NOT NULL
+);
+
+
+--
+-- Name: COLUMN library_synonym.pub_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN library_synonym.pub_id IS 'The pub_id link is for
+relating the usage of a given synonym to the publication in which it was used.';
+
+
+--
+-- Name: COLUMN library_synonym.is_current; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN library_synonym.is_current IS 'The is_current bit indicates whether the linked synonym is the current -official- symbol for the linked library.';
+
+
+--
+-- Name: COLUMN library_synonym.is_internal; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN library_synonym.is_internal IS 'Typically a synonym
+exists so that somebody querying the database with an obsolete name
+can find the object they are looking for under its current name. If
+the synonym has been used publicly and deliberately (e.g. in a paper), it my also be listed in reports as a synonym. If the synonym was not used deliberately (e.g., there was a typo which went public), then the is_internal bit may be set to "true" so that it is known that the synonym is "internal" and should be queryable but should not be listed in reports as a valid synonym.';
+
+
+--
+-- Name: library_synonym_library_synonym_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE library_synonym_library_synonym_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: library_synonym_library_synonym_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE library_synonym_library_synonym_id_seq OWNED BY library_synonym.library_synonym_id;
+
+
+--
+-- Name: libraryprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE libraryprop (
+ libraryprop_id integer NOT NULL,
+ library_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: libraryprop_libraryprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE libraryprop_libraryprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: libraryprop_libraryprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE libraryprop_libraryprop_id_seq OWNED BY libraryprop.libraryprop_id;
+
+
+--
+-- Name: libraryprop_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE libraryprop_pub (
+ libraryprop_pub_id integer NOT NULL,
+ libraryprop_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: libraryprop_pub_libraryprop_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE libraryprop_pub_libraryprop_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: libraryprop_pub_libraryprop_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE libraryprop_pub_libraryprop_pub_id_seq OWNED BY libraryprop_pub.libraryprop_pub_id;
+
+
+--
+-- Name: magedocumentation; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE magedocumentation (
+ magedocumentation_id integer NOT NULL,
+ mageml_id integer NOT NULL,
+ tableinfo_id integer NOT NULL,
+ row_id integer NOT NULL,
+ mageidentifier text NOT NULL
+);
+
+
+--
+-- Name: magedocumentation_magedocumentation_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE magedocumentation_magedocumentation_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: magedocumentation_magedocumentation_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE magedocumentation_magedocumentation_id_seq OWNED BY magedocumentation.magedocumentation_id;
+
+
+--
+-- Name: mageml; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE mageml (
+ mageml_id integer NOT NULL,
+ mage_package text NOT NULL,
+ mage_ml text NOT NULL
+);
+
+
+--
+-- Name: TABLE mageml; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE mageml IS 'This table is for storing extra bits of MAGEml in a denormalized form. More normalization would require many more tables.';
+
+
+--
+-- Name: mageml_mageml_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE mageml_mageml_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: mageml_mageml_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE mageml_mageml_id_seq OWNED BY mageml.mageml_id;
+
+
+--
+-- Name: materialized_view; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE materialized_view (
+ materialized_view_id integer NOT NULL,
+ last_update timestamp without time zone,
+ refresh_time integer,
+ name character varying(64),
+ mv_schema character varying(64),
+ mv_table character varying(128),
+ mv_specs text,
+ indexed text,
+ query text,
+ special_index text
+);
+
+
+--
+-- Name: materialized_view_materialized_view_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE materialized_view_materialized_view_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: materialized_view_materialized_view_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE materialized_view_materialized_view_id_seq OWNED BY materialized_view.materialized_view_id;
+
+
+--
+-- Name: nd_experiment; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experiment (
+ nd_experiment_id integer NOT NULL,
+ nd_geolocation_id integer NOT NULL,
+ type_id integer NOT NULL
+);
+
+
+--
+-- Name: nd_experiment_contact; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experiment_contact (
+ nd_experiment_contact_id integer NOT NULL,
+ nd_experiment_id integer NOT NULL,
+ contact_id integer NOT NULL
+);
+
+
+--
+-- Name: nd_experiment_contact_nd_experiment_contact_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experiment_contact_nd_experiment_contact_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experiment_contact_nd_experiment_contact_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experiment_contact_nd_experiment_contact_id_seq OWNED BY nd_experiment_contact.nd_experiment_contact_id;
+
+
+--
+-- Name: nd_experiment_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experiment_dbxref (
+ nd_experiment_dbxref_id integer NOT NULL,
+ nd_experiment_id integer NOT NULL,
+ dbxref_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_experiment_dbxref; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_experiment_dbxref IS 'Cross-reference experiment to accessions, images, etc';
+
+
+--
+-- Name: nd_experiment_dbxref_nd_experiment_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experiment_dbxref_nd_experiment_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experiment_dbxref_nd_experiment_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experiment_dbxref_nd_experiment_dbxref_id_seq OWNED BY nd_experiment_dbxref.nd_experiment_dbxref_id;
+
+
+--
+-- Name: nd_experiment_genotype; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experiment_genotype (
+ nd_experiment_genotype_id integer NOT NULL,
+ nd_experiment_id integer NOT NULL,
+ genotype_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_experiment_genotype; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_experiment_genotype IS 'Linking table: experiments to the genotypes they produce. There is a one-to-one relationship between an experiment and a genotype since each genotype record should point to one experiment. Add a new experiment_id for each genotype record.';
+
+
+--
+-- Name: nd_experiment_genotype_nd_experiment_genotype_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experiment_genotype_nd_experiment_genotype_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experiment_genotype_nd_experiment_genotype_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experiment_genotype_nd_experiment_genotype_id_seq OWNED BY nd_experiment_genotype.nd_experiment_genotype_id;
+
+
+--
+-- Name: nd_experiment_nd_experiment_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experiment_nd_experiment_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experiment_nd_experiment_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experiment_nd_experiment_id_seq OWNED BY nd_experiment.nd_experiment_id;
+
+
+--
+-- Name: nd_experiment_phenotype; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experiment_phenotype (
+ nd_experiment_phenotype_id integer NOT NULL,
+ nd_experiment_id integer NOT NULL,
+ phenotype_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_experiment_phenotype; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_experiment_phenotype IS 'Linking table: experiments to the phenotypes they produce. There is a one-to-one relationship between an experiment and a phenotype since each phenotype record should point to one experiment. Add a new experiment_id for each phenotype record.';
+
+
+--
+-- Name: nd_experiment_phenotype_nd_experiment_phenotype_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experiment_phenotype_nd_experiment_phenotype_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experiment_phenotype_nd_experiment_phenotype_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experiment_phenotype_nd_experiment_phenotype_id_seq OWNED BY nd_experiment_phenotype.nd_experiment_phenotype_id;
+
+
+--
+-- Name: nd_experiment_project; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experiment_project (
+ nd_experiment_project_id integer NOT NULL,
+ project_id integer NOT NULL,
+ nd_experiment_id integer NOT NULL
+);
+
+
+--
+-- Name: nd_experiment_project_nd_experiment_project_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experiment_project_nd_experiment_project_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experiment_project_nd_experiment_project_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experiment_project_nd_experiment_project_id_seq OWNED BY nd_experiment_project.nd_experiment_project_id;
+
+
+--
+-- Name: nd_experiment_protocol; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experiment_protocol (
+ nd_experiment_protocol_id integer NOT NULL,
+ nd_experiment_id integer NOT NULL,
+ nd_protocol_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_experiment_protocol; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_experiment_protocol IS 'Linking table: experiments to the protocols they involve.';
+
+
+--
+-- Name: nd_experiment_protocol_nd_experiment_protocol_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experiment_protocol_nd_experiment_protocol_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experiment_protocol_nd_experiment_protocol_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experiment_protocol_nd_experiment_protocol_id_seq OWNED BY nd_experiment_protocol.nd_experiment_protocol_id;
+
+
+--
+-- Name: nd_experiment_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experiment_pub (
+ nd_experiment_pub_id integer NOT NULL,
+ nd_experiment_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_experiment_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_experiment_pub IS 'Linking nd_experiment(s) to chado.tion(s)';
+
+
+--
+-- Name: nd_experiment_pub_nd_experiment_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experiment_pub_nd_experiment_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experiment_pub_nd_experiment_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experiment_pub_nd_experiment_pub_id_seq OWNED BY nd_experiment_pub.nd_experiment_pub_id;
+
+
+--
+-- Name: nd_experiment_stock; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experiment_stock (
+ nd_experiment_stock_id integer NOT NULL,
+ nd_experiment_id integer NOT NULL,
+ stock_id integer NOT NULL,
+ type_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_experiment_stock; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_experiment_stock IS 'Part of a stock or a clone of a stock that is used in an experiment';
+
+
+--
+-- Name: COLUMN nd_experiment_stock.stock_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_experiment_stock.stock_id IS 'stock used in the extraction or the corresponding stock for the clone';
+
+
+--
+-- Name: nd_experiment_stock_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experiment_stock_dbxref (
+ nd_experiment_stock_dbxref_id integer NOT NULL,
+ nd_experiment_stock_id integer NOT NULL,
+ dbxref_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_experiment_stock_dbxref; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_experiment_stock_dbxref IS 'Cross-reference experiment_stock to accessions, images, etc';
+
+
+--
+-- Name: nd_experiment_stock_dbxref_nd_experiment_stock_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experiment_stock_dbxref_nd_experiment_stock_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experiment_stock_dbxref_nd_experiment_stock_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experiment_stock_dbxref_nd_experiment_stock_dbxref_id_seq OWNED BY nd_experiment_stock_dbxref.nd_experiment_stock_dbxref_id;
+
+
+--
+-- Name: nd_experiment_stock_nd_experiment_stock_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experiment_stock_nd_experiment_stock_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experiment_stock_nd_experiment_stock_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experiment_stock_nd_experiment_stock_id_seq OWNED BY nd_experiment_stock.nd_experiment_stock_id;
+
+
+--
+-- Name: nd_experiment_stockprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experiment_stockprop (
+ nd_experiment_stockprop_id integer NOT NULL,
+ nd_experiment_stock_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_experiment_stockprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_experiment_stockprop IS 'Property/value associations for experiment_stocks. This table can store the properties such as treatment';
+
+
+--
+-- Name: COLUMN nd_experiment_stockprop.nd_experiment_stock_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_experiment_stockprop.nd_experiment_stock_id IS 'The experiment_stock to which the property applies.';
+
+
+--
+-- Name: COLUMN nd_experiment_stockprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_experiment_stockprop.type_id IS 'The name of the property as a reference to a controlled vocabulary term.';
+
+
+--
+-- Name: COLUMN nd_experiment_stockprop.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_experiment_stockprop.value IS 'The value of the property.';
+
+
+--
+-- Name: COLUMN nd_experiment_stockprop.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_experiment_stockprop.rank IS 'The rank of the property value, if the property has an array of values.';
+
+
+--
+-- Name: nd_experiment_stockprop_nd_experiment_stockprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experiment_stockprop_nd_experiment_stockprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experiment_stockprop_nd_experiment_stockprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experiment_stockprop_nd_experiment_stockprop_id_seq OWNED BY nd_experiment_stockprop.nd_experiment_stockprop_id;
+
+
+--
+-- Name: nd_experimentprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_experimentprop (
+ nd_experimentprop_id integer NOT NULL,
+ nd_experiment_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: nd_experimentprop_nd_experimentprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_experimentprop_nd_experimentprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_experimentprop_nd_experimentprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_experimentprop_nd_experimentprop_id_seq OWNED BY nd_experimentprop.nd_experimentprop_id;
+
+
+--
+-- Name: nd_geolocation; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_geolocation (
+ nd_geolocation_id integer NOT NULL,
+ description character varying(255),
+ latitude real,
+ longitude real,
+ geodetic_datum character varying(32),
+ altitude real
+);
+
+
+--
+-- Name: TABLE nd_geolocation; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_geolocation IS 'The geo-referencable location of the stock. NOTE: This entity is subject to change as a more general and possibly more OpenGIS-compliant geolocation module may be introduced into Chado.';
+
+
+--
+-- Name: COLUMN nd_geolocation.description; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_geolocation.description IS 'A textual representation of the location, if this is the original georeference. Optional if the original georeference is available in lat/long coordinates.';
+
+
+--
+-- Name: COLUMN nd_geolocation.latitude; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_geolocation.latitude IS 'The decimal latitude coordinate of the georeference, using positive and negative sign to indicate N and S, respectively.';
+
+
+--
+-- Name: COLUMN nd_geolocation.longitude; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_geolocation.longitude IS 'The decimal longitude coordinate of the georeference, using positive and negative sign to indicate E and W, respectively.';
+
+
+--
+-- Name: COLUMN nd_geolocation.geodetic_datum; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_geolocation.geodetic_datum IS 'The geodetic system on which the geo-reference coordinates are based. For geo-references measured between 1984 and 2010, this will typically be WGS84.';
+
+
+--
+-- Name: COLUMN nd_geolocation.altitude; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_geolocation.altitude IS 'The altitude (elevation) of the location in meters. If the altitude is only known as a range, this is the average, and altitude_dev will hold half of the width of the range.';
+
+
+--
+-- Name: nd_geolocation_nd_geolocation_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_geolocation_nd_geolocation_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_geolocation_nd_geolocation_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_geolocation_nd_geolocation_id_seq OWNED BY nd_geolocation.nd_geolocation_id;
+
+
+--
+-- Name: nd_geolocationprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_geolocationprop (
+ nd_geolocationprop_id integer NOT NULL,
+ nd_geolocation_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_geolocationprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_geolocationprop IS 'Property/value associations for geolocations. This table can store the properties such as location and environment';
+
+
+--
+-- Name: COLUMN nd_geolocationprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_geolocationprop.type_id IS 'The name of the property as a reference to a controlled vocabulary term.';
+
+
+--
+-- Name: COLUMN nd_geolocationprop.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_geolocationprop.value IS 'The value of the property.';
+
+
+--
+-- Name: COLUMN nd_geolocationprop.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_geolocationprop.rank IS 'The rank of the property value, if the property has an array of values.';
+
+
+--
+-- Name: nd_geolocationprop_nd_geolocationprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_geolocationprop_nd_geolocationprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_geolocationprop_nd_geolocationprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_geolocationprop_nd_geolocationprop_id_seq OWNED BY nd_geolocationprop.nd_geolocationprop_id;
+
+
+--
+-- Name: nd_protocol; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_protocol (
+ nd_protocol_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ type_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_protocol; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_protocol IS 'A protocol can be anything that is done as part of the experiment.';
+
+
+--
+-- Name: COLUMN nd_protocol.name; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_protocol.name IS 'The protocol name.';
+
+
+--
+-- Name: nd_protocol_nd_protocol_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_protocol_nd_protocol_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_protocol_nd_protocol_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_protocol_nd_protocol_id_seq OWNED BY nd_protocol.nd_protocol_id;
+
+
+--
+-- Name: nd_protocol_reagent; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_protocol_reagent (
+ nd_protocol_reagent_id integer NOT NULL,
+ nd_protocol_id integer NOT NULL,
+ reagent_id integer NOT NULL,
+ type_id integer NOT NULL
+);
+
+
+--
+-- Name: nd_protocol_reagent_nd_protocol_reagent_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_protocol_reagent_nd_protocol_reagent_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_protocol_reagent_nd_protocol_reagent_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_protocol_reagent_nd_protocol_reagent_id_seq OWNED BY nd_protocol_reagent.nd_protocol_reagent_id;
+
+
+--
+-- Name: nd_protocolprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_protocolprop (
+ nd_protocolprop_id integer NOT NULL,
+ nd_protocol_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_protocolprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_protocolprop IS 'Property/value associations for protocol.';
+
+
+--
+-- Name: COLUMN nd_protocolprop.nd_protocol_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_protocolprop.nd_protocol_id IS 'The protocol to which the property applies.';
+
+
+--
+-- Name: COLUMN nd_protocolprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_protocolprop.type_id IS 'The name of the property as a reference to a controlled vocabulary term.';
+
+
+--
+-- Name: COLUMN nd_protocolprop.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_protocolprop.value IS 'The value of the property.';
+
+
+--
+-- Name: COLUMN nd_protocolprop.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_protocolprop.rank IS 'The rank of the property value, if the property has an array of values.';
+
+
+--
+-- Name: nd_protocolprop_nd_protocolprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_protocolprop_nd_protocolprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_protocolprop_nd_protocolprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_protocolprop_nd_protocolprop_id_seq OWNED BY nd_protocolprop.nd_protocolprop_id;
+
+
+--
+-- Name: nd_reagent; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_reagent (
+ nd_reagent_id integer NOT NULL,
+ name character varying(80) NOT NULL,
+ type_id integer NOT NULL,
+ feature_id integer
+);
+
+
+--
+-- Name: TABLE nd_reagent; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_reagent IS 'A reagent such as a primer, an enzyme, an adapter oligo, a linker oligo. Reagents are used in genotyping experiments, or in any other kind of experiment.';
+
+
+--
+-- Name: COLUMN nd_reagent.name; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_reagent.name IS 'The name of the reagent. The name should be unique for a given type.';
+
+
+--
+-- Name: COLUMN nd_reagent.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_reagent.type_id IS 'The type of the reagent, for example linker oligomer, or forward primer.';
+
+
+--
+-- Name: COLUMN nd_reagent.feature_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_reagent.feature_id IS 'If the reagent is a primer, the feature that it corresponds to. More generally, the corresponding feature for any reagent that has a sequence that maps to another sequence.';
+
+
+--
+-- Name: nd_reagent_nd_reagent_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_reagent_nd_reagent_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_reagent_nd_reagent_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_reagent_nd_reagent_id_seq OWNED BY nd_reagent.nd_reagent_id;
+
+
+--
+-- Name: nd_reagent_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_reagent_relationship (
+ nd_reagent_relationship_id integer NOT NULL,
+ subject_reagent_id integer NOT NULL,
+ object_reagent_id integer NOT NULL,
+ type_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE nd_reagent_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE nd_reagent_relationship IS 'Relationships between reagents. Some reagents form a group. i.e., they are used all together or not at all. Examples are adapter/linker/enzyme experiment reagents.';
+
+
+--
+-- Name: COLUMN nd_reagent_relationship.subject_reagent_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_reagent_relationship.subject_reagent_id IS 'The subject reagent in the relationship. In parent/child terminology, the subject is the child. For example, in "linkerA 3prime-overhang-linker enzymeA" linkerA is the subject, 3prime-overhand-linker is the type, and enzymeA is the object.';
+
+
+--
+-- Name: COLUMN nd_reagent_relationship.object_reagent_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_reagent_relationship.object_reagent_id IS 'The object reagent in the relationship. In parent/child terminology, the object is the parent. For example, in "linkerA 3prime-overhang-linker enzymeA" linkerA is the subject, 3prime-overhand-linker is the type, and enzymeA is the object.';
+
+
+--
+-- Name: COLUMN nd_reagent_relationship.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN nd_reagent_relationship.type_id IS 'The type (or predicate) of the relationship. For example, in "linkerA 3prime-overhang-linker enzymeA" linkerA is the subject, 3prime-overhand-linker is the type, and enzymeA is the object.';
+
+
+--
+-- Name: nd_reagent_relationship_nd_reagent_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_reagent_relationship_nd_reagent_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_reagent_relationship_nd_reagent_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_reagent_relationship_nd_reagent_relationship_id_seq OWNED BY nd_reagent_relationship.nd_reagent_relationship_id;
+
+
+--
+-- Name: nd_reagentprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE nd_reagentprop (
+ nd_reagentprop_id integer NOT NULL,
+ nd_reagent_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: nd_reagentprop_nd_reagentprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE nd_reagentprop_nd_reagentprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: nd_reagentprop_nd_reagentprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE nd_reagentprop_nd_reagentprop_id_seq OWNED BY nd_reagentprop.nd_reagentprop_id;
+
+
+--
+-- Name: organism; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE organism (
+ organism_id integer NOT NULL,
+ abbreviation character varying(255),
+ genus character varying(255) NOT NULL,
+ species character varying(255) NOT NULL,
+ common_name character varying(255),
+ comment text
+);
+
+
+--
+-- Name: TABLE organism; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE organism IS 'The organismal taxonomic
+classification. Note that phylogenies are represented using the
+phylogeny module, and taxonomies can be represented using the cvterm
+module or the phylogeny module.';
+
+
+--
+-- Name: COLUMN organism.species; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN organism.species IS 'A type of organism is always
+uniquely identified by genus and species. When mapping from the NCBI
+taxonomy names.dmp file, this column must be used where it
+is present, as the common_name column is not always unique (e.g. environmental
+samples). If a particular strain or subspecies is to be represented,
+this is appended onto the species name. Follows standard NCBI taxonomy
+pattern.';
+
+
+--
+-- Name: organism_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE organism_dbxref (
+ organism_dbxref_id integer NOT NULL,
+ organism_id integer NOT NULL,
+ dbxref_id integer NOT NULL
+);
+
+
+--
+-- Name: organism_dbxref_organism_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE organism_dbxref_organism_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: organism_dbxref_organism_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE organism_dbxref_organism_dbxref_id_seq OWNED BY organism_dbxref.organism_dbxref_id;
+
+
+--
+-- Name: organism_feature_count; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE organism_feature_count (
+ organism_id integer,
+ genus character varying(255),
+ species character varying(255),
+ common_name character varying(255),
+ num_features integer,
+ cvterm_id integer,
+ feature_type character varying(255)
+);
+
+
+--
+-- Name: organism_for_search; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE organism_for_search (
+ organism_id integer,
+ organism_name text NOT NULL
+);
+
+
+--
+-- Name: organism_image; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE organism_image (
+ organism_image_id integer NOT NULL,
+ organism_id integer NOT NULL,
+ eimage_id integer NOT NULL
+);
+
+
+--
+-- Name: organism_image_organism_image_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE organism_image_organism_image_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: organism_image_organism_image_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE organism_image_organism_image_id_seq OWNED BY organism_image.organism_image_id;
+
+
+--
+-- Name: organism_organism_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE organism_organism_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: organism_organism_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE organism_organism_id_seq OWNED BY organism.organism_id;
+
+
+--
+-- Name: organism_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE organism_pub (
+ organism_pub_id integer NOT NULL,
+ organism_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: organism_pub_organism_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE organism_pub_organism_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: organism_pub_organism_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE organism_pub_organism_pub_id_seq OWNED BY organism_pub.organism_pub_id;
+
+
+--
+-- Name: organism_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE organism_relationship (
+ organism_relationship_id integer NOT NULL,
+ subject_organism_id integer NOT NULL,
+ object_organism_id integer NOT NULL,
+ type_id integer NOT NULL
+);
+
+
+--
+-- Name: organism_relationship_organism_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE organism_relationship_organism_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: organism_relationship_organism_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE organism_relationship_organism_relationship_id_seq OWNED BY organism_relationship.organism_relationship_id;
+
+
+--
+-- Name: organism_stock_count; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE organism_stock_count (
+ organism_id integer NOT NULL,
+ genus character varying(255) NOT NULL,
+ species character varying(255) NOT NULL,
+ common_name character varying(255),
+ num_stocks integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ stock_type character varying(255) NOT NULL
+);
+
+
+--
+-- Name: TABLE organism_stock_count; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE organism_stock_count IS 'Stores the type and number of stocks per organism';
+
+
+--
+-- Name: organism_unigene_mview; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE organism_unigene_mview (
+ analysis_id integer,
+ organism_id integer
+);
+
+
+--
+-- Name: organismprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE organismprop (
+ organismprop_id integer NOT NULL,
+ organism_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE organismprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE organismprop IS 'Tag-value properties - follows standard chado model.';
+
+
+--
+-- Name: organismprop_organismprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE organismprop_organismprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: organismprop_organismprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE organismprop_organismprop_id_seq OWNED BY organismprop.organismprop_id;
+
+
+--
+-- Name: phendesc; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phendesc (
+ phendesc_id integer NOT NULL,
+ genotype_id integer NOT NULL,
+ environment_id integer NOT NULL,
+ description text NOT NULL,
+ type_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE phendesc; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE phendesc IS 'A summary of a _set_ of phenotypic statements for any one gcontext made in any one chado.tion.';
+
+
+--
+-- Name: phendesc_phendesc_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phendesc_phendesc_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phendesc_phendesc_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phendesc_phendesc_id_seq OWNED BY phendesc.phendesc_id;
+
+
+--
+-- Name: phenotype; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phenotype (
+ phenotype_id integer NOT NULL,
+ uniquename text NOT NULL,
+ observable_id integer,
+ attr_id integer,
+ value text,
+ cvalue_id integer,
+ assay_id integer,
+ name text
+);
+
+
+--
+-- Name: TABLE phenotype; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE phenotype IS 'A phenotypic statement, or a single
+atomic phenotypic observation, is a controlled sentence describing
+observable effects of non-wild type function. E.g. Obs=eye, attribute=color, cvalue=red.';
+
+
+--
+-- Name: COLUMN phenotype.observable_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN phenotype.observable_id IS 'The entity: e.g. anatomy_part, biological_process.';
+
+
+--
+-- Name: COLUMN phenotype.attr_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN phenotype.attr_id IS 'Phenotypic attribute (quality, property, attribute, character) - drawn from PATO.';
+
+
+--
+-- Name: COLUMN phenotype.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN phenotype.value IS 'Value of attribute - unconstrained free text. Used only if cvalue_id is not appropriate.';
+
+
+--
+-- Name: COLUMN phenotype.cvalue_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN phenotype.cvalue_id IS 'Phenotype attribute value (state).';
+
+
+--
+-- Name: COLUMN phenotype.assay_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN phenotype.assay_id IS 'Evidence type.';
+
+
+--
+-- Name: phenotype_comparison; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phenotype_comparison (
+ phenotype_comparison_id integer NOT NULL,
+ genotype1_id integer NOT NULL,
+ environment1_id integer NOT NULL,
+ genotype2_id integer NOT NULL,
+ environment2_id integer NOT NULL,
+ phenotype1_id integer NOT NULL,
+ phenotype2_id integer,
+ pub_id integer NOT NULL,
+ organism_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE phenotype_comparison; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE phenotype_comparison IS 'Comparison of phenotypes e.g., genotype1/environment1/phenotype1 "non-suppressible" with respect to genotype2/environment2/phenotype2.';
+
+
+--
+-- Name: phenotype_comparison_cvterm; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phenotype_comparison_cvterm (
+ phenotype_comparison_cvterm_id integer NOT NULL,
+ phenotype_comparison_id integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ pub_id integer NOT NULL,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: phenotype_comparison_cvterm_phenotype_comparison_cvterm_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phenotype_comparison_cvterm_phenotype_comparison_cvterm_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phenotype_comparison_cvterm_phenotype_comparison_cvterm_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phenotype_comparison_cvterm_phenotype_comparison_cvterm_id_seq OWNED BY phenotype_comparison_cvterm.phenotype_comparison_cvterm_id;
+
+
+--
+-- Name: phenotype_comparison_phenotype_comparison_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phenotype_comparison_phenotype_comparison_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phenotype_comparison_phenotype_comparison_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phenotype_comparison_phenotype_comparison_id_seq OWNED BY phenotype_comparison.phenotype_comparison_id;
+
+
+--
+-- Name: phenotype_cvterm; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phenotype_cvterm (
+ phenotype_cvterm_id integer NOT NULL,
+ phenotype_id integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: phenotype_cvterm_phenotype_cvterm_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phenotype_cvterm_phenotype_cvterm_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phenotype_cvterm_phenotype_cvterm_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phenotype_cvterm_phenotype_cvterm_id_seq OWNED BY phenotype_cvterm.phenotype_cvterm_id;
+
+
+--
+-- Name: phenotype_phenotype_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phenotype_phenotype_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phenotype_phenotype_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phenotype_phenotype_id_seq OWNED BY phenotype.phenotype_id;
+
+
+--
+-- Name: phenstatement; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phenstatement (
+ phenstatement_id integer NOT NULL,
+ genotype_id integer NOT NULL,
+ environment_id integer NOT NULL,
+ phenotype_id integer NOT NULL,
+ type_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE phenstatement; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE phenstatement IS 'Phenotypes are things like "larval lethal". Phenstatements are things like "dpp-1 is recessive larval lethal". So essentially phenstatement is a linking table expressing the relationship between genotype, environment, and phenotype.';
+
+
+--
+-- Name: phenstatement_phenstatement_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phenstatement_phenstatement_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phenstatement_phenstatement_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phenstatement_phenstatement_id_seq OWNED BY phenstatement.phenstatement_id;
+
+
+--
+-- Name: phenstatementprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phenstatementprop (
+ phenstatementprop_id integer NOT NULL,
+ phenstatement_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: phenstatementprop_phenstatementprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phenstatementprop_phenstatementprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phenstatementprop_phenstatementprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phenstatementprop_phenstatementprop_id_seq OWNED BY phenstatementprop.phenstatementprop_id;
+
+
+--
+-- Name: phylonode; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phylonode (
+ phylonode_id integer NOT NULL,
+ phylotree_id integer NOT NULL,
+ parent_phylonode_id integer,
+ left_idx integer NOT NULL,
+ right_idx integer NOT NULL,
+ type_id integer,
+ feature_id integer,
+ label character varying(255),
+ distance double precision
+);
+
+
+--
+-- Name: TABLE phylonode; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE phylonode IS 'This is the most pervasive
+ element in the phylogeny module, cataloging the "phylonodes" of
+ tree graphs. Edges are implied by the parent_phylonode_id
+ reflexive closure. For all nodes in a nested set implementation the left and right index will be *between* the parents left and right indexes.';
+
+
+--
+-- Name: COLUMN phylonode.parent_phylonode_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN phylonode.parent_phylonode_id IS 'Root phylonode can have null parent_phylonode_id value.';
+
+
+--
+-- Name: COLUMN phylonode.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN phylonode.type_id IS 'Type: e.g. root, interior, leaf.';
+
+
+--
+-- Name: COLUMN phylonode.feature_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN phylonode.feature_id IS 'Phylonodes can have optional features attached to them e.g. a protein or nucleotide sequence usually attached to a leaf of the phylotree for non-leaf nodes, the feature may be a feature that is an instance of SO:match; this feature is the alignment of all leaf features beneath it.';
+
+
+--
+-- Name: phylonode_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phylonode_dbxref (
+ phylonode_dbxref_id integer NOT NULL,
+ phylonode_id integer NOT NULL,
+ dbxref_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE phylonode_dbxref; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE phylonode_dbxref IS 'For example, for orthology, paralogy group identifiers; could also be used for NCBI taxonomy; for sequences, refer to phylonode_feature, feature associated dbxrefs.';
+
+
+--
+-- Name: phylonode_dbxref_phylonode_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phylonode_dbxref_phylonode_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phylonode_dbxref_phylonode_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phylonode_dbxref_phylonode_dbxref_id_seq OWNED BY phylonode_dbxref.phylonode_dbxref_id;
+
+
+--
+-- Name: phylonode_organism; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phylonode_organism (
+ phylonode_organism_id integer NOT NULL,
+ phylonode_id integer NOT NULL,
+ organism_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE phylonode_organism; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE phylonode_organism IS 'This linking table should only be used for nodes in taxonomy trees; it provides a mapping between the node and an organism. One node can have zero or one organisms, one organism can have zero or more nodes (although typically it should only have one in the standard NCBI taxonomy tree).';
+
+
+--
+-- Name: COLUMN phylonode_organism.phylonode_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN phylonode_organism.phylonode_id IS 'One phylonode cannot refer to >1 organism.';
+
+
+--
+-- Name: phylonode_organism_phylonode_organism_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phylonode_organism_phylonode_organism_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phylonode_organism_phylonode_organism_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phylonode_organism_phylonode_organism_id_seq OWNED BY phylonode_organism.phylonode_organism_id;
+
+
+--
+-- Name: phylonode_phylonode_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phylonode_phylonode_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phylonode_phylonode_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phylonode_phylonode_id_seq OWNED BY phylonode.phylonode_id;
+
+
+--
+-- Name: phylonode_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phylonode_pub (
+ phylonode_pub_id integer NOT NULL,
+ phylonode_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: phylonode_pub_phylonode_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phylonode_pub_phylonode_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phylonode_pub_phylonode_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phylonode_pub_phylonode_pub_id_seq OWNED BY phylonode_pub.phylonode_pub_id;
+
+
+--
+-- Name: phylonode_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phylonode_relationship (
+ phylonode_relationship_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ object_id integer NOT NULL,
+ type_id integer NOT NULL,
+ rank integer,
+ phylotree_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE phylonode_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE phylonode_relationship IS 'This is for
+relationships that are not strictly hierarchical; for example,
+horizontal gene transfer. Most phylogenetic trees are strictly
+hierarchical, nevertheless it is here for completeness.';
+
+
+--
+-- Name: phylonode_relationship_phylonode_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phylonode_relationship_phylonode_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phylonode_relationship_phylonode_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phylonode_relationship_phylonode_relationship_id_seq OWNED BY phylonode_relationship.phylonode_relationship_id;
+
+
+--
+-- Name: phylonodeprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phylonodeprop (
+ phylonodeprop_id integer NOT NULL,
+ phylonode_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text DEFAULT ''::text NOT NULL,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: COLUMN phylonodeprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN phylonodeprop.type_id IS 'type_id could designate phylonode hierarchy relationships, for example: species taxonomy (kingdom, order, family, genus, species), "ortholog/paralog", "fold/superfold", etc.';
+
+
+--
+-- Name: phylonodeprop_phylonodeprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phylonodeprop_phylonodeprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phylonodeprop_phylonodeprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phylonodeprop_phylonodeprop_id_seq OWNED BY phylonodeprop.phylonodeprop_id;
+
+
+--
+-- Name: phylotree; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phylotree (
+ phylotree_id integer NOT NULL,
+ dbxref_id integer NOT NULL,
+ name character varying(255),
+ type_id integer,
+ analysis_id integer,
+ comment text
+);
+
+
+--
+-- Name: TABLE phylotree; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE phylotree IS 'Global anchor for phylogenetic tree.';
+
+
+--
+-- Name: COLUMN phylotree.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN phylotree.type_id IS 'Type: protein, nucleotide, taxonomy, for example. The type should be any SO type, or "taxonomy".';
+
+
+--
+-- Name: phylotree_phylotree_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phylotree_phylotree_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phylotree_phylotree_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phylotree_phylotree_id_seq OWNED BY phylotree.phylotree_id;
+
+
+--
+-- Name: phylotree_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE phylotree_pub (
+ phylotree_pub_id integer NOT NULL,
+ phylotree_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE phylotree_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE phylotree_pub IS 'Tracks citations global to the tree e.g. multiple sequence alignment supporting tree construction.';
+
+
+--
+-- Name: phylotree_pub_phylotree_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE phylotree_pub_phylotree_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: phylotree_pub_phylotree_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE phylotree_pub_phylotree_pub_id_seq OWNED BY phylotree_pub.phylotree_pub_id;
+
+
+--
+-- Name: project; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE project (
+ project_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ description character varying(255) NOT NULL
+);
+
+
+--
+-- Name: project_contact; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE project_contact (
+ project_contact_id integer NOT NULL,
+ project_id integer NOT NULL,
+ contact_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE project_contact; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE project_contact IS 'Linking project(s) to contact(s)';
+
+
+--
+-- Name: project_contact_project_contact_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE project_contact_project_contact_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: project_contact_project_contact_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE project_contact_project_contact_id_seq OWNED BY project_contact.project_contact_id;
+
+
+--
+-- Name: project_project_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE project_project_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: project_project_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE project_project_id_seq OWNED BY project.project_id;
+
+
+--
+-- Name: project_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE project_pub (
+ project_pub_id integer NOT NULL,
+ project_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE project_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE project_pub IS 'Linking project(s) to chado.tion(s)';
+
+
+--
+-- Name: project_pub_project_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE project_pub_project_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: project_pub_project_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE project_pub_project_pub_id_seq OWNED BY project_pub.project_pub_id;
+
+
+--
+-- Name: project_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE project_relationship (
+ project_relationship_id integer NOT NULL,
+ subject_project_id integer NOT NULL,
+ object_project_id integer NOT NULL,
+ type_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE project_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE project_relationship IS 'A project can be composed of several smaller scale projects';
+
+
+--
+-- Name: COLUMN project_relationship.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN project_relationship.type_id IS 'The type of relationship being stated, such as "is part of".';
+
+
+--
+-- Name: project_relationship_project_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE project_relationship_project_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: project_relationship_project_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE project_relationship_project_relationship_id_seq OWNED BY project_relationship.project_relationship_id;
+
+
+--
+-- Name: projectprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE projectprop (
+ projectprop_id integer NOT NULL,
+ project_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: projectprop_projectprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE projectprop_projectprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: projectprop_projectprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE projectprop_projectprop_id_seq OWNED BY projectprop.projectprop_id;
+
+
+--
+-- Name: protocol; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE protocol (
+ protocol_id integer NOT NULL,
+ type_id integer NOT NULL,
+ pub_id integer,
+ dbxref_id integer,
+ name text NOT NULL,
+ uri text,
+ protocoldescription text,
+ hardwaredescription text,
+ softwaredescription text
+);
+
+
+--
+-- Name: TABLE protocol; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE protocol IS 'Procedural notes on how data was prepared and processed.';
+
+
+--
+-- Name: protocol_protocol_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE protocol_protocol_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: protocol_protocol_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE protocol_protocol_id_seq OWNED BY protocol.protocol_id;
+
+
+--
+-- Name: protocolparam; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE protocolparam (
+ protocolparam_id integer NOT NULL,
+ protocol_id integer NOT NULL,
+ name text NOT NULL,
+ datatype_id integer,
+ unittype_id integer,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE protocolparam; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE protocolparam IS 'Parameters related to a
+protocol. For example, if the protocol is a soak, this might include attributes of bath temperature and duration.';
+
+
+--
+-- Name: protocolparam_protocolparam_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE protocolparam_protocolparam_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: protocolparam_protocolparam_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE protocolparam_protocolparam_id_seq OWNED BY protocolparam.protocolparam_id;
+
+
+--
+-- Name: pub_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE pub_dbxref (
+ pub_dbxref_id integer NOT NULL,
+ pub_id integer NOT NULL,
+ dbxref_id integer NOT NULL,
+ is_current boolean DEFAULT true NOT NULL
+);
+
+
+--
+-- Name: TABLE pub_dbxref; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE pub_dbxref IS 'Handle links to repositories,
+e.g. Pubmed, Biosis, zoorec, OCLC, Medline, ISSN, coden...';
+
+
+--
+-- Name: pub_dbxref_pub_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE pub_dbxref_pub_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: pub_dbxref_pub_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE pub_dbxref_pub_dbxref_id_seq OWNED BY pub_dbxref.pub_dbxref_id;
+
+
+--
+-- Name: pub_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE pub_pub_id_seq
+ START WITH 4901
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: pub_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE pub_pub_id_seq OWNED BY pub.pub_id;
+
+
+--
+-- Name: pub_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE pub_relationship (
+ pub_relationship_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ object_id integer NOT NULL,
+ type_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE pub_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE pub_relationship IS 'Handle relationships between
+publications, e.g. when one publication makes others obsolete, when one
+publication contains errata with respect to other publication(s), or
+when one publication also appears in another pub.';
+
+
+--
+-- Name: pub_relationship_pub_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE pub_relationship_pub_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: pub_relationship_pub_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE pub_relationship_pub_relationship_id_seq OWNED BY pub_relationship.pub_relationship_id;
+
+
+--
+-- Name: pubauthor; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE pubauthor (
+ pubauthor_id integer NOT NULL,
+ pub_id integer NOT NULL,
+ rank integer NOT NULL,
+ editor boolean DEFAULT false,
+ surname character varying(100) NOT NULL,
+ givennames character varying(100),
+ suffix character varying(100)
+);
+
+
+--
+-- Name: TABLE pubauthor; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE pubauthor IS 'An author for a chado.tion. Note the denormalisation (hence lack of _ in table name) - this is deliberate as it is in general too hard to assign IDs to authors.';
+
+
+--
+-- Name: COLUMN pubauthor.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN pubauthor.rank IS 'Order of author in author list for this pub - order is important.';
+
+
+--
+-- Name: COLUMN pubauthor.editor; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN pubauthor.editor IS 'Indicates whether the author is an editor for linked chado.tion. Note: this is a boolean field but does not follow the normal chado convention for naming booleans.';
+
+
+--
+-- Name: COLUMN pubauthor.givennames; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN pubauthor.givennames IS 'First name, initials';
+
+
+--
+-- Name: COLUMN pubauthor.suffix; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN pubauthor.suffix IS 'Jr., Sr., etc';
+
+
+--
+-- Name: pubauthor_contact; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE pubauthor_contact (
+ pubauthor_contact_id integer NOT NULL,
+ contact_id integer NOT NULL,
+ pubauthor_id integer NOT NULL
+);
+
+
+--
+-- Name: pubauthor_contact_pubauthor_contact_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE pubauthor_contact_pubauthor_contact_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: pubauthor_contact_pubauthor_contact_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE pubauthor_contact_pubauthor_contact_id_seq OWNED BY pubauthor_contact.pubauthor_contact_id;
+
+
+--
+-- Name: pubauthor_pubauthor_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE pubauthor_pubauthor_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: pubauthor_pubauthor_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE pubauthor_pubauthor_id_seq OWNED BY pubauthor.pubauthor_id;
+
+
+--
+-- Name: pubprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE pubprop (
+ pubprop_id integer NOT NULL,
+ pub_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text NOT NULL,
+ rank integer
+);
+
+
+--
+-- Name: TABLE pubprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE pubprop IS 'Property-value pairs for a pub. Follows standard chado pattern.';
+
+
+--
+-- Name: pubprop_pubprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE pubprop_pubprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: pubprop_pubprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE pubprop_pubprop_id_seq OWNED BY pubprop.pubprop_id;
+
+
+--
+-- Name: qtl_search; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE qtl_search (
+ qtl_nid integer,
+ qtl text NOT NULL,
+ org_nid integer,
+ organism character varying(510) NOT NULL,
+ symbol text,
+ trait character varying(255),
+ category character varying(1024),
+ category_filter text,
+ map_nid integer,
+ map character varying(255),
+ col_marker_nid integer,
+ col_marker_uniquename text,
+ neighbor_marker_nid integer,
+ neighbor_marker_uniquename text,
+ study_project_id integer,
+ study character varying(255),
+ pop_nid integer,
+ population text,
+ lod text,
+ r2 text,
+ ad_ratio text,
+ ref_pub_id integer,
+ reference text,
+ aliases text,
+ type character varying(100) NOT NULL
+);
+
+
+--
+-- Name: quantification; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE quantification (
+ quantification_id integer NOT NULL,
+ acquisition_id integer NOT NULL,
+ operator_id integer,
+ protocol_id integer,
+ analysis_id integer NOT NULL,
+ quantificationdate timestamp without time zone DEFAULT now(),
+ name text,
+ uri text
+);
+
+
+--
+-- Name: TABLE quantification; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE quantification IS 'Quantification is the transformation of an image acquisition to numeric data. This typically involves statistical procedures.';
+
+
+--
+-- Name: quantification_quantification_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE quantification_quantification_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: quantification_quantification_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE quantification_quantification_id_seq OWNED BY quantification.quantification_id;
+
+
+--
+-- Name: quantification_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE quantification_relationship (
+ quantification_relationship_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ type_id integer NOT NULL,
+ object_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE quantification_relationship; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE quantification_relationship IS 'There may be multiple rounds of quantification, this allows us to keep an audit trail of what values went where.';
+
+
+--
+-- Name: quantification_relationship_quantification_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE quantification_relationship_quantification_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: quantification_relationship_quantification_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE quantification_relationship_quantification_relationship_id_seq OWNED BY quantification_relationship.quantification_relationship_id;
+
+
+--
+-- Name: quantificationprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE quantificationprop (
+ quantificationprop_id integer NOT NULL,
+ quantification_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE quantificationprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE quantificationprop IS 'Extra quantification properties that are not accounted for in quantification.';
+
+
+--
+-- Name: quantificationprop_quantificationprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE quantificationprop_quantificationprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: quantificationprop_quantificationprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE quantificationprop_quantificationprop_id_seq OWNED BY quantificationprop.quantificationprop_id;
+
+
+--
+-- Name: search_by_gene; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE search_by_gene (
+ feature_id integer,
+ analysis_id integer,
+ analysis_name character varying(255),
+ organism_id integer,
+ feature_name character varying(255),
+ feature_type_id integer,
+ landmark character varying(255),
+ fmin integer,
+ fmax integer,
+ strand smallint,
+ feature_type character varying(1025),
+ feature_nid integer,
+ analysis_nid integer
+);
+
+
+--
+-- Name: search_by_go; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE search_by_go (
+ feature_id integer,
+ type_id integer,
+ feature_type character varying(1025),
+ organism_id integer,
+ feature_name character varying(255),
+ analysis_id integer,
+ analysis_name character varying(255),
+ source_analysis_id integer,
+ source_name character varying(255),
+ source_analysis_nid integer,
+ landmark character varying(255),
+ fmin integer,
+ fmax integer,
+ strand smallint,
+ go_cvterm_id integer,
+ go_name character varying(1025),
+ go_accession character varying(255),
+ feature_nid integer,
+ analysis_nid integer
+);
+
+
+--
+-- Name: search_by_homology; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE search_by_homology (
+ feature_id integer,
+ type_id integer,
+ feature_type character varying(1025),
+ analysis_id integer,
+ analysis_name character varying(255),
+ source_analysis_id integer,
+ source_name character varying(255),
+ organism_id integer,
+ feature_name character varying(255),
+ landmark character varying(255),
+ fmin integer,
+ fmax integer,
+ strand smallint,
+ feature_nid integer,
+ analysis_nid integer,
+ source_analysis_nid integer
+);
+
+
+--
+-- Name: search_by_interpro; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE search_by_interpro (
+ feature_id integer,
+ type_id integer,
+ feature_type character varying(1024),
+ analysis_id integer,
+ analysis_name character varying(255),
+ source_analysis_id integer,
+ source_name character varying(255),
+ organism_id integer,
+ feature_name character varying(255),
+ feature_type_id integer,
+ landmark character varying(255),
+ fmin integer,
+ fmax integer,
+ strand smallint,
+ accession character varying(255),
+ term_name character varying(1024),
+ feature_nid integer,
+ analysis_nid integer,
+ source_analysis_nid integer
+);
+
+
+--
+-- Name: search_by_kegg; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE search_by_kegg (
+ feature_id integer,
+ type_id integer,
+ feature_type character varying(1025),
+ organism_id integer,
+ feature_name character varying(255),
+ analysis_id integer,
+ analysis_name character varying(255),
+ source_analysis_id integer,
+ source_name character varying(255),
+ source_analysis_nid integer,
+ landmark character varying(255),
+ fmin integer,
+ fmax integer,
+ strand smallint,
+ accession character varying(255),
+ kegg_term text,
+ feature_nid integer,
+ analysis_nid integer
+);
+
+
+--
+-- Name: search_by_map; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE search_by_map (
+ featuremap_id integer NOT NULL,
+ featuremap_name character varying(256),
+ featuremap_nid integer,
+ organism character varying(512),
+ organism_id integer,
+ organism_nid integer,
+ pop_stock_id integer,
+ maternal_stock_id integer,
+ maternal_stock_uniquename character varying(255),
+ maternal_stock_nid integer,
+ paternal_stock_id integer,
+ paternal_stock_uniquename character varying(255),
+ paternal_stock_nid integer,
+ genome text,
+ pop_size text,
+ pop_type text,
+ num_of_lg integer,
+ num_of_loci integer
+);
+
+
+--
+-- Name: searchable_features; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE searchable_features (
+ feature_id integer NOT NULL,
+ organism_id integer NOT NULL,
+ type_id integer NOT NULL,
+ feature_type character varying(1025) NOT NULL,
+ source_analysis_id integer NOT NULL,
+ source_name character varying(255) NOT NULL,
+ feature_name character varying(255) NOT NULL,
+ landmark character varying(255),
+ fmin integer,
+ fmax integer,
+ strand integer
+);
+
+
+--
+-- Name: species_summary; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE species_summary (
+ organism_id integer NOT NULL,
+ species character varying(510) NOT NULL,
+ common_name character varying(255),
+ grin character varying(255),
+ haploid_chromosome_number text,
+ ploidy text,
+ geographic_origin text,
+ num_germplasm text,
+ num_sequences text,
+ num_libraries text,
+ organism_nid integer
+);
+
+
+--
+-- Name: stats_paths_to_root; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW stats_paths_to_root AS
+ SELECT cvtermpath.subject_id AS cvterm_id,
+ count(DISTINCT cvtermpath.cvtermpath_id) AS total_paths,
+ avg(cvtermpath.pathdistance) AS avg_distance,
+ min(cvtermpath.pathdistance) AS min_distance,
+ max(cvtermpath.pathdistance) AS max_distance
+ FROM (cvtermpath
+ JOIN cv_root ON ((cvtermpath.object_id = cv_root.root_cvterm_id)))
+ GROUP BY cvtermpath.subject_id;
+
+
+--
+-- Name: VIEW stats_paths_to_root; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW stats_paths_to_root IS 'per-cvterm statistics on its
+placement in the DAG relative to the root. There may be multiple paths
+from any term to the root. This gives the total number of paths, and
+the average minimum and maximum distances. Here distance is defined by
+cvtermpath.pathdistance';
+
+
+--
+-- Name: stock; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stock (
+ stock_id integer NOT NULL,
+ dbxref_id integer,
+ organism_id integer,
+ name character varying(255),
+ uniquename text NOT NULL,
+ description text,
+ type_id integer NOT NULL,
+ is_obsolete boolean DEFAULT false NOT NULL
+);
+
+
+--
+-- Name: TABLE stock; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stock IS 'Any stock can be globally identified by the
+combination of organism, uniquename and stock type. A stock is the physical entities, either living or preserved, held by collections. Stocks belong to a collection; they have IDs, type, organism, description and may have a genotype.';
+
+
+--
+-- Name: COLUMN stock.dbxref_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock.dbxref_id IS 'The dbxref_id is an optional primary stable identifier for this stock. Secondary indentifiers and external dbxrefs go in table: stock_dbxref.';
+
+
+--
+-- Name: COLUMN stock.organism_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock.organism_id IS 'The organism_id is the organism to which the stock belongs. This column is mandatory.';
+
+
+--
+-- Name: COLUMN stock.name; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock.name IS 'The name is a human-readable local name for a stock.';
+
+
+--
+-- Name: COLUMN stock.description; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock.description IS 'The description is the genetic description provided in the stock list.';
+
+
+--
+-- Name: COLUMN stock.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock.type_id IS 'The type_id foreign key links to a controlled vocabulary of stock types. The would include living stock, genomic DNA, preserved specimen. Secondary cvterms for stocks would go in stock_cvterm.';
+
+
+--
+-- Name: stock_cvterm; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stock_cvterm (
+ stock_cvterm_id integer NOT NULL,
+ stock_id integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ pub_id integer NOT NULL,
+ is_not boolean DEFAULT false NOT NULL,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE stock_cvterm; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stock_cvterm IS 'stock_cvterm links a stock to cvterms. This is for secondary cvterms; primary cvterms should use stock.type_id.';
+
+
+--
+-- Name: stock_cvterm_stock_cvterm_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stock_cvterm_stock_cvterm_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stock_cvterm_stock_cvterm_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stock_cvterm_stock_cvterm_id_seq OWNED BY stock_cvterm.stock_cvterm_id;
+
+
+--
+-- Name: stock_cvtermprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stock_cvtermprop (
+ stock_cvtermprop_id integer NOT NULL,
+ stock_cvterm_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE stock_cvtermprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stock_cvtermprop IS 'Extensible properties for
+ stock to cvterm associations. Examples: GO evidence codes;
+ qualifiers; metadata such as the date on which the entry was curated
+ and the source of the association. See the stockprop table for
+ meanings of type_id, value and rank.';
+
+
+--
+-- Name: COLUMN stock_cvtermprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock_cvtermprop.type_id IS 'The name of the
+ property/slot is a cvterm. The meaning of the property is defined in
+ that cvterm. cvterms may come from the OBO evidence code cv.';
+
+
+--
+-- Name: COLUMN stock_cvtermprop.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock_cvtermprop.value IS 'The value of the
+ property, represented as text. Numeric values are converted to their
+ text representation. This is less efficient than using native database
+ types, but is easier to query.';
+
+
+--
+-- Name: COLUMN stock_cvtermprop.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock_cvtermprop.rank IS 'Property-Value
+ ordering. Any stock_cvterm can have multiple values for any particular
+ property type - these are ordered in a list using rank, counting from
+ zero. For properties that are single-valued rather than multi-valued,
+ the default 0 value should be used.';
+
+
+--
+-- Name: stock_cvtermprop_stock_cvtermprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stock_cvtermprop_stock_cvtermprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stock_cvtermprop_stock_cvtermprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stock_cvtermprop_stock_cvtermprop_id_seq OWNED BY stock_cvtermprop.stock_cvtermprop_id;
+
+
+--
+-- Name: stock_dbxref; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stock_dbxref (
+ stock_dbxref_id integer NOT NULL,
+ stock_id integer NOT NULL,
+ dbxref_id integer NOT NULL,
+ is_current boolean DEFAULT true NOT NULL
+);
+
+
+--
+-- Name: TABLE stock_dbxref; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stock_dbxref IS 'stock_dbxref links a stock to dbxrefs. This is for secondary identifiers; primary identifiers should use stock.dbxref_id.';
+
+
+--
+-- Name: COLUMN stock_dbxref.is_current; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock_dbxref.is_current IS 'The is_current boolean indicates whether the linked dbxref is the current -official- dbxref for the linked stock.';
+
+
+--
+-- Name: stock_dbxref_stock_dbxref_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stock_dbxref_stock_dbxref_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stock_dbxref_stock_dbxref_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stock_dbxref_stock_dbxref_id_seq OWNED BY stock_dbxref.stock_dbxref_id;
+
+
+--
+-- Name: stock_dbxrefprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stock_dbxrefprop (
+ stock_dbxrefprop_id integer NOT NULL,
+ stock_dbxref_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE stock_dbxrefprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stock_dbxrefprop IS 'A stock_dbxref can have any number of
+ slot-value property tags attached to it. This is useful for storing properties related to dbxref annotations of stocks, such as evidence codes, and references, and metadata, such as create/modify dates. This is an alternative to
+ hardcoding a list of columns in the relational schema, and is
+ completely extensible. There is a unique constraint, stock_dbxrefprop_c1, for
+ the combination of stock_dbxref_id, rank, and type_id. Multivalued property-value pairs must be differentiated by rank.';
+
+
+--
+-- Name: stock_dbxrefprop_stock_dbxrefprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stock_dbxrefprop_stock_dbxrefprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stock_dbxrefprop_stock_dbxrefprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stock_dbxrefprop_stock_dbxrefprop_id_seq OWNED BY stock_dbxrefprop.stock_dbxrefprop_id;
+
+
+--
+-- Name: stock_genotype; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stock_genotype (
+ stock_genotype_id integer NOT NULL,
+ stock_id integer NOT NULL,
+ genotype_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE stock_genotype; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stock_genotype IS 'Simple table linking a stock to
+a genotype. Features with genotypes can be linked to stocks thru feature_genotype -> genotype -> stock_genotype -> stock.';
+
+
+--
+-- Name: stock_genotype_stock_genotype_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stock_genotype_stock_genotype_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stock_genotype_stock_genotype_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stock_genotype_stock_genotype_id_seq OWNED BY stock_genotype.stock_genotype_id;
+
+
+--
+-- Name: stock_image; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stock_image (
+ stock_image_id integer NOT NULL,
+ stock_id integer NOT NULL,
+ eimage_id integer NOT NULL
+);
+
+
+--
+-- Name: stock_image_stock_image_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stock_image_stock_image_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stock_image_stock_image_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stock_image_stock_image_id_seq OWNED BY stock_image.stock_image_id;
+
+
+--
+-- Name: stock_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stock_pub (
+ stock_pub_id integer NOT NULL,
+ stock_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE stock_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stock_pub IS 'Provenance. Linking table between stocks and, for example, a stocklist computer file.';
+
+
+--
+-- Name: stock_pub_stock_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stock_pub_stock_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stock_pub_stock_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stock_pub_stock_pub_id_seq OWNED BY stock_pub.stock_pub_id;
+
+
+--
+-- Name: stock_relationship; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stock_relationship (
+ stock_relationship_id integer NOT NULL,
+ subject_id integer NOT NULL,
+ object_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: COLUMN stock_relationship.subject_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock_relationship.subject_id IS 'stock_relationship.subject_id is the subject of the subj-predicate-obj sentence. This is typically the substock.';
+
+
+--
+-- Name: COLUMN stock_relationship.object_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock_relationship.object_id IS 'stock_relationship.object_id is the object of the subj-predicate-obj sentence. This is typically the container stock.';
+
+
+--
+-- Name: COLUMN stock_relationship.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock_relationship.type_id IS 'stock_relationship.type_id is relationship type between subject and object. This is a cvterm, typically from the OBO relationship ontology, although other relationship types are allowed.';
+
+
+--
+-- Name: COLUMN stock_relationship.value; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock_relationship.value IS 'stock_relationship.value is for additional notes or comments.';
+
+
+--
+-- Name: COLUMN stock_relationship.rank; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stock_relationship.rank IS 'stock_relationship.rank is the ordering of subject stocks with respect to the object stock may be important where rank is used to order these; starts from zero.';
+
+
+--
+-- Name: stock_relationship_cvterm; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stock_relationship_cvterm (
+ stock_relationship_cvterm_id integer NOT NULL,
+ stock_relationship_id integer NOT NULL,
+ cvterm_id integer NOT NULL,
+ pub_id integer
+);
+
+
+--
+-- Name: TABLE stock_relationship_cvterm; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stock_relationship_cvterm IS 'For germplasm maintenance and pedigree data, stock_relationship. type_id will record cvterms such as "is a female parent of", "a parent for mutation", "is a group_id of", "is a source_id of", etc The cvterms for higher categories such as "generative", "derivative" or "maintenance" can be stored in table stock_relationship_cvterm';
+
+
+--
+-- Name: stock_relationship_cvterm_stock_relationship_cvterm_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stock_relationship_cvterm_stock_relationship_cvterm_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stock_relationship_cvterm_stock_relationship_cvterm_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stock_relationship_cvterm_stock_relationship_cvterm_id_seq OWNED BY stock_relationship_cvterm.stock_relationship_cvterm_id;
+
+
+--
+-- Name: stock_relationship_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stock_relationship_pub (
+ stock_relationship_pub_id integer NOT NULL,
+ stock_relationship_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE stock_relationship_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stock_relationship_pub IS 'Provenance. Attach optional evidence to a stock_relationship in the form of a chado.tion.';
+
+
+--
+-- Name: stock_relationship_pub_stock_relationship_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stock_relationship_pub_stock_relationship_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stock_relationship_pub_stock_relationship_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stock_relationship_pub_stock_relationship_pub_id_seq OWNED BY stock_relationship_pub.stock_relationship_pub_id;
+
+
+--
+-- Name: stock_relationship_stock_relationship_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stock_relationship_stock_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stock_relationship_stock_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stock_relationship_stock_relationship_id_seq OWNED BY stock_relationship.stock_relationship_id;
+
+
+--
+-- Name: stock_stock_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stock_stock_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stock_stock_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stock_stock_id_seq OWNED BY stock.stock_id;
+
+
+--
+-- Name: stockcollection; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stockcollection (
+ stockcollection_id integer NOT NULL,
+ type_id integer NOT NULL,
+ contact_id integer,
+ name character varying(255),
+ uniquename text NOT NULL
+);
+
+
+--
+-- Name: TABLE stockcollection; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stockcollection IS 'The lab or stock center distributing the stocks in their collection.';
+
+
+--
+-- Name: COLUMN stockcollection.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stockcollection.type_id IS 'type_id is the collection type cv.';
+
+
+--
+-- Name: COLUMN stockcollection.contact_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stockcollection.contact_id IS 'contact_id links to the contact information for the collection.';
+
+
+--
+-- Name: COLUMN stockcollection.name; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stockcollection.name IS 'name is the collection.';
+
+
+--
+-- Name: COLUMN stockcollection.uniquename; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stockcollection.uniquename IS 'uniqename is the value of the collection cv.';
+
+
+--
+-- Name: stockcollection_stock; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stockcollection_stock (
+ stockcollection_stock_id integer NOT NULL,
+ stockcollection_id integer NOT NULL,
+ stock_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE stockcollection_stock; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stockcollection_stock IS 'stockcollection_stock links
+a stock collection to the stocks which are contained in the collection.';
+
+
+--
+-- Name: stockcollection_stock_stockcollection_stock_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stockcollection_stock_stockcollection_stock_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stockcollection_stock_stockcollection_stock_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stockcollection_stock_stockcollection_stock_id_seq OWNED BY stockcollection_stock.stockcollection_stock_id;
+
+
+--
+-- Name: stockcollection_stockcollection_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stockcollection_stockcollection_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stockcollection_stockcollection_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stockcollection_stockcollection_id_seq OWNED BY stockcollection.stockcollection_id;
+
+
+--
+-- Name: stockcollectionprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stockcollectionprop (
+ stockcollectionprop_id integer NOT NULL,
+ stockcollection_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE stockcollectionprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stockcollectionprop IS 'The table stockcollectionprop
+contains the value of the stock collection such as website/email URLs;
+the value of the stock collection order URLs.';
+
+
+--
+-- Name: COLUMN stockcollectionprop.type_id; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON COLUMN stockcollectionprop.type_id IS 'The cv for the type_id is "stockcollection property type".';
+
+
+--
+-- Name: stockcollectionprop_stockcollectionprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stockcollectionprop_stockcollectionprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stockcollectionprop_stockcollectionprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stockcollectionprop_stockcollectionprop_id_seq OWNED BY stockcollectionprop.stockcollectionprop_id;
+
+
+--
+-- Name: stockprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stockprop (
+ stockprop_id integer NOT NULL,
+ stock_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE stockprop; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stockprop IS 'A stock can have any number of
+slot-value property tags attached to it. This is an alternative to
+hardcoding a list of columns in the relational schema, and is
+completely extensible. There is a unique constraint, stockprop_c1, for
+the combination of stock_id, rank, and type_id. Multivalued property-value pairs must be differentiated by rank.';
+
+
+--
+-- Name: stockprop_pub; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE stockprop_pub (
+ stockprop_pub_id integer NOT NULL,
+ stockprop_id integer NOT NULL,
+ pub_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE stockprop_pub; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE stockprop_pub IS 'Provenance. Any stockprop assignment can optionally be supported by a chado.tion.';
+
+
+--
+-- Name: stockprop_pub_stockprop_pub_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stockprop_pub_stockprop_pub_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stockprop_pub_stockprop_pub_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stockprop_pub_stockprop_pub_id_seq OWNED BY stockprop_pub.stockprop_pub_id;
+
+
+--
+-- Name: stockprop_stockprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE stockprop_stockprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: stockprop_stockprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE stockprop_stockprop_id_seq OWNED BY stockprop.stockprop_id;
+
+
+--
+-- Name: study; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE study (
+ study_id integer NOT NULL,
+ contact_id integer NOT NULL,
+ pub_id integer,
+ dbxref_id integer,
+ name text NOT NULL,
+ description text
+);
+
+
+--
+-- Name: study_assay; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE study_assay (
+ study_assay_id integer NOT NULL,
+ study_id integer NOT NULL,
+ assay_id integer NOT NULL
+);
+
+
+--
+-- Name: study_assay_study_assay_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE study_assay_study_assay_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: study_assay_study_assay_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE study_assay_study_assay_id_seq OWNED BY study_assay.study_assay_id;
+
+
+--
+-- Name: study_study_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE study_study_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: study_study_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE study_study_id_seq OWNED BY study.study_id;
+
+
+--
+-- Name: studydesign; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE studydesign (
+ studydesign_id integer NOT NULL,
+ study_id integer NOT NULL,
+ description text
+);
+
+
+--
+-- Name: studydesign_studydesign_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE studydesign_studydesign_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: studydesign_studydesign_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE studydesign_studydesign_id_seq OWNED BY studydesign.studydesign_id;
+
+
+--
+-- Name: studydesignprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE studydesignprop (
+ studydesignprop_id integer NOT NULL,
+ studydesign_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: studydesignprop_studydesignprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE studydesignprop_studydesignprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: studydesignprop_studydesignprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE studydesignprop_studydesignprop_id_seq OWNED BY studydesignprop.studydesignprop_id;
+
+
+--
+-- Name: studyfactor; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE studyfactor (
+ studyfactor_id integer NOT NULL,
+ studydesign_id integer NOT NULL,
+ type_id integer,
+ name text NOT NULL,
+ description text
+);
+
+
+--
+-- Name: studyfactor_studyfactor_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE studyfactor_studyfactor_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: studyfactor_studyfactor_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE studyfactor_studyfactor_id_seq OWNED BY studyfactor.studyfactor_id;
+
+
+--
+-- Name: studyfactorvalue; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE studyfactorvalue (
+ studyfactorvalue_id integer NOT NULL,
+ studyfactor_id integer NOT NULL,
+ assay_id integer NOT NULL,
+ factorvalue text,
+ name text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: studyfactorvalue_studyfactorvalue_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE studyfactorvalue_studyfactorvalue_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: studyfactorvalue_studyfactorvalue_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE studyfactorvalue_studyfactorvalue_id_seq OWNED BY studyfactorvalue.studyfactorvalue_id;
+
+
+--
+-- Name: studyprop; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE studyprop (
+ studyprop_id integer NOT NULL,
+ study_id integer NOT NULL,
+ type_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: studyprop_feature; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE studyprop_feature (
+ studyprop_feature_id integer NOT NULL,
+ studyprop_id integer NOT NULL,
+ feature_id integer NOT NULL,
+ type_id integer
+);
+
+
+--
+-- Name: studyprop_feature_studyprop_feature_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE studyprop_feature_studyprop_feature_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: studyprop_feature_studyprop_feature_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE studyprop_feature_studyprop_feature_id_seq OWNED BY studyprop_feature.studyprop_feature_id;
+
+
+--
+-- Name: studyprop_studyprop_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE studyprop_studyprop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: studyprop_studyprop_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE studyprop_studyprop_id_seq OWNED BY studyprop.studyprop_id;
+
+
+--
+-- Name: synonym_synonym_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE synonym_synonym_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: synonym_synonym_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE synonym_synonym_id_seq OWNED BY synonym.synonym_id;
+
+
+--
+-- Name: tableinfo; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE tableinfo (
+ tableinfo_id integer NOT NULL,
+ name character varying(30) NOT NULL,
+ primary_key_column character varying(30),
+ is_view integer DEFAULT 0 NOT NULL,
+ view_on_table_id integer,
+ superclass_table_id integer,
+ is_updateable integer DEFAULT 1 NOT NULL,
+ modification_date date DEFAULT now() NOT NULL
+);
+
+
+--
+-- Name: tableinfo_tableinfo_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE tableinfo_tableinfo_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: tableinfo_tableinfo_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE tableinfo_tableinfo_id_seq OWNED BY tableinfo.tableinfo_id;
+
+
+--
+-- Name: treatment; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE treatment (
+ treatment_id integer NOT NULL,
+ rank integer DEFAULT 0 NOT NULL,
+ biomaterial_id integer NOT NULL,
+ type_id integer NOT NULL,
+ protocol_id integer,
+ name text
+);
+
+
+--
+-- Name: TABLE treatment; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON TABLE treatment IS 'A biomaterial may undergo multiple
+treatments. Examples of treatments: apoxia, fluorophore and biotin labeling.';
+
+
+--
+-- Name: treatment_treatment_id_seq; Type: SEQUENCE; Schema: chado; Owner: -
+--
+
+CREATE SEQUENCE treatment_treatment_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: treatment_treatment_id_seq; Type: SEQUENCE OWNED BY; Schema: chado; Owner: -
+--
+
+ALTER SEQUENCE treatment_treatment_id_seq OWNED BY treatment.treatment_id;
+
+
+--
+-- Name: tripal_gff_temp; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE tripal_gff_temp (
+ feature_id integer NOT NULL,
+ organism_id integer NOT NULL,
+ uniquename text NOT NULL,
+ type_name character varying(1024) NOT NULL
+);
+
+
+--
+-- Name: tripal_gffcds_temp; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE tripal_gffcds_temp (
+ feature_id integer NOT NULL,
+ parent_id integer NOT NULL,
+ phase integer NOT NULL,
+ strand integer NOT NULL,
+ fmin integer NOT NULL,
+ fmax integer NOT NULL
+);
+
+
+--
+-- Name: tripal_gffprotein_temp; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE tripal_gffprotein_temp (
+ feature_id integer NOT NULL,
+ parent_id integer NOT NULL,
+ fmin integer NOT NULL,
+ fmax integer NOT NULL
+);
+
+
+--
+-- Name: tripal_obo_temp; Type: TABLE; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE TABLE tripal_obo_temp (
+ id character varying(255) NOT NULL,
+ stanza text NOT NULL,
+ type character varying(50) NOT NULL
+);
+
+
+--
+-- Name: type_feature_count; Type: VIEW; Schema: chado; Owner: -
+--
+
+CREATE VIEW type_feature_count AS
+ SELECT t.name AS type,
+ count(*) AS num_features
+ FROM (cvterm t
+ JOIN feature ON ((feature.type_id = t.cvterm_id)))
+ GROUP BY t.name;
+
+
+--
+-- Name: VIEW type_feature_count; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON VIEW type_feature_count IS 'per-feature-type feature counts';
+
+
+--
+-- Name: acquisition_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY acquisition ALTER COLUMN acquisition_id SET DEFAULT nextval('acquisition_acquisition_id_seq'::regclass);
+
+
+--
+-- Name: acquisition_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY acquisition_relationship ALTER COLUMN acquisition_relationship_id SET DEFAULT nextval('acquisition_relationship_acquisition_relationship_id_seq'::regclass);
+
+
+--
+-- Name: acquisitionprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY acquisitionprop ALTER COLUMN acquisitionprop_id SET DEFAULT nextval('acquisitionprop_acquisitionprop_id_seq'::regclass);
+
+
+--
+-- Name: analysisfeatureprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY analysisfeatureprop ALTER COLUMN analysisfeatureprop_id SET DEFAULT nextval('analysisfeatureprop_analysisfeatureprop_id_seq'::regclass);
+
+
+--
+-- Name: analysisprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY analysisprop ALTER COLUMN analysisprop_id SET DEFAULT nextval('analysisprop_analysisprop_id_seq'::regclass);
+
+
+--
+-- Name: arraydesign_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY arraydesign ALTER COLUMN arraydesign_id SET DEFAULT nextval('arraydesign_arraydesign_id_seq'::regclass);
+
+
+--
+-- Name: arraydesignprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY arraydesignprop ALTER COLUMN arraydesignprop_id SET DEFAULT nextval('arraydesignprop_arraydesignprop_id_seq'::regclass);
+
+
+--
+-- Name: assay_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay ALTER COLUMN assay_id SET DEFAULT nextval('assay_assay_id_seq'::regclass);
+
+
+--
+-- Name: assay_biomaterial_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay_biomaterial ALTER COLUMN assay_biomaterial_id SET DEFAULT nextval('assay_biomaterial_assay_biomaterial_id_seq'::regclass);
+
+
+--
+-- Name: assay_project_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay_project ALTER COLUMN assay_project_id SET DEFAULT nextval('assay_project_assay_project_id_seq'::regclass);
+
+
+--
+-- Name: assayprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assayprop ALTER COLUMN assayprop_id SET DEFAULT nextval('assayprop_assayprop_id_seq'::regclass);
+
+
+--
+-- Name: biomaterial_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial ALTER COLUMN biomaterial_id SET DEFAULT nextval('biomaterial_biomaterial_id_seq'::regclass);
+
+
+--
+-- Name: biomaterial_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial_dbxref ALTER COLUMN biomaterial_dbxref_id SET DEFAULT nextval('biomaterial_dbxref_biomaterial_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: biomaterial_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial_relationship ALTER COLUMN biomaterial_relationship_id SET DEFAULT nextval('biomaterial_relationship_biomaterial_relationship_id_seq'::regclass);
+
+
+--
+-- Name: biomaterial_treatment_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial_treatment ALTER COLUMN biomaterial_treatment_id SET DEFAULT nextval('biomaterial_treatment_biomaterial_treatment_id_seq'::regclass);
+
+
+--
+-- Name: biomaterialprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterialprop ALTER COLUMN biomaterialprop_id SET DEFAULT nextval('biomaterialprop_biomaterialprop_id_seq'::regclass);
+
+
+--
+-- Name: blast_org_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY blast_organisms ALTER COLUMN blast_org_id SET DEFAULT nextval('blast_organisms_blast_org_id_seq'::regclass);
+
+
+--
+-- Name: cell_line_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line ALTER COLUMN cell_line_id SET DEFAULT nextval('cell_line_cell_line_id_seq'::regclass);
+
+
+--
+-- Name: cell_line_cvterm_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_cvterm ALTER COLUMN cell_line_cvterm_id SET DEFAULT nextval('cell_line_cvterm_cell_line_cvterm_id_seq'::regclass);
+
+
+--
+-- Name: cell_line_cvtermprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_cvtermprop ALTER COLUMN cell_line_cvtermprop_id SET DEFAULT nextval('cell_line_cvtermprop_cell_line_cvtermprop_id_seq'::regclass);
+
+
+--
+-- Name: cell_line_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_dbxref ALTER COLUMN cell_line_dbxref_id SET DEFAULT nextval('cell_line_dbxref_cell_line_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: cell_line_feature_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_feature ALTER COLUMN cell_line_feature_id SET DEFAULT nextval('cell_line_feature_cell_line_feature_id_seq'::regclass);
+
+
+--
+-- Name: cell_line_library_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_library ALTER COLUMN cell_line_library_id SET DEFAULT nextval('cell_line_library_cell_line_library_id_seq'::regclass);
+
+
+--
+-- Name: cell_line_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_pub ALTER COLUMN cell_line_pub_id SET DEFAULT nextval('cell_line_pub_cell_line_pub_id_seq'::regclass);
+
+
+--
+-- Name: cell_line_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_relationship ALTER COLUMN cell_line_relationship_id SET DEFAULT nextval('cell_line_relationship_cell_line_relationship_id_seq'::regclass);
+
+
+--
+-- Name: cell_line_synonym_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_synonym ALTER COLUMN cell_line_synonym_id SET DEFAULT nextval('cell_line_synonym_cell_line_synonym_id_seq'::regclass);
+
+
+--
+-- Name: cell_lineprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_lineprop ALTER COLUMN cell_lineprop_id SET DEFAULT nextval('cell_lineprop_cell_lineprop_id_seq'::regclass);
+
+
+--
+-- Name: cell_lineprop_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_lineprop_pub ALTER COLUMN cell_lineprop_pub_id SET DEFAULT nextval('cell_lineprop_pub_cell_lineprop_pub_id_seq'::regclass);
+
+
+--
+-- Name: chadoprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY chadoprop ALTER COLUMN chadoprop_id SET DEFAULT nextval('chadoprop_chadoprop_id_seq'::regclass);
+
+
+--
+-- Name: channel_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY channel ALTER COLUMN channel_id SET DEFAULT nextval('channel_channel_id_seq'::regclass);
+
+
+--
+-- Name: contact_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contact ALTER COLUMN contact_id SET DEFAULT nextval('contact_contact_id_seq'::regclass);
+
+
+--
+-- Name: contact_image_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contact_image ALTER COLUMN contact_image_id SET DEFAULT nextval('contact_image_contact_image_id_seq'::regclass);
+
+
+--
+-- Name: contact_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contact_relationship ALTER COLUMN contact_relationship_id SET DEFAULT nextval('contact_relationship_contact_relationship_id_seq'::regclass);
+
+
+--
+-- Name: contactprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contactprop ALTER COLUMN contactprop_id SET DEFAULT nextval('contactprop_contactprop_id_seq'::regclass);
+
+
+--
+-- Name: control_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY control ALTER COLUMN control_id SET DEFAULT nextval('control_control_id_seq'::regclass);
+
+
+--
+-- Name: cv_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cv ALTER COLUMN cv_id SET DEFAULT nextval('cv_cv_id_seq'::regclass);
+
+
+--
+-- Name: cvprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvprop ALTER COLUMN cvprop_id SET DEFAULT nextval('cvprop_cvprop_id_seq'::regclass);
+
+
+--
+-- Name: cvterm_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvterm ALTER COLUMN cvterm_id SET DEFAULT nextval('cvterm_cvterm_id_seq'::regclass);
+
+
+--
+-- Name: cvterm_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvterm_dbxref ALTER COLUMN cvterm_dbxref_id SET DEFAULT nextval('cvterm_dbxref_cvterm_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: cvterm_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvterm_relationship ALTER COLUMN cvterm_relationship_id SET DEFAULT nextval('cvterm_relationship_cvterm_relationship_id_seq'::regclass);
+
+
+--
+-- Name: cvtermpath_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvtermpath ALTER COLUMN cvtermpath_id SET DEFAULT nextval('cvtermpath_cvtermpath_id_seq'::regclass);
+
+
+--
+-- Name: cvtermprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvtermprop ALTER COLUMN cvtermprop_id SET DEFAULT nextval('cvtermprop_cvtermprop_id_seq'::regclass);
+
+
+--
+-- Name: cvtermsynonym_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvtermsynonym ALTER COLUMN cvtermsynonym_id SET DEFAULT nextval('cvtermsynonym_cvtermsynonym_id_seq'::regclass);
+
+
+--
+-- Name: db_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY db ALTER COLUMN db_id SET DEFAULT nextval('db_db_id_seq'::regclass);
+
+
+--
+-- Name: dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY dbxref ALTER COLUMN dbxref_id SET DEFAULT nextval('dbxref_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: dbxrefprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY dbxrefprop ALTER COLUMN dbxrefprop_id SET DEFAULT nextval('dbxrefprop_dbxrefprop_id_seq'::regclass);
+
+
+--
+-- Name: eimage_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY eimage ALTER COLUMN eimage_id SET DEFAULT nextval('eimage_eimage_id_seq'::regclass);
+
+
+--
+-- Name: eimageprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY eimageprop ALTER COLUMN eimageprop_id SET DEFAULT nextval('eimageprop_eimageprop_id_seq'::regclass);
+
+
+--
+-- Name: element_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY element ALTER COLUMN element_id SET DEFAULT nextval('element_element_id_seq'::regclass);
+
+
+--
+-- Name: element_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY element_relationship ALTER COLUMN element_relationship_id SET DEFAULT nextval('element_relationship_element_relationship_id_seq'::regclass);
+
+
+--
+-- Name: elementresult_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY elementresult ALTER COLUMN elementresult_id SET DEFAULT nextval('elementresult_elementresult_id_seq'::regclass);
+
+
+--
+-- Name: elementresult_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY elementresult_relationship ALTER COLUMN elementresult_relationship_id SET DEFAULT nextval('elementresult_relationship_elementresult_relationship_id_seq'::regclass);
+
+
+--
+-- Name: environment_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY environment ALTER COLUMN environment_id SET DEFAULT nextval('environment_environment_id_seq'::regclass);
+
+
+--
+-- Name: environment_cvterm_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY environment_cvterm ALTER COLUMN environment_cvterm_id SET DEFAULT nextval('environment_cvterm_environment_cvterm_id_seq'::regclass);
+
+
+--
+-- Name: expression_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression ALTER COLUMN expression_id SET DEFAULT nextval('expression_expression_id_seq'::regclass);
+
+
+--
+-- Name: expression_cvterm_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_cvterm ALTER COLUMN expression_cvterm_id SET DEFAULT nextval('expression_cvterm_expression_cvterm_id_seq'::regclass);
+
+
+--
+-- Name: expression_cvtermprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_cvtermprop ALTER COLUMN expression_cvtermprop_id SET DEFAULT nextval('expression_cvtermprop_expression_cvtermprop_id_seq'::regclass);
+
+
+--
+-- Name: expression_image_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_image ALTER COLUMN expression_image_id SET DEFAULT nextval('expression_image_expression_image_id_seq'::regclass);
+
+
+--
+-- Name: expression_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_pub ALTER COLUMN expression_pub_id SET DEFAULT nextval('expression_pub_expression_pub_id_seq'::regclass);
+
+
+--
+-- Name: expressionprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expressionprop ALTER COLUMN expressionprop_id SET DEFAULT nextval('expressionprop_expressionprop_id_seq'::regclass);
+
+
+--
+-- Name: feature_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature ALTER COLUMN feature_id SET DEFAULT nextval('feature_feature_id_seq'::regclass);
+
+
+--
+-- Name: feature_contact_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_contact ALTER COLUMN feature_contact_id SET DEFAULT nextval('feature_contact_feature_contact_id_seq'::regclass);
+
+
+--
+-- Name: feature_cvterm_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvterm ALTER COLUMN feature_cvterm_id SET DEFAULT nextval('feature_cvterm_feature_cvterm_id_seq'::regclass);
+
+
+--
+-- Name: feature_cvterm_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvterm_dbxref ALTER COLUMN feature_cvterm_dbxref_id SET DEFAULT nextval('feature_cvterm_dbxref_feature_cvterm_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: feature_cvterm_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvterm_pub ALTER COLUMN feature_cvterm_pub_id SET DEFAULT nextval('feature_cvterm_pub_feature_cvterm_pub_id_seq'::regclass);
+
+
+--
+-- Name: feature_cvtermprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvtermprop ALTER COLUMN feature_cvtermprop_id SET DEFAULT nextval('feature_cvtermprop_feature_cvtermprop_id_seq'::regclass);
+
+
+--
+-- Name: feature_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_dbxref ALTER COLUMN feature_dbxref_id SET DEFAULT nextval('feature_dbxref_feature_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: feature_expression_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_expression ALTER COLUMN feature_expression_id SET DEFAULT nextval('feature_expression_feature_expression_id_seq'::regclass);
+
+
+--
+-- Name: feature_expressionprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_expressionprop ALTER COLUMN feature_expressionprop_id SET DEFAULT nextval('feature_expressionprop_feature_expressionprop_id_seq'::regclass);
+
+
+--
+-- Name: feature_genotype_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_genotype ALTER COLUMN feature_genotype_id SET DEFAULT nextval('feature_genotype_feature_genotype_id_seq'::regclass);
+
+
+--
+-- Name: feature_image_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_image ALTER COLUMN feature_image_id SET DEFAULT nextval('feature_image_feature_image_id_seq'::regclass);
+
+
+--
+-- Name: feature_phenotype_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_phenotype ALTER COLUMN feature_phenotype_id SET DEFAULT nextval('feature_phenotype_feature_phenotype_id_seq'::regclass);
+
+
+--
+-- Name: feature_project_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_project ALTER COLUMN feature_project_id SET DEFAULT nextval('feature_project_feature_project_id_seq'::regclass);
+
+
+--
+-- Name: feature_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_pub ALTER COLUMN feature_pub_id SET DEFAULT nextval('feature_pub_feature_pub_id_seq'::regclass);
+
+
+--
+-- Name: feature_pubprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_pubprop ALTER COLUMN feature_pubprop_id SET DEFAULT nextval('feature_pubprop_feature_pubprop_id_seq'::regclass);
+
+
+--
+-- Name: feature_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationship ALTER COLUMN feature_relationship_id SET DEFAULT nextval('feature_relationship_feature_relationship_id_seq'::regclass);
+
+
+--
+-- Name: feature_relationship_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationship_pub ALTER COLUMN feature_relationship_pub_id SET DEFAULT nextval('feature_relationship_pub_feature_relationship_pub_id_seq'::regclass);
+
+
+--
+-- Name: feature_relationshipprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationshipprop ALTER COLUMN feature_relationshipprop_id SET DEFAULT nextval('feature_relationshipprop_feature_relationshipprop_id_seq'::regclass);
+
+
+--
+-- Name: feature_relationshipprop_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationshipprop_pub ALTER COLUMN feature_relationshipprop_pub_id SET DEFAULT nextval('feature_relationshipprop_pub_feature_relationshipprop_pub_i_seq'::regclass);
+
+
+--
+-- Name: feature_stock_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_stock ALTER COLUMN feature_stock_id SET DEFAULT nextval('feature_stock_feature_stock_id_seq'::regclass);
+
+
+--
+-- Name: feature_synonym_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_synonym ALTER COLUMN feature_synonym_id SET DEFAULT nextval('feature_synonym_feature_synonym_id_seq'::regclass);
+
+
+--
+-- Name: featureloc_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureloc ALTER COLUMN featureloc_id SET DEFAULT nextval('featureloc_featureloc_id_seq'::regclass);
+
+
+--
+-- Name: featureloc_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureloc_pub ALTER COLUMN featureloc_pub_id SET DEFAULT nextval('featureloc_pub_featureloc_pub_id_seq'::regclass);
+
+
+--
+-- Name: featuremap_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap ALTER COLUMN featuremap_id SET DEFAULT nextval('featuremap_featuremap_id_seq'::regclass);
+
+
+--
+-- Name: featuremap_contact_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_contact ALTER COLUMN featuremap_contact_id SET DEFAULT nextval('featuremap_contact_featuremap_contact_id_seq'::regclass);
+
+
+--
+-- Name: featuremap_organism_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_organism ALTER COLUMN featuremap_organism_id SET DEFAULT nextval('featuremap_organism_featuremap_organism_id_seq'::regclass);
+
+
+--
+-- Name: featuremap_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_pub ALTER COLUMN featuremap_pub_id SET DEFAULT nextval('featuremap_pub_featuremap_pub_id_seq'::regclass);
+
+
+--
+-- Name: featuremap_stock_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_stock ALTER COLUMN featuremap_stock_id SET DEFAULT nextval('featuremap_stock_featuremap_stock_id_seq'::regclass);
+
+
+--
+-- Name: featuremapprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremapprop ALTER COLUMN featuremapprop_id SET DEFAULT nextval('featuremapprop_featuremapprop_id_seq'::regclass);
+
+
+--
+-- Name: featurepos_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featurepos ALTER COLUMN featurepos_id SET DEFAULT nextval('featurepos_featurepos_id_seq'::regclass);
+
+
+--
+-- Name: featureposprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureposprop ALTER COLUMN featureposprop_id SET DEFAULT nextval('featureposprop_featureposprop_id_seq'::regclass);
+
+
+--
+-- Name: featureprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureprop ALTER COLUMN featureprop_id SET DEFAULT nextval('featureprop_featureprop_id_seq'::regclass);
+
+
+--
+-- Name: featureprop_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureprop_pub ALTER COLUMN featureprop_pub_id SET DEFAULT nextval('featureprop_pub_featureprop_pub_id_seq'::regclass);
+
+
+--
+-- Name: featurerange_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featurerange ALTER COLUMN featurerange_id SET DEFAULT nextval('featurerange_featurerange_id_seq'::regclass);
+
+
+--
+-- Name: genotype_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY genotype ALTER COLUMN genotype_id SET DEFAULT nextval('genotype_genotype_id_seq'::regclass);
+
+
+--
+-- Name: genotypeprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY genotypeprop ALTER COLUMN genotypeprop_id SET DEFAULT nextval('genotypeprop_genotypeprop_id_seq'::regclass);
+
+
+--
+-- Name: library_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library ALTER COLUMN library_id SET DEFAULT nextval('library_library_id_seq'::regclass);
+
+
+--
+-- Name: library_contact_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_contact ALTER COLUMN library_contact_id SET DEFAULT nextval('library_contact_library_contact_id_seq'::regclass);
+
+
+--
+-- Name: library_cvterm_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_cvterm ALTER COLUMN library_cvterm_id SET DEFAULT nextval('library_cvterm_library_cvterm_id_seq'::regclass);
+
+
+--
+-- Name: library_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_dbxref ALTER COLUMN library_dbxref_id SET DEFAULT nextval('library_dbxref_library_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: library_feature_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_feature ALTER COLUMN library_feature_id SET DEFAULT nextval('library_feature_library_feature_id_seq'::regclass);
+
+
+--
+-- Name: library_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_pub ALTER COLUMN library_pub_id SET DEFAULT nextval('library_pub_library_pub_id_seq'::regclass);
+
+
+--
+-- Name: library_stock_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_stock ALTER COLUMN library_stock_id SET DEFAULT nextval('library_stock_library_stock_id_seq'::regclass);
+
+
+--
+-- Name: library_synonym_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_synonym ALTER COLUMN library_synonym_id SET DEFAULT nextval('library_synonym_library_synonym_id_seq'::regclass);
+
+
+--
+-- Name: libraryprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY libraryprop ALTER COLUMN libraryprop_id SET DEFAULT nextval('libraryprop_libraryprop_id_seq'::regclass);
+
+
+--
+-- Name: libraryprop_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY libraryprop_pub ALTER COLUMN libraryprop_pub_id SET DEFAULT nextval('libraryprop_pub_libraryprop_pub_id_seq'::regclass);
+
+
+--
+-- Name: magedocumentation_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY magedocumentation ALTER COLUMN magedocumentation_id SET DEFAULT nextval('magedocumentation_magedocumentation_id_seq'::regclass);
+
+
+--
+-- Name: mageml_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY mageml ALTER COLUMN mageml_id SET DEFAULT nextval('mageml_mageml_id_seq'::regclass);
+
+
+--
+-- Name: materialized_view_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY materialized_view ALTER COLUMN materialized_view_id SET DEFAULT nextval('materialized_view_materialized_view_id_seq'::regclass);
+
+
+--
+-- Name: nd_experiment_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment ALTER COLUMN nd_experiment_id SET DEFAULT nextval('nd_experiment_nd_experiment_id_seq'::regclass);
+
+
+--
+-- Name: nd_experiment_contact_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_contact ALTER COLUMN nd_experiment_contact_id SET DEFAULT nextval('nd_experiment_contact_nd_experiment_contact_id_seq'::regclass);
+
+
+--
+-- Name: nd_experiment_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_dbxref ALTER COLUMN nd_experiment_dbxref_id SET DEFAULT nextval('nd_experiment_dbxref_nd_experiment_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: nd_experiment_genotype_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_genotype ALTER COLUMN nd_experiment_genotype_id SET DEFAULT nextval('nd_experiment_genotype_nd_experiment_genotype_id_seq'::regclass);
+
+
+--
+-- Name: nd_experiment_phenotype_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_phenotype ALTER COLUMN nd_experiment_phenotype_id SET DEFAULT nextval('nd_experiment_phenotype_nd_experiment_phenotype_id_seq'::regclass);
+
+
+--
+-- Name: nd_experiment_project_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_project ALTER COLUMN nd_experiment_project_id SET DEFAULT nextval('nd_experiment_project_nd_experiment_project_id_seq'::regclass);
+
+
+--
+-- Name: nd_experiment_protocol_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_protocol ALTER COLUMN nd_experiment_protocol_id SET DEFAULT nextval('nd_experiment_protocol_nd_experiment_protocol_id_seq'::regclass);
+
+
+--
+-- Name: nd_experiment_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_pub ALTER COLUMN nd_experiment_pub_id SET DEFAULT nextval('nd_experiment_pub_nd_experiment_pub_id_seq'::regclass);
+
+
+--
+-- Name: nd_experiment_stock_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_stock ALTER COLUMN nd_experiment_stock_id SET DEFAULT nextval('nd_experiment_stock_nd_experiment_stock_id_seq'::regclass);
+
+
+--
+-- Name: nd_experiment_stock_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_stock_dbxref ALTER COLUMN nd_experiment_stock_dbxref_id SET DEFAULT nextval('nd_experiment_stock_dbxref_nd_experiment_stock_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: nd_experiment_stockprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_stockprop ALTER COLUMN nd_experiment_stockprop_id SET DEFAULT nextval('nd_experiment_stockprop_nd_experiment_stockprop_id_seq'::regclass);
+
+
+--
+-- Name: nd_experimentprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experimentprop ALTER COLUMN nd_experimentprop_id SET DEFAULT nextval('nd_experimentprop_nd_experimentprop_id_seq'::regclass);
+
+
+--
+-- Name: nd_geolocation_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_geolocation ALTER COLUMN nd_geolocation_id SET DEFAULT nextval('nd_geolocation_nd_geolocation_id_seq'::regclass);
+
+
+--
+-- Name: nd_geolocationprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_geolocationprop ALTER COLUMN nd_geolocationprop_id SET DEFAULT nextval('nd_geolocationprop_nd_geolocationprop_id_seq'::regclass);
+
+
+--
+-- Name: nd_protocol_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_protocol ALTER COLUMN nd_protocol_id SET DEFAULT nextval('nd_protocol_nd_protocol_id_seq'::regclass);
+
+
+--
+-- Name: nd_protocol_reagent_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_protocol_reagent ALTER COLUMN nd_protocol_reagent_id SET DEFAULT nextval('nd_protocol_reagent_nd_protocol_reagent_id_seq'::regclass);
+
+
+--
+-- Name: nd_protocolprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_protocolprop ALTER COLUMN nd_protocolprop_id SET DEFAULT nextval('nd_protocolprop_nd_protocolprop_id_seq'::regclass);
+
+
+--
+-- Name: nd_reagent_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_reagent ALTER COLUMN nd_reagent_id SET DEFAULT nextval('nd_reagent_nd_reagent_id_seq'::regclass);
+
+
+--
+-- Name: nd_reagent_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_reagent_relationship ALTER COLUMN nd_reagent_relationship_id SET DEFAULT nextval('nd_reagent_relationship_nd_reagent_relationship_id_seq'::regclass);
+
+
+--
+-- Name: nd_reagentprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_reagentprop ALTER COLUMN nd_reagentprop_id SET DEFAULT nextval('nd_reagentprop_nd_reagentprop_id_seq'::regclass);
+
+
+--
+-- Name: organism_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism ALTER COLUMN organism_id SET DEFAULT nextval('organism_organism_id_seq'::regclass);
+
+
+--
+-- Name: organism_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_dbxref ALTER COLUMN organism_dbxref_id SET DEFAULT nextval('organism_dbxref_organism_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: organism_image_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_image ALTER COLUMN organism_image_id SET DEFAULT nextval('organism_image_organism_image_id_seq'::regclass);
+
+
+--
+-- Name: organism_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_pub ALTER COLUMN organism_pub_id SET DEFAULT nextval('organism_pub_organism_pub_id_seq'::regclass);
+
+
+--
+-- Name: organism_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_relationship ALTER COLUMN organism_relationship_id SET DEFAULT nextval('organism_relationship_organism_relationship_id_seq'::regclass);
+
+
+--
+-- Name: organismprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organismprop ALTER COLUMN organismprop_id SET DEFAULT nextval('organismprop_organismprop_id_seq'::regclass);
+
+
+--
+-- Name: phendesc_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phendesc ALTER COLUMN phendesc_id SET DEFAULT nextval('phendesc_phendesc_id_seq'::regclass);
+
+
+--
+-- Name: phenotype_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype ALTER COLUMN phenotype_id SET DEFAULT nextval('phenotype_phenotype_id_seq'::regclass);
+
+
+--
+-- Name: phenotype_comparison_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison ALTER COLUMN phenotype_comparison_id SET DEFAULT nextval('phenotype_comparison_phenotype_comparison_id_seq'::regclass);
+
+
+--
+-- Name: phenotype_comparison_cvterm_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison_cvterm ALTER COLUMN phenotype_comparison_cvterm_id SET DEFAULT nextval('phenotype_comparison_cvterm_phenotype_comparison_cvterm_id_seq'::regclass);
+
+
+--
+-- Name: phenotype_cvterm_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_cvterm ALTER COLUMN phenotype_cvterm_id SET DEFAULT nextval('phenotype_cvterm_phenotype_cvterm_id_seq'::regclass);
+
+
+--
+-- Name: phenstatement_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenstatement ALTER COLUMN phenstatement_id SET DEFAULT nextval('phenstatement_phenstatement_id_seq'::regclass);
+
+
+--
+-- Name: phenstatementprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenstatementprop ALTER COLUMN phenstatementprop_id SET DEFAULT nextval('phenstatementprop_phenstatementprop_id_seq'::regclass);
+
+
+--
+-- Name: phylonode_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode ALTER COLUMN phylonode_id SET DEFAULT nextval('phylonode_phylonode_id_seq'::regclass);
+
+
+--
+-- Name: phylonode_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_dbxref ALTER COLUMN phylonode_dbxref_id SET DEFAULT nextval('phylonode_dbxref_phylonode_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: phylonode_organism_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_organism ALTER COLUMN phylonode_organism_id SET DEFAULT nextval('phylonode_organism_phylonode_organism_id_seq'::regclass);
+
+
+--
+-- Name: phylonode_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_pub ALTER COLUMN phylonode_pub_id SET DEFAULT nextval('phylonode_pub_phylonode_pub_id_seq'::regclass);
+
+
+--
+-- Name: phylonode_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_relationship ALTER COLUMN phylonode_relationship_id SET DEFAULT nextval('phylonode_relationship_phylonode_relationship_id_seq'::regclass);
+
+
+--
+-- Name: phylonodeprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonodeprop ALTER COLUMN phylonodeprop_id SET DEFAULT nextval('phylonodeprop_phylonodeprop_id_seq'::regclass);
+
+
+--
+-- Name: phylotree_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylotree ALTER COLUMN phylotree_id SET DEFAULT nextval('phylotree_phylotree_id_seq'::regclass);
+
+
+--
+-- Name: phylotree_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylotree_pub ALTER COLUMN phylotree_pub_id SET DEFAULT nextval('phylotree_pub_phylotree_pub_id_seq'::regclass);
+
+
+--
+-- Name: project_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY project ALTER COLUMN project_id SET DEFAULT nextval('project_project_id_seq'::regclass);
+
+
+--
+-- Name: project_contact_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY project_contact ALTER COLUMN project_contact_id SET DEFAULT nextval('project_contact_project_contact_id_seq'::regclass);
+
+
+--
+-- Name: project_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY project_pub ALTER COLUMN project_pub_id SET DEFAULT nextval('project_pub_project_pub_id_seq'::regclass);
+
+
+--
+-- Name: project_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY project_relationship ALTER COLUMN project_relationship_id SET DEFAULT nextval('project_relationship_project_relationship_id_seq'::regclass);
+
+
+--
+-- Name: projectprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY projectprop ALTER COLUMN projectprop_id SET DEFAULT nextval('projectprop_projectprop_id_seq'::regclass);
+
+
+--
+-- Name: protocol_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY protocol ALTER COLUMN protocol_id SET DEFAULT nextval('protocol_protocol_id_seq'::regclass);
+
+
+--
+-- Name: protocolparam_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY protocolparam ALTER COLUMN protocolparam_id SET DEFAULT nextval('protocolparam_protocolparam_id_seq'::regclass);
+
+
+--
+-- Name: pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pub ALTER COLUMN pub_id SET DEFAULT nextval('pub_pub_id_seq'::regclass);
+
+
+--
+-- Name: pub_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pub_dbxref ALTER COLUMN pub_dbxref_id SET DEFAULT nextval('pub_dbxref_pub_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: pub_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pub_relationship ALTER COLUMN pub_relationship_id SET DEFAULT nextval('pub_relationship_pub_relationship_id_seq'::regclass);
+
+
+--
+-- Name: pubauthor_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pubauthor ALTER COLUMN pubauthor_id SET DEFAULT nextval('pubauthor_pubauthor_id_seq'::regclass);
+
+
+--
+-- Name: pubauthor_contact_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pubauthor_contact ALTER COLUMN pubauthor_contact_id SET DEFAULT nextval('pubauthor_contact_pubauthor_contact_id_seq'::regclass);
+
+
+--
+-- Name: pubprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pubprop ALTER COLUMN pubprop_id SET DEFAULT nextval('pubprop_pubprop_id_seq'::regclass);
+
+
+--
+-- Name: quantification_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY quantification ALTER COLUMN quantification_id SET DEFAULT nextval('quantification_quantification_id_seq'::regclass);
+
+
+--
+-- Name: quantification_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY quantification_relationship ALTER COLUMN quantification_relationship_id SET DEFAULT nextval('quantification_relationship_quantification_relationship_id_seq'::regclass);
+
+
+--
+-- Name: quantificationprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY quantificationprop ALTER COLUMN quantificationprop_id SET DEFAULT nextval('quantificationprop_quantificationprop_id_seq'::regclass);
+
+
+--
+-- Name: stock_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock ALTER COLUMN stock_id SET DEFAULT nextval('stock_stock_id_seq'::regclass);
+
+
+--
+-- Name: stock_cvterm_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_cvterm ALTER COLUMN stock_cvterm_id SET DEFAULT nextval('stock_cvterm_stock_cvterm_id_seq'::regclass);
+
+
+--
+-- Name: stock_cvtermprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_cvtermprop ALTER COLUMN stock_cvtermprop_id SET DEFAULT nextval('stock_cvtermprop_stock_cvtermprop_id_seq'::regclass);
+
+
+--
+-- Name: stock_dbxref_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_dbxref ALTER COLUMN stock_dbxref_id SET DEFAULT nextval('stock_dbxref_stock_dbxref_id_seq'::regclass);
+
+
+--
+-- Name: stock_dbxrefprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_dbxrefprop ALTER COLUMN stock_dbxrefprop_id SET DEFAULT nextval('stock_dbxrefprop_stock_dbxrefprop_id_seq'::regclass);
+
+
+--
+-- Name: stock_genotype_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_genotype ALTER COLUMN stock_genotype_id SET DEFAULT nextval('stock_genotype_stock_genotype_id_seq'::regclass);
+
+
+--
+-- Name: stock_image_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_image ALTER COLUMN stock_image_id SET DEFAULT nextval('stock_image_stock_image_id_seq'::regclass);
+
+
+--
+-- Name: stock_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_pub ALTER COLUMN stock_pub_id SET DEFAULT nextval('stock_pub_stock_pub_id_seq'::regclass);
+
+
+--
+-- Name: stock_relationship_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_relationship ALTER COLUMN stock_relationship_id SET DEFAULT nextval('stock_relationship_stock_relationship_id_seq'::regclass);
+
+
+--
+-- Name: stock_relationship_cvterm_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_relationship_cvterm ALTER COLUMN stock_relationship_cvterm_id SET DEFAULT nextval('stock_relationship_cvterm_stock_relationship_cvterm_id_seq'::regclass);
+
+
+--
+-- Name: stock_relationship_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_relationship_pub ALTER COLUMN stock_relationship_pub_id SET DEFAULT nextval('stock_relationship_pub_stock_relationship_pub_id_seq'::regclass);
+
+
+--
+-- Name: stockcollection_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockcollection ALTER COLUMN stockcollection_id SET DEFAULT nextval('stockcollection_stockcollection_id_seq'::regclass);
+
+
+--
+-- Name: stockcollection_stock_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockcollection_stock ALTER COLUMN stockcollection_stock_id SET DEFAULT nextval('stockcollection_stock_stockcollection_stock_id_seq'::regclass);
+
+
+--
+-- Name: stockcollectionprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockcollectionprop ALTER COLUMN stockcollectionprop_id SET DEFAULT nextval('stockcollectionprop_stockcollectionprop_id_seq'::regclass);
+
+
+--
+-- Name: stockprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockprop ALTER COLUMN stockprop_id SET DEFAULT nextval('stockprop_stockprop_id_seq'::regclass);
+
+
+--
+-- Name: stockprop_pub_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockprop_pub ALTER COLUMN stockprop_pub_id SET DEFAULT nextval('stockprop_pub_stockprop_pub_id_seq'::regclass);
+
+
+--
+-- Name: study_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY study ALTER COLUMN study_id SET DEFAULT nextval('study_study_id_seq'::regclass);
+
+
+--
+-- Name: study_assay_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY study_assay ALTER COLUMN study_assay_id SET DEFAULT nextval('study_assay_study_assay_id_seq'::regclass);
+
+
+--
+-- Name: studydesign_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studydesign ALTER COLUMN studydesign_id SET DEFAULT nextval('studydesign_studydesign_id_seq'::regclass);
+
+
+--
+-- Name: studydesignprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studydesignprop ALTER COLUMN studydesignprop_id SET DEFAULT nextval('studydesignprop_studydesignprop_id_seq'::regclass);
+
+
+--
+-- Name: studyfactor_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyfactor ALTER COLUMN studyfactor_id SET DEFAULT nextval('studyfactor_studyfactor_id_seq'::regclass);
+
+
+--
+-- Name: studyfactorvalue_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyfactorvalue ALTER COLUMN studyfactorvalue_id SET DEFAULT nextval('studyfactorvalue_studyfactorvalue_id_seq'::regclass);
+
+
+--
+-- Name: studyprop_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyprop ALTER COLUMN studyprop_id SET DEFAULT nextval('studyprop_studyprop_id_seq'::regclass);
+
+
+--
+-- Name: studyprop_feature_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyprop_feature ALTER COLUMN studyprop_feature_id SET DEFAULT nextval('studyprop_feature_studyprop_feature_id_seq'::regclass);
+
+
+--
+-- Name: synonym_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY synonym ALTER COLUMN synonym_id SET DEFAULT nextval('synonym_synonym_id_seq'::regclass);
+
+
+--
+-- Name: tableinfo_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY tableinfo ALTER COLUMN tableinfo_id SET DEFAULT nextval('tableinfo_tableinfo_id_seq'::regclass);
+
+
+--
+-- Name: treatment_id; Type: DEFAULT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY treatment ALTER COLUMN treatment_id SET DEFAULT nextval('treatment_treatment_id_seq'::regclass);
+
+
+--
+-- Name: acquisition_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY acquisition
+ ADD CONSTRAINT acquisition_c1 UNIQUE (name);
+
+
+--
+-- Name: acquisition_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY acquisition
+ ADD CONSTRAINT acquisition_pkey PRIMARY KEY (acquisition_id);
+
+
+--
+-- Name: acquisition_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY acquisition_relationship
+ ADD CONSTRAINT acquisition_relationship_c1 UNIQUE (subject_id, object_id, type_id, rank);
+
+
+--
+-- Name: acquisition_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY acquisition_relationship
+ ADD CONSTRAINT acquisition_relationship_pkey PRIMARY KEY (acquisition_relationship_id);
+
+
+--
+-- Name: acquisitionprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY acquisitionprop
+ ADD CONSTRAINT acquisitionprop_c1 UNIQUE (acquisition_id, type_id, rank);
+
+
+--
+-- Name: acquisitionprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY acquisitionprop
+ ADD CONSTRAINT acquisitionprop_pkey PRIMARY KEY (acquisitionprop_id);
+
+
+--
+-- Name: analysisfeature_id_type_id_rank; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY analysisfeatureprop
+ ADD CONSTRAINT analysisfeature_id_type_id_rank UNIQUE (analysisfeature_id, type_id, rank);
+
+
+--
+-- Name: analysisfeatureprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY analysisfeatureprop
+ ADD CONSTRAINT analysisfeatureprop_pkey PRIMARY KEY (analysisfeatureprop_id);
+
+
+--
+-- Name: analysisprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY analysisprop
+ ADD CONSTRAINT analysisprop_c1 UNIQUE (analysis_id, type_id, rank);
+
+
+--
+-- Name: analysisprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY analysisprop
+ ADD CONSTRAINT analysisprop_pkey PRIMARY KEY (analysisprop_id);
+
+
+--
+-- Name: arraydesign_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY arraydesign
+ ADD CONSTRAINT arraydesign_c1 UNIQUE (name);
+
+
+--
+-- Name: arraydesign_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY arraydesign
+ ADD CONSTRAINT arraydesign_pkey PRIMARY KEY (arraydesign_id);
+
+
+--
+-- Name: arraydesignprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY arraydesignprop
+ ADD CONSTRAINT arraydesignprop_c1 UNIQUE (arraydesign_id, type_id, rank);
+
+
+--
+-- Name: arraydesignprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY arraydesignprop
+ ADD CONSTRAINT arraydesignprop_pkey PRIMARY KEY (arraydesignprop_id);
+
+
+--
+-- Name: assay_biomaterial_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY assay_biomaterial
+ ADD CONSTRAINT assay_biomaterial_c1 UNIQUE (assay_id, biomaterial_id, channel_id, rank);
+
+
+--
+-- Name: assay_biomaterial_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY assay_biomaterial
+ ADD CONSTRAINT assay_biomaterial_pkey PRIMARY KEY (assay_biomaterial_id);
+
+
+--
+-- Name: assay_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY assay
+ ADD CONSTRAINT assay_c1 UNIQUE (name);
+
+
+--
+-- Name: assay_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY assay
+ ADD CONSTRAINT assay_pkey PRIMARY KEY (assay_id);
+
+
+--
+-- Name: assay_project_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY assay_project
+ ADD CONSTRAINT assay_project_c1 UNIQUE (assay_id, project_id);
+
+
+--
+-- Name: assay_project_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY assay_project
+ ADD CONSTRAINT assay_project_pkey PRIMARY KEY (assay_project_id);
+
+
+--
+-- Name: assayprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY assayprop
+ ADD CONSTRAINT assayprop_c1 UNIQUE (assay_id, type_id, rank);
+
+
+--
+-- Name: assayprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY assayprop
+ ADD CONSTRAINT assayprop_pkey PRIMARY KEY (assayprop_id);
+
+
+--
+-- Name: biomaterial_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY biomaterial
+ ADD CONSTRAINT biomaterial_c1 UNIQUE (name);
+
+
+--
+-- Name: biomaterial_dbxref_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY biomaterial_dbxref
+ ADD CONSTRAINT biomaterial_dbxref_c1 UNIQUE (biomaterial_id, dbxref_id);
+
+
+--
+-- Name: biomaterial_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY biomaterial_dbxref
+ ADD CONSTRAINT biomaterial_dbxref_pkey PRIMARY KEY (biomaterial_dbxref_id);
+
+
+--
+-- Name: biomaterial_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY biomaterial
+ ADD CONSTRAINT biomaterial_pkey PRIMARY KEY (biomaterial_id);
+
+
+--
+-- Name: biomaterial_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY biomaterial_relationship
+ ADD CONSTRAINT biomaterial_relationship_c1 UNIQUE (subject_id, object_id, type_id);
+
+
+--
+-- Name: biomaterial_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY biomaterial_relationship
+ ADD CONSTRAINT biomaterial_relationship_pkey PRIMARY KEY (biomaterial_relationship_id);
+
+
+--
+-- Name: biomaterial_treatment_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY biomaterial_treatment
+ ADD CONSTRAINT biomaterial_treatment_c1 UNIQUE (biomaterial_id, treatment_id);
+
+
+--
+-- Name: biomaterial_treatment_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY biomaterial_treatment
+ ADD CONSTRAINT biomaterial_treatment_pkey PRIMARY KEY (biomaterial_treatment_id);
+
+
+--
+-- Name: biomaterialprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY biomaterialprop
+ ADD CONSTRAINT biomaterialprop_c1 UNIQUE (biomaterial_id, type_id, rank);
+
+
+--
+-- Name: biomaterialprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY biomaterialprop
+ ADD CONSTRAINT biomaterialprop_pkey PRIMARY KEY (biomaterialprop_id);
+
+
+--
+-- Name: blast_organisms_blast_org_name_uq_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY blast_organisms
+ ADD CONSTRAINT blast_organisms_blast_org_name_uq_key UNIQUE (blast_org_name);
+
+
+--
+-- Name: blast_organisms_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY blast_organisms
+ ADD CONSTRAINT blast_organisms_pkey PRIMARY KEY (blast_org_id);
+
+
+--
+-- Name: cell_line_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line
+ ADD CONSTRAINT cell_line_c1 UNIQUE (uniquename, organism_id);
+
+
+--
+-- Name: cell_line_cvterm_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_cvterm
+ ADD CONSTRAINT cell_line_cvterm_c1 UNIQUE (cell_line_id, cvterm_id, pub_id, rank);
+
+
+--
+-- Name: cell_line_cvterm_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_cvterm
+ ADD CONSTRAINT cell_line_cvterm_pkey PRIMARY KEY (cell_line_cvterm_id);
+
+
+--
+-- Name: cell_line_cvtermprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_cvtermprop
+ ADD CONSTRAINT cell_line_cvtermprop_c1 UNIQUE (cell_line_cvterm_id, type_id, rank);
+
+
+--
+-- Name: cell_line_cvtermprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_cvtermprop
+ ADD CONSTRAINT cell_line_cvtermprop_pkey PRIMARY KEY (cell_line_cvtermprop_id);
+
+
+--
+-- Name: cell_line_dbxref_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_dbxref
+ ADD CONSTRAINT cell_line_dbxref_c1 UNIQUE (cell_line_id, dbxref_id);
+
+
+--
+-- Name: cell_line_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_dbxref
+ ADD CONSTRAINT cell_line_dbxref_pkey PRIMARY KEY (cell_line_dbxref_id);
+
+
+--
+-- Name: cell_line_feature_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_feature
+ ADD CONSTRAINT cell_line_feature_c1 UNIQUE (cell_line_id, feature_id, pub_id);
+
+
+--
+-- Name: cell_line_feature_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_feature
+ ADD CONSTRAINT cell_line_feature_pkey PRIMARY KEY (cell_line_feature_id);
+
+
+--
+-- Name: cell_line_library_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_library
+ ADD CONSTRAINT cell_line_library_c1 UNIQUE (cell_line_id, library_id, pub_id);
+
+
+--
+-- Name: cell_line_library_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_library
+ ADD CONSTRAINT cell_line_library_pkey PRIMARY KEY (cell_line_library_id);
+
+
+--
+-- Name: cell_line_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line
+ ADD CONSTRAINT cell_line_pkey PRIMARY KEY (cell_line_id);
+
+
+--
+-- Name: cell_line_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_pub
+ ADD CONSTRAINT cell_line_pub_c1 UNIQUE (cell_line_id, pub_id);
+
+
+--
+-- Name: cell_line_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_pub
+ ADD CONSTRAINT cell_line_pub_pkey PRIMARY KEY (cell_line_pub_id);
+
+
+--
+-- Name: cell_line_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_relationship
+ ADD CONSTRAINT cell_line_relationship_c1 UNIQUE (subject_id, object_id, type_id);
+
+
+--
+-- Name: cell_line_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_relationship
+ ADD CONSTRAINT cell_line_relationship_pkey PRIMARY KEY (cell_line_relationship_id);
+
+
+--
+-- Name: cell_line_synonym_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_synonym
+ ADD CONSTRAINT cell_line_synonym_c1 UNIQUE (synonym_id, cell_line_id, pub_id);
+
+
+--
+-- Name: cell_line_synonym_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_line_synonym
+ ADD CONSTRAINT cell_line_synonym_pkey PRIMARY KEY (cell_line_synonym_id);
+
+
+--
+-- Name: cell_lineprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_lineprop
+ ADD CONSTRAINT cell_lineprop_c1 UNIQUE (cell_line_id, type_id, rank);
+
+
+--
+-- Name: cell_lineprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_lineprop
+ ADD CONSTRAINT cell_lineprop_pkey PRIMARY KEY (cell_lineprop_id);
+
+
+--
+-- Name: cell_lineprop_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_lineprop_pub
+ ADD CONSTRAINT cell_lineprop_pub_c1 UNIQUE (cell_lineprop_id, pub_id);
+
+
+--
+-- Name: cell_lineprop_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cell_lineprop_pub
+ ADD CONSTRAINT cell_lineprop_pub_pkey PRIMARY KEY (cell_lineprop_pub_id);
+
+
+--
+-- Name: chadoprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY chadoprop
+ ADD CONSTRAINT chadoprop_c1 UNIQUE (type_id, rank);
+
+
+--
+-- Name: chadoprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY chadoprop
+ ADD CONSTRAINT chadoprop_pkey PRIMARY KEY (chadoprop_id);
+
+
+--
+-- Name: channel_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY channel
+ ADD CONSTRAINT channel_c1 UNIQUE (name);
+
+
+--
+-- Name: channel_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY channel
+ ADD CONSTRAINT channel_pkey PRIMARY KEY (channel_id);
+
+
+--
+-- Name: contact_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY contact
+ ADD CONSTRAINT contact_c1 UNIQUE (name);
+
+
+--
+-- Name: contact_image_contact_id_eimage_id_type_id_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY contact_image
+ ADD CONSTRAINT contact_image_contact_id_eimage_id_type_id_key UNIQUE (contact_id, eimage_id, type_id);
+
+
+--
+-- Name: contact_image_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY contact_image
+ ADD CONSTRAINT contact_image_pkey PRIMARY KEY (contact_image_id);
+
+
+--
+-- Name: contact_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY contact
+ ADD CONSTRAINT contact_pkey PRIMARY KEY (contact_id);
+
+
+--
+-- Name: contact_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY contact_relationship
+ ADD CONSTRAINT contact_relationship_c1 UNIQUE (subject_id, object_id, type_id);
+
+
+--
+-- Name: contact_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY contact_relationship
+ ADD CONSTRAINT contact_relationship_pkey PRIMARY KEY (contact_relationship_id);
+
+
+--
+-- Name: contactprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY contactprop
+ ADD CONSTRAINT contactprop_c1 UNIQUE (contact_id, type_id, rank);
+
+
+--
+-- Name: contactprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY contactprop
+ ADD CONSTRAINT contactprop_pkey PRIMARY KEY (contactprop_id);
+
+
+--
+-- Name: content_type_chado_analysis_unigene_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY content_type_chado_analysis_unigene
+ ADD CONSTRAINT content_type_chado_analysis_unigene_pkey PRIMARY KEY (vid);
+
+
+--
+-- Name: control_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY control
+ ADD CONSTRAINT control_pkey PRIMARY KEY (control_id);
+
+
+--
+-- Name: cvprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvprop
+ ADD CONSTRAINT cvprop_c1 UNIQUE (cv_id, type_id, rank);
+
+
+--
+-- Name: cvprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvprop
+ ADD CONSTRAINT cvprop_pkey PRIMARY KEY (cvprop_id);
+
+
+--
+-- Name: cvterm_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvterm
+ ADD CONSTRAINT cvterm_c1 UNIQUE (name, cv_id, is_obsolete);
+
+
+--
+-- Name: cvterm_c2; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvterm
+ ADD CONSTRAINT cvterm_c2 UNIQUE (dbxref_id);
+
+
+--
+-- Name: cvterm_dbxref_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvterm_dbxref
+ ADD CONSTRAINT cvterm_dbxref_c1 UNIQUE (cvterm_id, dbxref_id);
+
+
+--
+-- Name: cvterm_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvterm_dbxref
+ ADD CONSTRAINT cvterm_dbxref_pkey PRIMARY KEY (cvterm_dbxref_id);
+
+
+--
+-- Name: cvterm_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvterm
+ ADD CONSTRAINT cvterm_pkey PRIMARY KEY (cvterm_id);
+
+
+--
+-- Name: cvterm_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvterm_relationship
+ ADD CONSTRAINT cvterm_relationship_c1 UNIQUE (subject_id, object_id, type_id);
+
+
+--
+-- Name: cvterm_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvterm_relationship
+ ADD CONSTRAINT cvterm_relationship_pkey PRIMARY KEY (cvterm_relationship_id);
+
+
+--
+-- Name: cvtermpath_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvtermpath
+ ADD CONSTRAINT cvtermpath_c1 UNIQUE (subject_id, object_id, type_id, pathdistance);
+
+
+--
+-- Name: cvtermpath_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvtermpath
+ ADD CONSTRAINT cvtermpath_pkey PRIMARY KEY (cvtermpath_id);
+
+
+--
+-- Name: cvtermprop_cvterm_id_type_id_value_rank_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvtermprop
+ ADD CONSTRAINT cvtermprop_cvterm_id_type_id_value_rank_key UNIQUE (cvterm_id, type_id, value, rank);
+
+
+--
+-- Name: cvtermprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvtermprop
+ ADD CONSTRAINT cvtermprop_pkey PRIMARY KEY (cvtermprop_id);
+
+
+--
+-- Name: cvtermsynonym_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvtermsynonym
+ ADD CONSTRAINT cvtermsynonym_c1 UNIQUE (cvterm_id, synonym);
+
+
+--
+-- Name: cvtermsynonym_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cvtermsynonym
+ ADD CONSTRAINT cvtermsynonym_pkey PRIMARY KEY (cvtermsynonym_id);
+
+
+--
+-- Name: db_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY db
+ ADD CONSTRAINT db_c1 UNIQUE (name);
+
+
+--
+-- Name: db_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY db
+ ADD CONSTRAINT db_pkey PRIMARY KEY (db_id);
+
+
+--
+-- Name: dbxref_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY dbxref
+ ADD CONSTRAINT dbxref_c1 UNIQUE (db_id, accession, version);
+
+
+--
+-- Name: dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY dbxref
+ ADD CONSTRAINT dbxref_pkey PRIMARY KEY (dbxref_id);
+
+
+--
+-- Name: dbxrefprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY dbxrefprop
+ ADD CONSTRAINT dbxrefprop_c1 UNIQUE (dbxref_id, type_id, rank);
+
+
+--
+-- Name: dbxrefprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY dbxrefprop
+ ADD CONSTRAINT dbxrefprop_pkey PRIMARY KEY (dbxrefprop_id);
+
+
+--
+-- Name: eimage_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY eimage
+ ADD CONSTRAINT eimage_pkey PRIMARY KEY (eimage_id);
+
+
+--
+-- Name: eimageprop_eimage_id_type_id_rank_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY eimageprop
+ ADD CONSTRAINT eimageprop_eimage_id_type_id_rank_key UNIQUE (eimage_id, type_id, rank);
+
+
+--
+-- Name: eimageprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY eimageprop
+ ADD CONSTRAINT eimageprop_pkey PRIMARY KEY (eimageprop_id);
+
+
+--
+-- Name: element_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY element
+ ADD CONSTRAINT element_c1 UNIQUE (feature_id, arraydesign_id);
+
+
+--
+-- Name: element_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY element
+ ADD CONSTRAINT element_pkey PRIMARY KEY (element_id);
+
+
+--
+-- Name: element_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY element_relationship
+ ADD CONSTRAINT element_relationship_c1 UNIQUE (subject_id, object_id, type_id, rank);
+
+
+--
+-- Name: element_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY element_relationship
+ ADD CONSTRAINT element_relationship_pkey PRIMARY KEY (element_relationship_id);
+
+
+--
+-- Name: elementresult_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY elementresult
+ ADD CONSTRAINT elementresult_c1 UNIQUE (element_id, quantification_id);
+
+
+--
+-- Name: elementresult_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY elementresult
+ ADD CONSTRAINT elementresult_pkey PRIMARY KEY (elementresult_id);
+
+
+--
+-- Name: elementresult_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY elementresult_relationship
+ ADD CONSTRAINT elementresult_relationship_c1 UNIQUE (subject_id, object_id, type_id, rank);
+
+
+--
+-- Name: elementresult_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY elementresult_relationship
+ ADD CONSTRAINT elementresult_relationship_pkey PRIMARY KEY (elementresult_relationship_id);
+
+
+--
+-- Name: environment_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY environment
+ ADD CONSTRAINT environment_c1 UNIQUE (uniquename);
+
+
+--
+-- Name: environment_cvterm_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY environment_cvterm
+ ADD CONSTRAINT environment_cvterm_c1 UNIQUE (environment_id, cvterm_id);
+
+
+--
+-- Name: environment_cvterm_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY environment_cvterm
+ ADD CONSTRAINT environment_cvterm_pkey PRIMARY KEY (environment_cvterm_id);
+
+
+--
+-- Name: environment_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY environment
+ ADD CONSTRAINT environment_pkey PRIMARY KEY (environment_id);
+
+
+--
+-- Name: expression_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expression
+ ADD CONSTRAINT expression_c1 UNIQUE (uniquename);
+
+
+--
+-- Name: expression_cvterm_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expression_cvterm
+ ADD CONSTRAINT expression_cvterm_c1 UNIQUE (expression_id, cvterm_id, cvterm_type_id);
+
+
+--
+-- Name: expression_cvterm_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expression_cvterm
+ ADD CONSTRAINT expression_cvterm_pkey PRIMARY KEY (expression_cvterm_id);
+
+
+--
+-- Name: expression_cvtermprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expression_cvtermprop
+ ADD CONSTRAINT expression_cvtermprop_c1 UNIQUE (expression_cvterm_id, type_id, rank);
+
+
+--
+-- Name: expression_cvtermprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expression_cvtermprop
+ ADD CONSTRAINT expression_cvtermprop_pkey PRIMARY KEY (expression_cvtermprop_id);
+
+
+--
+-- Name: expression_image_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expression_image
+ ADD CONSTRAINT expression_image_c1 UNIQUE (expression_id, eimage_id);
+
+
+--
+-- Name: expression_image_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expression_image
+ ADD CONSTRAINT expression_image_pkey PRIMARY KEY (expression_image_id);
+
+
+--
+-- Name: expression_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expression
+ ADD CONSTRAINT expression_pkey PRIMARY KEY (expression_id);
+
+
+--
+-- Name: expression_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expression_pub
+ ADD CONSTRAINT expression_pub_c1 UNIQUE (expression_id, pub_id);
+
+
+--
+-- Name: expression_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expression_pub
+ ADD CONSTRAINT expression_pub_pkey PRIMARY KEY (expression_pub_id);
+
+
+--
+-- Name: expressionprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expressionprop
+ ADD CONSTRAINT expressionprop_c1 UNIQUE (expression_id, type_id, rank);
+
+
+--
+-- Name: expressionprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY expressionprop
+ ADD CONSTRAINT expressionprop_pkey PRIMARY KEY (expressionprop_id);
+
+
+--
+-- Name: feature_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature
+ ADD CONSTRAINT feature_c1 UNIQUE (organism_id, uniquename, type_id);
+
+
+--
+-- Name: feature_contact_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_contact
+ ADD CONSTRAINT feature_contact_c1 UNIQUE (feature_id, contact_id);
+
+
+--
+-- Name: feature_contact_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_contact
+ ADD CONSTRAINT feature_contact_pkey PRIMARY KEY (feature_contact_id);
+
+
+--
+-- Name: feature_cvterm_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_cvterm
+ ADD CONSTRAINT feature_cvterm_c1 UNIQUE (feature_id, cvterm_id, pub_id, rank);
+
+
+--
+-- Name: feature_cvterm_dbxref_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_cvterm_dbxref
+ ADD CONSTRAINT feature_cvterm_dbxref_c1 UNIQUE (feature_cvterm_id, dbxref_id);
+
+
+--
+-- Name: feature_cvterm_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_cvterm_dbxref
+ ADD CONSTRAINT feature_cvterm_dbxref_pkey PRIMARY KEY (feature_cvterm_dbxref_id);
+
+
+--
+-- Name: feature_cvterm_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_cvterm
+ ADD CONSTRAINT feature_cvterm_pkey PRIMARY KEY (feature_cvterm_id);
+
+
+--
+-- Name: feature_cvterm_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_cvterm_pub
+ ADD CONSTRAINT feature_cvterm_pub_c1 UNIQUE (feature_cvterm_id, pub_id);
+
+
+--
+-- Name: feature_cvterm_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_cvterm_pub
+ ADD CONSTRAINT feature_cvterm_pub_pkey PRIMARY KEY (feature_cvterm_pub_id);
+
+
+--
+-- Name: feature_cvtermprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_cvtermprop
+ ADD CONSTRAINT feature_cvtermprop_c1 UNIQUE (feature_cvterm_id, type_id, rank);
+
+
+--
+-- Name: feature_cvtermprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_cvtermprop
+ ADD CONSTRAINT feature_cvtermprop_pkey PRIMARY KEY (feature_cvtermprop_id);
+
+
+--
+-- Name: feature_dbxref_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_dbxref
+ ADD CONSTRAINT feature_dbxref_c1 UNIQUE (feature_id, dbxref_id);
+
+
+--
+-- Name: feature_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_dbxref
+ ADD CONSTRAINT feature_dbxref_pkey PRIMARY KEY (feature_dbxref_id);
+
+
+--
+-- Name: feature_expression_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_expression
+ ADD CONSTRAINT feature_expression_c1 UNIQUE (expression_id, feature_id, pub_id);
+
+
+--
+-- Name: feature_expression_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_expression
+ ADD CONSTRAINT feature_expression_pkey PRIMARY KEY (feature_expression_id);
+
+
+--
+-- Name: feature_expressionprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_expressionprop
+ ADD CONSTRAINT feature_expressionprop_c1 UNIQUE (feature_expression_id, type_id, rank);
+
+
+--
+-- Name: feature_expressionprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_expressionprop
+ ADD CONSTRAINT feature_expressionprop_pkey PRIMARY KEY (feature_expressionprop_id);
+
+
+--
+-- Name: feature_genotype_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_genotype
+ ADD CONSTRAINT feature_genotype_c1 UNIQUE (feature_id, genotype_id, cvterm_id, chromosome_id, rank, cgroup);
+
+
+--
+-- Name: feature_genotype_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_genotype
+ ADD CONSTRAINT feature_genotype_pkey PRIMARY KEY (feature_genotype_id);
+
+
+--
+-- Name: feature_image_feature_id_eimage_id_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_image
+ ADD CONSTRAINT feature_image_feature_id_eimage_id_key UNIQUE (feature_id, eimage_id);
+
+
+--
+-- Name: feature_image_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_image
+ ADD CONSTRAINT feature_image_pkey PRIMARY KEY (feature_image_id);
+
+
+--
+-- Name: feature_phenotype_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_phenotype
+ ADD CONSTRAINT feature_phenotype_c1 UNIQUE (feature_id, phenotype_id);
+
+
+--
+-- Name: feature_phenotype_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_phenotype
+ ADD CONSTRAINT feature_phenotype_pkey PRIMARY KEY (feature_phenotype_id);
+
+
+--
+-- Name: feature_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature
+ ADD CONSTRAINT feature_pkey PRIMARY KEY (feature_id);
+
+
+--
+-- Name: feature_project_feature_id_project_id_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_project
+ ADD CONSTRAINT feature_project_feature_id_project_id_key UNIQUE (feature_id, project_id);
+
+
+--
+-- Name: feature_project_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_project
+ ADD CONSTRAINT feature_project_pkey PRIMARY KEY (feature_project_id);
+
+
+--
+-- Name: feature_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_pub
+ ADD CONSTRAINT feature_pub_c1 UNIQUE (feature_id, pub_id);
+
+
+--
+-- Name: feature_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_pub
+ ADD CONSTRAINT feature_pub_pkey PRIMARY KEY (feature_pub_id);
+
+
+--
+-- Name: feature_pubprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_pubprop
+ ADD CONSTRAINT feature_pubprop_c1 UNIQUE (feature_pub_id, type_id, rank);
+
+
+--
+-- Name: feature_pubprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_pubprop
+ ADD CONSTRAINT feature_pubprop_pkey PRIMARY KEY (feature_pubprop_id);
+
+
+--
+-- Name: feature_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_relationship
+ ADD CONSTRAINT feature_relationship_c1 UNIQUE (subject_id, object_id, type_id, rank);
+
+
+--
+-- Name: feature_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_relationship
+ ADD CONSTRAINT feature_relationship_pkey PRIMARY KEY (feature_relationship_id);
+
+
+--
+-- Name: feature_relationship_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_relationship_pub
+ ADD CONSTRAINT feature_relationship_pub_c1 UNIQUE (feature_relationship_id, pub_id);
+
+
+--
+-- Name: feature_relationship_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_relationship_pub
+ ADD CONSTRAINT feature_relationship_pub_pkey PRIMARY KEY (feature_relationship_pub_id);
+
+
+--
+-- Name: feature_relationshipprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_relationshipprop
+ ADD CONSTRAINT feature_relationshipprop_c1 UNIQUE (feature_relationship_id, type_id, rank);
+
+
+--
+-- Name: feature_relationshipprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_relationshipprop
+ ADD CONSTRAINT feature_relationshipprop_pkey PRIMARY KEY (feature_relationshipprop_id);
+
+
+--
+-- Name: feature_relationshipprop_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_relationshipprop_pub
+ ADD CONSTRAINT feature_relationshipprop_pub_c1 UNIQUE (feature_relationshipprop_id, pub_id);
+
+
+--
+-- Name: feature_relationshipprop_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_relationshipprop_pub
+ ADD CONSTRAINT feature_relationshipprop_pub_pkey PRIMARY KEY (feature_relationshipprop_pub_id);
+
+
+--
+-- Name: feature_stock_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_stock
+ ADD CONSTRAINT feature_stock_pkey PRIMARY KEY (feature_stock_id);
+
+
+--
+-- Name: feature_synonym_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_synonym
+ ADD CONSTRAINT feature_synonym_c1 UNIQUE (synonym_id, feature_id, pub_id);
+
+
+--
+-- Name: feature_synonym_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY feature_synonym
+ ADD CONSTRAINT feature_synonym_pkey PRIMARY KEY (feature_synonym_id);
+
+
+--
+-- Name: featureloc_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featureloc
+ ADD CONSTRAINT featureloc_c1 UNIQUE (feature_id, locgroup, rank);
+
+
+--
+-- Name: featureloc_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featureloc
+ ADD CONSTRAINT featureloc_pkey PRIMARY KEY (featureloc_id);
+
+
+--
+-- Name: featureloc_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featureloc_pub
+ ADD CONSTRAINT featureloc_pub_c1 UNIQUE (featureloc_id, pub_id);
+
+
+--
+-- Name: featureloc_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featureloc_pub
+ ADD CONSTRAINT featureloc_pub_pkey PRIMARY KEY (featureloc_pub_id);
+
+
+--
+-- Name: featuremap_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremap
+ ADD CONSTRAINT featuremap_c1 UNIQUE (name);
+
+
+--
+-- Name: featuremap_contact_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremap_contact
+ ADD CONSTRAINT featuremap_contact_c1 UNIQUE (featuremap_id, contact_id);
+
+
+--
+-- Name: featuremap_contact_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremap_contact
+ ADD CONSTRAINT featuremap_contact_pkey PRIMARY KEY (featuremap_contact_id);
+
+
+--
+-- Name: featuremap_dbxref_featuremap_dbxref_c1_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremap_dbxref
+ ADD CONSTRAINT featuremap_dbxref_featuremap_dbxref_c1_key UNIQUE (featuremap_id, dbxref_id);
+
+
+--
+-- Name: featuremap_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremap_dbxref
+ ADD CONSTRAINT featuremap_dbxref_pkey PRIMARY KEY (featuremap_dbxref_id);
+
+
+--
+-- Name: featuremap_organism_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremap_organism
+ ADD CONSTRAINT featuremap_organism_c1 UNIQUE (featuremap_id, organism_id);
+
+
+--
+-- Name: featuremap_organism_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremap_organism
+ ADD CONSTRAINT featuremap_organism_pkey PRIMARY KEY (featuremap_organism_id);
+
+
+--
+-- Name: featuremap_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremap
+ ADD CONSTRAINT featuremap_pkey PRIMARY KEY (featuremap_id);
+
+
+--
+-- Name: featuremap_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremap_pub
+ ADD CONSTRAINT featuremap_pub_pkey PRIMARY KEY (featuremap_pub_id);
+
+
+--
+-- Name: featuremap_stock_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremap_stock
+ ADD CONSTRAINT featuremap_stock_c1 UNIQUE (featuremap_id, stock_id);
+
+
+--
+-- Name: featuremap_stock_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremap_stock
+ ADD CONSTRAINT featuremap_stock_pkey PRIMARY KEY (featuremap_stock_id);
+
+
+--
+-- Name: featuremapprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremapprop
+ ADD CONSTRAINT featuremapprop_c1 UNIQUE (featuremap_id, type_id, rank);
+
+
+--
+-- Name: featuremapprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featuremapprop
+ ADD CONSTRAINT featuremapprop_pkey PRIMARY KEY (featuremapprop_id);
+
+
+--
+-- Name: featurepos_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featurepos
+ ADD CONSTRAINT featurepos_pkey PRIMARY KEY (featurepos_id);
+
+
+--
+-- Name: featureposprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featureposprop
+ ADD CONSTRAINT featureposprop_pkey PRIMARY KEY (featureposprop_id);
+
+
+--
+-- Name: featureprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featureprop
+ ADD CONSTRAINT featureprop_c1 UNIQUE (feature_id, type_id, rank);
+
+
+--
+-- Name: featureprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featureprop
+ ADD CONSTRAINT featureprop_pkey PRIMARY KEY (featureprop_id);
+
+
+--
+-- Name: featureprop_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featureprop_pub
+ ADD CONSTRAINT featureprop_pub_c1 UNIQUE (featureprop_id, pub_id);
+
+
+--
+-- Name: featureprop_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featureprop_pub
+ ADD CONSTRAINT featureprop_pub_pkey PRIMARY KEY (featureprop_pub_id);
+
+
+--
+-- Name: featurerange_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY featurerange
+ ADD CONSTRAINT featurerange_pkey PRIMARY KEY (featurerange_id);
+
+
+--
+-- Name: genotype_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY genotype
+ ADD CONSTRAINT genotype_c1 UNIQUE (uniquename);
+
+
+--
+-- Name: genotype_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY genotype
+ ADD CONSTRAINT genotype_pkey PRIMARY KEY (genotype_id);
+
+
+--
+-- Name: genotypeprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY genotypeprop
+ ADD CONSTRAINT genotypeprop_c1 UNIQUE (genotype_id, type_id, rank);
+
+
+--
+-- Name: genotypeprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY genotypeprop
+ ADD CONSTRAINT genotypeprop_pkey PRIMARY KEY (genotypeprop_id);
+
+
+--
+-- Name: library_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library
+ ADD CONSTRAINT library_c1 UNIQUE (organism_id, uniquename, type_id);
+
+
+--
+-- Name: library_contact_library_contact_c1_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_contact
+ ADD CONSTRAINT library_contact_library_contact_c1_key UNIQUE (library_id, contact_id);
+
+
+--
+-- Name: library_contact_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_contact
+ ADD CONSTRAINT library_contact_pkey PRIMARY KEY (library_contact_id);
+
+
+--
+-- Name: library_cvterm_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_cvterm
+ ADD CONSTRAINT library_cvterm_c1 UNIQUE (library_id, cvterm_id, pub_id);
+
+
+--
+-- Name: library_cvterm_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_cvterm
+ ADD CONSTRAINT library_cvterm_pkey PRIMARY KEY (library_cvterm_id);
+
+
+--
+-- Name: library_dbxref_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_dbxref
+ ADD CONSTRAINT library_dbxref_c1 UNIQUE (library_id, dbxref_id);
+
+
+--
+-- Name: library_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_dbxref
+ ADD CONSTRAINT library_dbxref_pkey PRIMARY KEY (library_dbxref_id);
+
+
+--
+-- Name: library_feature_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_feature
+ ADD CONSTRAINT library_feature_c1 UNIQUE (library_id, feature_id);
+
+
+--
+-- Name: library_feature_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_feature
+ ADD CONSTRAINT library_feature_pkey PRIMARY KEY (library_feature_id);
+
+
+--
+-- Name: library_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library
+ ADD CONSTRAINT library_pkey PRIMARY KEY (library_id);
+
+
+--
+-- Name: library_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_pub
+ ADD CONSTRAINT library_pub_c1 UNIQUE (library_id, pub_id);
+
+
+--
+-- Name: library_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_pub
+ ADD CONSTRAINT library_pub_pkey PRIMARY KEY (library_pub_id);
+
+
+--
+-- Name: library_stock_library_stock_c1_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_stock
+ ADD CONSTRAINT library_stock_library_stock_c1_key UNIQUE (library_id, stock_id);
+
+
+--
+-- Name: library_stock_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_stock
+ ADD CONSTRAINT library_stock_pkey PRIMARY KEY (library_stock_id);
+
+
+--
+-- Name: library_synonym_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_synonym
+ ADD CONSTRAINT library_synonym_c1 UNIQUE (synonym_id, library_id, pub_id);
+
+
+--
+-- Name: library_synonym_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY library_synonym
+ ADD CONSTRAINT library_synonym_pkey PRIMARY KEY (library_synonym_id);
+
+
+--
+-- Name: libraryprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY libraryprop
+ ADD CONSTRAINT libraryprop_c1 UNIQUE (library_id, type_id, rank);
+
+
+--
+-- Name: libraryprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY libraryprop
+ ADD CONSTRAINT libraryprop_pkey PRIMARY KEY (libraryprop_id);
+
+
+--
+-- Name: libraryprop_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY libraryprop_pub
+ ADD CONSTRAINT libraryprop_pub_c1 UNIQUE (libraryprop_id, pub_id);
+
+
+--
+-- Name: libraryprop_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY libraryprop_pub
+ ADD CONSTRAINT libraryprop_pub_pkey PRIMARY KEY (libraryprop_pub_id);
+
+
+--
+-- Name: magedocumentation_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY magedocumentation
+ ADD CONSTRAINT magedocumentation_pkey PRIMARY KEY (magedocumentation_id);
+
+
+--
+-- Name: mageml_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY mageml
+ ADD CONSTRAINT mageml_pkey PRIMARY KEY (mageml_id);
+
+
+--
+-- Name: materialized_view_name_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY materialized_view
+ ADD CONSTRAINT materialized_view_name_key UNIQUE (name);
+
+
+--
+-- Name: nd_experiment_contact_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_contact
+ ADD CONSTRAINT nd_experiment_contact_pkey PRIMARY KEY (nd_experiment_contact_id);
+
+
+--
+-- Name: nd_experiment_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_dbxref
+ ADD CONSTRAINT nd_experiment_dbxref_pkey PRIMARY KEY (nd_experiment_dbxref_id);
+
+
+--
+-- Name: nd_experiment_genotype_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_genotype
+ ADD CONSTRAINT nd_experiment_genotype_c1 UNIQUE (nd_experiment_id, genotype_id);
+
+
+--
+-- Name: nd_experiment_genotype_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_genotype
+ ADD CONSTRAINT nd_experiment_genotype_pkey PRIMARY KEY (nd_experiment_genotype_id);
+
+
+--
+-- Name: nd_experiment_phenotype_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_phenotype
+ ADD CONSTRAINT nd_experiment_phenotype_c1 UNIQUE (nd_experiment_id, phenotype_id);
+
+
+--
+-- Name: nd_experiment_phenotype_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_phenotype
+ ADD CONSTRAINT nd_experiment_phenotype_pkey PRIMARY KEY (nd_experiment_phenotype_id);
+
+
+--
+-- Name: nd_experiment_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment
+ ADD CONSTRAINT nd_experiment_pkey PRIMARY KEY (nd_experiment_id);
+
+
+--
+-- Name: nd_experiment_project_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_project
+ ADD CONSTRAINT nd_experiment_project_pkey PRIMARY KEY (nd_experiment_project_id);
+
+
+--
+-- Name: nd_experiment_protocol_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_protocol
+ ADD CONSTRAINT nd_experiment_protocol_pkey PRIMARY KEY (nd_experiment_protocol_id);
+
+
+--
+-- Name: nd_experiment_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_pub
+ ADD CONSTRAINT nd_experiment_pub_c1 UNIQUE (nd_experiment_id, pub_id);
+
+
+--
+-- Name: nd_experiment_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_pub
+ ADD CONSTRAINT nd_experiment_pub_pkey PRIMARY KEY (nd_experiment_pub_id);
+
+
+--
+-- Name: nd_experiment_stock_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_stock_dbxref
+ ADD CONSTRAINT nd_experiment_stock_dbxref_pkey PRIMARY KEY (nd_experiment_stock_dbxref_id);
+
+
+--
+-- Name: nd_experiment_stock_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_stock
+ ADD CONSTRAINT nd_experiment_stock_pkey PRIMARY KEY (nd_experiment_stock_id);
+
+
+--
+-- Name: nd_experiment_stockprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_stockprop
+ ADD CONSTRAINT nd_experiment_stockprop_c1 UNIQUE (nd_experiment_stock_id, type_id, rank);
+
+
+--
+-- Name: nd_experiment_stockprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experiment_stockprop
+ ADD CONSTRAINT nd_experiment_stockprop_pkey PRIMARY KEY (nd_experiment_stockprop_id);
+
+
+--
+-- Name: nd_experimentprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experimentprop
+ ADD CONSTRAINT nd_experimentprop_c1 UNIQUE (nd_experiment_id, type_id, rank);
+
+
+--
+-- Name: nd_experimentprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_experimentprop
+ ADD CONSTRAINT nd_experimentprop_pkey PRIMARY KEY (nd_experimentprop_id);
+
+
+--
+-- Name: nd_geolocation_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_geolocation
+ ADD CONSTRAINT nd_geolocation_pkey PRIMARY KEY (nd_geolocation_id);
+
+
+--
+-- Name: nd_geolocationprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_geolocationprop
+ ADD CONSTRAINT nd_geolocationprop_c1 UNIQUE (nd_geolocation_id, type_id, rank);
+
+
+--
+-- Name: nd_geolocationprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_geolocationprop
+ ADD CONSTRAINT nd_geolocationprop_pkey PRIMARY KEY (nd_geolocationprop_id);
+
+
+--
+-- Name: nd_protocol_name_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_protocol
+ ADD CONSTRAINT nd_protocol_name_key UNIQUE (name);
+
+
+--
+-- Name: nd_protocol_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_protocol
+ ADD CONSTRAINT nd_protocol_pkey PRIMARY KEY (nd_protocol_id);
+
+
+--
+-- Name: nd_protocol_reagent_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_protocol_reagent
+ ADD CONSTRAINT nd_protocol_reagent_pkey PRIMARY KEY (nd_protocol_reagent_id);
+
+
+--
+-- Name: nd_protocolprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_protocolprop
+ ADD CONSTRAINT nd_protocolprop_c1 UNIQUE (nd_protocol_id, type_id, rank);
+
+
+--
+-- Name: nd_protocolprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_protocolprop
+ ADD CONSTRAINT nd_protocolprop_pkey PRIMARY KEY (nd_protocolprop_id);
+
+
+--
+-- Name: nd_reagent_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_reagent
+ ADD CONSTRAINT nd_reagent_pkey PRIMARY KEY (nd_reagent_id);
+
+
+--
+-- Name: nd_reagent_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_reagent_relationship
+ ADD CONSTRAINT nd_reagent_relationship_pkey PRIMARY KEY (nd_reagent_relationship_id);
+
+
+--
+-- Name: nd_reagentprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_reagentprop
+ ADD CONSTRAINT nd_reagentprop_c1 UNIQUE (nd_reagent_id, type_id, rank);
+
+
+--
+-- Name: nd_reagentprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY nd_reagentprop
+ ADD CONSTRAINT nd_reagentprop_pkey PRIMARY KEY (nd_reagentprop_id);
+
+
+--
+-- Name: organism_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY organism
+ ADD CONSTRAINT organism_c1 UNIQUE (genus, species);
+
+
+--
+-- Name: organism_dbxref_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY organism_dbxref
+ ADD CONSTRAINT organism_dbxref_c1 UNIQUE (organism_id, dbxref_id);
+
+
+--
+-- Name: organism_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY organism_dbxref
+ ADD CONSTRAINT organism_dbxref_pkey PRIMARY KEY (organism_dbxref_id);
+
+
+--
+-- Name: organism_image_organism_id_eimage_id_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY organism_image
+ ADD CONSTRAINT organism_image_organism_id_eimage_id_key UNIQUE (organism_id, eimage_id);
+
+
+--
+-- Name: organism_image_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY organism_image
+ ADD CONSTRAINT organism_image_pkey PRIMARY KEY (organism_image_id);
+
+
+--
+-- Name: organism_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY organism
+ ADD CONSTRAINT organism_pkey PRIMARY KEY (organism_id);
+
+
+--
+-- Name: organism_pub_organism_id_pub_id_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY organism_pub
+ ADD CONSTRAINT organism_pub_organism_id_pub_id_key UNIQUE (organism_id, pub_id);
+
+
+--
+-- Name: organism_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY organism_pub
+ ADD CONSTRAINT organism_pub_pkey PRIMARY KEY (organism_pub_id);
+
+
+--
+-- Name: organism_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY organism_relationship
+ ADD CONSTRAINT organism_relationship_pkey PRIMARY KEY (organism_relationship_id);
+
+
+--
+-- Name: organismprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY organismprop
+ ADD CONSTRAINT organismprop_c1 UNIQUE (organism_id, type_id, rank);
+
+
+--
+-- Name: organismprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY organismprop
+ ADD CONSTRAINT organismprop_pkey PRIMARY KEY (organismprop_id);
+
+
+--
+-- Name: phendesc_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phendesc
+ ADD CONSTRAINT phendesc_c1 UNIQUE (genotype_id, environment_id, type_id, pub_id);
+
+
+--
+-- Name: phendesc_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phendesc
+ ADD CONSTRAINT phendesc_pkey PRIMARY KEY (phendesc_id);
+
+
+--
+-- Name: phenotype_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenotype
+ ADD CONSTRAINT phenotype_c1 UNIQUE (uniquename);
+
+
+--
+-- Name: phenotype_comparison_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenotype_comparison
+ ADD CONSTRAINT phenotype_comparison_c1 UNIQUE (genotype1_id, environment1_id, genotype2_id, environment2_id, phenotype1_id, pub_id);
+
+
+--
+-- Name: phenotype_comparison_cvterm_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenotype_comparison_cvterm
+ ADD CONSTRAINT phenotype_comparison_cvterm_c1 UNIQUE (phenotype_comparison_id, cvterm_id);
+
+
+--
+-- Name: phenotype_comparison_cvterm_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenotype_comparison_cvterm
+ ADD CONSTRAINT phenotype_comparison_cvterm_pkey PRIMARY KEY (phenotype_comparison_cvterm_id);
+
+
+--
+-- Name: phenotype_comparison_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenotype_comparison
+ ADD CONSTRAINT phenotype_comparison_pkey PRIMARY KEY (phenotype_comparison_id);
+
+
+--
+-- Name: phenotype_cvterm_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenotype_cvterm
+ ADD CONSTRAINT phenotype_cvterm_c1 UNIQUE (phenotype_id, cvterm_id, rank);
+
+
+--
+-- Name: phenotype_cvterm_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenotype_cvterm
+ ADD CONSTRAINT phenotype_cvterm_pkey PRIMARY KEY (phenotype_cvterm_id);
+
+
+--
+-- Name: phenotype_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenotype
+ ADD CONSTRAINT phenotype_pkey PRIMARY KEY (phenotype_id);
+
+
+--
+-- Name: phenstatement_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenstatement
+ ADD CONSTRAINT phenstatement_c1 UNIQUE (genotype_id, phenotype_id, environment_id, type_id, pub_id);
+
+
+--
+-- Name: phenstatement_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenstatement
+ ADD CONSTRAINT phenstatement_pkey PRIMARY KEY (phenstatement_id);
+
+
+--
+-- Name: phenstatementprop_phenstatement_id_type_id_rank_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenstatementprop
+ ADD CONSTRAINT phenstatementprop_phenstatement_id_type_id_rank_key UNIQUE (phenstatement_id, type_id, rank);
+
+
+--
+-- Name: phenstatementprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phenstatementprop
+ ADD CONSTRAINT phenstatementprop_pkey PRIMARY KEY (phenstatementprop_id);
+
+
+--
+-- Name: phylonode_dbxref_phylonode_id_dbxref_id_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonode_dbxref
+ ADD CONSTRAINT phylonode_dbxref_phylonode_id_dbxref_id_key UNIQUE (phylonode_id, dbxref_id);
+
+
+--
+-- Name: phylonode_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonode_dbxref
+ ADD CONSTRAINT phylonode_dbxref_pkey PRIMARY KEY (phylonode_dbxref_id);
+
+
+--
+-- Name: phylonode_organism_phylonode_id_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonode_organism
+ ADD CONSTRAINT phylonode_organism_phylonode_id_key UNIQUE (phylonode_id);
+
+
+--
+-- Name: phylonode_organism_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonode_organism
+ ADD CONSTRAINT phylonode_organism_pkey PRIMARY KEY (phylonode_organism_id);
+
+
+--
+-- Name: phylonode_phylotree_id_left_idx_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonode
+ ADD CONSTRAINT phylonode_phylotree_id_left_idx_key UNIQUE (phylotree_id, left_idx);
+
+
+--
+-- Name: phylonode_phylotree_id_right_idx_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonode
+ ADD CONSTRAINT phylonode_phylotree_id_right_idx_key UNIQUE (phylotree_id, right_idx);
+
+
+--
+-- Name: phylonode_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonode
+ ADD CONSTRAINT phylonode_pkey PRIMARY KEY (phylonode_id);
+
+
+--
+-- Name: phylonode_pub_phylonode_id_pub_id_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonode_pub
+ ADD CONSTRAINT phylonode_pub_phylonode_id_pub_id_key UNIQUE (phylonode_id, pub_id);
+
+
+--
+-- Name: phylonode_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonode_pub
+ ADD CONSTRAINT phylonode_pub_pkey PRIMARY KEY (phylonode_pub_id);
+
+
+--
+-- Name: phylonode_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonode_relationship
+ ADD CONSTRAINT phylonode_relationship_pkey PRIMARY KEY (phylonode_relationship_id);
+
+
+--
+-- Name: phylonode_relationship_subject_id_object_id_type_id_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonode_relationship
+ ADD CONSTRAINT phylonode_relationship_subject_id_object_id_type_id_key UNIQUE (subject_id, object_id, type_id);
+
+
+--
+-- Name: phylonodeprop_phylonode_id_type_id_value_rank_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonodeprop
+ ADD CONSTRAINT phylonodeprop_phylonode_id_type_id_value_rank_key UNIQUE (phylonode_id, type_id, value, rank);
+
+
+--
+-- Name: phylonodeprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylonodeprop
+ ADD CONSTRAINT phylonodeprop_pkey PRIMARY KEY (phylonodeprop_id);
+
+
+--
+-- Name: phylotree_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylotree
+ ADD CONSTRAINT phylotree_pkey PRIMARY KEY (phylotree_id);
+
+
+--
+-- Name: phylotree_pub_phylotree_id_pub_id_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylotree_pub
+ ADD CONSTRAINT phylotree_pub_phylotree_id_pub_id_key UNIQUE (phylotree_id, pub_id);
+
+
+--
+-- Name: phylotree_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY phylotree_pub
+ ADD CONSTRAINT phylotree_pub_pkey PRIMARY KEY (phylotree_pub_id);
+
+
+--
+-- Name: project_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY project
+ ADD CONSTRAINT project_c1 UNIQUE (name);
+
+
+--
+-- Name: project_contact_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY project_contact
+ ADD CONSTRAINT project_contact_c1 UNIQUE (project_id, contact_id);
+
+
+--
+-- Name: project_contact_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY project_contact
+ ADD CONSTRAINT project_contact_pkey PRIMARY KEY (project_contact_id);
+
+
+--
+-- Name: project_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY project
+ ADD CONSTRAINT project_pkey PRIMARY KEY (project_id);
+
+
+--
+-- Name: project_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY project_pub
+ ADD CONSTRAINT project_pub_c1 UNIQUE (project_id, pub_id);
+
+
+--
+-- Name: project_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY project_pub
+ ADD CONSTRAINT project_pub_pkey PRIMARY KEY (project_pub_id);
+
+
+--
+-- Name: project_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY project_relationship
+ ADD CONSTRAINT project_relationship_c1 UNIQUE (subject_project_id, object_project_id, type_id);
+
+
+--
+-- Name: project_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY project_relationship
+ ADD CONSTRAINT project_relationship_pkey PRIMARY KEY (project_relationship_id);
+
+
+--
+-- Name: projectprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY projectprop
+ ADD CONSTRAINT projectprop_c1 UNIQUE (project_id, type_id, rank);
+
+
+--
+-- Name: projectprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY projectprop
+ ADD CONSTRAINT projectprop_pkey PRIMARY KEY (projectprop_id);
+
+
+--
+-- Name: protocol_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY protocol
+ ADD CONSTRAINT protocol_c1 UNIQUE (name);
+
+
+--
+-- Name: protocol_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY protocol
+ ADD CONSTRAINT protocol_pkey PRIMARY KEY (protocol_id);
+
+
+--
+-- Name: protocolparam_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY protocolparam
+ ADD CONSTRAINT protocolparam_pkey PRIMARY KEY (protocolparam_id);
+
+
+--
+-- Name: pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pub
+ ADD CONSTRAINT pub_c1 UNIQUE (uniquename);
+
+
+--
+-- Name: pub_dbxref_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pub_dbxref
+ ADD CONSTRAINT pub_dbxref_c1 UNIQUE (pub_id, dbxref_id);
+
+
+--
+-- Name: pub_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pub_dbxref
+ ADD CONSTRAINT pub_dbxref_pkey PRIMARY KEY (pub_dbxref_id);
+
+
+--
+-- Name: pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pub
+ ADD CONSTRAINT pub_pkey PRIMARY KEY (pub_id);
+
+
+--
+-- Name: pub_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pub_relationship
+ ADD CONSTRAINT pub_relationship_c1 UNIQUE (subject_id, object_id, type_id);
+
+
+--
+-- Name: pub_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pub_relationship
+ ADD CONSTRAINT pub_relationship_pkey PRIMARY KEY (pub_relationship_id);
+
+
+--
+-- Name: pubauthor_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pubauthor
+ ADD CONSTRAINT pubauthor_c1 UNIQUE (pub_id, rank);
+
+
+--
+-- Name: pubauthor_contact_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pubauthor_contact
+ ADD CONSTRAINT pubauthor_contact_pkey PRIMARY KEY (pubauthor_contact_id);
+
+
+--
+-- Name: pubauthor_contact_pubauthor_contact_c1_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pubauthor_contact
+ ADD CONSTRAINT pubauthor_contact_pubauthor_contact_c1_key UNIQUE (contact_id, pubauthor_id);
+
+
+--
+-- Name: pubauthor_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pubauthor
+ ADD CONSTRAINT pubauthor_pkey PRIMARY KEY (pubauthor_id);
+
+
+--
+-- Name: pubprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pubprop
+ ADD CONSTRAINT pubprop_c1 UNIQUE (pub_id, type_id, rank);
+
+
+--
+-- Name: pubprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY pubprop
+ ADD CONSTRAINT pubprop_pkey PRIMARY KEY (pubprop_id);
+
+
+--
+-- Name: quantification_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY quantification
+ ADD CONSTRAINT quantification_c1 UNIQUE (name, analysis_id);
+
+
+--
+-- Name: quantification_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY quantification
+ ADD CONSTRAINT quantification_pkey PRIMARY KEY (quantification_id);
+
+
+--
+-- Name: quantification_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY quantification_relationship
+ ADD CONSTRAINT quantification_relationship_c1 UNIQUE (subject_id, object_id, type_id);
+
+
+--
+-- Name: quantification_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY quantification_relationship
+ ADD CONSTRAINT quantification_relationship_pkey PRIMARY KEY (quantification_relationship_id);
+
+
+--
+-- Name: quantificationprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY quantificationprop
+ ADD CONSTRAINT quantificationprop_c1 UNIQUE (quantification_id, type_id, rank);
+
+
+--
+-- Name: quantificationprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY quantificationprop
+ ADD CONSTRAINT quantificationprop_pkey PRIMARY KEY (quantificationprop_id);
+
+
+--
+-- Name: stock_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock
+ ADD CONSTRAINT stock_c1 UNIQUE (organism_id, uniquename, type_id);
+
+
+--
+-- Name: stock_cvterm_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_cvterm
+ ADD CONSTRAINT stock_cvterm_c1 UNIQUE (stock_id, cvterm_id, pub_id, rank);
+
+
+--
+-- Name: stock_cvterm_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_cvterm
+ ADD CONSTRAINT stock_cvterm_pkey PRIMARY KEY (stock_cvterm_id);
+
+
+--
+-- Name: stock_cvtermprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_cvtermprop
+ ADD CONSTRAINT stock_cvtermprop_c1 UNIQUE (stock_cvterm_id, type_id, rank);
+
+
+--
+-- Name: stock_cvtermprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_cvtermprop
+ ADD CONSTRAINT stock_cvtermprop_pkey PRIMARY KEY (stock_cvtermprop_id);
+
+
+--
+-- Name: stock_dbxref_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_dbxref
+ ADD CONSTRAINT stock_dbxref_c1 UNIQUE (stock_id, dbxref_id);
+
+
+--
+-- Name: stock_dbxref_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_dbxref
+ ADD CONSTRAINT stock_dbxref_pkey PRIMARY KEY (stock_dbxref_id);
+
+
+--
+-- Name: stock_dbxrefprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_dbxrefprop
+ ADD CONSTRAINT stock_dbxrefprop_c1 UNIQUE (stock_dbxref_id, type_id, rank);
+
+
+--
+-- Name: stock_dbxrefprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_dbxrefprop
+ ADD CONSTRAINT stock_dbxrefprop_pkey PRIMARY KEY (stock_dbxrefprop_id);
+
+
+--
+-- Name: stock_genotype_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_genotype
+ ADD CONSTRAINT stock_genotype_c1 UNIQUE (stock_id, genotype_id);
+
+
+--
+-- Name: stock_genotype_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_genotype
+ ADD CONSTRAINT stock_genotype_pkey PRIMARY KEY (stock_genotype_id);
+
+
+--
+-- Name: stock_image_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_image
+ ADD CONSTRAINT stock_image_pkey PRIMARY KEY (stock_image_id);
+
+
+--
+-- Name: stock_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock
+ ADD CONSTRAINT stock_pkey PRIMARY KEY (stock_id);
+
+
+--
+-- Name: stock_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_pub
+ ADD CONSTRAINT stock_pub_c1 UNIQUE (stock_id, pub_id);
+
+
+--
+-- Name: stock_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_pub
+ ADD CONSTRAINT stock_pub_pkey PRIMARY KEY (stock_pub_id);
+
+
+--
+-- Name: stock_relationship_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_relationship
+ ADD CONSTRAINT stock_relationship_c1 UNIQUE (subject_id, object_id, type_id, rank);
+
+
+--
+-- Name: stock_relationship_cvterm_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_relationship_cvterm
+ ADD CONSTRAINT stock_relationship_cvterm_pkey PRIMARY KEY (stock_relationship_cvterm_id);
+
+
+--
+-- Name: stock_relationship_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_relationship
+ ADD CONSTRAINT stock_relationship_pkey PRIMARY KEY (stock_relationship_id);
+
+
+--
+-- Name: stock_relationship_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_relationship_pub
+ ADD CONSTRAINT stock_relationship_pub_c1 UNIQUE (stock_relationship_id, pub_id);
+
+
+--
+-- Name: stock_relationship_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stock_relationship_pub
+ ADD CONSTRAINT stock_relationship_pub_pkey PRIMARY KEY (stock_relationship_pub_id);
+
+
+--
+-- Name: stockcollection_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stockcollection
+ ADD CONSTRAINT stockcollection_c1 UNIQUE (uniquename, type_id);
+
+
+--
+-- Name: stockcollection_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stockcollection
+ ADD CONSTRAINT stockcollection_pkey PRIMARY KEY (stockcollection_id);
+
+
+--
+-- Name: stockcollection_stock_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stockcollection_stock
+ ADD CONSTRAINT stockcollection_stock_c1 UNIQUE (stockcollection_id, stock_id);
+
+
+--
+-- Name: stockcollection_stock_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stockcollection_stock
+ ADD CONSTRAINT stockcollection_stock_pkey PRIMARY KEY (stockcollection_stock_id);
+
+
+--
+-- Name: stockcollectionprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stockcollectionprop
+ ADD CONSTRAINT stockcollectionprop_c1 UNIQUE (stockcollection_id, type_id, rank);
+
+
+--
+-- Name: stockcollectionprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stockcollectionprop
+ ADD CONSTRAINT stockcollectionprop_pkey PRIMARY KEY (stockcollectionprop_id);
+
+
+--
+-- Name: stockprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stockprop
+ ADD CONSTRAINT stockprop_c1 UNIQUE (stock_id, type_id, rank);
+
+
+--
+-- Name: stockprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stockprop
+ ADD CONSTRAINT stockprop_pkey PRIMARY KEY (stockprop_id);
+
+
+--
+-- Name: stockprop_pub_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stockprop_pub
+ ADD CONSTRAINT stockprop_pub_c1 UNIQUE (stockprop_id, pub_id);
+
+
+--
+-- Name: stockprop_pub_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY stockprop_pub
+ ADD CONSTRAINT stockprop_pub_pkey PRIMARY KEY (stockprop_pub_id);
+
+
+--
+-- Name: study_assay_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY study_assay
+ ADD CONSTRAINT study_assay_c1 UNIQUE (study_id, assay_id);
+
+
+--
+-- Name: study_assay_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY study_assay
+ ADD CONSTRAINT study_assay_pkey PRIMARY KEY (study_assay_id);
+
+
+--
+-- Name: study_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY study
+ ADD CONSTRAINT study_c1 UNIQUE (name);
+
+
+--
+-- Name: study_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY study
+ ADD CONSTRAINT study_pkey PRIMARY KEY (study_id);
+
+
+--
+-- Name: studydesign_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY studydesign
+ ADD CONSTRAINT studydesign_pkey PRIMARY KEY (studydesign_id);
+
+
+--
+-- Name: studydesignprop_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY studydesignprop
+ ADD CONSTRAINT studydesignprop_c1 UNIQUE (studydesign_id, type_id, rank);
+
+
+--
+-- Name: studydesignprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY studydesignprop
+ ADD CONSTRAINT studydesignprop_pkey PRIMARY KEY (studydesignprop_id);
+
+
+--
+-- Name: studyfactor_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY studyfactor
+ ADD CONSTRAINT studyfactor_pkey PRIMARY KEY (studyfactor_id);
+
+
+--
+-- Name: studyfactorvalue_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY studyfactorvalue
+ ADD CONSTRAINT studyfactorvalue_pkey PRIMARY KEY (studyfactorvalue_id);
+
+
+--
+-- Name: studyprop_feature_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY studyprop_feature
+ ADD CONSTRAINT studyprop_feature_pkey PRIMARY KEY (studyprop_feature_id);
+
+
+--
+-- Name: studyprop_feature_studyprop_id_feature_id_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY studyprop_feature
+ ADD CONSTRAINT studyprop_feature_studyprop_id_feature_id_key UNIQUE (studyprop_id, feature_id);
+
+
+--
+-- Name: studyprop_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY studyprop
+ ADD CONSTRAINT studyprop_pkey PRIMARY KEY (studyprop_id);
+
+
+--
+-- Name: studyprop_study_id_type_id_rank_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY studyprop
+ ADD CONSTRAINT studyprop_study_id_type_id_rank_key UNIQUE (study_id, type_id, rank);
+
+
+--
+-- Name: synonym_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY synonym
+ ADD CONSTRAINT synonym_c1 UNIQUE (name, type_id);
+
+
+--
+-- Name: synonym_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY synonym
+ ADD CONSTRAINT synonym_pkey PRIMARY KEY (synonym_id);
+
+
+--
+-- Name: tableinfo_c1; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tableinfo
+ ADD CONSTRAINT tableinfo_c1 UNIQUE (name);
+
+
+--
+-- Name: tableinfo_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tableinfo
+ ADD CONSTRAINT tableinfo_pkey PRIMARY KEY (tableinfo_id);
+
+
+--
+-- Name: treatment_pkey; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY treatment
+ ADD CONSTRAINT treatment_pkey PRIMARY KEY (treatment_id);
+
+
+--
+-- Name: tripal_gff_temp_tripal_gff_temp_uq0_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_gff_temp
+ ADD CONSTRAINT tripal_gff_temp_tripal_gff_temp_uq0_key UNIQUE (feature_id);
+
+
+--
+-- Name: tripal_gff_temp_tripal_gff_temp_uq1_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_gff_temp
+ ADD CONSTRAINT tripal_gff_temp_tripal_gff_temp_uq1_key UNIQUE (uniquename, organism_id, type_name);
+
+
+--
+-- Name: tripal_gffprotein_temp_tripal_gff_temp_uq0_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_gffprotein_temp
+ ADD CONSTRAINT tripal_gffprotein_temp_tripal_gff_temp_uq0_key UNIQUE (feature_id);
+
+
+--
+-- Name: tripal_obo_temp_tripal_obo_temp_uq0_key; Type: CONSTRAINT; Schema: chado; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_obo_temp
+ ADD CONSTRAINT tripal_obo_temp_tripal_obo_temp_uq0_key UNIQUE (id);
+
+
+--
+-- Name: acquisition_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX acquisition_idx1 ON acquisition USING btree (assay_id);
+
+
+--
+-- Name: acquisition_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX acquisition_idx2 ON acquisition USING btree (protocol_id);
+
+
+--
+-- Name: acquisition_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX acquisition_idx3 ON acquisition USING btree (channel_id);
+
+
+--
+-- Name: acquisition_relationship_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX acquisition_relationship_idx1 ON acquisition_relationship USING btree (subject_id);
+
+
+--
+-- Name: acquisition_relationship_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX acquisition_relationship_idx2 ON acquisition_relationship USING btree (type_id);
+
+
+--
+-- Name: acquisition_relationship_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX acquisition_relationship_idx3 ON acquisition_relationship USING btree (object_id);
+
+
+--
+-- Name: acquisitionprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX acquisitionprop_idx1 ON acquisitionprop USING btree (acquisition_id);
+
+
+--
+-- Name: acquisitionprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX acquisitionprop_idx2 ON acquisitionprop USING btree (type_id);
+
+
+--
+-- Name: analysis_organism_networkmod_qtl_indx0_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX analysis_organism_networkmod_qtl_indx0_idx ON analysis_organism USING btree (analysis_id);
+
+
+--
+-- Name: analysis_organism_networkmod_qtl_indx1_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX analysis_organism_networkmod_qtl_indx1_idx ON analysis_organism USING btree (organism_id);
+
+
+--
+-- Name: analysisfeatureprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX analysisfeatureprop_idx1 ON analysisfeatureprop USING btree (analysisfeature_id);
+
+
+--
+-- Name: analysisfeatureprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX analysisfeatureprop_idx2 ON analysisfeatureprop USING btree (type_id);
+
+
+--
+-- Name: analysisprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX analysisprop_idx1 ON analysisprop USING btree (analysis_id);
+
+
+--
+-- Name: analysisprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX analysisprop_idx2 ON analysisprop USING btree (type_id);
+
+
+--
+-- Name: arraydesign_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX arraydesign_idx1 ON arraydesign USING btree (manufacturer_id);
+
+
+--
+-- Name: arraydesign_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX arraydesign_idx2 ON arraydesign USING btree (platformtype_id);
+
+
+--
+-- Name: arraydesign_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX arraydesign_idx3 ON arraydesign USING btree (substratetype_id);
+
+
+--
+-- Name: arraydesign_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX arraydesign_idx4 ON arraydesign USING btree (protocol_id);
+
+
+--
+-- Name: arraydesign_idx5; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX arraydesign_idx5 ON arraydesign USING btree (dbxref_id);
+
+
+--
+-- Name: arraydesignprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX arraydesignprop_idx1 ON arraydesignprop USING btree (arraydesign_id);
+
+
+--
+-- Name: arraydesignprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX arraydesignprop_idx2 ON arraydesignprop USING btree (type_id);
+
+
+--
+-- Name: assay_biomaterial_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX assay_biomaterial_idx1 ON assay_biomaterial USING btree (assay_id);
+
+
+--
+-- Name: assay_biomaterial_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX assay_biomaterial_idx2 ON assay_biomaterial USING btree (biomaterial_id);
+
+
+--
+-- Name: assay_biomaterial_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX assay_biomaterial_idx3 ON assay_biomaterial USING btree (channel_id);
+
+
+--
+-- Name: assay_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX assay_idx1 ON assay USING btree (arraydesign_id);
+
+
+--
+-- Name: assay_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX assay_idx2 ON assay USING btree (protocol_id);
+
+
+--
+-- Name: assay_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX assay_idx3 ON assay USING btree (operator_id);
+
+
+--
+-- Name: assay_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX assay_idx4 ON assay USING btree (dbxref_id);
+
+
+--
+-- Name: assay_project_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX assay_project_idx1 ON assay_project USING btree (assay_id);
+
+
+--
+-- Name: assay_project_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX assay_project_idx2 ON assay_project USING btree (project_id);
+
+
+--
+-- Name: assayprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX assayprop_idx1 ON assayprop USING btree (assay_id);
+
+
+--
+-- Name: assayprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX assayprop_idx2 ON assayprop USING btree (type_id);
+
+
+--
+-- Name: binloc_boxrange; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX binloc_boxrange ON featureloc USING gist (boxrange(fmin, fmax));
+
+
+--
+-- Name: binloc_boxrange_src; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX binloc_boxrange_src ON featureloc USING gist (boxrange(srcfeature_id, fmin, fmax));
+
+
+--
+-- Name: biomaterial_dbxref_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterial_dbxref_idx1 ON biomaterial_dbxref USING btree (biomaterial_id);
+
+
+--
+-- Name: biomaterial_dbxref_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterial_dbxref_idx2 ON biomaterial_dbxref USING btree (dbxref_id);
+
+
+--
+-- Name: biomaterial_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterial_idx1 ON biomaterial USING btree (taxon_id);
+
+
+--
+-- Name: biomaterial_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterial_idx2 ON biomaterial USING btree (biosourceprovider_id);
+
+
+--
+-- Name: biomaterial_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterial_idx3 ON biomaterial USING btree (dbxref_id);
+
+
+--
+-- Name: biomaterial_relationship_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterial_relationship_idx1 ON biomaterial_relationship USING btree (subject_id);
+
+
+--
+-- Name: biomaterial_relationship_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterial_relationship_idx2 ON biomaterial_relationship USING btree (object_id);
+
+
+--
+-- Name: biomaterial_relationship_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterial_relationship_idx3 ON biomaterial_relationship USING btree (type_id);
+
+
+--
+-- Name: biomaterial_treatment_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterial_treatment_idx1 ON biomaterial_treatment USING btree (biomaterial_id);
+
+
+--
+-- Name: biomaterial_treatment_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterial_treatment_idx2 ON biomaterial_treatment USING btree (treatment_id);
+
+
+--
+-- Name: biomaterial_treatment_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterial_treatment_idx3 ON biomaterial_treatment USING btree (unittype_id);
+
+
+--
+-- Name: biomaterialprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterialprop_idx1 ON biomaterialprop USING btree (biomaterial_id);
+
+
+--
+-- Name: biomaterialprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX biomaterialprop_idx2 ON biomaterialprop USING btree (type_id);
+
+
+--
+-- Name: blast_hit_data_analysis_id_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX blast_hit_data_analysis_id_idx ON blast_hit_data USING btree (analysis_id);
+
+
+--
+-- Name: blast_hit_data_analysisfeature_id_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX blast_hit_data_analysisfeature_id_idx ON blast_hit_data USING btree (analysisfeature_id);
+
+
+--
+-- Name: blast_hit_data_blast_org_id_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX blast_hit_data_blast_org_id_idx ON blast_hit_data USING btree (blast_org_id);
+
+
+--
+-- Name: blast_hit_data_db_id_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX blast_hit_data_db_id_idx ON blast_hit_data USING btree (db_id);
+
+
+--
+-- Name: blast_hit_data_feature_id_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX blast_hit_data_feature_id_idx ON blast_hit_data USING btree (feature_id);
+
+
+--
+-- Name: blast_hit_data_hit_accession_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX blast_hit_data_hit_accession_idx ON blast_hit_data USING btree (hit_accession);
+
+
+--
+-- Name: blast_hit_data_hit_best_eval_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX blast_hit_data_hit_best_eval_idx ON blast_hit_data USING btree (hit_best_eval);
+
+
+--
+-- Name: blast_hit_data_hit_name_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX blast_hit_data_hit_name_idx ON blast_hit_data USING btree (hit_organism);
+
+
+--
+-- Name: blast_hit_data_hit_organism_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX blast_hit_data_hit_organism_idx ON blast_hit_data USING btree (hit_organism);
+
+
+--
+-- Name: blast_organisms_blast_org_name_idx_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX blast_organisms_blast_org_name_idx_idx ON blast_organisms USING btree (blast_org_name);
+
+
+--
+-- Name: contact_relationship_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX contact_relationship_idx1 ON contact_relationship USING btree (type_id);
+
+
+--
+-- Name: contact_relationship_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX contact_relationship_idx2 ON contact_relationship USING btree (subject_id);
+
+
+--
+-- Name: contact_relationship_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX contact_relationship_idx3 ON contact_relationship USING btree (object_id);
+
+
+--
+-- Name: contactprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX contactprop_idx1 ON contactprop USING btree (contact_id);
+
+
+--
+-- Name: contactprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX contactprop_idx2 ON contactprop USING btree (type_id);
+
+
+--
+-- Name: content_type_chado_analysis_unigene_nid_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX content_type_chado_analysis_unigene_nid_idx ON content_type_chado_analysis_unigene USING btree (nid);
+
+
+--
+-- Name: control_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX control_idx1 ON control USING btree (type_id);
+
+
+--
+-- Name: control_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX control_idx2 ON control USING btree (assay_id);
+
+
+--
+-- Name: control_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX control_idx3 ON control USING btree (tableinfo_id);
+
+
+--
+-- Name: control_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX control_idx4 ON control USING btree (row_id);
+
+
+--
+-- Name: INDEX cvterm_c1; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON INDEX cvterm_c1 IS 'A name can mean different things in
+different contexts; for example "chromosome" in SO and GO. A name
+should be unique within an ontology or cv. A name may exist twice in a
+cv, in both obsolete and non-obsolete forms - these will be for
+different cvterms with different OBO identifiers; so GO documentation
+for more details on obsoletion. Note that occasionally multiple
+obsolete terms with the same name will exist in the same cv. If this
+is a possibility for the ontology under consideration (e.g. GO) then the
+ID should be appended to the name to ensure uniqueness.';
+
+
+--
+-- Name: INDEX cvterm_c2; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON INDEX cvterm_c2 IS 'The OBO identifier is globally unique.';
+
+
+--
+-- Name: cvterm_dbxref_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvterm_dbxref_idx1 ON cvterm_dbxref USING btree (cvterm_id);
+
+
+--
+-- Name: cvterm_dbxref_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvterm_dbxref_idx2 ON cvterm_dbxref USING btree (dbxref_id);
+
+
+--
+-- Name: cvterm_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvterm_idx1 ON cvterm USING btree (cv_id);
+
+
+--
+-- Name: cvterm_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvterm_idx2 ON cvterm USING btree (name);
+
+
+--
+-- Name: cvterm_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvterm_idx3 ON cvterm USING btree (dbxref_id);
+
+
+--
+-- Name: cvterm_relationship_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvterm_relationship_idx1 ON cvterm_relationship USING btree (type_id);
+
+
+--
+-- Name: cvterm_relationship_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvterm_relationship_idx2 ON cvterm_relationship USING btree (subject_id);
+
+
+--
+-- Name: cvterm_relationship_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvterm_relationship_idx3 ON cvterm_relationship USING btree (object_id);
+
+
+--
+-- Name: cvtermpath_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvtermpath_idx1 ON cvtermpath USING btree (type_id);
+
+
+--
+-- Name: cvtermpath_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvtermpath_idx2 ON cvtermpath USING btree (subject_id);
+
+
+--
+-- Name: cvtermpath_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvtermpath_idx3 ON cvtermpath USING btree (object_id);
+
+
+--
+-- Name: cvtermpath_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvtermpath_idx4 ON cvtermpath USING btree (cv_id);
+
+
+--
+-- Name: cvtermprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvtermprop_idx1 ON cvtermprop USING btree (cvterm_id);
+
+
+--
+-- Name: cvtermprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvtermprop_idx2 ON cvtermprop USING btree (type_id);
+
+
+--
+-- Name: cvtermsynonym_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX cvtermsynonym_idx1 ON cvtermsynonym USING btree (cvterm_id);
+
+
+--
+-- Name: dbxref_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX dbxref_idx1 ON dbxref USING btree (db_id);
+
+
+--
+-- Name: dbxref_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX dbxref_idx2 ON dbxref USING btree (accession);
+
+
+--
+-- Name: dbxref_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX dbxref_idx3 ON dbxref USING btree (version);
+
+
+--
+-- Name: dbxrefprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX dbxrefprop_idx1 ON dbxrefprop USING btree (dbxref_id);
+
+
+--
+-- Name: dbxrefprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX dbxrefprop_idx2 ON dbxrefprop USING btree (type_id);
+
+
+--
+-- Name: element_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX element_idx1 ON element USING btree (feature_id);
+
+
+--
+-- Name: element_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX element_idx2 ON element USING btree (arraydesign_id);
+
+
+--
+-- Name: element_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX element_idx3 ON element USING btree (type_id);
+
+
+--
+-- Name: element_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX element_idx4 ON element USING btree (dbxref_id);
+
+
+--
+-- Name: element_relationship_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX element_relationship_idx1 ON element_relationship USING btree (subject_id);
+
+
+--
+-- Name: element_relationship_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX element_relationship_idx2 ON element_relationship USING btree (type_id);
+
+
+--
+-- Name: element_relationship_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX element_relationship_idx3 ON element_relationship USING btree (object_id);
+
+
+--
+-- Name: element_relationship_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX element_relationship_idx4 ON element_relationship USING btree (value);
+
+
+--
+-- Name: elementresult_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX elementresult_idx1 ON elementresult USING btree (element_id);
+
+
+--
+-- Name: elementresult_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX elementresult_idx2 ON elementresult USING btree (quantification_id);
+
+
+--
+-- Name: elementresult_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX elementresult_idx3 ON elementresult USING btree (signal);
+
+
+--
+-- Name: elementresult_relationship_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX elementresult_relationship_idx1 ON elementresult_relationship USING btree (subject_id);
+
+
+--
+-- Name: elementresult_relationship_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX elementresult_relationship_idx2 ON elementresult_relationship USING btree (type_id);
+
+
+--
+-- Name: elementresult_relationship_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX elementresult_relationship_idx3 ON elementresult_relationship USING btree (object_id);
+
+
+--
+-- Name: elementresult_relationship_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX elementresult_relationship_idx4 ON elementresult_relationship USING btree (value);
+
+
+--
+-- Name: environment_cvterm_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX environment_cvterm_idx1 ON environment_cvterm USING btree (environment_id);
+
+
+--
+-- Name: environment_cvterm_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX environment_cvterm_idx2 ON environment_cvterm USING btree (cvterm_id);
+
+
+--
+-- Name: environment_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX environment_idx1 ON environment USING btree (uniquename);
+
+
+--
+-- Name: expression_cvterm_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX expression_cvterm_idx1 ON expression_cvterm USING btree (expression_id);
+
+
+--
+-- Name: expression_cvterm_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX expression_cvterm_idx2 ON expression_cvterm USING btree (cvterm_id);
+
+
+--
+-- Name: expression_cvterm_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX expression_cvterm_idx3 ON expression_cvterm USING btree (cvterm_type_id);
+
+
+--
+-- Name: expression_cvtermprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX expression_cvtermprop_idx1 ON expression_cvtermprop USING btree (expression_cvterm_id);
+
+
+--
+-- Name: expression_cvtermprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX expression_cvtermprop_idx2 ON expression_cvtermprop USING btree (type_id);
+
+
+--
+-- Name: expression_image_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX expression_image_idx1 ON expression_image USING btree (expression_id);
+
+
+--
+-- Name: expression_image_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX expression_image_idx2 ON expression_image USING btree (eimage_id);
+
+
+--
+-- Name: expression_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX expression_pub_idx1 ON expression_pub USING btree (expression_id);
+
+
+--
+-- Name: expression_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX expression_pub_idx2 ON expression_pub USING btree (pub_id);
+
+
+--
+-- Name: expressionprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX expressionprop_idx1 ON expressionprop USING btree (expression_id);
+
+
+--
+-- Name: expressionprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX expressionprop_idx2 ON expressionprop USING btree (type_id);
+
+
+--
+-- Name: feature_contact_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_contact_idx1 ON feature_contact USING btree (feature_id);
+
+
+--
+-- Name: feature_contact_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_contact_idx2 ON feature_contact USING btree (contact_id);
+
+
+--
+-- Name: feature_cvterm_dbxref_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_cvterm_dbxref_idx1 ON feature_cvterm_dbxref USING btree (feature_cvterm_id);
+
+
+--
+-- Name: feature_cvterm_dbxref_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_cvterm_dbxref_idx2 ON feature_cvterm_dbxref USING btree (dbxref_id);
+
+
+--
+-- Name: feature_cvterm_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_cvterm_idx1 ON feature_cvterm USING btree (feature_id);
+
+
+--
+-- Name: feature_cvterm_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_cvterm_idx2 ON feature_cvterm USING btree (cvterm_id);
+
+
+--
+-- Name: feature_cvterm_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_cvterm_idx3 ON feature_cvterm USING btree (pub_id);
+
+
+--
+-- Name: feature_cvterm_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_cvterm_pub_idx1 ON feature_cvterm_pub USING btree (feature_cvterm_id);
+
+
+--
+-- Name: feature_cvterm_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_cvterm_pub_idx2 ON feature_cvterm_pub USING btree (pub_id);
+
+
+--
+-- Name: feature_cvtermprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_cvtermprop_idx1 ON feature_cvtermprop USING btree (feature_cvterm_id);
+
+
+--
+-- Name: feature_cvtermprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_cvtermprop_idx2 ON feature_cvtermprop USING btree (type_id);
+
+
+--
+-- Name: feature_dbxref_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_dbxref_idx1 ON feature_dbxref USING btree (feature_id);
+
+
+--
+-- Name: feature_dbxref_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_dbxref_idx2 ON feature_dbxref USING btree (dbxref_id);
+
+
+--
+-- Name: feature_expression_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_expression_idx1 ON feature_expression USING btree (expression_id);
+
+
+--
+-- Name: feature_expression_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_expression_idx2 ON feature_expression USING btree (feature_id);
+
+
+--
+-- Name: feature_expression_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_expression_idx3 ON feature_expression USING btree (pub_id);
+
+
+--
+-- Name: feature_expressionprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_expressionprop_idx1 ON feature_expressionprop USING btree (feature_expression_id);
+
+
+--
+-- Name: feature_expressionprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_expressionprop_idx2 ON feature_expressionprop USING btree (type_id);
+
+
+--
+-- Name: feature_genotype_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_genotype_idx1 ON feature_genotype USING btree (feature_id);
+
+
+--
+-- Name: feature_genotype_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_genotype_idx2 ON feature_genotype USING btree (genotype_id);
+
+
+--
+-- Name: feature_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_idx1 ON feature USING btree (dbxref_id);
+
+
+--
+-- Name: feature_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_idx2 ON feature USING btree (organism_id);
+
+
+--
+-- Name: feature_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_idx3 ON feature USING btree (type_id);
+
+
+--
+-- Name: feature_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_idx4 ON feature USING btree (uniquename);
+
+
+--
+-- Name: feature_idx5; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_idx5 ON feature USING btree (lower((name)::text));
+
+
+--
+-- Name: feature_name_ind1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_name_ind1 ON feature USING btree (name);
+
+
+--
+-- Name: feature_phenotype_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_phenotype_idx1 ON feature_phenotype USING btree (feature_id);
+
+
+--
+-- Name: feature_phenotype_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_phenotype_idx2 ON feature_phenotype USING btree (phenotype_id);
+
+
+--
+-- Name: feature_project_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_project_idx1 ON feature_project USING btree (feature_id);
+
+
+--
+-- Name: feature_project_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_project_idx2 ON feature_project USING btree (project_id);
+
+
+--
+-- Name: feature_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_pub_idx1 ON feature_pub USING btree (feature_id);
+
+
+--
+-- Name: feature_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_pub_idx2 ON feature_pub USING btree (pub_id);
+
+
+--
+-- Name: feature_pubprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_pubprop_idx1 ON feature_pubprop USING btree (feature_pub_id);
+
+
+--
+-- Name: feature_relationship_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_relationship_idx1 ON feature_relationship USING btree (subject_id);
+
+
+--
+-- Name: feature_relationship_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_relationship_idx2 ON feature_relationship USING btree (object_id);
+
+
+--
+-- Name: feature_relationship_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_relationship_idx3 ON feature_relationship USING btree (type_id);
+
+
+--
+-- Name: feature_relationship_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_relationship_pub_idx1 ON feature_relationship_pub USING btree (feature_relationship_id);
+
+
+--
+-- Name: feature_relationship_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_relationship_pub_idx2 ON feature_relationship_pub USING btree (pub_id);
+
+
+--
+-- Name: feature_relationshipprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_relationshipprop_idx1 ON feature_relationshipprop USING btree (feature_relationship_id);
+
+
+--
+-- Name: feature_relationshipprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_relationshipprop_idx2 ON feature_relationshipprop USING btree (type_id);
+
+
+--
+-- Name: feature_relationshipprop_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_relationshipprop_pub_idx1 ON feature_relationshipprop_pub USING btree (feature_relationshipprop_id);
+
+
+--
+-- Name: feature_relationshipprop_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_relationshipprop_pub_idx2 ON feature_relationshipprop_pub USING btree (pub_id);
+
+
+--
+-- Name: feature_stock_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_stock_idx1 ON feature_stock USING btree (feature_id);
+
+
+--
+-- Name: feature_stock_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_stock_idx2 ON feature_stock USING btree (stock_id);
+
+
+--
+-- Name: feature_synonym_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_synonym_idx1 ON feature_synonym USING btree (synonym_id);
+
+
+--
+-- Name: feature_synonym_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_synonym_idx2 ON feature_synonym USING btree (feature_id);
+
+
+--
+-- Name: feature_synonym_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX feature_synonym_idx3 ON feature_synonym USING btree (pub_id);
+
+
+--
+-- Name: featureloc_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featureloc_idx1 ON featureloc USING btree (feature_id);
+
+
+--
+-- Name: featureloc_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featureloc_idx2 ON featureloc USING btree (srcfeature_id);
+
+
+--
+-- Name: featureloc_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featureloc_idx3 ON featureloc USING btree (srcfeature_id, fmin, fmax);
+
+
+--
+-- Name: featureloc_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featureloc_pub_idx1 ON featureloc_pub USING btree (featureloc_id);
+
+
+--
+-- Name: featureloc_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featureloc_pub_idx2 ON featureloc_pub USING btree (pub_id);
+
+
+--
+-- Name: featuremap_contact_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featuremap_contact_idx1 ON featuremap_contact USING btree (featuremap_id);
+
+
+--
+-- Name: featuremap_contact_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featuremap_contact_idx2 ON featuremap_contact USING btree (contact_id);
+
+
+--
+-- Name: featuremap_organism_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featuremap_organism_idx1 ON featuremap_organism USING btree (featuremap_id);
+
+
+--
+-- Name: featuremap_organism_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featuremap_organism_idx2 ON featuremap_organism USING btree (organism_id);
+
+
+--
+-- Name: featuremap_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featuremap_pub_idx1 ON featuremap_pub USING btree (featuremap_id);
+
+
+--
+-- Name: featuremap_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featuremap_pub_idx2 ON featuremap_pub USING btree (pub_id);
+
+
+--
+-- Name: featuremap_stock_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featuremap_stock_idx1 ON featuremap_stock USING btree (featuremap_id);
+
+
+--
+-- Name: featuremap_stock_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featuremap_stock_idx2 ON featuremap_stock USING btree (stock_id);
+
+
+--
+-- Name: featuremapprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featuremapprop_idx1 ON featuremapprop USING btree (featuremap_id);
+
+
+--
+-- Name: featuremapprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featuremapprop_idx2 ON featuremapprop USING btree (type_id);
+
+
+--
+-- Name: featurepos_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featurepos_idx1 ON featurepos USING btree (featuremap_id);
+
+
+--
+-- Name: featurepos_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featurepos_idx2 ON featurepos USING btree (feature_id);
+
+
+--
+-- Name: featurepos_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featurepos_idx3 ON featurepos USING btree (map_feature_id);
+
+
+--
+-- Name: featureposprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featureposprop_idx1 ON featureposprop USING btree (featurepos_id);
+
+
+--
+-- Name: featureposprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featureposprop_idx2 ON featureposprop USING btree (type_id);
+
+
+--
+-- Name: INDEX featureprop_c1; Type: COMMENT; Schema: chado; Owner: -
+--
+
+COMMENT ON INDEX featureprop_c1 IS 'For any one feature, multivalued
+property-value pairs must be differentiated by rank.';
+
+
+--
+-- Name: featureprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featureprop_idx1 ON featureprop USING btree (feature_id);
+
+
+--
+-- Name: featureprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featureprop_idx2 ON featureprop USING btree (type_id);
+
+
+--
+-- Name: featureprop_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featureprop_pub_idx1 ON featureprop_pub USING btree (featureprop_id);
+
+
+--
+-- Name: featureprop_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featureprop_pub_idx2 ON featureprop_pub USING btree (pub_id);
+
+
+--
+-- Name: featurerange_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featurerange_idx1 ON featurerange USING btree (featuremap_id);
+
+
+--
+-- Name: featurerange_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featurerange_idx2 ON featurerange USING btree (feature_id);
+
+
+--
+-- Name: featurerange_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featurerange_idx3 ON featurerange USING btree (leftstartf_id);
+
+
+--
+-- Name: featurerange_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featurerange_idx4 ON featurerange USING btree (leftendf_id);
+
+
+--
+-- Name: featurerange_idx5; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featurerange_idx5 ON featurerange USING btree (rightstartf_id);
+
+
+--
+-- Name: featurerange_idx6; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX featurerange_idx6 ON featurerange USING btree (rightendf_id);
+
+
+--
+-- Name: genotype_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX genotype_idx1 ON genotype USING btree (uniquename);
+
+
+--
+-- Name: genotype_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX genotype_idx2 ON genotype USING btree (name);
+
+
+--
+-- Name: genotypeprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX genotypeprop_idx1 ON genotypeprop USING btree (genotype_id);
+
+
+--
+-- Name: genotypeprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX genotypeprop_idx2 ON genotypeprop USING btree (type_id);
+
+
+--
+-- Name: idx_cv_root_mview_cv_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_cv_root_mview_cv_id ON cv_root_mview USING btree (cv_id);
+
+
+--
+-- Name: idx_cv_root_mview_cvterm_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_cv_root_mview_cvterm_id ON cv_root_mview USING btree (cvterm_id);
+
+
+--
+-- Name: idx_go_count_analysis_analysis_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_go_count_analysis_analysis_id ON go_count_analysis USING btree (analysis_id);
+
+
+--
+-- Name: idx_go_count_analysis_cvterm_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_go_count_analysis_cvterm_id ON go_count_analysis USING btree (cvterm_id);
+
+
+--
+-- Name: idx_go_count_analysis_organism_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_go_count_analysis_organism_id ON go_count_analysis USING btree (organism_id);
+
+
+--
+-- Name: idx_go_count_organism_cvterm_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_go_count_organism_cvterm_id ON go_count_organism USING btree (cvterm_id);
+
+
+--
+-- Name: idx_go_count_organism_organism_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_go_count_organism_organism_id ON go_count_organism USING btree (organism_id);
+
+
+--
+-- Name: idx_kegg_by_organism_analysis_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_kegg_by_organism_analysis_id ON kegg_by_organism USING btree (analysis_id);
+
+
+--
+-- Name: idx_kegg_by_organism_organism_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_kegg_by_organism_organism_id ON kegg_by_organism USING btree (organism_id);
+
+
+--
+-- Name: idx_organism_feature_count_cvterm_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_organism_feature_count_cvterm_id ON organism_feature_count USING btree (cvterm_id);
+
+
+--
+-- Name: idx_organism_feature_count_feature_type; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_organism_feature_count_feature_type ON organism_feature_count USING btree (feature_type);
+
+
+--
+-- Name: idx_organism_feature_count_organism_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_organism_feature_count_organism_id ON organism_feature_count USING btree (organism_id);
+
+
+--
+-- Name: idx_organism_unigene_mview_analysis_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_organism_unigene_mview_analysis_id ON organism_unigene_mview USING btree (analysis_id);
+
+
+--
+-- Name: idx_organism_unigene_mview_organism_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_organism_unigene_mview_organism_id ON organism_unigene_mview USING btree (organism_id);
+
+
+--
+-- Name: idx_search_by_gene_analysis_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_gene_analysis_id ON search_by_gene USING btree (analysis_id);
+
+
+--
+-- Name: idx_search_by_gene_analysis_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_gene_analysis_name ON search_by_gene USING btree (analysis_name);
+
+
+--
+-- Name: idx_search_by_gene_feature_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_gene_feature_id ON search_by_gene USING btree (feature_id);
+
+
+--
+-- Name: idx_search_by_gene_feature_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_gene_feature_name ON search_by_gene USING btree (feature_name);
+
+
+--
+-- Name: idx_search_by_gene_organism_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_gene_organism_id ON search_by_gene USING btree (organism_id);
+
+
+--
+-- Name: idx_search_by_go_analysis_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_analysis_id ON search_by_go USING btree (analysis_id);
+
+
+--
+-- Name: idx_search_by_go_analysis_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_analysis_name ON search_by_go USING btree (analysis_name);
+
+
+--
+-- Name: idx_search_by_go_analysis_nid; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_analysis_nid ON search_by_go USING btree (analysis_nid);
+
+
+--
+-- Name: idx_search_by_go_feature_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_feature_id ON search_by_go USING btree (feature_id);
+
+
+--
+-- Name: idx_search_by_go_feature_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_feature_name ON search_by_go USING btree (feature_name);
+
+
+--
+-- Name: idx_search_by_go_feature_nid; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_feature_nid ON search_by_go USING btree (feature_nid);
+
+
+--
+-- Name: idx_search_by_go_feature_type; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_feature_type ON search_by_go USING btree (feature_type);
+
+
+--
+-- Name: idx_search_by_go_fmax; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_fmax ON search_by_go USING btree (fmax);
+
+
+--
+-- Name: idx_search_by_go_fmin; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_fmin ON search_by_go USING btree (fmin);
+
+
+--
+-- Name: idx_search_by_go_go_accession; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_go_accession ON search_by_go USING btree (go_accession);
+
+
+--
+-- Name: idx_search_by_go_go_cvterm_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_go_cvterm_id ON search_by_go USING btree (go_cvterm_id);
+
+
+--
+-- Name: idx_search_by_go_go_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_go_name ON search_by_go USING btree (go_name);
+
+
+--
+-- Name: idx_search_by_go_landmark; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_landmark ON search_by_go USING btree (landmark);
+
+
+--
+-- Name: idx_search_by_go_organism_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_organism_id ON search_by_go USING btree (organism_id);
+
+
+--
+-- Name: idx_search_by_go_source_analysis_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_source_analysis_id ON search_by_go USING btree (source_analysis_id);
+
+
+--
+-- Name: idx_search_by_go_source_analysis_nid; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_source_analysis_nid ON search_by_go USING btree (source_analysis_nid);
+
+
+--
+-- Name: idx_search_by_go_source_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_source_name ON search_by_go USING btree (source_name);
+
+
+--
+-- Name: idx_search_by_go_strand; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_strand ON search_by_go USING btree (strand);
+
+
+--
+-- Name: idx_search_by_go_type_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_go_type_id ON search_by_go USING btree (type_id);
+
+
+--
+-- Name: idx_search_by_homology_analysis_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_homology_analysis_id ON search_by_homology USING btree (analysis_id);
+
+
+--
+-- Name: idx_search_by_homology_feature_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_homology_feature_id ON search_by_homology USING btree (feature_id);
+
+
+--
+-- Name: idx_search_by_homology_organism_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_homology_organism_id ON search_by_homology USING btree (organism_id);
+
+
+--
+-- Name: idx_search_by_interpro_accession; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_accession ON search_by_interpro USING btree (accession);
+
+
+--
+-- Name: idx_search_by_interpro_analysis_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_analysis_id ON search_by_interpro USING btree (analysis_id);
+
+
+--
+-- Name: idx_search_by_interpro_analysis_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_analysis_name ON search_by_interpro USING btree (analysis_name);
+
+
+--
+-- Name: idx_search_by_interpro_analysis_nid; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_analysis_nid ON search_by_interpro USING btree (analysis_nid);
+
+
+--
+-- Name: idx_search_by_interpro_feature_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_feature_id ON search_by_interpro USING btree (feature_id);
+
+
+--
+-- Name: idx_search_by_interpro_feature_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_feature_name ON search_by_interpro USING btree (feature_name);
+
+
+--
+-- Name: idx_search_by_interpro_feature_nid; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_feature_nid ON search_by_interpro USING btree (feature_nid);
+
+
+--
+-- Name: idx_search_by_interpro_feature_type; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_feature_type ON search_by_interpro USING btree (feature_type);
+
+
+--
+-- Name: idx_search_by_interpro_feature_type_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_feature_type_id ON search_by_interpro USING btree (feature_type_id);
+
+
+--
+-- Name: idx_search_by_interpro_fmax; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_fmax ON search_by_interpro USING btree (fmax);
+
+
+--
+-- Name: idx_search_by_interpro_fmin; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_fmin ON search_by_interpro USING btree (fmin);
+
+
+--
+-- Name: idx_search_by_interpro_landmark; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_landmark ON search_by_interpro USING btree (landmark);
+
+
+--
+-- Name: idx_search_by_interpro_organism_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_organism_id ON search_by_interpro USING btree (organism_id);
+
+
+--
+-- Name: idx_search_by_interpro_source_analysis_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_source_analysis_id ON search_by_interpro USING btree (source_analysis_id);
+
+
+--
+-- Name: idx_search_by_interpro_source_analysis_nid; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_source_analysis_nid ON search_by_interpro USING btree (source_analysis_nid);
+
+
+--
+-- Name: idx_search_by_interpro_source_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_source_name ON search_by_interpro USING btree (source_name);
+
+
+--
+-- Name: idx_search_by_interpro_strand; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_strand ON search_by_interpro USING btree (strand);
+
+
+--
+-- Name: idx_search_by_interpro_term_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_term_name ON search_by_interpro USING btree (term_name);
+
+
+--
+-- Name: idx_search_by_interpro_type_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_interpro_type_id ON search_by_interpro USING btree (type_id);
+
+
+--
+-- Name: idx_search_by_kegg_accession; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_kegg_accession ON search_by_kegg USING btree (accession);
+
+
+--
+-- Name: idx_search_by_kegg_analysis_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_kegg_analysis_id ON search_by_kegg USING btree (analysis_id);
+
+
+--
+-- Name: idx_search_by_kegg_feature_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_kegg_feature_id ON search_by_kegg USING btree (feature_id);
+
+
+--
+-- Name: idx_search_by_kegg_feature_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_kegg_feature_name ON search_by_kegg USING btree (feature_name);
+
+
+--
+-- Name: idx_search_by_kegg_feature_type; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_kegg_feature_type ON search_by_kegg USING btree (feature_type);
+
+
+--
+-- Name: idx_search_by_kegg_kegg_term; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_kegg_kegg_term ON search_by_kegg USING btree (kegg_term);
+
+
+--
+-- Name: idx_search_by_kegg_organism_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_kegg_organism_id ON search_by_kegg USING btree (organism_id);
+
+
+--
+-- Name: idx_search_by_kegg_source_analysis_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_kegg_source_analysis_id ON search_by_kegg USING btree (source_analysis_id);
+
+
+--
+-- Name: idx_search_by_kegg_source_name; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_kegg_source_name ON search_by_kegg USING btree (source_name);
+
+
+--
+-- Name: idx_search_by_kegg_type_id; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX idx_search_by_kegg_type_id ON search_by_kegg USING btree (type_id);
+
+
+--
+-- Name: library_cvterm_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_cvterm_idx1 ON library_cvterm USING btree (library_id);
+
+
+--
+-- Name: library_cvterm_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_cvterm_idx2 ON library_cvterm USING btree (cvterm_id);
+
+
+--
+-- Name: library_cvterm_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_cvterm_idx3 ON library_cvterm USING btree (pub_id);
+
+
+--
+-- Name: library_dbxref_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_dbxref_idx1 ON library_dbxref USING btree (library_id);
+
+
+--
+-- Name: library_dbxref_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_dbxref_idx2 ON library_dbxref USING btree (dbxref_id);
+
+
+--
+-- Name: library_feature_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_feature_idx1 ON library_feature USING btree (library_id);
+
+
+--
+-- Name: library_feature_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_feature_idx2 ON library_feature USING btree (feature_id);
+
+
+--
+-- Name: library_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_idx1 ON library USING btree (organism_id);
+
+
+--
+-- Name: library_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_idx2 ON library USING btree (type_id);
+
+
+--
+-- Name: library_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_idx3 ON library USING btree (uniquename);
+
+
+--
+-- Name: library_name_ind1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_name_ind1 ON library USING btree (name);
+
+
+--
+-- Name: library_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_pub_idx1 ON library_pub USING btree (library_id);
+
+
+--
+-- Name: library_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_pub_idx2 ON library_pub USING btree (pub_id);
+
+
+--
+-- Name: library_synonym_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_synonym_idx1 ON library_synonym USING btree (synonym_id);
+
+
+--
+-- Name: library_synonym_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_synonym_idx2 ON library_synonym USING btree (library_id);
+
+
+--
+-- Name: library_synonym_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX library_synonym_idx3 ON library_synonym USING btree (pub_id);
+
+
+--
+-- Name: libraryprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX libraryprop_idx1 ON libraryprop USING btree (library_id);
+
+
+--
+-- Name: libraryprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX libraryprop_idx2 ON libraryprop USING btree (type_id);
+
+
+--
+-- Name: libraryprop_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX libraryprop_pub_idx1 ON libraryprop_pub USING btree (libraryprop_id);
+
+
+--
+-- Name: libraryprop_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX libraryprop_pub_idx2 ON libraryprop_pub USING btree (pub_id);
+
+
+--
+-- Name: magedocumentation_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX magedocumentation_idx1 ON magedocumentation USING btree (mageml_id);
+
+
+--
+-- Name: magedocumentation_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX magedocumentation_idx2 ON magedocumentation USING btree (tableinfo_id);
+
+
+--
+-- Name: magedocumentation_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX magedocumentation_idx3 ON magedocumentation USING btree (row_id);
+
+
+--
+-- Name: nd_experiment_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX nd_experiment_pub_idx1 ON nd_experiment_pub USING btree (nd_experiment_id);
+
+
+--
+-- Name: nd_experiment_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX nd_experiment_pub_idx2 ON nd_experiment_pub USING btree (pub_id);
+
+
+--
+-- Name: organism_dbxref_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX organism_dbxref_idx1 ON organism_dbxref USING btree (organism_id);
+
+
+--
+-- Name: organism_dbxref_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX organism_dbxref_idx2 ON organism_dbxref USING btree (dbxref_id);
+
+
+--
+-- Name: organism_for_search_organism_for_search_indx0_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX organism_for_search_organism_for_search_indx0_idx ON organism_for_search USING btree (organism_name);
+
+
+--
+-- Name: organism_stock_count_organism_stock_count_idx1_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX organism_stock_count_organism_stock_count_idx1_idx ON organism_stock_count USING btree (organism_id);
+
+
+--
+-- Name: organism_stock_count_organism_stock_count_idx2_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX organism_stock_count_organism_stock_count_idx2_idx ON organism_stock_count USING btree (cvterm_id);
+
+
+--
+-- Name: organism_stock_count_organism_stock_count_idx3_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX organism_stock_count_organism_stock_count_idx3_idx ON organism_stock_count USING btree (stock_type);
+
+
+--
+-- Name: organismprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX organismprop_idx1 ON organismprop USING btree (organism_id);
+
+
+--
+-- Name: organismprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX organismprop_idx2 ON organismprop USING btree (type_id);
+
+
+--
+-- Name: phendesc_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phendesc_idx1 ON phendesc USING btree (genotype_id);
+
+
+--
+-- Name: phendesc_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phendesc_idx2 ON phendesc USING btree (environment_id);
+
+
+--
+-- Name: phendesc_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phendesc_idx3 ON phendesc USING btree (pub_id);
+
+
+--
+-- Name: phenotype_comparison_cvterm_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenotype_comparison_cvterm_idx1 ON phenotype_comparison_cvterm USING btree (phenotype_comparison_id);
+
+
+--
+-- Name: phenotype_comparison_cvterm_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenotype_comparison_cvterm_idx2 ON phenotype_comparison_cvterm USING btree (cvterm_id);
+
+
+--
+-- Name: phenotype_comparison_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenotype_comparison_idx1 ON phenotype_comparison USING btree (genotype1_id);
+
+
+--
+-- Name: phenotype_comparison_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenotype_comparison_idx2 ON phenotype_comparison USING btree (genotype2_id);
+
+
+--
+-- Name: phenotype_comparison_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenotype_comparison_idx4 ON phenotype_comparison USING btree (pub_id);
+
+
+--
+-- Name: phenotype_cvterm_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenotype_cvterm_idx1 ON phenotype_cvterm USING btree (phenotype_id);
+
+
+--
+-- Name: phenotype_cvterm_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenotype_cvterm_idx2 ON phenotype_cvterm USING btree (cvterm_id);
+
+
+--
+-- Name: phenotype_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenotype_idx1 ON phenotype USING btree (cvalue_id);
+
+
+--
+-- Name: phenotype_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenotype_idx2 ON phenotype USING btree (observable_id);
+
+
+--
+-- Name: phenotype_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenotype_idx3 ON phenotype USING btree (attr_id);
+
+
+--
+-- Name: phenstatement_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenstatement_idx1 ON phenstatement USING btree (genotype_id);
+
+
+--
+-- Name: phenstatement_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phenstatement_idx2 ON phenstatement USING btree (phenotype_id);
+
+
+--
+-- Name: phylonode_dbxref_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylonode_dbxref_idx1 ON phylonode_dbxref USING btree (phylonode_id);
+
+
+--
+-- Name: phylonode_dbxref_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylonode_dbxref_idx2 ON phylonode_dbxref USING btree (dbxref_id);
+
+
+--
+-- Name: phylonode_organism_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylonode_organism_idx1 ON phylonode_organism USING btree (phylonode_id);
+
+
+--
+-- Name: phylonode_organism_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylonode_organism_idx2 ON phylonode_organism USING btree (organism_id);
+
+
+--
+-- Name: phylonode_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylonode_pub_idx1 ON phylonode_pub USING btree (phylonode_id);
+
+
+--
+-- Name: phylonode_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylonode_pub_idx2 ON phylonode_pub USING btree (pub_id);
+
+
+--
+-- Name: phylonode_relationship_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylonode_relationship_idx1 ON phylonode_relationship USING btree (subject_id);
+
+
+--
+-- Name: phylonode_relationship_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylonode_relationship_idx2 ON phylonode_relationship USING btree (object_id);
+
+
+--
+-- Name: phylonode_relationship_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylonode_relationship_idx3 ON phylonode_relationship USING btree (type_id);
+
+
+--
+-- Name: phylonodeprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylonodeprop_idx1 ON phylonodeprop USING btree (phylonode_id);
+
+
+--
+-- Name: phylonodeprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylonodeprop_idx2 ON phylonodeprop USING btree (type_id);
+
+
+--
+-- Name: phylotree_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylotree_idx1 ON phylotree USING btree (phylotree_id);
+
+
+--
+-- Name: phylotree_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylotree_pub_idx1 ON phylotree_pub USING btree (phylotree_id);
+
+
+--
+-- Name: phylotree_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX phylotree_pub_idx2 ON phylotree_pub USING btree (pub_id);
+
+
+--
+-- Name: project_contact_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX project_contact_idx1 ON project_contact USING btree (project_id);
+
+
+--
+-- Name: project_contact_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX project_contact_idx2 ON project_contact USING btree (contact_id);
+
+
+--
+-- Name: project_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX project_pub_idx1 ON project_pub USING btree (project_id);
+
+
+--
+-- Name: project_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX project_pub_idx2 ON project_pub USING btree (pub_id);
+
+
+--
+-- Name: protocol_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX protocol_idx1 ON protocol USING btree (type_id);
+
+
+--
+-- Name: protocol_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX protocol_idx2 ON protocol USING btree (pub_id);
+
+
+--
+-- Name: protocol_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX protocol_idx3 ON protocol USING btree (dbxref_id);
+
+
+--
+-- Name: protocolparam_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX protocolparam_idx1 ON protocolparam USING btree (protocol_id);
+
+
+--
+-- Name: protocolparam_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX protocolparam_idx2 ON protocolparam USING btree (datatype_id);
+
+
+--
+-- Name: protocolparam_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX protocolparam_idx3 ON protocolparam USING btree (unittype_id);
+
+
+--
+-- Name: pub_dbxref_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX pub_dbxref_idx1 ON pub_dbxref USING btree (pub_id);
+
+
+--
+-- Name: pub_dbxref_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX pub_dbxref_idx2 ON pub_dbxref USING btree (dbxref_id);
+
+
+--
+-- Name: pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX pub_idx1 ON pub USING btree (type_id);
+
+
+--
+-- Name: pub_relationship_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX pub_relationship_idx1 ON pub_relationship USING btree (subject_id);
+
+
+--
+-- Name: pub_relationship_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX pub_relationship_idx2 ON pub_relationship USING btree (object_id);
+
+
+--
+-- Name: pub_relationship_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX pub_relationship_idx3 ON pub_relationship USING btree (type_id);
+
+
+--
+-- Name: pubauthor_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX pubauthor_idx2 ON pubauthor USING btree (pub_id);
+
+
+--
+-- Name: pubprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX pubprop_idx1 ON pubprop USING btree (pub_id);
+
+
+--
+-- Name: pubprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX pubprop_idx2 ON pubprop USING btree (type_id);
+
+
+--
+-- Name: qtl_search_qtl_search_indx0_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX qtl_search_qtl_search_indx0_idx ON qtl_search USING btree (organism);
+
+
+--
+-- Name: qtl_search_qtl_search_indx1_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX qtl_search_qtl_search_indx1_idx ON qtl_search USING btree (qtl);
+
+
+--
+-- Name: qtl_search_qtl_search_indx2_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX qtl_search_qtl_search_indx2_idx ON qtl_search USING btree (symbol);
+
+
+--
+-- Name: qtl_search_qtl_search_indx3_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX qtl_search_qtl_search_indx3_idx ON qtl_search USING btree (trait);
+
+
+--
+-- Name: quantification_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX quantification_idx1 ON quantification USING btree (acquisition_id);
+
+
+--
+-- Name: quantification_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX quantification_idx2 ON quantification USING btree (operator_id);
+
+
+--
+-- Name: quantification_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX quantification_idx3 ON quantification USING btree (protocol_id);
+
+
+--
+-- Name: quantification_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX quantification_idx4 ON quantification USING btree (analysis_id);
+
+
+--
+-- Name: quantification_relationship_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX quantification_relationship_idx1 ON quantification_relationship USING btree (subject_id);
+
+
+--
+-- Name: quantification_relationship_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX quantification_relationship_idx2 ON quantification_relationship USING btree (type_id);
+
+
+--
+-- Name: quantification_relationship_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX quantification_relationship_idx3 ON quantification_relationship USING btree (object_id);
+
+
+--
+-- Name: quantificationprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX quantificationprop_idx1 ON quantificationprop USING btree (quantification_id);
+
+
+--
+-- Name: quantificationprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX quantificationprop_idx2 ON quantificationprop USING btree (type_id);
+
+
+--
+-- Name: search_by_map_search_by_map_idx12_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx12_idx ON search_by_map USING btree (genome);
+
+
+--
+-- Name: search_by_map_search_by_map_idx13_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx13_idx ON search_by_map USING btree (pop_size);
+
+
+--
+-- Name: search_by_map_search_by_map_idx14_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx14_idx ON search_by_map USING btree (pop_type);
+
+
+--
+-- Name: search_by_map_search_by_map_idx15_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx15_idx ON search_by_map USING btree (num_of_lg);
+
+
+--
+-- Name: search_by_map_search_by_map_idx16_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx16_idx ON search_by_map USING btree (num_of_loci);
+
+
+--
+-- Name: search_by_map_search_by_map_idx1_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx1_idx ON search_by_map USING btree (featuremap_id);
+
+
+--
+-- Name: search_by_map_search_by_map_idx2_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx2_idx ON search_by_map USING btree (organism_id);
+
+
+--
+-- Name: search_by_map_search_by_map_idx3_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx3_idx ON search_by_map USING btree (pop_stock_id);
+
+
+--
+-- Name: search_by_map_search_by_map_idx4_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx4_idx ON search_by_map USING btree (maternal_stock_id);
+
+
+--
+-- Name: search_by_map_search_by_map_idx5_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx5_idx ON search_by_map USING btree (maternal_stock_uniquename);
+
+
+--
+-- Name: search_by_map_search_by_map_idx6_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx6_idx ON search_by_map USING btree (maternal_stock_nid);
+
+
+--
+-- Name: search_by_map_search_by_map_idx7_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx7_idx ON search_by_map USING btree (paternal_stock_id);
+
+
+--
+-- Name: search_by_map_search_by_map_idx8_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx8_idx ON search_by_map USING btree (paternal_stock_uniquename);
+
+
+--
+-- Name: search_by_map_search_by_map_idx9_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_by_map_search_by_map_idx9_idx ON search_by_map USING btree (paternal_stock_nid);
+
+
+--
+-- Name: searchable_features_feature_id_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX searchable_features_feature_id_idx ON searchable_features USING btree (feature_id);
+
+
+--
+-- Name: searchable_features_feature_name_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX searchable_features_feature_name_idx ON searchable_features USING btree (feature_name);
+
+
+--
+-- Name: searchable_features_feature_type_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX searchable_features_feature_type_idx ON searchable_features USING btree (feature_type);
+
+
+--
+-- Name: searchable_features_organism_id_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX searchable_features_organism_id_idx ON searchable_features USING btree (organism_id);
+
+
+--
+-- Name: searchable_features_source_analysis_id_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX searchable_features_source_analysis_id_idx ON searchable_features USING btree (source_analysis_id);
+
+
+--
+-- Name: searchable_features_source_name_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX searchable_features_source_name_idx ON searchable_features USING btree (source_name);
+
+
+--
+-- Name: searchable_features_type_id_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX searchable_features_type_id_idx ON searchable_features USING btree (type_id);
+
+
+--
+-- Name: species_summary_species_summary_idx0_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX species_summary_species_summary_idx0_idx ON species_summary USING btree (organism_id);
+
+
+--
+-- Name: stock_cvterm_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_cvterm_idx1 ON stock_cvterm USING btree (stock_id);
+
+
+--
+-- Name: stock_cvterm_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_cvterm_idx2 ON stock_cvterm USING btree (cvterm_id);
+
+
+--
+-- Name: stock_cvterm_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_cvterm_idx3 ON stock_cvterm USING btree (pub_id);
+
+
+--
+-- Name: stock_cvtermprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_cvtermprop_idx1 ON stock_cvtermprop USING btree (stock_cvterm_id);
+
+
+--
+-- Name: stock_cvtermprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_cvtermprop_idx2 ON stock_cvtermprop USING btree (type_id);
+
+
+--
+-- Name: stock_dbxref_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_dbxref_idx1 ON stock_dbxref USING btree (stock_id);
+
+
+--
+-- Name: stock_dbxref_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_dbxref_idx2 ON stock_dbxref USING btree (dbxref_id);
+
+
+--
+-- Name: stock_dbxrefprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_dbxrefprop_idx1 ON stock_dbxrefprop USING btree (stock_dbxref_id);
+
+
+--
+-- Name: stock_dbxrefprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_dbxrefprop_idx2 ON stock_dbxrefprop USING btree (type_id);
+
+
+--
+-- Name: stock_genotype_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_genotype_idx1 ON stock_genotype USING btree (stock_id);
+
+
+--
+-- Name: stock_genotype_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_genotype_idx2 ON stock_genotype USING btree (genotype_id);
+
+
+--
+-- Name: stock_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_idx1 ON stock USING btree (dbxref_id);
+
+
+--
+-- Name: stock_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_idx2 ON stock USING btree (organism_id);
+
+
+--
+-- Name: stock_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_idx3 ON stock USING btree (type_id);
+
+
+--
+-- Name: stock_idx4; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_idx4 ON stock USING btree (uniquename);
+
+
+--
+-- Name: stock_image_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_image_idx1 ON stock_image USING btree (stock_id);
+
+
+--
+-- Name: stock_image_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_image_idx2 ON stock_image USING btree (eimage_id);
+
+
+--
+-- Name: stock_name_ind1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_name_ind1 ON stock USING btree (name);
+
+
+--
+-- Name: stock_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_pub_idx1 ON stock_pub USING btree (stock_id);
+
+
+--
+-- Name: stock_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_pub_idx2 ON stock_pub USING btree (pub_id);
+
+
+--
+-- Name: stock_relationship_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_relationship_idx1 ON stock_relationship USING btree (subject_id);
+
+
+--
+-- Name: stock_relationship_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_relationship_idx2 ON stock_relationship USING btree (object_id);
+
+
+--
+-- Name: stock_relationship_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_relationship_idx3 ON stock_relationship USING btree (type_id);
+
+
+--
+-- Name: stock_relationship_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_relationship_pub_idx1 ON stock_relationship_pub USING btree (stock_relationship_id);
+
+
+--
+-- Name: stock_relationship_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stock_relationship_pub_idx2 ON stock_relationship_pub USING btree (pub_id);
+
+
+--
+-- Name: stockcollection_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockcollection_idx1 ON stockcollection USING btree (contact_id);
+
+
+--
+-- Name: stockcollection_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockcollection_idx2 ON stockcollection USING btree (type_id);
+
+
+--
+-- Name: stockcollection_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockcollection_idx3 ON stockcollection USING btree (uniquename);
+
+
+--
+-- Name: stockcollection_name_ind1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockcollection_name_ind1 ON stockcollection USING btree (name);
+
+
+--
+-- Name: stockcollection_stock_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockcollection_stock_idx1 ON stockcollection_stock USING btree (stockcollection_id);
+
+
+--
+-- Name: stockcollection_stock_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockcollection_stock_idx2 ON stockcollection_stock USING btree (stock_id);
+
+
+--
+-- Name: stockcollectionprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockcollectionprop_idx1 ON stockcollectionprop USING btree (stockcollection_id);
+
+
+--
+-- Name: stockcollectionprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockcollectionprop_idx2 ON stockcollectionprop USING btree (type_id);
+
+
+--
+-- Name: stockprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockprop_idx1 ON stockprop USING btree (stock_id);
+
+
+--
+-- Name: stockprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockprop_idx2 ON stockprop USING btree (type_id);
+
+
+--
+-- Name: stockprop_pub_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockprop_pub_idx1 ON stockprop_pub USING btree (stockprop_id);
+
+
+--
+-- Name: stockprop_pub_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX stockprop_pub_idx2 ON stockprop_pub USING btree (pub_id);
+
+
+--
+-- Name: study_assay_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX study_assay_idx1 ON study_assay USING btree (study_id);
+
+
+--
+-- Name: study_assay_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX study_assay_idx2 ON study_assay USING btree (assay_id);
+
+
+--
+-- Name: study_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX study_idx1 ON study USING btree (contact_id);
+
+
+--
+-- Name: study_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX study_idx2 ON study USING btree (pub_id);
+
+
+--
+-- Name: study_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX study_idx3 ON study USING btree (dbxref_id);
+
+
+--
+-- Name: studydesign_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX studydesign_idx1 ON studydesign USING btree (study_id);
+
+
+--
+-- Name: studydesignprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX studydesignprop_idx1 ON studydesignprop USING btree (studydesign_id);
+
+
+--
+-- Name: studydesignprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX studydesignprop_idx2 ON studydesignprop USING btree (type_id);
+
+
+--
+-- Name: studyfactor_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX studyfactor_idx1 ON studyfactor USING btree (studydesign_id);
+
+
+--
+-- Name: studyfactor_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX studyfactor_idx2 ON studyfactor USING btree (type_id);
+
+
+--
+-- Name: studyfactorvalue_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX studyfactorvalue_idx1 ON studyfactorvalue USING btree (studyfactor_id);
+
+
+--
+-- Name: studyfactorvalue_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX studyfactorvalue_idx2 ON studyfactorvalue USING btree (assay_id);
+
+
+--
+-- Name: studyprop_feature_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX studyprop_feature_idx1 ON studyprop_feature USING btree (studyprop_id);
+
+
+--
+-- Name: studyprop_feature_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX studyprop_feature_idx2 ON studyprop_feature USING btree (feature_id);
+
+
+--
+-- Name: studyprop_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX studyprop_idx1 ON studyprop USING btree (study_id);
+
+
+--
+-- Name: studyprop_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX studyprop_idx2 ON studyprop USING btree (type_id);
+
+
+--
+-- Name: synonym_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX synonym_idx1 ON synonym USING btree (type_id);
+
+
+--
+-- Name: synonym_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX synonym_idx2 ON synonym USING btree (lower((synonym_sgml)::text));
+
+
+--
+-- Name: treatment_idx1; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX treatment_idx1 ON treatment USING btree (biomaterial_id);
+
+
+--
+-- Name: treatment_idx2; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX treatment_idx2 ON treatment USING btree (type_id);
+
+
+--
+-- Name: treatment_idx3; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX treatment_idx3 ON treatment USING btree (protocol_id);
+
+
+--
+-- Name: tripal_gff_temp_tripal_gff_temp_idx1_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_gff_temp_tripal_gff_temp_idx1_idx ON tripal_gff_temp USING btree (uniquename);
+
+
+--
+-- Name: tripal_gffcds_temp_tripal_gff_temp_idx0_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_gffcds_temp_tripal_gff_temp_idx0_idx ON tripal_gffcds_temp USING btree (parent_id);
+
+
+--
+-- Name: tripal_gffprotein_temp_tripal_gff_temp_idx0_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_gffprotein_temp_tripal_gff_temp_idx0_idx ON tripal_gffprotein_temp USING btree (parent_id);
+
+
+--
+-- Name: tripal_obo_temp_tripal_obo_temp_idx0_idx; Type: INDEX; Schema: chado; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_obo_temp_tripal_obo_temp_idx0_idx ON tripal_obo_temp USING btree (type);
+
+
+--
+-- Name: acquisition_assay_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY acquisition
+ ADD CONSTRAINT acquisition_assay_id_fkey FOREIGN KEY (assay_id) REFERENCES assay(assay_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: acquisition_channel_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY acquisition
+ ADD CONSTRAINT acquisition_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES channel(channel_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: acquisition_protocol_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY acquisition
+ ADD CONSTRAINT acquisition_protocol_id_fkey FOREIGN KEY (protocol_id) REFERENCES protocol(protocol_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: acquisition_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY acquisition_relationship
+ ADD CONSTRAINT acquisition_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES acquisition(acquisition_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: acquisition_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY acquisition_relationship
+ ADD CONSTRAINT acquisition_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES acquisition(acquisition_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: acquisition_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY acquisition_relationship
+ ADD CONSTRAINT acquisition_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: acquisitionprop_acquisition_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY acquisitionprop
+ ADD CONSTRAINT acquisitionprop_acquisition_id_fkey FOREIGN KEY (acquisition_id) REFERENCES acquisition(acquisition_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: acquisitionprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY acquisitionprop
+ ADD CONSTRAINT acquisitionprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: analysis_organism_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY analysis_organism
+ ADD CONSTRAINT analysis_organism_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: analysisfeatureprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY analysisfeatureprop
+ ADD CONSTRAINT analysisfeatureprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: analysisprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY analysisprop
+ ADD CONSTRAINT analysisprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: arraydesign_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY arraydesign
+ ADD CONSTRAINT arraydesign_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: arraydesign_manufacturer_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY arraydesign
+ ADD CONSTRAINT arraydesign_manufacturer_id_fkey FOREIGN KEY (manufacturer_id) REFERENCES contact(contact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: arraydesign_platformtype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY arraydesign
+ ADD CONSTRAINT arraydesign_platformtype_id_fkey FOREIGN KEY (platformtype_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: arraydesign_protocol_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY arraydesign
+ ADD CONSTRAINT arraydesign_protocol_id_fkey FOREIGN KEY (protocol_id) REFERENCES protocol(protocol_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: arraydesign_substratetype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY arraydesign
+ ADD CONSTRAINT arraydesign_substratetype_id_fkey FOREIGN KEY (substratetype_id) REFERENCES cvterm(cvterm_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: arraydesignprop_arraydesign_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY arraydesignprop
+ ADD CONSTRAINT arraydesignprop_arraydesign_id_fkey FOREIGN KEY (arraydesign_id) REFERENCES arraydesign(arraydesign_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: arraydesignprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY arraydesignprop
+ ADD CONSTRAINT arraydesignprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: assay_arraydesign_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay
+ ADD CONSTRAINT assay_arraydesign_id_fkey FOREIGN KEY (arraydesign_id) REFERENCES arraydesign(arraydesign_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: assay_biomaterial_assay_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay_biomaterial
+ ADD CONSTRAINT assay_biomaterial_assay_id_fkey FOREIGN KEY (assay_id) REFERENCES assay(assay_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: assay_biomaterial_biomaterial_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay_biomaterial
+ ADD CONSTRAINT assay_biomaterial_biomaterial_id_fkey FOREIGN KEY (biomaterial_id) REFERENCES biomaterial(biomaterial_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: assay_biomaterial_channel_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay_biomaterial
+ ADD CONSTRAINT assay_biomaterial_channel_id_fkey FOREIGN KEY (channel_id) REFERENCES channel(channel_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: assay_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay
+ ADD CONSTRAINT assay_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: assay_operator_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay
+ ADD CONSTRAINT assay_operator_id_fkey FOREIGN KEY (operator_id) REFERENCES contact(contact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: assay_project_assay_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay_project
+ ADD CONSTRAINT assay_project_assay_id_fkey FOREIGN KEY (assay_id) REFERENCES assay(assay_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: assay_project_project_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay_project
+ ADD CONSTRAINT assay_project_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(project_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: assay_protocol_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assay
+ ADD CONSTRAINT assay_protocol_id_fkey FOREIGN KEY (protocol_id) REFERENCES protocol(protocol_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: assayprop_assay_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assayprop
+ ADD CONSTRAINT assayprop_assay_id_fkey FOREIGN KEY (assay_id) REFERENCES assay(assay_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: assayprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY assayprop
+ ADD CONSTRAINT assayprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterial_biosourceprovider_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial
+ ADD CONSTRAINT biomaterial_biosourceprovider_id_fkey FOREIGN KEY (biosourceprovider_id) REFERENCES contact(contact_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterial_dbxref_biomaterial_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial_dbxref
+ ADD CONSTRAINT biomaterial_dbxref_biomaterial_id_fkey FOREIGN KEY (biomaterial_id) REFERENCES biomaterial(biomaterial_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterial_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial_dbxref
+ ADD CONSTRAINT biomaterial_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterial_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial
+ ADD CONSTRAINT biomaterial_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterial_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial_relationship
+ ADD CONSTRAINT biomaterial_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES biomaterial(biomaterial_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterial_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial_relationship
+ ADD CONSTRAINT biomaterial_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES biomaterial(biomaterial_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterial_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial_relationship
+ ADD CONSTRAINT biomaterial_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterial_taxon_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial
+ ADD CONSTRAINT biomaterial_taxon_id_fkey FOREIGN KEY (taxon_id) REFERENCES organism(organism_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterial_treatment_biomaterial_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial_treatment
+ ADD CONSTRAINT biomaterial_treatment_biomaterial_id_fkey FOREIGN KEY (biomaterial_id) REFERENCES biomaterial(biomaterial_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterial_treatment_treatment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial_treatment
+ ADD CONSTRAINT biomaterial_treatment_treatment_id_fkey FOREIGN KEY (treatment_id) REFERENCES treatment(treatment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterial_treatment_unittype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterial_treatment
+ ADD CONSTRAINT biomaterial_treatment_unittype_id_fkey FOREIGN KEY (unittype_id) REFERENCES cvterm(cvterm_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterialprop_biomaterial_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterialprop
+ ADD CONSTRAINT biomaterialprop_biomaterial_id_fkey FOREIGN KEY (biomaterial_id) REFERENCES biomaterial(biomaterial_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: biomaterialprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY biomaterialprop
+ ADD CONSTRAINT biomaterialprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: blast_hit_data_blast_org_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY blast_hit_data
+ ADD CONSTRAINT blast_hit_data_blast_org_id_fkey FOREIGN KEY (blast_org_id) REFERENCES blast_organisms(blast_org_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: blast_hit_data_db_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY blast_hit_data
+ ADD CONSTRAINT blast_hit_data_db_id_fkey FOREIGN KEY (db_id) REFERENCES db(db_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: blast_hit_data_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY blast_hit_data
+ ADD CONSTRAINT blast_hit_data_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_cvterm_cell_line_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_cvterm
+ ADD CONSTRAINT cell_line_cvterm_cell_line_id_fkey FOREIGN KEY (cell_line_id) REFERENCES cell_line(cell_line_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_cvterm_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_cvterm
+ ADD CONSTRAINT cell_line_cvterm_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_cvterm_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_cvterm
+ ADD CONSTRAINT cell_line_cvterm_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_cvtermprop_cell_line_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_cvtermprop
+ ADD CONSTRAINT cell_line_cvtermprop_cell_line_cvterm_id_fkey FOREIGN KEY (cell_line_cvterm_id) REFERENCES cell_line_cvterm(cell_line_cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_cvtermprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_cvtermprop
+ ADD CONSTRAINT cell_line_cvtermprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_dbxref_cell_line_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_dbxref
+ ADD CONSTRAINT cell_line_dbxref_cell_line_id_fkey FOREIGN KEY (cell_line_id) REFERENCES cell_line(cell_line_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_dbxref
+ ADD CONSTRAINT cell_line_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_feature_cell_line_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_feature
+ ADD CONSTRAINT cell_line_feature_cell_line_id_fkey FOREIGN KEY (cell_line_id) REFERENCES cell_line(cell_line_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_feature_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_feature
+ ADD CONSTRAINT cell_line_feature_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_feature_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_feature
+ ADD CONSTRAINT cell_line_feature_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_library_cell_line_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_library
+ ADD CONSTRAINT cell_line_library_cell_line_id_fkey FOREIGN KEY (cell_line_id) REFERENCES cell_line(cell_line_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_library_library_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_library
+ ADD CONSTRAINT cell_line_library_library_id_fkey FOREIGN KEY (library_id) REFERENCES library(library_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_library_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_library
+ ADD CONSTRAINT cell_line_library_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line
+ ADD CONSTRAINT cell_line_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_pub_cell_line_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_pub
+ ADD CONSTRAINT cell_line_pub_cell_line_id_fkey FOREIGN KEY (cell_line_id) REFERENCES cell_line(cell_line_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_pub
+ ADD CONSTRAINT cell_line_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_relationship
+ ADD CONSTRAINT cell_line_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES cell_line(cell_line_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_relationship
+ ADD CONSTRAINT cell_line_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES cell_line(cell_line_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_relationship
+ ADD CONSTRAINT cell_line_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_synonym_cell_line_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_synonym
+ ADD CONSTRAINT cell_line_synonym_cell_line_id_fkey FOREIGN KEY (cell_line_id) REFERENCES cell_line(cell_line_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_synonym_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_synonym
+ ADD CONSTRAINT cell_line_synonym_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line_synonym_synonym_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_line_synonym
+ ADD CONSTRAINT cell_line_synonym_synonym_id_fkey FOREIGN KEY (synonym_id) REFERENCES synonym(synonym_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_lineprop_cell_line_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_lineprop
+ ADD CONSTRAINT cell_lineprop_cell_line_id_fkey FOREIGN KEY (cell_line_id) REFERENCES cell_line(cell_line_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_lineprop_pub_cell_lineprop_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_lineprop_pub
+ ADD CONSTRAINT cell_lineprop_pub_cell_lineprop_id_fkey FOREIGN KEY (cell_lineprop_id) REFERENCES cell_lineprop(cell_lineprop_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_lineprop_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_lineprop_pub
+ ADD CONSTRAINT cell_lineprop_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_lineprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cell_lineprop
+ ADD CONSTRAINT cell_lineprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: chadoprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY chadoprop
+ ADD CONSTRAINT chadoprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: contact_image_contact_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contact_image
+ ADD CONSTRAINT contact_image_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES contact(contact_id);
+
+
+--
+-- Name: contact_image_eimage_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contact_image
+ ADD CONSTRAINT contact_image_eimage_id_fkey FOREIGN KEY (eimage_id) REFERENCES eimage(eimage_id);
+
+
+--
+-- Name: contact_image_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contact_image
+ ADD CONSTRAINT contact_image_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id);
+
+
+--
+-- Name: contact_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contact_relationship
+ ADD CONSTRAINT contact_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES contact(contact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: contact_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contact_relationship
+ ADD CONSTRAINT contact_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES contact(contact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: contact_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contact_relationship
+ ADD CONSTRAINT contact_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: contact_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contact
+ ADD CONSTRAINT contact_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id);
+
+
+--
+-- Name: contactprop_contact_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contactprop
+ ADD CONSTRAINT contactprop_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES contact(contact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: contactprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY contactprop
+ ADD CONSTRAINT contactprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: control_assay_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY control
+ ADD CONSTRAINT control_assay_id_fkey FOREIGN KEY (assay_id) REFERENCES assay(assay_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: control_tableinfo_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY control
+ ADD CONSTRAINT control_tableinfo_id_fkey FOREIGN KEY (tableinfo_id) REFERENCES tableinfo(tableinfo_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: control_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY control
+ ADD CONSTRAINT control_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvprop
+ ADD CONSTRAINT cvprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvterm_dbxref_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvterm_dbxref
+ ADD CONSTRAINT cvterm_dbxref_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvterm_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvterm_dbxref
+ ADD CONSTRAINT cvterm_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvterm_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvterm
+ ADD CONSTRAINT cvterm_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvterm_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvterm_relationship
+ ADD CONSTRAINT cvterm_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvterm_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvterm_relationship
+ ADD CONSTRAINT cvterm_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvterm_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvterm_relationship
+ ADD CONSTRAINT cvterm_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvtermpath_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvtermpath
+ ADD CONSTRAINT cvtermpath_object_id_fkey FOREIGN KEY (object_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvtermpath_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvtermpath
+ ADD CONSTRAINT cvtermpath_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvtermpath_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvtermpath
+ ADD CONSTRAINT cvtermpath_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvtermprop_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvtermprop
+ ADD CONSTRAINT cvtermprop_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: cvtermprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvtermprop
+ ADD CONSTRAINT cvtermprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: cvtermsynonym_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvtermsynonym
+ ADD CONSTRAINT cvtermsynonym_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cvtermsynonym_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY cvtermsynonym
+ ADD CONSTRAINT cvtermsynonym_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: dbxrefprop_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY dbxrefprop
+ ADD CONSTRAINT dbxrefprop_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: dbxrefprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY dbxrefprop
+ ADD CONSTRAINT dbxrefprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: eimageprop_eimage_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY eimageprop
+ ADD CONSTRAINT eimageprop_eimage_id_fkey FOREIGN KEY (eimage_id) REFERENCES eimage(eimage_id) ON DELETE CASCADE;
+
+
+--
+-- Name: eimageprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY eimageprop
+ ADD CONSTRAINT eimageprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: element_arraydesign_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY element
+ ADD CONSTRAINT element_arraydesign_id_fkey FOREIGN KEY (arraydesign_id) REFERENCES arraydesign(arraydesign_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: element_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY element
+ ADD CONSTRAINT element_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: element_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY element
+ ADD CONSTRAINT element_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: element_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY element_relationship
+ ADD CONSTRAINT element_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES element(element_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: element_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY element_relationship
+ ADD CONSTRAINT element_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES element(element_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: element_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY element_relationship
+ ADD CONSTRAINT element_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: element_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY element
+ ADD CONSTRAINT element_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: elementresult_element_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY elementresult
+ ADD CONSTRAINT elementresult_element_id_fkey FOREIGN KEY (element_id) REFERENCES element(element_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: elementresult_quantification_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY elementresult
+ ADD CONSTRAINT elementresult_quantification_id_fkey FOREIGN KEY (quantification_id) REFERENCES quantification(quantification_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: elementresult_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY elementresult_relationship
+ ADD CONSTRAINT elementresult_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES elementresult(elementresult_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: elementresult_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY elementresult_relationship
+ ADD CONSTRAINT elementresult_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES elementresult(elementresult_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: elementresult_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY elementresult_relationship
+ ADD CONSTRAINT elementresult_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: environment_cvterm_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY environment_cvterm
+ ADD CONSTRAINT environment_cvterm_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: environment_cvterm_environment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY environment_cvterm
+ ADD CONSTRAINT environment_cvterm_environment_id_fkey FOREIGN KEY (environment_id) REFERENCES environment(environment_id) ON DELETE CASCADE;
+
+
+--
+-- Name: expression_cvterm_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_cvterm
+ ADD CONSTRAINT expression_cvterm_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: expression_cvterm_cvterm_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_cvterm
+ ADD CONSTRAINT expression_cvterm_cvterm_type_id_fkey FOREIGN KEY (cvterm_type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: expression_cvterm_expression_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_cvterm
+ ADD CONSTRAINT expression_cvterm_expression_id_fkey FOREIGN KEY (expression_id) REFERENCES expression(expression_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: expression_cvtermprop_expression_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_cvtermprop
+ ADD CONSTRAINT expression_cvtermprop_expression_cvterm_id_fkey FOREIGN KEY (expression_cvterm_id) REFERENCES expression_cvterm(expression_cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: expression_cvtermprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_cvtermprop
+ ADD CONSTRAINT expression_cvtermprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: expression_image_eimage_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_image
+ ADD CONSTRAINT expression_image_eimage_id_fkey FOREIGN KEY (eimage_id) REFERENCES eimage(eimage_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: expression_image_expression_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_image
+ ADD CONSTRAINT expression_image_expression_id_fkey FOREIGN KEY (expression_id) REFERENCES expression(expression_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: expression_pub_expression_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_pub
+ ADD CONSTRAINT expression_pub_expression_id_fkey FOREIGN KEY (expression_id) REFERENCES expression(expression_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: expression_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expression_pub
+ ADD CONSTRAINT expression_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: expressionprop_expression_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expressionprop
+ ADD CONSTRAINT expressionprop_expression_id_fkey FOREIGN KEY (expression_id) REFERENCES expression(expression_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: expressionprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY expressionprop
+ ADD CONSTRAINT expressionprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_contact_contact_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_contact
+ ADD CONSTRAINT feature_contact_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES contact(contact_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_contact_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_contact
+ ADD CONSTRAINT feature_contact_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_cvterm_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvterm
+ ADD CONSTRAINT feature_cvterm_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_cvterm_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvterm_dbxref
+ ADD CONSTRAINT feature_cvterm_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_cvterm_dbxref_feature_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvterm_dbxref
+ ADD CONSTRAINT feature_cvterm_dbxref_feature_cvterm_id_fkey FOREIGN KEY (feature_cvterm_id) REFERENCES feature_cvterm(feature_cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_cvterm_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvterm
+ ADD CONSTRAINT feature_cvterm_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_cvterm_pub_feature_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvterm_pub
+ ADD CONSTRAINT feature_cvterm_pub_feature_cvterm_id_fkey FOREIGN KEY (feature_cvterm_id) REFERENCES feature_cvterm(feature_cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_cvterm_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvterm
+ ADD CONSTRAINT feature_cvterm_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_cvterm_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvterm_pub
+ ADD CONSTRAINT feature_cvterm_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_cvtermprop_feature_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvtermprop
+ ADD CONSTRAINT feature_cvtermprop_feature_cvterm_id_fkey FOREIGN KEY (feature_cvterm_id) REFERENCES feature_cvterm(feature_cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_cvtermprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_cvtermprop
+ ADD CONSTRAINT feature_cvtermprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_dbxref
+ ADD CONSTRAINT feature_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_dbxref_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_dbxref
+ ADD CONSTRAINT feature_dbxref_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature
+ ADD CONSTRAINT feature_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_expression_expression_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_expression
+ ADD CONSTRAINT feature_expression_expression_id_fkey FOREIGN KEY (expression_id) REFERENCES expression(expression_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_expression_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_expression
+ ADD CONSTRAINT feature_expression_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_expression_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_expression
+ ADD CONSTRAINT feature_expression_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_expressionprop_feature_expression_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_expressionprop
+ ADD CONSTRAINT feature_expressionprop_feature_expression_id_fkey FOREIGN KEY (feature_expression_id) REFERENCES feature_expression(feature_expression_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_expressionprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_expressionprop
+ ADD CONSTRAINT feature_expressionprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_genotype_chromosome_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_genotype
+ ADD CONSTRAINT feature_genotype_chromosome_id_fkey FOREIGN KEY (chromosome_id) REFERENCES feature(feature_id) ON DELETE SET NULL;
+
+
+--
+-- Name: feature_genotype_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_genotype
+ ADD CONSTRAINT feature_genotype_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_genotype_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_genotype
+ ADD CONSTRAINT feature_genotype_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_genotype_genotype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_genotype
+ ADD CONSTRAINT feature_genotype_genotype_id_fkey FOREIGN KEY (genotype_id) REFERENCES genotype(genotype_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_image_eimage_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_image
+ ADD CONSTRAINT feature_image_eimage_id_fkey FOREIGN KEY (eimage_id) REFERENCES eimage(eimage_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_image_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_image
+ ADD CONSTRAINT feature_image_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature
+ ADD CONSTRAINT feature_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_phenotype_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_phenotype
+ ADD CONSTRAINT feature_phenotype_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_phenotype_phenotype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_phenotype
+ ADD CONSTRAINT feature_phenotype_phenotype_id_fkey FOREIGN KEY (phenotype_id) REFERENCES phenotype(phenotype_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_project_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_project
+ ADD CONSTRAINT feature_project_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_project_project_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_project
+ ADD CONSTRAINT feature_project_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(project_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_pub_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_pub
+ ADD CONSTRAINT feature_pub_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_pub
+ ADD CONSTRAINT feature_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_pubprop_feature_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_pubprop
+ ADD CONSTRAINT feature_pubprop_feature_pub_id_fkey FOREIGN KEY (feature_pub_id) REFERENCES feature_pub(feature_pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_pubprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_pubprop
+ ADD CONSTRAINT feature_pubprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationship
+ ADD CONSTRAINT feature_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_relationship_pub_feature_relationship_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationship_pub
+ ADD CONSTRAINT feature_relationship_pub_feature_relationship_id_fkey FOREIGN KEY (feature_relationship_id) REFERENCES feature_relationship(feature_relationship_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_relationship_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationship_pub
+ ADD CONSTRAINT feature_relationship_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationship
+ ADD CONSTRAINT feature_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationship
+ ADD CONSTRAINT feature_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_relationshipprop_feature_relationship_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationshipprop
+ ADD CONSTRAINT feature_relationshipprop_feature_relationship_id_fkey FOREIGN KEY (feature_relationship_id) REFERENCES feature_relationship(feature_relationship_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_relationshipprop_pub_feature_relationshipprop_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationshipprop_pub
+ ADD CONSTRAINT feature_relationshipprop_pub_feature_relationshipprop_id_fkey FOREIGN KEY (feature_relationshipprop_id) REFERENCES feature_relationshipprop(feature_relationshipprop_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_relationshipprop_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationshipprop_pub
+ ADD CONSTRAINT feature_relationshipprop_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_relationshipprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_relationshipprop
+ ADD CONSTRAINT feature_relationshipprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_stock_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_stock
+ ADD CONSTRAINT feature_stock_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_stock_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_stock
+ ADD CONSTRAINT feature_stock_stock_id_fkey FOREIGN KEY (stock_id) REFERENCES stock(stock_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_stock_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_stock
+ ADD CONSTRAINT feature_stock_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: feature_synonym_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_synonym
+ ADD CONSTRAINT feature_synonym_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_synonym_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_synonym
+ ADD CONSTRAINT feature_synonym_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_synonym_synonym_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature_synonym
+ ADD CONSTRAINT feature_synonym_synonym_id_fkey FOREIGN KEY (synonym_id) REFERENCES synonym(synonym_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: feature_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY feature
+ ADD CONSTRAINT feature_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featureloc_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureloc
+ ADD CONSTRAINT featureloc_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featureloc_pub_featureloc_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureloc_pub
+ ADD CONSTRAINT featureloc_pub_featureloc_id_fkey FOREIGN KEY (featureloc_id) REFERENCES featureloc(featureloc_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featureloc_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureloc_pub
+ ADD CONSTRAINT featureloc_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featureloc_srcfeature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureloc
+ ADD CONSTRAINT featureloc_srcfeature_id_fkey FOREIGN KEY (srcfeature_id) REFERENCES feature(feature_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featuremap_contact_contact_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_contact
+ ADD CONSTRAINT featuremap_contact_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES contact(contact_id) ON DELETE CASCADE;
+
+
+--
+-- Name: featuremap_contact_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_contact
+ ADD CONSTRAINT featuremap_contact_feature_id_fkey FOREIGN KEY (featuremap_id) REFERENCES featuremap(featuremap_id) ON DELETE CASCADE;
+
+
+--
+-- Name: featuremap_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_dbxref
+ ADD CONSTRAINT featuremap_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featuremap_dbxref_featuremap_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_dbxref
+ ADD CONSTRAINT featuremap_dbxref_featuremap_id_fkey FOREIGN KEY (featuremap_id) REFERENCES featuremap(featuremap_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featuremap_organism_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_organism
+ ADD CONSTRAINT featuremap_organism_feature_id_fkey FOREIGN KEY (featuremap_id) REFERENCES featuremap(featuremap_id) ON DELETE CASCADE;
+
+
+--
+-- Name: featuremap_organism_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_organism
+ ADD CONSTRAINT featuremap_organism_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE;
+
+
+--
+-- Name: featuremap_pub_featuremap_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_pub
+ ADD CONSTRAINT featuremap_pub_featuremap_id_fkey FOREIGN KEY (featuremap_id) REFERENCES featuremap(featuremap_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featuremap_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_pub
+ ADD CONSTRAINT featuremap_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featuremap_stock_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_stock
+ ADD CONSTRAINT featuremap_stock_feature_id_fkey FOREIGN KEY (featuremap_id) REFERENCES featuremap(featuremap_id) ON DELETE CASCADE;
+
+
+--
+-- Name: featuremap_stock_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap_stock
+ ADD CONSTRAINT featuremap_stock_stock_id_fkey FOREIGN KEY (stock_id) REFERENCES stock(stock_id) ON DELETE CASCADE;
+
+
+--
+-- Name: featuremap_unittype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremap
+ ADD CONSTRAINT featuremap_unittype_id_fkey FOREIGN KEY (unittype_id) REFERENCES cvterm(cvterm_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featuremapprop_featuremap_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremapprop
+ ADD CONSTRAINT featuremapprop_featuremap_id_fkey FOREIGN KEY (featuremap_id) REFERENCES featuremap(featuremap_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featuremapprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featuremapprop
+ ADD CONSTRAINT featuremapprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featurepos_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featurepos
+ ADD CONSTRAINT featurepos_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featurepos_featuremap_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featurepos
+ ADD CONSTRAINT featurepos_featuremap_id_fkey FOREIGN KEY (featuremap_id) REFERENCES featuremap(featuremap_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featurepos_map_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featurepos
+ ADD CONSTRAINT featurepos_map_feature_id_fkey FOREIGN KEY (map_feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featureposprop_featurepos_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureposprop
+ ADD CONSTRAINT featureposprop_featurepos_id_fkey FOREIGN KEY (featurepos_id) REFERENCES featurepos(featurepos_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featureposprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureposprop
+ ADD CONSTRAINT featureposprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featureprop_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureprop
+ ADD CONSTRAINT featureprop_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featureprop_pub_featureprop_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureprop_pub
+ ADD CONSTRAINT featureprop_pub_featureprop_id_fkey FOREIGN KEY (featureprop_id) REFERENCES featureprop(featureprop_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featureprop_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureprop_pub
+ ADD CONSTRAINT featureprop_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featureprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featureprop
+ ADD CONSTRAINT featureprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featurerange_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featurerange
+ ADD CONSTRAINT featurerange_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featurerange_featuremap_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featurerange
+ ADD CONSTRAINT featurerange_featuremap_id_fkey FOREIGN KEY (featuremap_id) REFERENCES featuremap(featuremap_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featurerange_leftendf_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featurerange
+ ADD CONSTRAINT featurerange_leftendf_id_fkey FOREIGN KEY (leftendf_id) REFERENCES feature(feature_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featurerange_leftstartf_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featurerange
+ ADD CONSTRAINT featurerange_leftstartf_id_fkey FOREIGN KEY (leftstartf_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featurerange_rightendf_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featurerange
+ ADD CONSTRAINT featurerange_rightendf_id_fkey FOREIGN KEY (rightendf_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: featurerange_rightstartf_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY featurerange
+ ADD CONSTRAINT featurerange_rightstartf_id_fkey FOREIGN KEY (rightstartf_id) REFERENCES feature(feature_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: genotype_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY genotype
+ ADD CONSTRAINT genotype_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: genotypeprop_genotype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY genotypeprop
+ ADD CONSTRAINT genotypeprop_genotype_id_fkey FOREIGN KEY (genotype_id) REFERENCES genotype(genotype_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: genotypeprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY genotypeprop
+ ADD CONSTRAINT genotypeprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: library_cvterm_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_cvterm
+ ADD CONSTRAINT library_cvterm_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id);
+
+
+--
+-- Name: library_cvterm_library_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_cvterm
+ ADD CONSTRAINT library_cvterm_library_id_fkey FOREIGN KEY (library_id) REFERENCES library(library_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: library_cvterm_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_cvterm
+ ADD CONSTRAINT library_cvterm_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id);
+
+
+--
+-- Name: library_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_dbxref
+ ADD CONSTRAINT library_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: library_dbxref_library_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_dbxref
+ ADD CONSTRAINT library_dbxref_library_id_fkey FOREIGN KEY (library_id) REFERENCES library(library_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: library_feature_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_feature
+ ADD CONSTRAINT library_feature_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: library_feature_library_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_feature
+ ADD CONSTRAINT library_feature_library_id_fkey FOREIGN KEY (library_id) REFERENCES library(library_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: library_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library
+ ADD CONSTRAINT library_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id);
+
+
+--
+-- Name: library_pub_library_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_pub
+ ADD CONSTRAINT library_pub_library_id_fkey FOREIGN KEY (library_id) REFERENCES library(library_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: library_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_pub
+ ADD CONSTRAINT library_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: library_synonym_library_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_synonym
+ ADD CONSTRAINT library_synonym_library_id_fkey FOREIGN KEY (library_id) REFERENCES library(library_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: library_synonym_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_synonym
+ ADD CONSTRAINT library_synonym_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: library_synonym_synonym_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library_synonym
+ ADD CONSTRAINT library_synonym_synonym_id_fkey FOREIGN KEY (synonym_id) REFERENCES synonym(synonym_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: library_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY library
+ ADD CONSTRAINT library_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id);
+
+
+--
+-- Name: libraryprop_library_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY libraryprop
+ ADD CONSTRAINT libraryprop_library_id_fkey FOREIGN KEY (library_id) REFERENCES library(library_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: libraryprop_pub_libraryprop_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY libraryprop_pub
+ ADD CONSTRAINT libraryprop_pub_libraryprop_id_fkey FOREIGN KEY (libraryprop_id) REFERENCES libraryprop(libraryprop_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: libraryprop_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY libraryprop_pub
+ ADD CONSTRAINT libraryprop_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: libraryprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY libraryprop
+ ADD CONSTRAINT libraryprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id);
+
+
+--
+-- Name: magedocumentation_mageml_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY magedocumentation
+ ADD CONSTRAINT magedocumentation_mageml_id_fkey FOREIGN KEY (mageml_id) REFERENCES mageml(mageml_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: magedocumentation_tableinfo_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY magedocumentation
+ ADD CONSTRAINT magedocumentation_tableinfo_id_fkey FOREIGN KEY (tableinfo_id) REFERENCES tableinfo(tableinfo_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_contact_contact_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_contact
+ ADD CONSTRAINT nd_experiment_contact_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES contact(contact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_contact_nd_experiment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_contact
+ ADD CONSTRAINT nd_experiment_contact_nd_experiment_id_fkey FOREIGN KEY (nd_experiment_id) REFERENCES nd_experiment(nd_experiment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_dbxref
+ ADD CONSTRAINT nd_experiment_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_dbxref_nd_experiment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_dbxref
+ ADD CONSTRAINT nd_experiment_dbxref_nd_experiment_id_fkey FOREIGN KEY (nd_experiment_id) REFERENCES nd_experiment(nd_experiment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_genotype_genotype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_genotype
+ ADD CONSTRAINT nd_experiment_genotype_genotype_id_fkey FOREIGN KEY (genotype_id) REFERENCES genotype(genotype_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_genotype_nd_experiment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_genotype
+ ADD CONSTRAINT nd_experiment_genotype_nd_experiment_id_fkey FOREIGN KEY (nd_experiment_id) REFERENCES nd_experiment(nd_experiment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_nd_geolocation_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment
+ ADD CONSTRAINT nd_experiment_nd_geolocation_id_fkey FOREIGN KEY (nd_geolocation_id) REFERENCES nd_geolocation(nd_geolocation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_phenotype_nd_experiment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_phenotype
+ ADD CONSTRAINT nd_experiment_phenotype_nd_experiment_id_fkey FOREIGN KEY (nd_experiment_id) REFERENCES nd_experiment(nd_experiment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_phenotype_phenotype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_phenotype
+ ADD CONSTRAINT nd_experiment_phenotype_phenotype_id_fkey FOREIGN KEY (phenotype_id) REFERENCES phenotype(phenotype_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_project_nd_experiment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_project
+ ADD CONSTRAINT nd_experiment_project_nd_experiment_id_fkey FOREIGN KEY (nd_experiment_id) REFERENCES nd_experiment(nd_experiment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_project_project_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_project
+ ADD CONSTRAINT nd_experiment_project_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(project_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_protocol_nd_experiment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_protocol
+ ADD CONSTRAINT nd_experiment_protocol_nd_experiment_id_fkey FOREIGN KEY (nd_experiment_id) REFERENCES nd_experiment(nd_experiment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_protocol_nd_protocol_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_protocol
+ ADD CONSTRAINT nd_experiment_protocol_nd_protocol_id_fkey FOREIGN KEY (nd_protocol_id) REFERENCES nd_protocol(nd_protocol_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_pub_nd_experiment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_pub
+ ADD CONSTRAINT nd_experiment_pub_nd_experiment_id_fkey FOREIGN KEY (nd_experiment_id) REFERENCES nd_experiment(nd_experiment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_pub
+ ADD CONSTRAINT nd_experiment_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_stock_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_stock_dbxref
+ ADD CONSTRAINT nd_experiment_stock_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_stock_dbxref_nd_experiment_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_stock_dbxref
+ ADD CONSTRAINT nd_experiment_stock_dbxref_nd_experiment_stock_id_fkey FOREIGN KEY (nd_experiment_stock_id) REFERENCES nd_experiment_stock(nd_experiment_stock_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_stock_nd_experiment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_stock
+ ADD CONSTRAINT nd_experiment_stock_nd_experiment_id_fkey FOREIGN KEY (nd_experiment_id) REFERENCES nd_experiment(nd_experiment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_stock_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_stock
+ ADD CONSTRAINT nd_experiment_stock_stock_id_fkey FOREIGN KEY (stock_id) REFERENCES stock(stock_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_stock_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_stock
+ ADD CONSTRAINT nd_experiment_stock_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_stockprop_nd_experiment_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_stockprop
+ ADD CONSTRAINT nd_experiment_stockprop_nd_experiment_stock_id_fkey FOREIGN KEY (nd_experiment_stock_id) REFERENCES nd_experiment_stock(nd_experiment_stock_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_stockprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment_stockprop
+ ADD CONSTRAINT nd_experiment_stockprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experiment_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experiment
+ ADD CONSTRAINT nd_experiment_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experimentprop_nd_experiment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experimentprop
+ ADD CONSTRAINT nd_experimentprop_nd_experiment_id_fkey FOREIGN KEY (nd_experiment_id) REFERENCES nd_experiment(nd_experiment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_experimentprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_experimentprop
+ ADD CONSTRAINT nd_experimentprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_geolocationprop_nd_geolocation_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_geolocationprop
+ ADD CONSTRAINT nd_geolocationprop_nd_geolocation_id_fkey FOREIGN KEY (nd_geolocation_id) REFERENCES nd_geolocation(nd_geolocation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_geolocationprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_geolocationprop
+ ADD CONSTRAINT nd_geolocationprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_protocol_reagent_nd_protocol_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_protocol_reagent
+ ADD CONSTRAINT nd_protocol_reagent_nd_protocol_id_fkey FOREIGN KEY (nd_protocol_id) REFERENCES nd_protocol(nd_protocol_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_protocol_reagent_reagent_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_protocol_reagent
+ ADD CONSTRAINT nd_protocol_reagent_reagent_id_fkey FOREIGN KEY (reagent_id) REFERENCES nd_reagent(nd_reagent_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_protocol_reagent_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_protocol_reagent
+ ADD CONSTRAINT nd_protocol_reagent_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_protocol_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_protocol
+ ADD CONSTRAINT nd_protocol_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_protocolprop_nd_protocol_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_protocolprop
+ ADD CONSTRAINT nd_protocolprop_nd_protocol_id_fkey FOREIGN KEY (nd_protocol_id) REFERENCES nd_protocol(nd_protocol_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_protocolprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_protocolprop
+ ADD CONSTRAINT nd_protocolprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_reagent_relationship_object_reagent_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_reagent_relationship
+ ADD CONSTRAINT nd_reagent_relationship_object_reagent_id_fkey FOREIGN KEY (object_reagent_id) REFERENCES nd_reagent(nd_reagent_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_reagent_relationship_subject_reagent_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_reagent_relationship
+ ADD CONSTRAINT nd_reagent_relationship_subject_reagent_id_fkey FOREIGN KEY (subject_reagent_id) REFERENCES nd_reagent(nd_reagent_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_reagent_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_reagent_relationship
+ ADD CONSTRAINT nd_reagent_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_reagent_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_reagent
+ ADD CONSTRAINT nd_reagent_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_reagentprop_nd_reagent_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_reagentprop
+ ADD CONSTRAINT nd_reagentprop_nd_reagent_id_fkey FOREIGN KEY (nd_reagent_id) REFERENCES nd_reagent(nd_reagent_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: nd_reagentprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY nd_reagentprop
+ ADD CONSTRAINT nd_reagentprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: organism_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_dbxref
+ ADD CONSTRAINT organism_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: organism_dbxref_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_dbxref
+ ADD CONSTRAINT organism_dbxref_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: organism_for_search_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_for_search
+ ADD CONSTRAINT organism_for_search_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: organism_image_eimage_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_image
+ ADD CONSTRAINT organism_image_eimage_id_fkey FOREIGN KEY (eimage_id) REFERENCES eimage(eimage_id) ON DELETE CASCADE;
+
+
+--
+-- Name: organism_image_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_image
+ ADD CONSTRAINT organism_image_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE;
+
+
+--
+-- Name: organism_pub_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_pub
+ ADD CONSTRAINT organism_pub_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE;
+
+
+--
+-- Name: organism_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_pub
+ ADD CONSTRAINT organism_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE;
+
+
+--
+-- Name: organism_relationship_object_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_relationship
+ ADD CONSTRAINT organism_relationship_object_organism_id_fkey FOREIGN KEY (object_organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE;
+
+
+--
+-- Name: organism_relationship_subject_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_relationship
+ ADD CONSTRAINT organism_relationship_subject_organism_id_fkey FOREIGN KEY (subject_organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE;
+
+
+--
+-- Name: organism_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organism_relationship
+ ADD CONSTRAINT organism_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: organismprop_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organismprop
+ ADD CONSTRAINT organismprop_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: organismprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY organismprop
+ ADD CONSTRAINT organismprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: phendesc_environment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phendesc
+ ADD CONSTRAINT phendesc_environment_id_fkey FOREIGN KEY (environment_id) REFERENCES environment(environment_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phendesc_genotype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phendesc
+ ADD CONSTRAINT phendesc_genotype_id_fkey FOREIGN KEY (genotype_id) REFERENCES genotype(genotype_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phendesc_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phendesc
+ ADD CONSTRAINT phendesc_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phendesc_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phendesc
+ ADD CONSTRAINT phendesc_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_assay_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype
+ ADD CONSTRAINT phenotype_assay_id_fkey FOREIGN KEY (assay_id) REFERENCES cvterm(cvterm_id) ON DELETE SET NULL;
+
+
+--
+-- Name: phenotype_attr_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype
+ ADD CONSTRAINT phenotype_attr_id_fkey FOREIGN KEY (attr_id) REFERENCES cvterm(cvterm_id) ON DELETE SET NULL;
+
+
+--
+-- Name: phenotype_comparison_cvterm_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison_cvterm
+ ADD CONSTRAINT phenotype_comparison_cvterm_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_comparison_cvterm_phenotype_comparison_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison_cvterm
+ ADD CONSTRAINT phenotype_comparison_cvterm_phenotype_comparison_id_fkey FOREIGN KEY (phenotype_comparison_id) REFERENCES phenotype_comparison(phenotype_comparison_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_comparison_cvterm_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison_cvterm
+ ADD CONSTRAINT phenotype_comparison_cvterm_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_comparison_environment1_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison
+ ADD CONSTRAINT phenotype_comparison_environment1_id_fkey FOREIGN KEY (environment1_id) REFERENCES environment(environment_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_comparison_environment2_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison
+ ADD CONSTRAINT phenotype_comparison_environment2_id_fkey FOREIGN KEY (environment2_id) REFERENCES environment(environment_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_comparison_genotype1_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison
+ ADD CONSTRAINT phenotype_comparison_genotype1_id_fkey FOREIGN KEY (genotype1_id) REFERENCES genotype(genotype_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_comparison_genotype2_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison
+ ADD CONSTRAINT phenotype_comparison_genotype2_id_fkey FOREIGN KEY (genotype2_id) REFERENCES genotype(genotype_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_comparison_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison
+ ADD CONSTRAINT phenotype_comparison_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_comparison_phenotype1_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison
+ ADD CONSTRAINT phenotype_comparison_phenotype1_id_fkey FOREIGN KEY (phenotype1_id) REFERENCES phenotype(phenotype_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_comparison_phenotype2_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison
+ ADD CONSTRAINT phenotype_comparison_phenotype2_id_fkey FOREIGN KEY (phenotype2_id) REFERENCES phenotype(phenotype_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_comparison_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_comparison
+ ADD CONSTRAINT phenotype_comparison_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_cvalue_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype
+ ADD CONSTRAINT phenotype_cvalue_id_fkey FOREIGN KEY (cvalue_id) REFERENCES cvterm(cvterm_id) ON DELETE SET NULL;
+
+
+--
+-- Name: phenotype_cvterm_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_cvterm
+ ADD CONSTRAINT phenotype_cvterm_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_cvterm_phenotype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype_cvterm
+ ADD CONSTRAINT phenotype_cvterm_phenotype_id_fkey FOREIGN KEY (phenotype_id) REFERENCES phenotype(phenotype_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenotype_observable_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenotype
+ ADD CONSTRAINT phenotype_observable_id_fkey FOREIGN KEY (observable_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenstatement_environment_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenstatement
+ ADD CONSTRAINT phenstatement_environment_id_fkey FOREIGN KEY (environment_id) REFERENCES environment(environment_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenstatement_genotype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenstatement
+ ADD CONSTRAINT phenstatement_genotype_id_fkey FOREIGN KEY (genotype_id) REFERENCES genotype(genotype_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenstatement_phenotype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenstatement
+ ADD CONSTRAINT phenstatement_phenotype_id_fkey FOREIGN KEY (phenotype_id) REFERENCES phenotype(phenotype_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenstatement_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenstatement
+ ADD CONSTRAINT phenstatement_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenstatement_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenstatement
+ ADD CONSTRAINT phenstatement_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenstatementprop_phenstatement_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenstatementprop
+ ADD CONSTRAINT phenstatementprop_phenstatement_id_fkey FOREIGN KEY (phenstatement_id) REFERENCES phenstatement(phenstatement_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phenstatementprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phenstatementprop
+ ADD CONSTRAINT phenstatementprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_dbxref
+ ADD CONSTRAINT phylonode_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_dbxref_phylonode_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_dbxref
+ ADD CONSTRAINT phylonode_dbxref_phylonode_id_fkey FOREIGN KEY (phylonode_id) REFERENCES phylonode(phylonode_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode
+ ADD CONSTRAINT phylonode_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_organism_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_organism
+ ADD CONSTRAINT phylonode_organism_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_organism_phylonode_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_organism
+ ADD CONSTRAINT phylonode_organism_phylonode_id_fkey FOREIGN KEY (phylonode_id) REFERENCES phylonode(phylonode_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_parent_phylonode_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode
+ ADD CONSTRAINT phylonode_parent_phylonode_id_fkey FOREIGN KEY (parent_phylonode_id) REFERENCES phylonode(phylonode_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_phylotree_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode
+ ADD CONSTRAINT phylonode_phylotree_id_fkey FOREIGN KEY (phylotree_id) REFERENCES phylotree(phylotree_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_pub_phylonode_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_pub
+ ADD CONSTRAINT phylonode_pub_phylonode_id_fkey FOREIGN KEY (phylonode_id) REFERENCES phylonode(phylonode_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_pub
+ ADD CONSTRAINT phylonode_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_relationship
+ ADD CONSTRAINT phylonode_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES phylonode(phylonode_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_relationship_phylotree_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_relationship
+ ADD CONSTRAINT phylonode_relationship_phylotree_id_fkey FOREIGN KEY (phylotree_id) REFERENCES phylotree(phylotree_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_relationship
+ ADD CONSTRAINT phylonode_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES phylonode(phylonode_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode_relationship
+ ADD CONSTRAINT phylonode_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonode_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonode
+ ADD CONSTRAINT phylonode_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonodeprop_phylonode_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonodeprop
+ ADD CONSTRAINT phylonodeprop_phylonode_id_fkey FOREIGN KEY (phylonode_id) REFERENCES phylonode(phylonode_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylonodeprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylonodeprop
+ ADD CONSTRAINT phylonodeprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylotree_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylotree
+ ADD CONSTRAINT phylotree_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylotree_pub_phylotree_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylotree_pub
+ ADD CONSTRAINT phylotree_pub_phylotree_id_fkey FOREIGN KEY (phylotree_id) REFERENCES phylotree(phylotree_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylotree_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylotree_pub
+ ADD CONSTRAINT phylotree_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE;
+
+
+--
+-- Name: phylotree_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY phylotree
+ ADD CONSTRAINT phylotree_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: project_contact_contact_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY project_contact
+ ADD CONSTRAINT project_contact_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES contact(contact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: project_contact_project_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY project_contact
+ ADD CONSTRAINT project_contact_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(project_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: project_pub_project_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY project_pub
+ ADD CONSTRAINT project_pub_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(project_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: project_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY project_pub
+ ADD CONSTRAINT project_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: project_relationship_object_project_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY project_relationship
+ ADD CONSTRAINT project_relationship_object_project_id_fkey FOREIGN KEY (object_project_id) REFERENCES project(project_id) ON DELETE CASCADE;
+
+
+--
+-- Name: project_relationship_subject_project_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY project_relationship
+ ADD CONSTRAINT project_relationship_subject_project_id_fkey FOREIGN KEY (subject_project_id) REFERENCES project(project_id) ON DELETE CASCADE;
+
+
+--
+-- Name: project_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY project_relationship
+ ADD CONSTRAINT project_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE RESTRICT;
+
+
+--
+-- Name: projectprop_project_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY projectprop
+ ADD CONSTRAINT projectprop_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(project_id) ON DELETE CASCADE;
+
+
+--
+-- Name: projectprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY projectprop
+ ADD CONSTRAINT projectprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: protocol_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY protocol
+ ADD CONSTRAINT protocol_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: protocol_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY protocol
+ ADD CONSTRAINT protocol_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: protocol_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY protocol
+ ADD CONSTRAINT protocol_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: protocolparam_datatype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY protocolparam
+ ADD CONSTRAINT protocolparam_datatype_id_fkey FOREIGN KEY (datatype_id) REFERENCES cvterm(cvterm_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: protocolparam_protocol_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY protocolparam
+ ADD CONSTRAINT protocolparam_protocol_id_fkey FOREIGN KEY (protocol_id) REFERENCES protocol(protocol_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: protocolparam_unittype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY protocolparam
+ ADD CONSTRAINT protocolparam_unittype_id_fkey FOREIGN KEY (unittype_id) REFERENCES cvterm(cvterm_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: pub_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pub_dbxref
+ ADD CONSTRAINT pub_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: pub_dbxref_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pub_dbxref
+ ADD CONSTRAINT pub_dbxref_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: pub_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pub_relationship
+ ADD CONSTRAINT pub_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: pub_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pub_relationship
+ ADD CONSTRAINT pub_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: pub_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pub_relationship
+ ADD CONSTRAINT pub_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: pub_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pub
+ ADD CONSTRAINT pub_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: pubauthor_contact_contact_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pubauthor_contact
+ ADD CONSTRAINT pubauthor_contact_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES contact(contact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: pubauthor_contact_pubauthor_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pubauthor_contact
+ ADD CONSTRAINT pubauthor_contact_pubauthor_id_fkey FOREIGN KEY (pubauthor_id) REFERENCES pubauthor(pubauthor_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: pubauthor_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pubauthor
+ ADD CONSTRAINT pubauthor_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: pubprop_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pubprop
+ ADD CONSTRAINT pubprop_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: pubprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY pubprop
+ ADD CONSTRAINT pubprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: qtl_search_ref_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY qtl_search
+ ADD CONSTRAINT qtl_search_ref_pub_id_fkey FOREIGN KEY (ref_pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: qtl_search_study_project_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY qtl_search
+ ADD CONSTRAINT qtl_search_study_project_id_fkey FOREIGN KEY (study_project_id) REFERENCES project(project_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: quantification_acquisition_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY quantification
+ ADD CONSTRAINT quantification_acquisition_id_fkey FOREIGN KEY (acquisition_id) REFERENCES acquisition(acquisition_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: quantification_operator_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY quantification
+ ADD CONSTRAINT quantification_operator_id_fkey FOREIGN KEY (operator_id) REFERENCES contact(contact_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: quantification_protocol_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY quantification
+ ADD CONSTRAINT quantification_protocol_id_fkey FOREIGN KEY (protocol_id) REFERENCES protocol(protocol_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: quantification_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY quantification_relationship
+ ADD CONSTRAINT quantification_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES quantification(quantification_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: quantification_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY quantification_relationship
+ ADD CONSTRAINT quantification_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES quantification(quantification_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: quantification_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY quantification_relationship
+ ADD CONSTRAINT quantification_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: quantificationprop_quantification_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY quantificationprop
+ ADD CONSTRAINT quantificationprop_quantification_id_fkey FOREIGN KEY (quantification_id) REFERENCES quantification(quantification_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: quantificationprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY quantificationprop
+ ADD CONSTRAINT quantificationprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: search_by_map_featuremap_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY search_by_map
+ ADD CONSTRAINT search_by_map_featuremap_id_fkey FOREIGN KEY (featuremap_id) REFERENCES featuremap(featuremap_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: search_by_map_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY search_by_map
+ ADD CONSTRAINT search_by_map_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: search_by_map_pop_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY search_by_map
+ ADD CONSTRAINT search_by_map_pop_stock_id_fkey FOREIGN KEY (pop_stock_id) REFERENCES stock(stock_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: searchable_features_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY searchable_features
+ ADD CONSTRAINT searchable_features_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: searchable_features_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY searchable_features
+ ADD CONSTRAINT searchable_features_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: species_summary_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY species_summary
+ ADD CONSTRAINT species_summary_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_cvterm_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_cvterm
+ ADD CONSTRAINT stock_cvterm_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_cvterm_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_cvterm
+ ADD CONSTRAINT stock_cvterm_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_cvterm_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_cvterm
+ ADD CONSTRAINT stock_cvterm_stock_id_fkey FOREIGN KEY (stock_id) REFERENCES stock(stock_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_cvtermprop_stock_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_cvtermprop
+ ADD CONSTRAINT stock_cvtermprop_stock_cvterm_id_fkey FOREIGN KEY (stock_cvterm_id) REFERENCES stock_cvterm(stock_cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: stock_cvtermprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_cvtermprop
+ ADD CONSTRAINT stock_cvtermprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_dbxref_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_dbxref
+ ADD CONSTRAINT stock_dbxref_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock
+ ADD CONSTRAINT stock_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_dbxref_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_dbxref
+ ADD CONSTRAINT stock_dbxref_stock_id_fkey FOREIGN KEY (stock_id) REFERENCES stock(stock_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_dbxrefprop_stock_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_dbxrefprop
+ ADD CONSTRAINT stock_dbxrefprop_stock_dbxref_id_fkey FOREIGN KEY (stock_dbxref_id) REFERENCES stock_dbxref(stock_dbxref_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_dbxrefprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_dbxrefprop
+ ADD CONSTRAINT stock_dbxrefprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_genotype_genotype_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_genotype
+ ADD CONSTRAINT stock_genotype_genotype_id_fkey FOREIGN KEY (genotype_id) REFERENCES genotype(genotype_id) ON DELETE CASCADE;
+
+
+--
+-- Name: stock_genotype_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_genotype
+ ADD CONSTRAINT stock_genotype_stock_id_fkey FOREIGN KEY (stock_id) REFERENCES stock(stock_id) ON DELETE CASCADE;
+
+
+--
+-- Name: stock_image_eimage_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_image
+ ADD CONSTRAINT stock_image_eimage_id_fkey FOREIGN KEY (eimage_id) REFERENCES eimage(eimage_id) ON DELETE CASCADE;
+
+
+--
+-- Name: stock_image_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_image
+ ADD CONSTRAINT stock_image_stock_id_fkey FOREIGN KEY (stock_id) REFERENCES stock(stock_id) ON DELETE CASCADE;
+
+
+--
+-- Name: stock_organism_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock
+ ADD CONSTRAINT stock_organism_id_fkey FOREIGN KEY (organism_id) REFERENCES organism(organism_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_pub
+ ADD CONSTRAINT stock_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_pub_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_pub
+ ADD CONSTRAINT stock_pub_stock_id_fkey FOREIGN KEY (stock_id) REFERENCES stock(stock_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_relationship_cvterm_cvterm_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_relationship_cvterm
+ ADD CONSTRAINT stock_relationship_cvterm_cvterm_id_fkey FOREIGN KEY (cvterm_id) REFERENCES cvterm(cvterm_id) ON DELETE RESTRICT;
+
+
+--
+-- Name: stock_relationship_cvterm_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_relationship_cvterm
+ ADD CONSTRAINT stock_relationship_cvterm_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE RESTRICT;
+
+
+--
+-- Name: stock_relationship_cvterm_stock_relationship_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_relationship_cvterm
+ ADD CONSTRAINT stock_relationship_cvterm_stock_relationship_id_fkey FOREIGN KEY (stock_relationship_id) REFERENCES stock_relationship(stock_relationship_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_relationship_object_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_relationship
+ ADD CONSTRAINT stock_relationship_object_id_fkey FOREIGN KEY (object_id) REFERENCES stock(stock_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_relationship_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_relationship_pub
+ ADD CONSTRAINT stock_relationship_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_relationship_pub_stock_relationship_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_relationship_pub
+ ADD CONSTRAINT stock_relationship_pub_stock_relationship_id_fkey FOREIGN KEY (stock_relationship_id) REFERENCES stock_relationship(stock_relationship_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_relationship_subject_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_relationship
+ ADD CONSTRAINT stock_relationship_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES stock(stock_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_relationship_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock_relationship
+ ADD CONSTRAINT stock_relationship_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stock_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stock
+ ADD CONSTRAINT stock_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stockcollection_contact_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockcollection
+ ADD CONSTRAINT stockcollection_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES contact(contact_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stockcollection_stock_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockcollection_stock
+ ADD CONSTRAINT stockcollection_stock_stock_id_fkey FOREIGN KEY (stock_id) REFERENCES stock(stock_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stockcollection_stock_stockcollection_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockcollection_stock
+ ADD CONSTRAINT stockcollection_stock_stockcollection_id_fkey FOREIGN KEY (stockcollection_id) REFERENCES stockcollection(stockcollection_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stockcollection_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockcollection
+ ADD CONSTRAINT stockcollection_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: stockcollectionprop_stockcollection_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockcollectionprop
+ ADD CONSTRAINT stockcollectionprop_stockcollection_id_fkey FOREIGN KEY (stockcollection_id) REFERENCES stockcollection(stockcollection_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stockcollectionprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockcollectionprop
+ ADD CONSTRAINT stockcollectionprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id);
+
+
+--
+-- Name: stockprop_pub_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockprop_pub
+ ADD CONSTRAINT stockprop_pub_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stockprop_pub_stockprop_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockprop_pub
+ ADD CONSTRAINT stockprop_pub_stockprop_id_fkey FOREIGN KEY (stockprop_id) REFERENCES stockprop(stockprop_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stockprop_stock_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockprop
+ ADD CONSTRAINT stockprop_stock_id_fkey FOREIGN KEY (stock_id) REFERENCES stock(stock_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: stockprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY stockprop
+ ADD CONSTRAINT stockprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: study_assay_assay_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY study_assay
+ ADD CONSTRAINT study_assay_assay_id_fkey FOREIGN KEY (assay_id) REFERENCES assay(assay_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: study_assay_study_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY study_assay
+ ADD CONSTRAINT study_assay_study_id_fkey FOREIGN KEY (study_id) REFERENCES study(study_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: study_contact_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY study
+ ADD CONSTRAINT study_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES contact(contact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: study_dbxref_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY study
+ ADD CONSTRAINT study_dbxref_id_fkey FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: study_pub_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY study
+ ADD CONSTRAINT study_pub_id_fkey FOREIGN KEY (pub_id) REFERENCES pub(pub_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: studydesign_study_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studydesign
+ ADD CONSTRAINT studydesign_study_id_fkey FOREIGN KEY (study_id) REFERENCES study(study_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: studydesignprop_studydesign_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studydesignprop
+ ADD CONSTRAINT studydesignprop_studydesign_id_fkey FOREIGN KEY (studydesign_id) REFERENCES studydesign(studydesign_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: studydesignprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studydesignprop
+ ADD CONSTRAINT studydesignprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: studyfactor_studydesign_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyfactor
+ ADD CONSTRAINT studyfactor_studydesign_id_fkey FOREIGN KEY (studydesign_id) REFERENCES studydesign(studydesign_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: studyfactor_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyfactor
+ ADD CONSTRAINT studyfactor_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: studyfactorvalue_assay_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyfactorvalue
+ ADD CONSTRAINT studyfactorvalue_assay_id_fkey FOREIGN KEY (assay_id) REFERENCES assay(assay_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: studyfactorvalue_studyfactor_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyfactorvalue
+ ADD CONSTRAINT studyfactorvalue_studyfactor_id_fkey FOREIGN KEY (studyfactor_id) REFERENCES studyfactor(studyfactor_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: studyprop_feature_feature_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyprop_feature
+ ADD CONSTRAINT studyprop_feature_feature_id_fkey FOREIGN KEY (feature_id) REFERENCES feature(feature_id) ON DELETE CASCADE;
+
+
+--
+-- Name: studyprop_feature_studyprop_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyprop_feature
+ ADD CONSTRAINT studyprop_feature_studyprop_id_fkey FOREIGN KEY (studyprop_id) REFERENCES studyprop(studyprop_id) ON DELETE CASCADE;
+
+
+--
+-- Name: studyprop_feature_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyprop_feature
+ ADD CONSTRAINT studyprop_feature_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: studyprop_study_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyprop
+ ADD CONSTRAINT studyprop_study_id_fkey FOREIGN KEY (study_id) REFERENCES study(study_id) ON DELETE CASCADE;
+
+
+--
+-- Name: studyprop_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY studyprop
+ ADD CONSTRAINT studyprop_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE;
+
+
+--
+-- Name: synonym_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY synonym
+ ADD CONSTRAINT synonym_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: treatment_biomaterial_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY treatment
+ ADD CONSTRAINT treatment_biomaterial_id_fkey FOREIGN KEY (biomaterial_id) REFERENCES biomaterial(biomaterial_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: treatment_protocol_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY treatment
+ ADD CONSTRAINT treatment_protocol_id_fkey FOREIGN KEY (protocol_id) REFERENCES protocol(protocol_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: treatment_type_id_fkey; Type: FK CONSTRAINT; Schema: chado; Owner: -
+--
+
+ALTER TABLE ONLY treatment
+ ADD CONSTRAINT treatment_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: cell_line; Type: ACL; Schema: chado; Owner: -
+--
+
+REVOKE ALL ON TABLE cell_line FROM PUBLIC;
+REVOKE ALL ON TABLE cell_line FROM postgres;
+GRANT ALL ON TABLE cell_line TO postgres;
+GRANT ALL ON TABLE cell_line TO PUBLIC;
+
+
+--
+-- Name: cell_line_cvterm; Type: ACL; Schema: chado; Owner: -
+--
+
+REVOKE ALL ON TABLE cell_line_cvterm FROM PUBLIC;
+REVOKE ALL ON TABLE cell_line_cvterm FROM postgres;
+GRANT ALL ON TABLE cell_line_cvterm TO postgres;
+GRANT ALL ON TABLE cell_line_cvterm TO PUBLIC;
+
+
+--
+-- Name: cell_line_cvtermprop; Type: ACL; Schema: chado; Owner: -
+--
+
+REVOKE ALL ON TABLE cell_line_cvtermprop FROM PUBLIC;
+REVOKE ALL ON TABLE cell_line_cvtermprop FROM postgres;
+GRANT ALL ON TABLE cell_line_cvtermprop TO postgres;
+GRANT ALL ON TABLE cell_line_cvtermprop TO PUBLIC;
+
+
+--
+-- Name: cell_line_dbxref; Type: ACL; Schema: chado; Owner: -
+--
+
+REVOKE ALL ON TABLE cell_line_dbxref FROM PUBLIC;
+REVOKE ALL ON TABLE cell_line_dbxref FROM postgres;
+GRANT ALL ON TABLE cell_line_dbxref TO postgres;
+GRANT ALL ON TABLE cell_line_dbxref TO PUBLIC;
+
+
+--
+-- Name: cell_line_feature; Type: ACL; Schema: chado; Owner: -
+--
+
+REVOKE ALL ON TABLE cell_line_feature FROM PUBLIC;
+REVOKE ALL ON TABLE cell_line_feature FROM postgres;
+GRANT ALL ON TABLE cell_line_feature TO postgres;
+GRANT ALL ON TABLE cell_line_feature TO PUBLIC;
+
+
+--
+-- Name: cell_line_library; Type: ACL; Schema: chado; Owner: -
+--
+
+REVOKE ALL ON TABLE cell_line_library FROM PUBLIC;
+REVOKE ALL ON TABLE cell_line_library FROM postgres;
+GRANT ALL ON TABLE cell_line_library TO postgres;
+GRANT ALL ON TABLE cell_line_library TO PUBLIC;
+
+
+--
+-- Name: cell_line_pub; Type: ACL; Schema: chado; Owner: -
+--
+
+REVOKE ALL ON TABLE cell_line_pub FROM PUBLIC;
+REVOKE ALL ON TABLE cell_line_pub FROM postgres;
+GRANT ALL ON TABLE cell_line_pub TO postgres;
+GRANT ALL ON TABLE cell_line_pub TO PUBLIC;
+
+
+--
+-- Name: cell_line_relationship; Type: ACL; Schema: chado; Owner: -
+--
+
+REVOKE ALL ON TABLE cell_line_relationship FROM PUBLIC;
+REVOKE ALL ON TABLE cell_line_relationship FROM postgres;
+GRANT ALL ON TABLE cell_line_relationship TO postgres;
+GRANT ALL ON TABLE cell_line_relationship TO PUBLIC;
+
+
+--
+-- Name: cell_line_synonym; Type: ACL; Schema: chado; Owner: -
+--
+
+REVOKE ALL ON TABLE cell_line_synonym FROM PUBLIC;
+REVOKE ALL ON TABLE cell_line_synonym FROM postgres;
+GRANT ALL ON TABLE cell_line_synonym TO postgres;
+GRANT ALL ON TABLE cell_line_synonym TO PUBLIC;
+
+
+--
+-- Name: cell_lineprop; Type: ACL; Schema: chado; Owner: -
+--
+
+REVOKE ALL ON TABLE cell_lineprop FROM PUBLIC;
+REVOKE ALL ON TABLE cell_lineprop FROM postgres;
+GRANT ALL ON TABLE cell_lineprop TO postgres;
+GRANT ALL ON TABLE cell_lineprop TO PUBLIC;
+
+
+--
+-- Name: cell_lineprop_pub; Type: ACL; Schema: chado; Owner: -
+--
+
+REVOKE ALL ON TABLE cell_lineprop_pub FROM PUBLIC;
+REVOKE ALL ON TABLE cell_lineprop_pub FROM postgres;
+GRANT ALL ON TABLE cell_lineprop_pub TO postgres;
+GRANT ALL ON TABLE cell_lineprop_pub TO PUBLIC;
+
+
+--
+-- PostgreSQL database dump complete
+--
+
diff --git a/schema/drupal7.public.sql b/schema/drupal7.public.sql
new file mode 100644
index 0000000..f2b22ac
--- /dev/null
+++ b/schema/drupal7.public.sql
@@ -0,0 +1,11336 @@
+--
+-- PostgreSQL database dump
+--
+
+SET statement_timeout = 0;
+SET lock_timeout = 0;
+SET client_encoding = 'UTF8';
+SET standard_conforming_strings = on;
+SET check_function_bodies = false;
+SET client_min_messages = warning;
+
+SET search_path = public, pg_catalog;
+
+--
+-- Name: concat(anynonarray, anynonarray); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION concat(anynonarray, anynonarray) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT CAST($1 AS text) || CAST($2 AS text);$_$;
+
+
+--
+-- Name: concat(anynonarray, text); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION concat(anynonarray, text) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT CAST($1 AS text) || $2;$_$;
+
+
+--
+-- Name: concat(text, anynonarray); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION concat(text, anynonarray) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT $1 || CAST($2 AS text);$_$;
+
+
+--
+-- Name: concat(text, text); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION concat(text, text) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT $1 || $2;$_$;
+
+
+--
+-- Name: first(anyelement, anyelement); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION first(anyelement, anyelement) RETURNS anyelement
+ LANGUAGE sql
+ AS $_$SELECT COALESCE($1, $2);$_$;
+
+
+--
+-- Name: gensas_update_seq_rank(integer); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION gensas_update_seq_rank(seq_group_id integer) RETURNS void
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ i int;
+ id int;
+ r1 RECORD;
+ BEGIN
+ i := 0;
+ id := seq_group_id;
+
+ -- assign rank to each sequence in a group
+ FOR r1 IN
+ SELECT GS.seq_id
+ FROM gensas_seq GS
+ WHERE GS.seq_group_id = id
+ ORDER BY GS.name
+ LOOP
+ -- update gensas_seq.rank
+ UPDATE gensas_seq SET rank = i WHERE seq_id = r1.seq_id;
+ i := i + 1;
+ END LOOP;
+ END;
+ $$;
+
+
+--
+-- Name: gensas_update_seq_rank_all(); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION gensas_update_seq_rank_all() RETURNS void
+ LANGUAGE plpgsql
+ AS $$
+ DECLARE
+ r1 RECORD;
+ BEGIN
+ -- get all sequence groups
+ FOR r1 IN
+ SELECT seq_group_id FROM gensas_seq_group
+ LOOP
+ PERFORM gensas_update_seq_rank(r1.seq_group_id);
+ END LOOP;
+ END;
+ $$;
+
+
+--
+-- Name: greatest(numeric, numeric); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION "greatest"(numeric, numeric) RETURNS numeric
+ LANGUAGE sql
+ AS $_$SELECT CASE WHEN (($1 > $2) OR ($2 IS NULL)) THEN $1 ELSE $2 END;$_$;
+
+
+--
+-- Name: greatest(numeric, numeric, numeric); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION "greatest"(numeric, numeric, numeric) RETURNS numeric
+ LANGUAGE sql
+ AS $_$SELECT greatest($1, greatest($2, $3));$_$;
+
+
+--
+-- Name: rand(); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION rand() RETURNS double precision
+ LANGUAGE sql
+ AS $$SELECT random();$$;
+
+
+--
+-- Name: substring_index(text, text, integer); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION substring_index(text, text, integer) RETURNS text
+ LANGUAGE sql
+ AS $_$SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);$_$;
+
+
+--
+-- Name: first(anyelement); Type: AGGREGATE; Schema: public; Owner: -
+--
+
+CREATE AGGREGATE first(anyelement) (
+ SFUNC = public.first,
+ STYPE = anyelement
+);
+
+
+SET default_tablespace = '';
+
+SET default_with_oids = false;
+
+--
+-- Name: actions; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE actions (
+ aid character varying(255) DEFAULT '0'::character varying NOT NULL,
+ type character varying(32) DEFAULT ''::character varying NOT NULL,
+ callback character varying(255) DEFAULT ''::character varying NOT NULL,
+ parameters bytea NOT NULL,
+ label character varying(255) DEFAULT '0'::character varying NOT NULL
+);
+
+
+--
+-- Name: TABLE actions; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE actions IS 'Stores action information.';
+
+
+--
+-- Name: COLUMN actions.aid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN actions.aid IS 'Primary Key: Unique actions ID.';
+
+
+--
+-- Name: COLUMN actions.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN actions.type IS 'The object that that action acts on (node, user, comment, system or custom types.)';
+
+
+--
+-- Name: COLUMN actions.callback; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN actions.callback IS 'The callback function that executes when the action runs.';
+
+
+--
+-- Name: COLUMN actions.parameters; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN actions.parameters IS 'Parameters to be passed to the callback function.';
+
+
+--
+-- Name: COLUMN actions.label; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN actions.label IS 'Label of the action.';
+
+
+--
+-- Name: authmap; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE authmap (
+ aid integer NOT NULL,
+ uid integer DEFAULT 0 NOT NULL,
+ authname character varying(128) DEFAULT ''::character varying NOT NULL,
+ module character varying(128) DEFAULT ''::character varying NOT NULL,
+ CONSTRAINT authmap_aid_check CHECK ((aid >= 0))
+);
+
+
+--
+-- Name: TABLE authmap; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE authmap IS 'Stores distributed authentication mapping.';
+
+
+--
+-- Name: COLUMN authmap.aid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN authmap.aid IS 'Primary Key: Unique authmap ID.';
+
+
+--
+-- Name: COLUMN authmap.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN authmap.uid IS 'User''s users.uid.';
+
+
+--
+-- Name: COLUMN authmap.authname; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN authmap.authname IS 'Unique authentication name.';
+
+
+--
+-- Name: COLUMN authmap.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN authmap.module IS 'Module which is controlling the authentication.';
+
+
+--
+-- Name: authmap_aid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE authmap_aid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: authmap_aid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE authmap_aid_seq OWNED BY authmap.aid;
+
+
+--
+-- Name: batch; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE batch (
+ bid bigint NOT NULL,
+ token character varying(64) NOT NULL,
+ "timestamp" integer NOT NULL,
+ batch bytea,
+ CONSTRAINT batch_bid_check CHECK ((bid >= 0))
+);
+
+
+--
+-- Name: TABLE batch; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE batch IS 'Stores details about batches (processes that run in multiple HTTP requests).';
+
+
+--
+-- Name: COLUMN batch.bid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN batch.bid IS 'Primary Key: Unique batch ID.';
+
+
+--
+-- Name: COLUMN batch.token; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN batch.token IS 'A string token generated against the current user''s session id and the batch id, used to ensure that only the user who submitted the batch can effectively access it.';
+
+
+--
+-- Name: COLUMN batch."timestamp"; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN batch."timestamp" IS 'A Unix timestamp indicating when this batch was submitted for processing. Stale batches are purged at cron time.';
+
+
+--
+-- Name: COLUMN batch.batch; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN batch.batch IS 'A serialized array containing the processing data for the batch.';
+
+
+--
+-- Name: bims_crop; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_crop (
+ crop_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ label character varying(255) NOT NULL,
+ image_url character varying(255) NOT NULL,
+ prop text
+);
+
+
+--
+-- Name: bims_crop_crop_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE bims_crop_crop_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: bims_crop_crop_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE bims_crop_crop_id_seq OWNED BY bims_crop.crop_id;
+
+
+--
+-- Name: bims_crop_organism; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_crop_organism (
+ crop_id integer NOT NULL,
+ organism_id integer NOT NULL
+);
+
+
+--
+-- Name: bims_dataset_stats; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_dataset_stats (
+ project_id integer NOT NULL,
+ stats text,
+ cvterm_id integer NOT NULL,
+ name character varying(255) NOT NULL
+);
+
+
+--
+-- Name: bims_descriptor; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_descriptor (
+ cv_id integer NOT NULL,
+ category character varying(255),
+ name character varying(255) NOT NULL,
+ cvterm_id integer NOT NULL,
+ definition text
+);
+
+
+--
+-- Name: bims_descriptor_group; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_descriptor_group (
+ cv_id integer NOT NULL,
+ cv_name character varying(255) NOT NULL,
+ definition text
+);
+
+
+--
+-- Name: bims_file; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_file (
+ file_id integer NOT NULL,
+ type character varying(255) NOT NULL,
+ filename character varying(255) NOT NULL,
+ filepath character varying(512) NOT NULL,
+ filesize integer DEFAULT 0 NOT NULL,
+ uri character varying(255) NOT NULL,
+ user_id integer NOT NULL,
+ job_id integer,
+ submit_date timestamp without time zone NOT NULL,
+ prop text
+);
+
+
+--
+-- Name: bims_file_file_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE bims_file_file_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: bims_file_file_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE bims_file_file_id_seq OWNED BY bims_file.file_id;
+
+
+--
+-- Name: bims_instruction; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_instruction (
+ instruction_id integer NOT NULL,
+ id character varying(255) NOT NULL,
+ instruction text
+);
+
+
+--
+-- Name: bims_instruction_instruction_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE bims_instruction_instruction_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: bims_instruction_instruction_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE bims_instruction_instruction_id_seq OWNED BY bims_instruction.instruction_id;
+
+
+--
+-- Name: bims_job; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_job (
+ job_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ type character varying(255) NOT NULL,
+ class_name character varying(255),
+ status integer,
+ param text,
+ prop text,
+ user_id integer NOT NULL,
+ program_id integer,
+ submit_date timestamp without time zone NOT NULL,
+ complete_date timestamp without time zone
+);
+
+
+--
+-- Name: bims_job_job_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE bims_job_job_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: bims_job_job_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE bims_job_job_id_seq OWNED BY bims_job.job_id;
+
+
+--
+-- Name: bims_list; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_list (
+ list_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ project_id integer NOT NULL,
+ user_id integer NOT NULL,
+ prop text
+);
+
+
+--
+-- Name: bims_list_list_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE bims_list_list_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: bims_list_list_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE bims_list_list_id_seq OWNED BY bims_list.list_id;
+
+
+--
+-- Name: bims_location; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_location (
+ location_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ type character varying(255) NOT NULL,
+ nd_geolocation_id integer NOT NULL,
+ latitude character varying(255),
+ longitude character varying(255),
+ altitude character varying(255),
+ country character varying(255),
+ state character varying(255),
+ region character varying(255),
+ address character varying(255)
+);
+
+
+--
+-- Name: bims_location_location_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE bims_location_location_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: bims_location_location_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE bims_location_location_id_seq OWNED BY bims_location.location_id;
+
+
+--
+-- Name: bims_mivew_24; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_mivew_24 (
+ stock_id integer NOT NULL,
+ name character varying(300) NOT NULL
+);
+
+
+--
+-- Name: bims_mivew_24_1; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_mivew_24_1 (
+ stock_id integer NOT NULL,
+ name character varying(300) NOT NULL
+);
+
+
+--
+-- Name: bims_mview; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_mview (
+ mview_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ type_id integer NOT NULL,
+ sql text NOT NULL,
+ description text
+);
+
+
+--
+-- Name: bims_mview_mview_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE bims_mview_mview_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: bims_mview_mview_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE bims_mview_mview_id_seq OWNED BY bims_mview.mview_id;
+
+
+--
+-- Name: bims_mview_type; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_mview_type (
+ mview_type_id integer NOT NULL,
+ type character varying(255) NOT NULL,
+ description text
+);
+
+
+--
+-- Name: bims_mview_type_mview_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE bims_mview_type_mview_type_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: bims_mview_type_mview_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE bims_mview_type_mview_type_id_seq OWNED BY bims_mview_type.mview_type_id;
+
+
+--
+-- Name: bims_node; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_node (
+ node_id integer NOT NULL,
+ name character varying(100) NOT NULL,
+ type character varying(100) NOT NULL,
+ prop text,
+ root_id integer,
+ crop_id integer,
+ user_id integer NOT NULL,
+ tree text,
+ description text
+);
+
+
+--
+-- Name: bims_node_location; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_node_location (
+ node_id integer NOT NULL,
+ location_id integer NOT NULL
+);
+
+
+--
+-- Name: bims_node_node_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE bims_node_node_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: bims_node_node_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE bims_node_node_id_seq OWNED BY bims_node.node_id;
+
+
+--
+-- Name: bims_node_relationship; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_node_relationship (
+ relationship_id integer NOT NULL,
+ parent_id integer NOT NULL,
+ child_id integer NOT NULL
+);
+
+
+--
+-- Name: bims_node_relationship_relationship_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE bims_node_relationship_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: bims_node_relationship_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE bims_node_relationship_relationship_id_seq OWNED BY bims_node_relationship.relationship_id;
+
+
+--
+-- Name: bims_program_member; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_program_member (
+ program_id integer NOT NULL,
+ user_id integer NOT NULL,
+ permission character varying(255) DEFAULT 'READ'::character varying
+);
+
+
+--
+-- Name: bims_user; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE bims_user (
+ user_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ uid integer NOT NULL,
+ mail character varying(255) NOT NULL,
+ breeder integer DEFAULT 0 NOT NULL,
+ prop text
+);
+
+
+--
+-- Name: block; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE block (
+ bid integer NOT NULL,
+ module character varying(64) DEFAULT ''::character varying NOT NULL,
+ delta character varying(32) DEFAULT '0'::character varying NOT NULL,
+ theme character varying(64) DEFAULT ''::character varying NOT NULL,
+ status smallint DEFAULT 0 NOT NULL,
+ weight integer DEFAULT 0 NOT NULL,
+ region character varying(64) DEFAULT ''::character varying NOT NULL,
+ custom smallint DEFAULT 0 NOT NULL,
+ visibility smallint DEFAULT 0 NOT NULL,
+ pages text NOT NULL,
+ title character varying(255) DEFAULT ''::character varying NOT NULL,
+ cache smallint DEFAULT 1 NOT NULL
+);
+
+
+--
+-- Name: TABLE block; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE block IS 'Stores block settings, such as region and visibility settings.';
+
+
+--
+-- Name: COLUMN block.bid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.bid IS 'Primary Key: Unique block ID.';
+
+
+--
+-- Name: COLUMN block.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.module IS 'The module from which the block originates; for example, ''user'' for the Who''s Online block, and ''block'' for any custom blocks.';
+
+
+--
+-- Name: COLUMN block.delta; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.delta IS 'Unique ID for block within a module.';
+
+
+--
+-- Name: COLUMN block.theme; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.theme IS 'The theme under which the block settings apply.';
+
+
+--
+-- Name: COLUMN block.status; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.status IS 'Block enabled status. (1 = enabled, 0 = disabled)';
+
+
+--
+-- Name: COLUMN block.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.weight IS 'Block weight within region.';
+
+
+--
+-- Name: COLUMN block.region; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.region IS 'Theme region within which the block is set.';
+
+
+--
+-- Name: COLUMN block.custom; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.custom IS 'Flag to indicate how users may control visibility of the block. (0 = Users cannot control, 1 = On by default, but can be hidden, 2 = Hidden by default, but can be shown)';
+
+
+--
+-- Name: COLUMN block.visibility; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.visibility IS 'Flag to indicate how to show blocks on pages. (0 = Show on all pages except listed pages, 1 = Show only on listed pages, 2 = Use custom PHP code to determine visibility)';
+
+
+--
+-- Name: COLUMN block.pages; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.pages IS 'Contents of the "Pages" block; contains either a list of paths on which to include/exclude the block or PHP code, depending on "visibility" setting.';
+
+
+--
+-- Name: COLUMN block.title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.title IS 'Custom title for the block. (Empty string will use block default title, will remove the title, text will cause block to use specified title.)';
+
+
+--
+-- Name: COLUMN block.cache; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block.cache IS 'Binary flag to indicate block cache mode. (-2: Custom cache, -1: Do not cache, 1: Cache per role, 2: Cache per user, 4: Cache per page, 8: Block cache global) See DRUPAL_CACHE_* constants in ../includes/common.inc for more detailed information.';
+
+
+--
+-- Name: block_bid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE block_bid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: block_bid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE block_bid_seq OWNED BY block.bid;
+
+
+--
+-- Name: block_custom; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE block_custom (
+ bid integer NOT NULL,
+ body text,
+ info character varying(128) DEFAULT ''::character varying NOT NULL,
+ format character varying(255),
+ CONSTRAINT block_custom_bid_check CHECK ((bid >= 0))
+);
+
+
+--
+-- Name: TABLE block_custom; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE block_custom IS 'Stores contents of custom-made blocks.';
+
+
+--
+-- Name: COLUMN block_custom.bid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block_custom.bid IS 'The block''s block.bid.';
+
+
+--
+-- Name: COLUMN block_custom.body; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block_custom.body IS 'Block contents.';
+
+
+--
+-- Name: COLUMN block_custom.info; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block_custom.info IS 'Block description.';
+
+
+--
+-- Name: COLUMN block_custom.format; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block_custom.format IS 'The filter_format.format of the block body.';
+
+
+--
+-- Name: block_custom_bid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE block_custom_bid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: block_custom_bid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE block_custom_bid_seq OWNED BY block_custom.bid;
+
+
+--
+-- Name: block_node_type; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE block_node_type (
+ module character varying(64) NOT NULL,
+ delta character varying(32) NOT NULL,
+ type character varying(32) NOT NULL
+);
+
+
+--
+-- Name: TABLE block_node_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE block_node_type IS 'Sets up display criteria for blocks based on content types';
+
+
+--
+-- Name: COLUMN block_node_type.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block_node_type.module IS 'The block''s origin module, from block.module.';
+
+
+--
+-- Name: COLUMN block_node_type.delta; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block_node_type.delta IS 'The block''s unique delta within module, from block.delta.';
+
+
+--
+-- Name: COLUMN block_node_type.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block_node_type.type IS 'The machine-readable name of this type from node_type.type.';
+
+
+--
+-- Name: block_role; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE block_role (
+ module character varying(64) NOT NULL,
+ delta character varying(32) NOT NULL,
+ rid bigint NOT NULL,
+ CONSTRAINT block_role_rid_check CHECK ((rid >= 0))
+);
+
+
+--
+-- Name: TABLE block_role; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE block_role IS 'Sets up access permissions for blocks based on user roles';
+
+
+--
+-- Name: COLUMN block_role.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block_role.module IS 'The block''s origin module, from block.module.';
+
+
+--
+-- Name: COLUMN block_role.delta; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block_role.delta IS 'The block''s unique delta within module, from block.delta.';
+
+
+--
+-- Name: COLUMN block_role.rid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN block_role.rid IS 'The user''s role ID from users_roles.rid.';
+
+
+--
+-- Name: blocked_ips; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE blocked_ips (
+ iid integer NOT NULL,
+ ip character varying(40) DEFAULT ''::character varying NOT NULL,
+ CONSTRAINT blocked_ips_iid_check CHECK ((iid >= 0))
+);
+
+
+--
+-- Name: TABLE blocked_ips; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE blocked_ips IS 'Stores blocked IP addresses.';
+
+
+--
+-- Name: COLUMN blocked_ips.iid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN blocked_ips.iid IS 'Primary Key: unique ID for IP addresses.';
+
+
+--
+-- Name: COLUMN blocked_ips.ip; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN blocked_ips.ip IS 'IP address';
+
+
+--
+-- Name: blocked_ips_iid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE blocked_ips_iid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: blocked_ips_iid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE blocked_ips_iid_seq OWNED BY blocked_ips.iid;
+
+
+--
+-- Name: book; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE book (
+ mlid bigint DEFAULT 0 NOT NULL,
+ nid bigint DEFAULT 0 NOT NULL,
+ bid bigint DEFAULT 0 NOT NULL,
+ CONSTRAINT book_bid_check CHECK ((bid >= 0)),
+ CONSTRAINT book_mlid_check CHECK ((mlid >= 0)),
+ CONSTRAINT book_nid_check CHECK ((nid >= 0))
+);
+
+
+--
+-- Name: TABLE book; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE book IS 'Stores book outline information. Uniquely connects each node in the outline to a link in menu_links';
+
+
+--
+-- Name: COLUMN book.mlid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN book.mlid IS 'The book page''s menu_links.mlid.';
+
+
+--
+-- Name: COLUMN book.nid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN book.nid IS 'The book page''s node.nid.';
+
+
+--
+-- Name: COLUMN book.bid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN book.bid IS 'The book ID is the book.nid of the top-level page.';
+
+
+--
+-- Name: cache; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache IS 'Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.';
+
+
+--
+-- Name: COLUMN cache.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_block; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_block (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_block; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_block IS 'Cache table for the Block module to store already built blocks, identified by module, delta, and various contexts which may change the block, such as theme, locale, and caching mode defined for the block.';
+
+
+--
+-- Name: COLUMN cache_block.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_block.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_block.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_block.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_block.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_block.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_block.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_block.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_block.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_block.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_bootstrap; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_bootstrap (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_bootstrap; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_bootstrap IS 'Cache table for data required to bootstrap Drupal, may be routed to a shared memory cache.';
+
+
+--
+-- Name: COLUMN cache_bootstrap.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_bootstrap.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_bootstrap.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_bootstrap.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_bootstrap.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_bootstrap.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_bootstrap.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_bootstrap.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_bootstrap.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_bootstrap.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_field; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_field (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_field; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_field IS 'Cache table for the Field module to store already built field information.';
+
+
+--
+-- Name: COLUMN cache_field.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_field.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_field.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_field.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_field.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_field.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_field.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_field.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_field.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_field.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_filter; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_filter (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_filter; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_filter IS 'Cache table for the Filter module to store already filtered pieces of text, identified by text format and hash of the text.';
+
+
+--
+-- Name: COLUMN cache_filter.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_filter.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_filter.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_filter.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_filter.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_filter.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_filter.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_filter.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_filter.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_filter.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_form; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_form (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_form; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_form IS 'Cache table for the form system to store recently built forms and their storage data, to be used in subsequent page requests.';
+
+
+--
+-- Name: COLUMN cache_form.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_form.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_form.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_form.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_form.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_form.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_form.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_form.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_form.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_form.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_image; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_image (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_image; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_image IS 'Cache table used to store information about image manipulations that are in-progress.';
+
+
+--
+-- Name: COLUMN cache_image.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_image.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_image.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_image.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_image.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_image.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_image.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_image.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_image.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_image.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_menu; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_menu (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_menu; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_menu IS 'Cache table for the menu system to store router information as well as generated link trees for various menu/page/user combinations.';
+
+
+--
+-- Name: COLUMN cache_menu.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_menu.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_menu.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_menu.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_menu.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_menu.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_menu.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_menu.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_menu.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_menu.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_page; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_page (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_page; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_page IS 'Cache table used to store compressed pages for anonymous users, if page caching is enabled.';
+
+
+--
+-- Name: COLUMN cache_page.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_page.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_page.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_page.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_page.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_page.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_page.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_page.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_page.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_page.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_path; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_path (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_path; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_path IS 'Cache table for path alias lookup.';
+
+
+--
+-- Name: COLUMN cache_path.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_path.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_path.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_path.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_path.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_path.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_path.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_path.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_path.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_path.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_update; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_update (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_update; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_update IS 'Cache table for the Update module to store information about available releases, fetched from central server.';
+
+
+--
+-- Name: COLUMN cache_update.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_update.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_update.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_update.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_update.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_update.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_update.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_update.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_update.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_update.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_views; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_views (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_views; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_views IS 'Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.';
+
+
+--
+-- Name: COLUMN cache_views.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_views.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_views.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_views.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_views.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_views.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_views.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_views.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_views.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_views.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: cache_views_data; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE cache_views_data (
+ cid character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ serialized smallint DEFAULT 1 NOT NULL
+);
+
+
+--
+-- Name: TABLE cache_views_data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE cache_views_data IS 'Cache table for views to store pre-rendered queries, results, and display output.';
+
+
+--
+-- Name: COLUMN cache_views_data.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_views_data.cid IS 'Primary Key: Unique cache ID.';
+
+
+--
+-- Name: COLUMN cache_views_data.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_views_data.data IS 'A collection of data to cache.';
+
+
+--
+-- Name: COLUMN cache_views_data.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_views_data.expire IS 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.';
+
+
+--
+-- Name: COLUMN cache_views_data.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_views_data.created IS 'A Unix timestamp indicating when the cache entry was created.';
+
+
+--
+-- Name: COLUMN cache_views_data.serialized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN cache_views_data.serialized IS 'A flag to indicate whether content is serialized (1) or not (0).';
+
+
+--
+-- Name: comment; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE comment (
+ cid integer NOT NULL,
+ pid integer DEFAULT 0 NOT NULL,
+ nid integer DEFAULT 0 NOT NULL,
+ uid integer DEFAULT 0 NOT NULL,
+ subject character varying(64) DEFAULT ''::character varying NOT NULL,
+ hostname character varying(128) DEFAULT ''::character varying NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ changed integer DEFAULT 0 NOT NULL,
+ status integer DEFAULT 1 NOT NULL,
+ thread character varying(255) NOT NULL,
+ name character varying(60),
+ mail character varying(64),
+ homepage character varying(255),
+ language character varying(12) DEFAULT ''::character varying NOT NULL,
+ CONSTRAINT comment_status_check CHECK ((status >= 0))
+);
+
+
+--
+-- Name: TABLE comment; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE comment IS 'Stores comments and associated data.';
+
+
+--
+-- Name: COLUMN comment.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.cid IS 'Primary Key: Unique comment ID.';
+
+
+--
+-- Name: COLUMN comment.pid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.pid IS 'The comment.cid to which this comment is a reply. If set to 0, this comment is not a reply to an existing comment.';
+
+
+--
+-- Name: COLUMN comment.nid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.nid IS 'The node.nid to which this comment is a reply.';
+
+
+--
+-- Name: COLUMN comment.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.uid IS 'The users.uid who authored the comment. If set to 0, this comment was created by an anonymous user.';
+
+
+--
+-- Name: COLUMN comment.subject; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.subject IS 'The comment title.';
+
+
+--
+-- Name: COLUMN comment.hostname; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.hostname IS 'The author''s host name.';
+
+
+--
+-- Name: COLUMN comment.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.created IS 'The time that the comment was created, as a Unix timestamp.';
+
+
+--
+-- Name: COLUMN comment.changed; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.changed IS 'The time that the comment was last edited, as a Unix timestamp.';
+
+
+--
+-- Name: COLUMN comment.status; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.status IS 'The published status of a comment. (0 = Not Published, 1 = Published)';
+
+
+--
+-- Name: COLUMN comment.thread; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.thread IS 'The vancode representation of the comment''s place in a thread.';
+
+
+--
+-- Name: COLUMN comment.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.name IS 'The comment author''s name. Uses users.name if the user is logged in, otherwise uses the value typed into the comment form.';
+
+
+--
+-- Name: COLUMN comment.mail; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.mail IS 'The comment author''s e-mail address from the comment form, if user is anonymous, and the ''Anonymous users may/must leave their contact information'' setting is turned on.';
+
+
+--
+-- Name: COLUMN comment.homepage; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.homepage IS 'The comment author''s home page address from the comment form, if user is anonymous, and the ''Anonymous users may/must leave their contact information'' setting is turned on.';
+
+
+--
+-- Name: COLUMN comment.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN comment.language IS 'The languages.language of this comment.';
+
+
+--
+-- Name: comment_cid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE comment_cid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: comment_cid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE comment_cid_seq OWNED BY comment.cid;
+
+
+--
+-- Name: contact; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE contact (
+ cid integer NOT NULL,
+ category character varying(255) DEFAULT ''::character varying NOT NULL,
+ recipients text NOT NULL,
+ reply text NOT NULL,
+ weight integer DEFAULT 0 NOT NULL,
+ selected smallint DEFAULT 0 NOT NULL,
+ CONSTRAINT contact_cid_check CHECK ((cid >= 0))
+);
+
+
+--
+-- Name: TABLE contact; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE contact IS 'Contact form category settings.';
+
+
+--
+-- Name: COLUMN contact.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN contact.cid IS 'Primary Key: Unique category ID.';
+
+
+--
+-- Name: COLUMN contact.category; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN contact.category IS 'Category name.';
+
+
+--
+-- Name: COLUMN contact.recipients; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN contact.recipients IS 'Comma-separated list of recipient e-mail addresses.';
+
+
+--
+-- Name: COLUMN contact.reply; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN contact.reply IS 'Text of the auto-reply message.';
+
+
+--
+-- Name: COLUMN contact.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN contact.weight IS 'The category''s weight.';
+
+
+--
+-- Name: COLUMN contact.selected; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN contact.selected IS 'Flag to indicate whether or not category is selected by default. (1 = Yes, 0 = No)';
+
+
+--
+-- Name: contact_cid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE contact_cid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: contact_cid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE contact_cid_seq OWNED BY contact.cid;
+
+
+--
+-- Name: ctools_css_cache; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE ctools_css_cache (
+ cid character varying(128) NOT NULL,
+ filename character varying(255),
+ css text,
+ filter smallint
+);
+
+
+--
+-- Name: TABLE ctools_css_cache; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE ctools_css_cache IS 'A special cache used to store CSS that must be non-volatile.';
+
+
+--
+-- Name: COLUMN ctools_css_cache.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN ctools_css_cache.cid IS 'The CSS ID this cache object belongs to.';
+
+
+--
+-- Name: COLUMN ctools_css_cache.filename; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN ctools_css_cache.filename IS 'The filename this CSS is stored in.';
+
+
+--
+-- Name: COLUMN ctools_css_cache.css; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN ctools_css_cache.css IS 'CSS being stored.';
+
+
+--
+-- Name: COLUMN ctools_css_cache.filter; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN ctools_css_cache.filter IS 'Whether or not this CSS needs to be filtered.';
+
+
+--
+-- Name: ctools_object_cache; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE ctools_object_cache (
+ sid character varying(64) NOT NULL,
+ name character varying(128) NOT NULL,
+ obj character varying(128) NOT NULL,
+ updated bigint DEFAULT 0 NOT NULL,
+ data bytea,
+ CONSTRAINT ctools_object_cache_updated_check CHECK ((updated >= 0))
+);
+
+
+--
+-- Name: TABLE ctools_object_cache; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE ctools_object_cache IS 'A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.';
+
+
+--
+-- Name: COLUMN ctools_object_cache.sid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN ctools_object_cache.sid IS 'The session ID this cache object belongs to.';
+
+
+--
+-- Name: COLUMN ctools_object_cache.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN ctools_object_cache.name IS 'The name of the object this cache is attached to.';
+
+
+--
+-- Name: COLUMN ctools_object_cache.obj; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN ctools_object_cache.obj IS 'The type of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.';
+
+
+--
+-- Name: COLUMN ctools_object_cache.updated; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN ctools_object_cache.updated IS 'The time this cache was created or updated.';
+
+
+--
+-- Name: COLUMN ctools_object_cache.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN ctools_object_cache.data IS 'Serialized data being stored.';
+
+
+--
+-- Name: date_format_locale; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE date_format_locale (
+ format character varying(100) NOT NULL,
+ type character varying(64) NOT NULL,
+ language character varying(12) NOT NULL
+);
+
+
+--
+-- Name: TABLE date_format_locale; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE date_format_locale IS 'Stores configured date formats for each locale.';
+
+
+--
+-- Name: COLUMN date_format_locale.format; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN date_format_locale.format IS 'The date format string.';
+
+
+--
+-- Name: COLUMN date_format_locale.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN date_format_locale.type IS 'The date format type, e.g. medium.';
+
+
+--
+-- Name: COLUMN date_format_locale.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN date_format_locale.language IS 'A languages.language for this format to be used with.';
+
+
+--
+-- Name: date_format_type; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE date_format_type (
+ type character varying(64) NOT NULL,
+ title character varying(255) NOT NULL,
+ locked smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE date_format_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE date_format_type IS 'Stores configured date format types.';
+
+
+--
+-- Name: COLUMN date_format_type.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN date_format_type.type IS 'The date format type, e.g. medium.';
+
+
+--
+-- Name: COLUMN date_format_type.title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN date_format_type.title IS 'The human readable name of the format type.';
+
+
+--
+-- Name: COLUMN date_format_type.locked; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN date_format_type.locked IS 'Whether or not this is a system provided format.';
+
+
+--
+-- Name: date_formats; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE date_formats (
+ dfid integer NOT NULL,
+ format character varying(100) NOT NULL,
+ type character varying(64) NOT NULL,
+ locked smallint DEFAULT 0 NOT NULL,
+ CONSTRAINT date_formats_dfid_check CHECK ((dfid >= 0))
+);
+
+
+--
+-- Name: TABLE date_formats; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE date_formats IS 'Stores configured date formats.';
+
+
+--
+-- Name: COLUMN date_formats.dfid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN date_formats.dfid IS 'The date format identifier.';
+
+
+--
+-- Name: COLUMN date_formats.format; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN date_formats.format IS 'The date format string.';
+
+
+--
+-- Name: COLUMN date_formats.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN date_formats.type IS 'The date format type, e.g. medium.';
+
+
+--
+-- Name: COLUMN date_formats.locked; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN date_formats.locked IS 'Whether or not this format can be modified.';
+
+
+--
+-- Name: date_formats_dfid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE date_formats_dfid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: date_formats_dfid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE date_formats_dfid_seq OWNED BY date_formats.dfid;
+
+
+--
+-- Name: do_group; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE do_group (
+ group_id integer NOT NULL,
+ name character varying(100) NOT NULL,
+ tree_json text,
+ group_node_id integer
+);
+
+
+--
+-- Name: do_group_group_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE do_group_group_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: do_group_group_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE do_group_group_id_seq OWNED BY do_group.group_id;
+
+
+--
+-- Name: do_node; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE do_node (
+ node_id integer NOT NULL,
+ name character varying(100) NOT NULL,
+ type character varying(100) NOT NULL,
+ prop text,
+ rank integer,
+ description text
+);
+
+
+--
+-- Name: do_node_node_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE do_node_node_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: do_node_node_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE do_node_node_id_seq OWNED BY do_node.node_id;
+
+
+--
+-- Name: do_node_relationship; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE do_node_relationship (
+ relationship_id integer NOT NULL,
+ parent_id integer NOT NULL,
+ child_id integer NOT NULL
+);
+
+
+--
+-- Name: do_node_relationship_relationship_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE do_node_relationship_relationship_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: do_node_relationship_relationship_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE do_node_relationship_relationship_id_seq OWNED BY do_node_relationship.relationship_id;
+
+
+--
+-- Name: do_overview; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE do_overview (
+ overview_id integer NOT NULL,
+ group_id integer NOT NULL,
+ description text,
+ submit_date timestamp without time zone,
+ filename character varying(100) NOT NULL
+);
+
+
+--
+-- Name: do_overview_overview_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE do_overview_overview_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: do_overview_overview_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE do_overview_overview_id_seq OWNED BY do_overview.overview_id;
+
+
+--
+-- Name: do_user; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE do_user (
+ user_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ uid character varying(255) NOT NULL,
+ mail character varying(255) NOT NULL,
+ prop text
+);
+
+
+--
+-- Name: field_config; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE field_config (
+ id integer NOT NULL,
+ field_name character varying(32) NOT NULL,
+ type character varying(128) NOT NULL,
+ module character varying(128) DEFAULT ''::character varying NOT NULL,
+ active smallint DEFAULT 0 NOT NULL,
+ storage_type character varying(128) NOT NULL,
+ storage_module character varying(128) DEFAULT ''::character varying NOT NULL,
+ storage_active smallint DEFAULT 0 NOT NULL,
+ locked smallint DEFAULT 0 NOT NULL,
+ data bytea NOT NULL,
+ cardinality smallint DEFAULT 0 NOT NULL,
+ translatable smallint DEFAULT 0 NOT NULL,
+ deleted smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: COLUMN field_config.id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config.id IS 'The primary identifier for a field';
+
+
+--
+-- Name: COLUMN field_config.field_name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config.field_name IS 'The name of this field. Non-deleted field names are unique, but multiple deleted fields can have the same name.';
+
+
+--
+-- Name: COLUMN field_config.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config.type IS 'The type of this field.';
+
+
+--
+-- Name: COLUMN field_config.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config.module IS 'The module that implements the field type.';
+
+
+--
+-- Name: COLUMN field_config.active; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config.active IS 'Boolean indicating whether the module that implements the field type is enabled.';
+
+
+--
+-- Name: COLUMN field_config.storage_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config.storage_type IS 'The storage backend for the field.';
+
+
+--
+-- Name: COLUMN field_config.storage_module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config.storage_module IS 'The module that implements the storage backend.';
+
+
+--
+-- Name: COLUMN field_config.storage_active; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config.storage_active IS 'Boolean indicating whether the module that implements the storage backend is enabled.';
+
+
+--
+-- Name: COLUMN field_config.locked; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config.locked IS '@TODO';
+
+
+--
+-- Name: COLUMN field_config.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config.data IS 'Serialized data containing the field properties that do not warrant a dedicated column.';
+
+
+--
+-- Name: field_config_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE field_config_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: field_config_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE field_config_id_seq OWNED BY field_config.id;
+
+
+--
+-- Name: field_config_instance; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE field_config_instance (
+ id integer NOT NULL,
+ field_id integer NOT NULL,
+ field_name character varying(32) DEFAULT ''::character varying NOT NULL,
+ entity_type character varying(32) DEFAULT ''::character varying NOT NULL,
+ bundle character varying(128) DEFAULT ''::character varying NOT NULL,
+ data bytea NOT NULL,
+ deleted smallint DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: COLUMN field_config_instance.id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config_instance.id IS 'The primary identifier for a field instance';
+
+
+--
+-- Name: COLUMN field_config_instance.field_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_config_instance.field_id IS 'The identifier of the field attached by this instance';
+
+
+--
+-- Name: field_config_instance_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE field_config_instance_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: field_config_instance_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE field_config_instance_id_seq OWNED BY field_config_instance.id;
+
+
+--
+-- Name: field_data_body; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE field_data_body (
+ entity_type character varying(128) DEFAULT ''::character varying NOT NULL,
+ bundle character varying(128) DEFAULT ''::character varying NOT NULL,
+ deleted smallint DEFAULT 0 NOT NULL,
+ entity_id bigint NOT NULL,
+ revision_id bigint,
+ language character varying(32) DEFAULT ''::character varying NOT NULL,
+ delta bigint NOT NULL,
+ body_value text,
+ body_summary text,
+ body_format character varying(255),
+ CONSTRAINT field_data_body_delta_check CHECK ((delta >= 0)),
+ CONSTRAINT field_data_body_entity_id_check CHECK ((entity_id >= 0)),
+ CONSTRAINT field_data_body_revision_id_check CHECK ((revision_id >= 0))
+);
+
+
+--
+-- Name: TABLE field_data_body; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE field_data_body IS 'Data storage for field 2 (body)';
+
+
+--
+-- Name: COLUMN field_data_body.entity_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_body.entity_type IS 'The entity type this data is attached to';
+
+
+--
+-- Name: COLUMN field_data_body.bundle; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_body.bundle IS 'The field instance bundle to which this row belongs, used when deleting a field instance';
+
+
+--
+-- Name: COLUMN field_data_body.deleted; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_body.deleted IS 'A boolean indicating whether this data item has been deleted';
+
+
+--
+-- Name: COLUMN field_data_body.entity_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_body.entity_id IS 'The entity id this data is attached to';
+
+
+--
+-- Name: COLUMN field_data_body.revision_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_body.revision_id IS 'The entity revision id this data is attached to, or NULL if the entity type is not versioned';
+
+
+--
+-- Name: COLUMN field_data_body.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_body.language IS 'The language for this data item.';
+
+
+--
+-- Name: COLUMN field_data_body.delta; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_body.delta IS 'The sequence number for this data item, used for multi-value fields';
+
+
+--
+-- Name: field_data_comment_body; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE field_data_comment_body (
+ entity_type character varying(128) DEFAULT ''::character varying NOT NULL,
+ bundle character varying(128) DEFAULT ''::character varying NOT NULL,
+ deleted smallint DEFAULT 0 NOT NULL,
+ entity_id bigint NOT NULL,
+ revision_id bigint,
+ language character varying(32) DEFAULT ''::character varying NOT NULL,
+ delta bigint NOT NULL,
+ comment_body_value text,
+ comment_body_format character varying(255),
+ CONSTRAINT field_data_comment_body_delta_check CHECK ((delta >= 0)),
+ CONSTRAINT field_data_comment_body_entity_id_check CHECK ((entity_id >= 0)),
+ CONSTRAINT field_data_comment_body_revision_id_check CHECK ((revision_id >= 0))
+);
+
+
+--
+-- Name: TABLE field_data_comment_body; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE field_data_comment_body IS 'Data storage for field 1 (comment_body)';
+
+
+--
+-- Name: COLUMN field_data_comment_body.entity_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_comment_body.entity_type IS 'The entity type this data is attached to';
+
+
+--
+-- Name: COLUMN field_data_comment_body.bundle; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_comment_body.bundle IS 'The field instance bundle to which this row belongs, used when deleting a field instance';
+
+
+--
+-- Name: COLUMN field_data_comment_body.deleted; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_comment_body.deleted IS 'A boolean indicating whether this data item has been deleted';
+
+
+--
+-- Name: COLUMN field_data_comment_body.entity_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_comment_body.entity_id IS 'The entity id this data is attached to';
+
+
+--
+-- Name: COLUMN field_data_comment_body.revision_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_comment_body.revision_id IS 'The entity revision id this data is attached to, or NULL if the entity type is not versioned';
+
+
+--
+-- Name: COLUMN field_data_comment_body.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_comment_body.language IS 'The language for this data item.';
+
+
+--
+-- Name: COLUMN field_data_comment_body.delta; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_comment_body.delta IS 'The sequence number for this data item, used for multi-value fields';
+
+
+--
+-- Name: field_data_field_image; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE field_data_field_image (
+ entity_type character varying(128) DEFAULT ''::character varying NOT NULL,
+ bundle character varying(128) DEFAULT ''::character varying NOT NULL,
+ deleted smallint DEFAULT 0 NOT NULL,
+ entity_id bigint NOT NULL,
+ revision_id bigint,
+ language character varying(32) DEFAULT ''::character varying NOT NULL,
+ delta bigint NOT NULL,
+ field_image_fid bigint,
+ field_image_alt character varying(512),
+ field_image_title character varying(1024),
+ field_image_width bigint,
+ field_image_height bigint,
+ CONSTRAINT field_data_field_image_delta_check CHECK ((delta >= 0)),
+ CONSTRAINT field_data_field_image_entity_id_check CHECK ((entity_id >= 0)),
+ CONSTRAINT field_data_field_image_field_image_fid_check CHECK ((field_image_fid >= 0)),
+ CONSTRAINT field_data_field_image_field_image_height_check CHECK ((field_image_height >= 0)),
+ CONSTRAINT field_data_field_image_field_image_width_check CHECK ((field_image_width >= 0)),
+ CONSTRAINT field_data_field_image_revision_id_check CHECK ((revision_id >= 0))
+);
+
+
+--
+-- Name: TABLE field_data_field_image; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE field_data_field_image IS 'Data storage for field 4 (field_image)';
+
+
+--
+-- Name: COLUMN field_data_field_image.entity_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.entity_type IS 'The entity type this data is attached to';
+
+
+--
+-- Name: COLUMN field_data_field_image.bundle; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.bundle IS 'The field instance bundle to which this row belongs, used when deleting a field instance';
+
+
+--
+-- Name: COLUMN field_data_field_image.deleted; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.deleted IS 'A boolean indicating whether this data item has been deleted';
+
+
+--
+-- Name: COLUMN field_data_field_image.entity_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.entity_id IS 'The entity id this data is attached to';
+
+
+--
+-- Name: COLUMN field_data_field_image.revision_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.revision_id IS 'The entity revision id this data is attached to, or NULL if the entity type is not versioned';
+
+
+--
+-- Name: COLUMN field_data_field_image.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.language IS 'The language for this data item.';
+
+
+--
+-- Name: COLUMN field_data_field_image.delta; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.delta IS 'The sequence number for this data item, used for multi-value fields';
+
+
+--
+-- Name: COLUMN field_data_field_image.field_image_fid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.field_image_fid IS 'The file_managed.fid being referenced in this field.';
+
+
+--
+-- Name: COLUMN field_data_field_image.field_image_alt; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.field_image_alt IS 'Alternative image text, for the image''s ''alt'' attribute.';
+
+
+--
+-- Name: COLUMN field_data_field_image.field_image_title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.field_image_title IS 'Image title text, for the image''s ''title'' attribute.';
+
+
+--
+-- Name: COLUMN field_data_field_image.field_image_width; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.field_image_width IS 'The width of the image in pixels.';
+
+
+--
+-- Name: COLUMN field_data_field_image.field_image_height; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_image.field_image_height IS 'The height of the image in pixels.';
+
+
+--
+-- Name: field_data_field_tags; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE field_data_field_tags (
+ entity_type character varying(128) DEFAULT ''::character varying NOT NULL,
+ bundle character varying(128) DEFAULT ''::character varying NOT NULL,
+ deleted smallint DEFAULT 0 NOT NULL,
+ entity_id bigint NOT NULL,
+ revision_id bigint,
+ language character varying(32) DEFAULT ''::character varying NOT NULL,
+ delta bigint NOT NULL,
+ field_tags_tid bigint,
+ CONSTRAINT field_data_field_tags_delta_check CHECK ((delta >= 0)),
+ CONSTRAINT field_data_field_tags_entity_id_check CHECK ((entity_id >= 0)),
+ CONSTRAINT field_data_field_tags_field_tags_tid_check CHECK ((field_tags_tid >= 0)),
+ CONSTRAINT field_data_field_tags_revision_id_check CHECK ((revision_id >= 0))
+);
+
+
+--
+-- Name: TABLE field_data_field_tags; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE field_data_field_tags IS 'Data storage for field 3 (field_tags)';
+
+
+--
+-- Name: COLUMN field_data_field_tags.entity_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_tags.entity_type IS 'The entity type this data is attached to';
+
+
+--
+-- Name: COLUMN field_data_field_tags.bundle; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_tags.bundle IS 'The field instance bundle to which this row belongs, used when deleting a field instance';
+
+
+--
+-- Name: COLUMN field_data_field_tags.deleted; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_tags.deleted IS 'A boolean indicating whether this data item has been deleted';
+
+
+--
+-- Name: COLUMN field_data_field_tags.entity_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_tags.entity_id IS 'The entity id this data is attached to';
+
+
+--
+-- Name: COLUMN field_data_field_tags.revision_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_tags.revision_id IS 'The entity revision id this data is attached to, or NULL if the entity type is not versioned';
+
+
+--
+-- Name: COLUMN field_data_field_tags.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_tags.language IS 'The language for this data item.';
+
+
+--
+-- Name: COLUMN field_data_field_tags.delta; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_data_field_tags.delta IS 'The sequence number for this data item, used for multi-value fields';
+
+
+--
+-- Name: field_revision_body; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE field_revision_body (
+ entity_type character varying(128) DEFAULT ''::character varying NOT NULL,
+ bundle character varying(128) DEFAULT ''::character varying NOT NULL,
+ deleted smallint DEFAULT 0 NOT NULL,
+ entity_id bigint NOT NULL,
+ revision_id bigint NOT NULL,
+ language character varying(32) DEFAULT ''::character varying NOT NULL,
+ delta bigint NOT NULL,
+ body_value text,
+ body_summary text,
+ body_format character varying(255),
+ CONSTRAINT field_revision_body_delta_check CHECK ((delta >= 0)),
+ CONSTRAINT field_revision_body_entity_id_check CHECK ((entity_id >= 0)),
+ CONSTRAINT field_revision_body_revision_id_check CHECK ((revision_id >= 0))
+);
+
+
+--
+-- Name: TABLE field_revision_body; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE field_revision_body IS 'Revision archive storage for field 2 (body)';
+
+
+--
+-- Name: COLUMN field_revision_body.entity_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_body.entity_type IS 'The entity type this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_body.bundle; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_body.bundle IS 'The field instance bundle to which this row belongs, used when deleting a field instance';
+
+
+--
+-- Name: COLUMN field_revision_body.deleted; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_body.deleted IS 'A boolean indicating whether this data item has been deleted';
+
+
+--
+-- Name: COLUMN field_revision_body.entity_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_body.entity_id IS 'The entity id this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_body.revision_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_body.revision_id IS 'The entity revision id this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_body.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_body.language IS 'The language for this data item.';
+
+
+--
+-- Name: COLUMN field_revision_body.delta; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_body.delta IS 'The sequence number for this data item, used for multi-value fields';
+
+
+--
+-- Name: field_revision_comment_body; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE field_revision_comment_body (
+ entity_type character varying(128) DEFAULT ''::character varying NOT NULL,
+ bundle character varying(128) DEFAULT ''::character varying NOT NULL,
+ deleted smallint DEFAULT 0 NOT NULL,
+ entity_id bigint NOT NULL,
+ revision_id bigint NOT NULL,
+ language character varying(32) DEFAULT ''::character varying NOT NULL,
+ delta bigint NOT NULL,
+ comment_body_value text,
+ comment_body_format character varying(255),
+ CONSTRAINT field_revision_comment_body_delta_check CHECK ((delta >= 0)),
+ CONSTRAINT field_revision_comment_body_entity_id_check CHECK ((entity_id >= 0)),
+ CONSTRAINT field_revision_comment_body_revision_id_check CHECK ((revision_id >= 0))
+);
+
+
+--
+-- Name: TABLE field_revision_comment_body; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE field_revision_comment_body IS 'Revision archive storage for field 1 (comment_body)';
+
+
+--
+-- Name: COLUMN field_revision_comment_body.entity_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_comment_body.entity_type IS 'The entity type this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_comment_body.bundle; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_comment_body.bundle IS 'The field instance bundle to which this row belongs, used when deleting a field instance';
+
+
+--
+-- Name: COLUMN field_revision_comment_body.deleted; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_comment_body.deleted IS 'A boolean indicating whether this data item has been deleted';
+
+
+--
+-- Name: COLUMN field_revision_comment_body.entity_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_comment_body.entity_id IS 'The entity id this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_comment_body.revision_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_comment_body.revision_id IS 'The entity revision id this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_comment_body.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_comment_body.language IS 'The language for this data item.';
+
+
+--
+-- Name: COLUMN field_revision_comment_body.delta; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_comment_body.delta IS 'The sequence number for this data item, used for multi-value fields';
+
+
+--
+-- Name: field_revision_field_image; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE field_revision_field_image (
+ entity_type character varying(128) DEFAULT ''::character varying NOT NULL,
+ bundle character varying(128) DEFAULT ''::character varying NOT NULL,
+ deleted smallint DEFAULT 0 NOT NULL,
+ entity_id bigint NOT NULL,
+ revision_id bigint NOT NULL,
+ language character varying(32) DEFAULT ''::character varying NOT NULL,
+ delta bigint NOT NULL,
+ field_image_fid bigint,
+ field_image_alt character varying(512),
+ field_image_title character varying(1024),
+ field_image_width bigint,
+ field_image_height bigint,
+ CONSTRAINT field_revision_field_image_delta_check CHECK ((delta >= 0)),
+ CONSTRAINT field_revision_field_image_entity_id_check CHECK ((entity_id >= 0)),
+ CONSTRAINT field_revision_field_image_field_image_fid_check CHECK ((field_image_fid >= 0)),
+ CONSTRAINT field_revision_field_image_field_image_height_check CHECK ((field_image_height >= 0)),
+ CONSTRAINT field_revision_field_image_field_image_width_check CHECK ((field_image_width >= 0)),
+ CONSTRAINT field_revision_field_image_revision_id_check CHECK ((revision_id >= 0))
+);
+
+
+--
+-- Name: TABLE field_revision_field_image; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE field_revision_field_image IS 'Revision archive storage for field 4 (field_image)';
+
+
+--
+-- Name: COLUMN field_revision_field_image.entity_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.entity_type IS 'The entity type this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_field_image.bundle; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.bundle IS 'The field instance bundle to which this row belongs, used when deleting a field instance';
+
+
+--
+-- Name: COLUMN field_revision_field_image.deleted; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.deleted IS 'A boolean indicating whether this data item has been deleted';
+
+
+--
+-- Name: COLUMN field_revision_field_image.entity_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.entity_id IS 'The entity id this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_field_image.revision_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.revision_id IS 'The entity revision id this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_field_image.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.language IS 'The language for this data item.';
+
+
+--
+-- Name: COLUMN field_revision_field_image.delta; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.delta IS 'The sequence number for this data item, used for multi-value fields';
+
+
+--
+-- Name: COLUMN field_revision_field_image.field_image_fid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.field_image_fid IS 'The file_managed.fid being referenced in this field.';
+
+
+--
+-- Name: COLUMN field_revision_field_image.field_image_alt; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.field_image_alt IS 'Alternative image text, for the image''s ''alt'' attribute.';
+
+
+--
+-- Name: COLUMN field_revision_field_image.field_image_title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.field_image_title IS 'Image title text, for the image''s ''title'' attribute.';
+
+
+--
+-- Name: COLUMN field_revision_field_image.field_image_width; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.field_image_width IS 'The width of the image in pixels.';
+
+
+--
+-- Name: COLUMN field_revision_field_image.field_image_height; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_image.field_image_height IS 'The height of the image in pixels.';
+
+
+--
+-- Name: field_revision_field_tags; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE field_revision_field_tags (
+ entity_type character varying(128) DEFAULT ''::character varying NOT NULL,
+ bundle character varying(128) DEFAULT ''::character varying NOT NULL,
+ deleted smallint DEFAULT 0 NOT NULL,
+ entity_id bigint NOT NULL,
+ revision_id bigint NOT NULL,
+ language character varying(32) DEFAULT ''::character varying NOT NULL,
+ delta bigint NOT NULL,
+ field_tags_tid bigint,
+ CONSTRAINT field_revision_field_tags_delta_check CHECK ((delta >= 0)),
+ CONSTRAINT field_revision_field_tags_entity_id_check CHECK ((entity_id >= 0)),
+ CONSTRAINT field_revision_field_tags_field_tags_tid_check CHECK ((field_tags_tid >= 0)),
+ CONSTRAINT field_revision_field_tags_revision_id_check CHECK ((revision_id >= 0))
+);
+
+
+--
+-- Name: TABLE field_revision_field_tags; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE field_revision_field_tags IS 'Revision archive storage for field 3 (field_tags)';
+
+
+--
+-- Name: COLUMN field_revision_field_tags.entity_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_tags.entity_type IS 'The entity type this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_field_tags.bundle; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_tags.bundle IS 'The field instance bundle to which this row belongs, used when deleting a field instance';
+
+
+--
+-- Name: COLUMN field_revision_field_tags.deleted; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_tags.deleted IS 'A boolean indicating whether this data item has been deleted';
+
+
+--
+-- Name: COLUMN field_revision_field_tags.entity_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_tags.entity_id IS 'The entity id this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_field_tags.revision_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_tags.revision_id IS 'The entity revision id this data is attached to';
+
+
+--
+-- Name: COLUMN field_revision_field_tags.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_tags.language IS 'The language for this data item.';
+
+
+--
+-- Name: COLUMN field_revision_field_tags.delta; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN field_revision_field_tags.delta IS 'The sequence number for this data item, used for multi-value fields';
+
+
+--
+-- Name: file_managed; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE file_managed (
+ fid integer NOT NULL,
+ uid bigint DEFAULT 0 NOT NULL,
+ filename character varying(255) DEFAULT ''::character varying NOT NULL,
+ uri character varying(255) DEFAULT ''::character varying NOT NULL,
+ filemime character varying(255) DEFAULT ''::character varying NOT NULL,
+ filesize bigint DEFAULT 0 NOT NULL,
+ status smallint DEFAULT 0 NOT NULL,
+ "timestamp" bigint DEFAULT 0 NOT NULL,
+ CONSTRAINT file_managed_fid_check CHECK ((fid >= 0)),
+ CONSTRAINT file_managed_filesize_check CHECK ((filesize >= 0)),
+ CONSTRAINT file_managed_timestamp_check CHECK (("timestamp" >= 0)),
+ CONSTRAINT file_managed_uid_check CHECK ((uid >= 0))
+);
+
+
+--
+-- Name: TABLE file_managed; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE file_managed IS 'Stores information for uploaded files.';
+
+
+--
+-- Name: COLUMN file_managed.fid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_managed.fid IS 'File ID.';
+
+
+--
+-- Name: COLUMN file_managed.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_managed.uid IS 'The users.uid of the user who is associated with the file.';
+
+
+--
+-- Name: COLUMN file_managed.filename; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_managed.filename IS 'Name of the file with no path components. This may differ from the basename of the URI if the file is renamed to avoid overwriting an existing file.';
+
+
+--
+-- Name: COLUMN file_managed.uri; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_managed.uri IS 'The URI to access the file (either local or remote).';
+
+
+--
+-- Name: COLUMN file_managed.filemime; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_managed.filemime IS 'The file''s MIME type.';
+
+
+--
+-- Name: COLUMN file_managed.filesize; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_managed.filesize IS 'The size of the file in bytes.';
+
+
+--
+-- Name: COLUMN file_managed.status; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_managed.status IS 'A field indicating the status of the file. Two status are defined in core: temporary (0) and permanent (1). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.';
+
+
+--
+-- Name: COLUMN file_managed."timestamp"; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_managed."timestamp" IS 'UNIX timestamp for when the file was added.';
+
+
+--
+-- Name: file_managed_fid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE file_managed_fid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: file_managed_fid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE file_managed_fid_seq OWNED BY file_managed.fid;
+
+
+--
+-- Name: file_usage; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE file_usage (
+ fid bigint NOT NULL,
+ module character varying(255) DEFAULT ''::character varying NOT NULL,
+ type character varying(64) DEFAULT ''::character varying NOT NULL,
+ id bigint DEFAULT 0 NOT NULL,
+ count bigint DEFAULT 0 NOT NULL,
+ CONSTRAINT file_usage_count_check CHECK ((count >= 0)),
+ CONSTRAINT file_usage_fid_check CHECK ((fid >= 0)),
+ CONSTRAINT file_usage_id_check CHECK ((id >= 0))
+);
+
+
+--
+-- Name: TABLE file_usage; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE file_usage IS 'Track where a file is used.';
+
+
+--
+-- Name: COLUMN file_usage.fid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_usage.fid IS 'File ID.';
+
+
+--
+-- Name: COLUMN file_usage.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_usage.module IS 'The name of the module that is using the file.';
+
+
+--
+-- Name: COLUMN file_usage.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_usage.type IS 'The name of the object type in which the file is used.';
+
+
+--
+-- Name: COLUMN file_usage.id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_usage.id IS 'The primary key of the object using the file.';
+
+
+--
+-- Name: COLUMN file_usage.count; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN file_usage.count IS 'The number of times this file is used by this object.';
+
+
+--
+-- Name: filter; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE filter (
+ format character varying(255) NOT NULL,
+ module character varying(64) DEFAULT ''::character varying NOT NULL,
+ name character varying(32) DEFAULT ''::character varying NOT NULL,
+ weight integer DEFAULT 0 NOT NULL,
+ status integer DEFAULT 0 NOT NULL,
+ settings bytea
+);
+
+
+--
+-- Name: TABLE filter; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE filter IS 'Table that maps filters (HTML corrector) to text formats (Filtered HTML).';
+
+
+--
+-- Name: COLUMN filter.format; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN filter.format IS 'Foreign key: The filter_format.format to which this filter is assigned.';
+
+
+--
+-- Name: COLUMN filter.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN filter.module IS 'The origin module of the filter.';
+
+
+--
+-- Name: COLUMN filter.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN filter.name IS 'Name of the filter being referenced.';
+
+
+--
+-- Name: COLUMN filter.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN filter.weight IS 'Weight of filter within format.';
+
+
+--
+-- Name: COLUMN filter.status; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN filter.status IS 'Filter enabled status. (1 = enabled, 0 = disabled)';
+
+
+--
+-- Name: COLUMN filter.settings; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN filter.settings IS 'A serialized array of name value pairs that store the filter settings for the specific format.';
+
+
+--
+-- Name: filter_format; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE filter_format (
+ format character varying(255) NOT NULL,
+ name character varying(255) DEFAULT ''::character varying NOT NULL,
+ cache smallint DEFAULT 0 NOT NULL,
+ status integer DEFAULT 1 NOT NULL,
+ weight integer DEFAULT 0 NOT NULL,
+ CONSTRAINT filter_format_status_check CHECK ((status >= 0))
+);
+
+
+--
+-- Name: TABLE filter_format; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE filter_format IS 'Stores text formats: custom groupings of filters, such as Filtered HTML.';
+
+
+--
+-- Name: COLUMN filter_format.format; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN filter_format.format IS 'Primary Key: Unique machine name of the format.';
+
+
+--
+-- Name: COLUMN filter_format.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN filter_format.name IS 'Name of the text format (Filtered HTML).';
+
+
+--
+-- Name: COLUMN filter_format.cache; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN filter_format.cache IS 'Flag to indicate whether format is cacheable. (1 = cacheable, 0 = not cacheable)';
+
+
+--
+-- Name: COLUMN filter_format.status; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN filter_format.status IS 'The status of the text format. (1 = enabled, 0 = disabled)';
+
+
+--
+-- Name: COLUMN filter_format.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN filter_format.weight IS 'Weight of text format to use when listing.';
+
+
+--
+-- Name: flood; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE flood (
+ fid integer NOT NULL,
+ event character varying(64) DEFAULT ''::character varying NOT NULL,
+ identifier character varying(128) DEFAULT ''::character varying NOT NULL,
+ "timestamp" integer DEFAULT 0 NOT NULL,
+ expiration integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE flood; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE flood IS 'Flood controls the threshold of events, such as the number of contact attempts.';
+
+
+--
+-- Name: COLUMN flood.fid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN flood.fid IS 'Unique flood event ID.';
+
+
+--
+-- Name: COLUMN flood.event; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN flood.event IS 'Name of event (e.g. contact).';
+
+
+--
+-- Name: COLUMN flood.identifier; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN flood.identifier IS 'Identifier of the visitor, such as an IP address or hostname.';
+
+
+--
+-- Name: COLUMN flood."timestamp"; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN flood."timestamp" IS 'Timestamp of the event.';
+
+
+--
+-- Name: COLUMN flood.expiration; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN flood.expiration IS 'Expiration timestamp. Expired events are purged on cron run.';
+
+
+--
+-- Name: flood_fid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE flood_fid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: flood_fid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE flood_fid_seq OWNED BY flood.fid;
+
+
+--
+-- Name: gensas_category; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_category (
+ category_id integer NOT NULL,
+ category_name character varying NOT NULL,
+ category_label character varying NOT NULL,
+ rank integer NOT NULL
+);
+
+
+--
+-- Name: gensas_category_category_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_category_category_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_category_category_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_category_category_id_seq OWNED BY gensas_category.category_id;
+
+
+--
+-- Name: gensas_db; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_db (
+ db_id integer NOT NULL,
+ db_name character varying(100) NOT NULL,
+ label character varying(100) NOT NULL,
+ url character varying(100),
+ url_prefix character varying(100),
+ description text,
+ regex_id character varying(200),
+ regex_def character varying(200),
+ regex_hit_id character varying(200),
+ regex_hit_acc character varying(200),
+ regex_hit_def character varying(200),
+ regex_hit_org character varying(200)
+);
+
+
+--
+-- Name: gensas_db_db_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_db_db_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_db_db_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_db_db_id_seq OWNED BY gensas_db.db_id;
+
+
+--
+-- Name: gensas_expire; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_expire (
+ task_id character varying(200) NOT NULL,
+ reset_date timestamp without time zone,
+ last_notify_date timestamp without time zone,
+ next_notify_days integer,
+ exempt integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: gensas_files; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_files (
+ file_id integer NOT NULL,
+ user_id integer NOT NULL,
+ file_name character varying(1024) NOT NULL,
+ file_path text NOT NULL,
+ drupal_path text NOT NULL,
+ file_size bigint NOT NULL,
+ type character varying(100)
+);
+
+
+--
+-- Name: gensas_files_file_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_files_file_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_files_file_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_files_file_id_seq OWNED BY gensas_files.file_id;
+
+
+--
+-- Name: gensas_gff3; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_gff3 (
+ job_id character varying(200) NOT NULL,
+ prop text,
+ id character varying(255) NOT NULL,
+ type character varying(255) NOT NULL,
+ start integer,
+ parent character varying(255),
+ landmark character varying(1024) NOT NULL
+);
+
+
+--
+-- Name: gensas_gff3_location_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_gff3_location_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_gff3_location_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_gff3_location_seq OWNED BY gensas_gff3.start;
+
+
+--
+-- Name: gensas_group; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_group (
+ group_id integer NOT NULL,
+ group_name character varying(1024) NOT NULL
+);
+
+
+--
+-- Name: gensas_group_group_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_group_group_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_group_group_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_group_group_id_seq OWNED BY gensas_group.group_id;
+
+
+--
+-- Name: gensas_group_seq; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_group_seq (
+ group_id integer NOT NULL,
+ seq_id integer NOT NULL,
+ type character varying(100) DEFAULT 'unknown'::character varying NOT NULL
+);
+
+
+--
+-- Name: gensas_group_task; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_group_task (
+ group_id integer NOT NULL,
+ task_id character varying(200) NOT NULL
+);
+
+
+--
+-- Name: gensas_group_user; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_group_user (
+ group_id integer NOT NULL,
+ user_id integer NOT NULL,
+ leader integer DEFAULT 0 NOT NULL,
+ read_only integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: gensas_job; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_job (
+ job_id character varying(200) NOT NULL,
+ id integer NOT NULL,
+ type character varying(50) NOT NULL,
+ output text,
+ create_date timestamp without time zone,
+ submit_date timestamp without time zone,
+ complete_date timestamp without time zone,
+ log text,
+ status integer,
+ params text,
+ output_parsed text,
+ source character varying(1024),
+ tool_id integer,
+ stderr text,
+ retval character varying(50),
+ num_run integer,
+ name character varying(100)
+);
+
+
+--
+-- Name: gensas_job_cmd; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_job_cmd (
+ id integer NOT NULL,
+ index integer NOT NULL,
+ cmd text,
+ sanitized_cmd text
+);
+
+
+--
+-- Name: gensas_job_execid; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_job_execid (
+ job_id character varying(200) NOT NULL,
+ resource_id integer NOT NULL,
+ exec_id integer NOT NULL
+);
+
+
+--
+-- Name: gensas_job_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_job_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_job_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_job_id_seq OWNED BY gensas_job.id;
+
+
+--
+-- Name: gensas_job_pid; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_job_pid (
+ job_id character varying(200) NOT NULL,
+ pid integer NOT NULL
+);
+
+
+--
+-- Name: gensas_job_resource; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_job_resource (
+ resource_id integer NOT NULL,
+ job_id character varying(200) NOT NULL
+);
+
+
+--
+-- Name: gensas_job_stats; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_job_stats (
+ job_id character varying(200) NOT NULL,
+ type character varying(50) NOT NULL,
+ num_features integer
+);
+
+
+--
+-- Name: gensas_library; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_library (
+ library_id integer NOT NULL,
+ name character varying(300) NOT NULL,
+ type_id integer NOT NULL,
+ label character varying(300) NOT NULL
+);
+
+
+--
+-- Name: gensas_library_library_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_library_library_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_library_library_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_library_library_id_seq OWNED BY gensas_library.library_id;
+
+
+--
+-- Name: gensas_library_type; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_library_type (
+ library_type_id integer NOT NULL,
+ type character varying(300) NOT NULL,
+ label character varying(300) NOT NULL
+);
+
+
+--
+-- Name: gensas_library_type_library_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_library_type_library_type_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_library_type_library_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_library_type_library_type_id_seq OWNED BY gensas_library_type.library_type_id;
+
+
+--
+-- Name: gensas_param_group; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_param_group (
+ param_group_id integer NOT NULL,
+ name character varying(128) NOT NULL,
+ tool_id integer NOT NULL,
+ title character varying(255) NOT NULL,
+ description text,
+ prop text
+);
+
+
+--
+-- Name: COLUMN gensas_param_group.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN gensas_param_group.name IS 'a computer readable name for the group';
+
+
+--
+-- Name: COLUMN gensas_param_group.title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN gensas_param_group.title IS 'a human readable name for the group';
+
+
+--
+-- Name: gensas_param_group_param_group_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_param_group_param_group_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_param_group_param_group_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_param_group_param_group_id_seq OWNED BY gensas_param_group.param_group_id;
+
+
+--
+-- Name: gensas_project_type; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_project_type (
+ project_type_id integer NOT NULL,
+ type character varying(200) NOT NULL,
+ name character varying(200) NOT NULL
+);
+
+
+--
+-- Name: gensas_project_type_project_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_project_type_project_type_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_project_type_project_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_project_type_project_type_id_seq OWNED BY gensas_project_type.project_type_id;
+
+
+--
+-- Name: gensas_publish; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_publish (
+ job_id character varying(200) NOT NULL,
+ version integer NOT NULL
+);
+
+
+--
+-- Name: gensas_resource; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_resource (
+ resource_id integer NOT NULL,
+ name character varying(150) NOT NULL,
+ type character varying(10) NOT NULL,
+ max_slots integer DEFAULT 1 NOT NULL,
+ rank integer NOT NULL,
+ enabled integer DEFAULT 1 NOT NULL,
+ working_directory text,
+ description text,
+ seqlib_directory text
+);
+
+
+--
+-- Name: COLUMN gensas_resource.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN gensas_resource.type IS 'The type of resource (e.g. local, ge or pbs).';
+
+
+--
+-- Name: COLUMN gensas_resource.max_slots; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN gensas_resource.max_slots IS 'The number of free slots on this resource.';
+
+
+--
+-- Name: COLUMN gensas_resource.rank; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN gensas_resource.rank IS 'An integer indicating the order in which resrouces should be selected for use. A lower rank indicates higher priority.';
+
+
+--
+-- Name: COLUMN gensas_resource.enabled; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN gensas_resource.enabled IS 'Set to 0 if this resource should not be used.';
+
+
+--
+-- Name: COLUMN gensas_resource.working_directory; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN gensas_resource.working_directory IS 'The directory on the resource where GenSAS will store temporary needed for and created during execution.';
+
+
+--
+-- Name: COLUMN gensas_resource.description; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN gensas_resource.description IS 'Provides a brief description about this .';
+
+
+--
+-- Name: gensas_resource_library; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_resource_library (
+ resource_id integer NOT NULL,
+ library_id character varying(200) NOT NULL,
+ file_path text NOT NULL
+);
+
+
+--
+-- Name: gensas_resource_resource_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_resource_resource_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_resource_resource_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_resource_resource_id_seq OWNED BY gensas_resource.resource_id;
+
+
+--
+-- Name: gensas_resource_submit; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_resource_submit (
+ resource_id integer NOT NULL,
+ hostname character varying(200) NOT NULL,
+ ssh_port integer NOT NULL,
+ username character varying(200) NOT NULL
+);
+
+
+--
+-- Name: gensas_resource_tool; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_resource_tool (
+ resource_id integer NOT NULL,
+ tool_id integer NOT NULL,
+ tool_path text NOT NULL
+);
+
+
+--
+-- Name: gensas_seq; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_seq (
+ seq_id integer NOT NULL,
+ seq_group_id integer NOT NULL,
+ create_date timestamp without time zone NOT NULL,
+ name text NOT NULL,
+ user_id integer NOT NULL,
+ description text
+);
+
+
+--
+-- Name: gensas_seq_group; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_seq_group (
+ seq_group_id integer NOT NULL,
+ user_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ type character varying(100) NOT NULL,
+ filename character varying(1028) DEFAULT 'unknown'::character varying NOT NULL,
+ num_seqs integer DEFAULT 0 NOT NULL,
+ version character varying(25) DEFAULT ''::character varying NOT NULL,
+ filtered text
+);
+
+
+--
+-- Name: gensas_seq_group_seq_group_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_seq_group_seq_group_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_seq_group_seq_group_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_seq_group_seq_group_id_seq OWNED BY gensas_seq_group.seq_group_id;
+
+
+--
+-- Name: gensas_seq_seq_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_seq_seq_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_seq_seq_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_seq_seq_id_seq OWNED BY gensas_seq.seq_id;
+
+
+--
+-- Name: gensas_seq_stats; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_seq_stats (
+ job_id character varying(200) NOT NULL,
+ seq_id integer,
+ type character varying(50) NOT NULL,
+ num_features integer
+);
+
+
+--
+-- Name: gensas_task; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_task (
+ task_id character varying(200) NOT NULL,
+ task_name character varying(50),
+ submit_date timestamp without time zone,
+ complete_date timestamp without time zone,
+ log text,
+ user_id integer,
+ status character varying(50),
+ task_info text
+);
+
+
+--
+-- Name: gensas_task_files; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_task_files (
+ task_id character varying(200) NOT NULL,
+ file_id integer
+);
+
+
+--
+-- Name: gensas_task_job; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_task_job (
+ task_id character varying(200) NOT NULL,
+ job_id character varying(200) NOT NULL,
+ is_owner smallint DEFAULT 1 NOT NULL
+);
+
+
+--
+-- Name: gensas_task_seq_group; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_task_seq_group (
+ task_id character varying(200) NOT NULL,
+ seq_group_id integer
+);
+
+
+--
+-- Name: gensas_task_user; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_task_user (
+ task_id character varying(200) NOT NULL,
+ user_id integer NOT NULL,
+ permission character varying(200) DEFAULT 'readonly'::character varying NOT NULL
+);
+
+
+--
+-- Name: gensas_tool; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_tool (
+ tool_id integer NOT NULL,
+ tool_name character varying(100) NOT NULL,
+ tool_label character varying(100) NOT NULL,
+ description text,
+ outfiles_desc text,
+ url character varying(100),
+ is_enabled smallint DEFAULT 1 NOT NULL,
+ category_id integer NOT NULL,
+ tool_path character varying,
+ profile_num integer DEFAULT 1 NOT NULL
+);
+
+
+--
+-- Name: COLUMN gensas_tool.profile_num; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN gensas_tool.profile_num IS 'Indicates the installed profile for this tool. This number should be increased when updates are made to the values of this table. The GenSAS Tool installer will check this field with the profile in the GenSASToolExec class. If the profile_number in the record differs from the profile_num provided in the install() function for the tool, then the record will be updated.';
+
+
+--
+-- Name: gensas_tool_param; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_tool_param (
+ tool_param_id integer NOT NULL,
+ tool_id integer NOT NULL,
+ param_elem_id character varying NOT NULL,
+ param_label character varying NOT NULL,
+ param_type character varying NOT NULL,
+ param_value text,
+ param_attr character varying,
+ param_default character varying,
+ rank integer,
+ cmd_prefix character varying(30),
+ cmd_surfix character varying(30),
+ param_note character varying(1024),
+ required integer,
+ param_group_id integer
+);
+
+
+--
+-- Name: gensas_tool_param_tool_param_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_tool_param_tool_param_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_tool_param_tool_param_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_tool_param_tool_param_id_seq OWNED BY gensas_tool_param.tool_param_id;
+
+
+--
+-- Name: gensas_tool_param_type; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_tool_param_type (
+ tool_param_type_id integer NOT NULL,
+ type character varying(300) NOT NULL,
+ label character varying(300) NOT NULL,
+ description text
+);
+
+
+--
+-- Name: gensas_tool_param_type_tool_param_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_tool_param_type_tool_param_type_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_tool_param_type_tool_param_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_tool_param_type_tool_param_type_id_seq OWNED BY gensas_tool_param_type.tool_param_type_id;
+
+
+--
+-- Name: gensas_tool_tool_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_tool_tool_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_tool_tool_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_tool_tool_id_seq OWNED BY gensas_tool.tool_id;
+
+
+--
+-- Name: gensas_tool_type; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_tool_type (
+ tool_type_id integer NOT NULL,
+ project_type_id integer NOT NULL,
+ tool_id integer NOT NULL
+);
+
+
+--
+-- Name: TABLE gensas_tool_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE gensas_tool_type IS 'Associates tools with the type of project they are appropriate for.';
+
+
+--
+-- Name: gensas_tool_type_tool_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE gensas_tool_type_tool_type_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: gensas_tool_type_tool_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE gensas_tool_type_tool_type_id_seq OWNED BY gensas_tool_type.tool_type_id;
+
+
+--
+-- Name: gensas_user_tool; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE gensas_user_tool (
+ user_id integer NOT NULL,
+ tool_id integer NOT NULL,
+ status character varying
+);
+
+
+--
+-- Name: history; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE history (
+ uid integer DEFAULT 0 NOT NULL,
+ nid bigint DEFAULT 0 NOT NULL,
+ "timestamp" integer DEFAULT 0 NOT NULL,
+ CONSTRAINT history_nid_check CHECK ((nid >= 0))
+);
+
+
+--
+-- Name: TABLE history; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE history IS 'A record of which users have read which nodes.';
+
+
+--
+-- Name: COLUMN history.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN history.uid IS 'The users.uid that read the node nid.';
+
+
+--
+-- Name: COLUMN history.nid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN history.nid IS 'The node.nid that was read.';
+
+
+--
+-- Name: COLUMN history."timestamp"; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN history."timestamp" IS 'The Unix timestamp at which the read occurred.';
+
+
+--
+-- Name: image_effects; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE image_effects (
+ ieid integer NOT NULL,
+ isid bigint DEFAULT 0 NOT NULL,
+ weight integer DEFAULT 0 NOT NULL,
+ name character varying(255) NOT NULL,
+ data bytea NOT NULL,
+ CONSTRAINT image_effects_ieid_check CHECK ((ieid >= 0)),
+ CONSTRAINT image_effects_isid_check CHECK ((isid >= 0))
+);
+
+
+--
+-- Name: TABLE image_effects; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE image_effects IS 'Stores configuration options for image effects.';
+
+
+--
+-- Name: COLUMN image_effects.ieid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN image_effects.ieid IS 'The primary identifier for an image effect.';
+
+
+--
+-- Name: COLUMN image_effects.isid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN image_effects.isid IS 'The image_styles.isid for an image style.';
+
+
+--
+-- Name: COLUMN image_effects.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN image_effects.weight IS 'The weight of the effect in the style.';
+
+
+--
+-- Name: COLUMN image_effects.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN image_effects.name IS 'The unique name of the effect to be executed.';
+
+
+--
+-- Name: COLUMN image_effects.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN image_effects.data IS 'The configuration data for the effect.';
+
+
+--
+-- Name: image_effects_ieid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE image_effects_ieid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: image_effects_ieid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE image_effects_ieid_seq OWNED BY image_effects.ieid;
+
+
+--
+-- Name: image_styles; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE image_styles (
+ isid integer NOT NULL,
+ name character varying(255) NOT NULL,
+ label character varying(255) DEFAULT ''::character varying NOT NULL,
+ CONSTRAINT image_styles_isid_check CHECK ((isid >= 0))
+);
+
+
+--
+-- Name: TABLE image_styles; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE image_styles IS 'Stores configuration options for image styles.';
+
+
+--
+-- Name: COLUMN image_styles.isid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN image_styles.isid IS 'The primary identifier for an image style.';
+
+
+--
+-- Name: COLUMN image_styles.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN image_styles.name IS 'The style machine name.';
+
+
+--
+-- Name: COLUMN image_styles.label; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN image_styles.label IS 'The style administrative name.';
+
+
+--
+-- Name: image_styles_isid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE image_styles_isid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: image_styles_isid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE image_styles_isid_seq OWNED BY image_styles.isid;
+
+
+--
+-- Name: masquerade; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE masquerade (
+ sid character varying(64) DEFAULT ''::character varying NOT NULL,
+ uid_from integer DEFAULT 0 NOT NULL,
+ uid_as integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE masquerade; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE masquerade IS 'Each masquerading user has their session recorded into the masquerade table. Each record represents a masquerading user.';
+
+
+--
+-- Name: COLUMN masquerade.sid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN masquerade.sid IS 'The current session for this masquerading user corresponding to their sessions.sid.';
+
+
+--
+-- Name: COLUMN masquerade.uid_from; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN masquerade.uid_from IS 'The users.uid corresponding to a session.';
+
+
+--
+-- Name: COLUMN masquerade.uid_as; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN masquerade.uid_as IS 'The users.uid this session is masquerading as.';
+
+
+--
+-- Name: masquerade_users; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE masquerade_users (
+ uid_from integer DEFAULT 0 NOT NULL,
+ uid_to integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE masquerade_users; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE masquerade_users IS 'Per-user permission table granting permissions to switch as a specific user.';
+
+
+--
+-- Name: COLUMN masquerade_users.uid_from; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN masquerade_users.uid_from IS 'The users.uid that can masquerade as masquerade_users.uid_to.';
+
+
+--
+-- Name: COLUMN masquerade_users.uid_to; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN masquerade_users.uid_to IS 'The users.uid that masquerade_users.uid_from can masquerade as.';
+
+
+--
+-- Name: mcl_file; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE mcl_file (
+ file_id integer NOT NULL,
+ type character varying(255) NOT NULL,
+ filename character varying(255) NOT NULL,
+ filepath character varying(512) NOT NULL,
+ filesize integer DEFAULT 0 NOT NULL,
+ uri character varying(255) NOT NULL,
+ user_id integer NOT NULL,
+ job_id integer,
+ submit_date timestamp without time zone NOT NULL,
+ prop text
+);
+
+
+--
+-- Name: mcl_file_file_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE mcl_file_file_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: mcl_file_file_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE mcl_file_file_id_seq OWNED BY mcl_file.file_id;
+
+
+--
+-- Name: mcl_job; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE mcl_job (
+ job_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ type character varying(255) NOT NULL,
+ class_name character varying(255),
+ status integer,
+ param text,
+ prop text,
+ user_id integer NOT NULL,
+ program_id integer,
+ submit_date timestamp without time zone NOT NULL,
+ complete_date timestamp without time zone
+);
+
+
+--
+-- Name: mcl_job_job_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE mcl_job_job_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: mcl_job_job_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE mcl_job_job_id_seq OWNED BY mcl_job.job_id;
+
+
+--
+-- Name: mcl_template; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE mcl_template (
+ template_id integer NOT NULL,
+ template character varying(255) NOT NULL,
+ template_type_id integer NOT NULL
+);
+
+
+--
+-- Name: mcl_template_template_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE mcl_template_template_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: mcl_template_template_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE mcl_template_template_id_seq OWNED BY mcl_template.template_id;
+
+
+--
+-- Name: mcl_template_type; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE mcl_template_type (
+ template_type_id integer NOT NULL,
+ type character varying(255) NOT NULL,
+ rank integer NOT NULL
+);
+
+
+--
+-- Name: mcl_template_type_template_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE mcl_template_type_template_type_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: mcl_template_type_template_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE mcl_template_type_template_type_id_seq OWNED BY mcl_template_type.template_type_id;
+
+
+--
+-- Name: mcl_user; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE mcl_user (
+ user_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ uid integer NOT NULL,
+ mail character varying(255) NOT NULL,
+ prop text
+);
+
+
+--
+-- Name: mcl_var; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE mcl_var (
+ var_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ type character varying(255) NOT NULL,
+ value character varying(1024),
+ description text
+);
+
+
+--
+-- Name: mcl_var_var_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE mcl_var_var_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: mcl_var_var_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE mcl_var_var_id_seq OWNED BY mcl_var.var_id;
+
+
+--
+-- Name: menu_custom; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE menu_custom (
+ menu_name character varying(32) DEFAULT ''::character varying NOT NULL,
+ title character varying(255) DEFAULT ''::character varying NOT NULL,
+ description text
+);
+
+
+--
+-- Name: TABLE menu_custom; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE menu_custom IS 'Holds definitions for top-level custom menus (for example, Main menu).';
+
+
+--
+-- Name: COLUMN menu_custom.menu_name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_custom.menu_name IS 'Primary Key: Unique key for menu. This is used as a block delta so length is 32.';
+
+
+--
+-- Name: COLUMN menu_custom.title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_custom.title IS 'Menu title; displayed at top of block.';
+
+
+--
+-- Name: COLUMN menu_custom.description; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_custom.description IS 'Menu description.';
+
+
+--
+-- Name: menu_links; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE menu_links (
+ menu_name character varying(32) DEFAULT ''::character varying NOT NULL,
+ mlid integer NOT NULL,
+ plid bigint DEFAULT 0 NOT NULL,
+ link_path character varying(255) DEFAULT ''::character varying NOT NULL,
+ router_path character varying(255) DEFAULT ''::character varying NOT NULL,
+ link_title character varying(255) DEFAULT ''::character varying NOT NULL,
+ options bytea,
+ module character varying(255) DEFAULT 'system'::character varying NOT NULL,
+ hidden smallint DEFAULT 0 NOT NULL,
+ external smallint DEFAULT 0 NOT NULL,
+ has_children smallint DEFAULT 0 NOT NULL,
+ expanded smallint DEFAULT 0 NOT NULL,
+ weight integer DEFAULT 0 NOT NULL,
+ depth smallint DEFAULT 0 NOT NULL,
+ customized smallint DEFAULT 0 NOT NULL,
+ p1 bigint DEFAULT 0 NOT NULL,
+ p2 bigint DEFAULT 0 NOT NULL,
+ p3 bigint DEFAULT 0 NOT NULL,
+ p4 bigint DEFAULT 0 NOT NULL,
+ p5 bigint DEFAULT 0 NOT NULL,
+ p6 bigint DEFAULT 0 NOT NULL,
+ p7 bigint DEFAULT 0 NOT NULL,
+ p8 bigint DEFAULT 0 NOT NULL,
+ p9 bigint DEFAULT 0 NOT NULL,
+ updated smallint DEFAULT 0 NOT NULL,
+ CONSTRAINT menu_links_mlid_check CHECK ((mlid >= 0)),
+ CONSTRAINT menu_links_p1_check CHECK ((p1 >= 0)),
+ CONSTRAINT menu_links_p2_check CHECK ((p2 >= 0)),
+ CONSTRAINT menu_links_p3_check CHECK ((p3 >= 0)),
+ CONSTRAINT menu_links_p4_check CHECK ((p4 >= 0)),
+ CONSTRAINT menu_links_p5_check CHECK ((p5 >= 0)),
+ CONSTRAINT menu_links_p6_check CHECK ((p6 >= 0)),
+ CONSTRAINT menu_links_p7_check CHECK ((p7 >= 0)),
+ CONSTRAINT menu_links_p8_check CHECK ((p8 >= 0)),
+ CONSTRAINT menu_links_p9_check CHECK ((p9 >= 0)),
+ CONSTRAINT menu_links_plid_check CHECK ((plid >= 0))
+);
+
+
+--
+-- Name: TABLE menu_links; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE menu_links IS 'Contains the individual links within a menu.';
+
+
+--
+-- Name: COLUMN menu_links.menu_name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.menu_name IS 'The menu name. All links with the same menu name (such as ''navigation'') are part of the same menu.';
+
+
+--
+-- Name: COLUMN menu_links.mlid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.mlid IS 'The menu link ID (mlid) is the integer primary key.';
+
+
+--
+-- Name: COLUMN menu_links.plid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.plid IS 'The parent link ID (plid) is the mlid of the link above in the hierarchy, or zero if the link is at the top level in its menu.';
+
+
+--
+-- Name: COLUMN menu_links.link_path; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.link_path IS 'The Drupal path or external path this link points to.';
+
+
+--
+-- Name: COLUMN menu_links.router_path; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.router_path IS 'For links corresponding to a Drupal path (external = 0), this connects the link to a menu_router.path for joins.';
+
+
+--
+-- Name: COLUMN menu_links.link_title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.link_title IS 'The text displayed for the link, which may be modified by a title callback stored in menu_router.';
+
+
+--
+-- Name: COLUMN menu_links.options; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.options IS 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.';
+
+
+--
+-- Name: COLUMN menu_links.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.module IS 'The name of the module that generated this link.';
+
+
+--
+-- Name: COLUMN menu_links.hidden; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.hidden IS 'A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)';
+
+
+--
+-- Name: COLUMN menu_links.external; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.external IS 'A flag to indicate if the link points to a full URL starting with a protocol,::text like http:// (1 = external, 0 = internal).';
+
+
+--
+-- Name: COLUMN menu_links.has_children; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.has_children IS 'Flag indicating whether any links have this link as a parent (1 = children exist, 0 = no children).';
+
+
+--
+-- Name: COLUMN menu_links.expanded; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.expanded IS 'Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)';
+
+
+--
+-- Name: COLUMN menu_links.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.weight IS 'Link weight among links in the same menu at the same depth.';
+
+
+--
+-- Name: COLUMN menu_links.depth; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.depth IS 'The depth relative to the top level. A link with plid == 0 will have depth == 1.';
+
+
+--
+-- Name: COLUMN menu_links.customized; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.customized IS 'A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized).';
+
+
+--
+-- Name: COLUMN menu_links.p1; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.p1 IS 'The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the plid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.';
+
+
+--
+-- Name: COLUMN menu_links.p2; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.p2 IS 'The second mlid in the materialized path. See p1.';
+
+
+--
+-- Name: COLUMN menu_links.p3; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.p3 IS 'The third mlid in the materialized path. See p1.';
+
+
+--
+-- Name: COLUMN menu_links.p4; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.p4 IS 'The fourth mlid in the materialized path. See p1.';
+
+
+--
+-- Name: COLUMN menu_links.p5; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.p5 IS 'The fifth mlid in the materialized path. See p1.';
+
+
+--
+-- Name: COLUMN menu_links.p6; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.p6 IS 'The sixth mlid in the materialized path. See p1.';
+
+
+--
+-- Name: COLUMN menu_links.p7; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.p7 IS 'The seventh mlid in the materialized path. See p1.';
+
+
+--
+-- Name: COLUMN menu_links.p8; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.p8 IS 'The eighth mlid in the materialized path. See p1.';
+
+
+--
+-- Name: COLUMN menu_links.p9; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.p9 IS 'The ninth mlid in the materialized path. See p1.';
+
+
+--
+-- Name: COLUMN menu_links.updated; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_links.updated IS 'Flag that indicates that this link was generated during the update from Drupal 5.';
+
+
+--
+-- Name: menu_links_mlid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE menu_links_mlid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: menu_links_mlid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE menu_links_mlid_seq OWNED BY menu_links.mlid;
+
+
+--
+-- Name: menu_router; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE menu_router (
+ path character varying(255) DEFAULT ''::character varying NOT NULL,
+ load_functions bytea NOT NULL,
+ to_arg_functions bytea NOT NULL,
+ access_callback character varying(255) DEFAULT ''::character varying NOT NULL,
+ access_arguments bytea,
+ page_callback character varying(255) DEFAULT ''::character varying NOT NULL,
+ page_arguments bytea,
+ delivery_callback character varying(255) DEFAULT ''::character varying NOT NULL,
+ fit integer DEFAULT 0 NOT NULL,
+ number_parts smallint DEFAULT 0 NOT NULL,
+ context integer DEFAULT 0 NOT NULL,
+ tab_parent character varying(255) DEFAULT ''::character varying NOT NULL,
+ tab_root character varying(255) DEFAULT ''::character varying NOT NULL,
+ title character varying(255) DEFAULT ''::character varying NOT NULL,
+ title_callback character varying(255) DEFAULT ''::character varying NOT NULL,
+ title_arguments character varying(255) DEFAULT ''::character varying NOT NULL,
+ theme_callback character varying(255) DEFAULT ''::character varying NOT NULL,
+ theme_arguments character varying(255) DEFAULT ''::character varying NOT NULL,
+ type integer DEFAULT 0 NOT NULL,
+ description text NOT NULL,
+ "position" character varying(255) DEFAULT ''::character varying NOT NULL,
+ weight integer DEFAULT 0 NOT NULL,
+ include_file text
+);
+
+
+--
+-- Name: TABLE menu_router; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE menu_router IS 'Maps paths to various callbacks (access, page and title)';
+
+
+--
+-- Name: COLUMN menu_router.path; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.path IS 'Primary Key: the Drupal path this entry describes';
+
+
+--
+-- Name: COLUMN menu_router.load_functions; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.load_functions IS 'A serialized array of function names (like node_load) to be called to load an object corresponding to a part of the current path.';
+
+
+--
+-- Name: COLUMN menu_router.to_arg_functions; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.to_arg_functions IS 'A serialized array of function names (like user_uid_optional_to_arg) to be called to replace a part of the router path with another string.';
+
+
+--
+-- Name: COLUMN menu_router.access_callback; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.access_callback IS 'The callback which determines the access to this router path. Defaults to user_access.';
+
+
+--
+-- Name: COLUMN menu_router.access_arguments; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.access_arguments IS 'A serialized array of arguments for the access callback.';
+
+
+--
+-- Name: COLUMN menu_router.page_callback; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.page_callback IS 'The name of the function that renders the page.';
+
+
+--
+-- Name: COLUMN menu_router.page_arguments; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.page_arguments IS 'A serialized array of arguments for the page callback.';
+
+
+--
+-- Name: COLUMN menu_router.delivery_callback; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.delivery_callback IS 'The name of the function that sends the result of the page_callback function to the browser.';
+
+
+--
+-- Name: COLUMN menu_router.fit; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.fit IS 'A numeric representation of how specific the path is.';
+
+
+--
+-- Name: COLUMN menu_router.number_parts; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.number_parts IS 'Number of parts in this router path.';
+
+
+--
+-- Name: COLUMN menu_router.context; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.context IS 'Only for local tasks (tabs) - the context of a local task to control its placement.';
+
+
+--
+-- Name: COLUMN menu_router.tab_parent; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.tab_parent IS 'Only for local tasks (tabs) - the router path of the parent page (which may also be a local task).';
+
+
+--
+-- Name: COLUMN menu_router.tab_root; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.tab_root IS 'Router path of the closest non-tab parent page. For pages that are not local tasks, this will be the same as the path.';
+
+
+--
+-- Name: COLUMN menu_router.title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.title IS 'The title for the current page, or the title for the tab if this is a local task.';
+
+
+--
+-- Name: COLUMN menu_router.title_callback; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.title_callback IS 'A function which will alter the title. Defaults to t()';
+
+
+--
+-- Name: COLUMN menu_router.title_arguments; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.title_arguments IS 'A serialized array of arguments for the title callback. If empty, the title will be used as the sole argument for the title callback.';
+
+
+--
+-- Name: COLUMN menu_router.theme_callback; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.theme_callback IS 'A function which returns the name of the theme that will be used to render this page. If left empty, the default theme will be used.';
+
+
+--
+-- Name: COLUMN menu_router.theme_arguments; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.theme_arguments IS 'A serialized array of arguments for the theme callback.';
+
+
+--
+-- Name: COLUMN menu_router.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.type IS 'Numeric representation of the type of the menu item,::text like MENU_LOCAL_TASK.';
+
+
+--
+-- Name: COLUMN menu_router.description; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.description IS 'A description of this item.';
+
+
+--
+-- Name: COLUMN menu_router."position"; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router."position" IS 'The position of the block (left or right) on the system administration page for this item.';
+
+
+--
+-- Name: COLUMN menu_router.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.weight IS 'Weight of the element. Lighter weights are higher up, heavier weights go down.';
+
+
+--
+-- Name: COLUMN menu_router.include_file; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN menu_router.include_file IS 'The file to include for this element, usually the page callback function lives in this file.';
+
+
+--
+-- Name: node; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE node (
+ nid integer NOT NULL,
+ vid bigint,
+ type character varying(32) DEFAULT ''::character varying NOT NULL,
+ language character varying(12) DEFAULT ''::character varying NOT NULL,
+ title character varying(255) DEFAULT ''::character varying NOT NULL,
+ uid integer DEFAULT 0 NOT NULL,
+ status integer DEFAULT 1 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ changed integer DEFAULT 0 NOT NULL,
+ comment integer DEFAULT 0 NOT NULL,
+ promote integer DEFAULT 0 NOT NULL,
+ sticky integer DEFAULT 0 NOT NULL,
+ tnid bigint DEFAULT 0 NOT NULL,
+ translate integer DEFAULT 0 NOT NULL,
+ CONSTRAINT node_nid_check CHECK ((nid >= 0)),
+ CONSTRAINT node_tnid_check CHECK ((tnid >= 0)),
+ CONSTRAINT node_vid_check CHECK ((vid >= 0))
+);
+
+
+--
+-- Name: TABLE node; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE node IS 'The base table for nodes.';
+
+
+--
+-- Name: COLUMN node.nid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.nid IS 'The primary identifier for a node.';
+
+
+--
+-- Name: COLUMN node.vid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.vid IS 'The current node_revision.vid version identifier.';
+
+
+--
+-- Name: COLUMN node.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.type IS 'The node_type.type of this node.';
+
+
+--
+-- Name: COLUMN node.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.language IS 'The languages.language of this node.';
+
+
+--
+-- Name: COLUMN node.title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.title IS 'The title of this node, always treated as non-markup plain text.';
+
+
+--
+-- Name: COLUMN node.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.uid IS 'The users.uid that owns this node; initially, this is the user that created it.';
+
+
+--
+-- Name: COLUMN node.status; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.status IS 'Boolean indicating whether the node is published (visible to non-administrators).';
+
+
+--
+-- Name: COLUMN node.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.created IS 'The Unix timestamp when the node was created.';
+
+
+--
+-- Name: COLUMN node.changed; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.changed IS 'The Unix timestamp when the node was most recently saved.';
+
+
+--
+-- Name: COLUMN node.comment; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.comment IS 'Whether comments are allowed on this node: 0 = no, 1 = closed (read only), 2 = open (read/write).';
+
+
+--
+-- Name: COLUMN node.promote; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.promote IS 'Boolean indicating whether the node should be displayed on the front page.';
+
+
+--
+-- Name: COLUMN node.sticky; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.sticky IS 'Boolean indicating whether the node should be displayed at the top of lists in which it appears.';
+
+
+--
+-- Name: COLUMN node.tnid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.tnid IS 'The translation set id for this node, which equals the node id of the source post in each set.';
+
+
+--
+-- Name: COLUMN node.translate; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node.translate IS 'A boolean indicating whether this translation page needs to be updated.';
+
+
+--
+-- Name: node_access; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE node_access (
+ nid bigint DEFAULT 0 NOT NULL,
+ gid bigint DEFAULT 0 NOT NULL,
+ realm character varying(255) DEFAULT ''::character varying NOT NULL,
+ grant_view integer DEFAULT 0 NOT NULL,
+ grant_update integer DEFAULT 0 NOT NULL,
+ grant_delete integer DEFAULT 0 NOT NULL,
+ CONSTRAINT node_access_gid_check CHECK ((gid >= 0)),
+ CONSTRAINT node_access_grant_delete_check CHECK ((grant_delete >= 0)),
+ CONSTRAINT node_access_grant_update_check CHECK ((grant_update >= 0)),
+ CONSTRAINT node_access_grant_view_check CHECK ((grant_view >= 0)),
+ CONSTRAINT node_access_nid_check CHECK ((nid >= 0))
+);
+
+
+--
+-- Name: TABLE node_access; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE node_access IS 'Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.';
+
+
+--
+-- Name: COLUMN node_access.nid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_access.nid IS 'The node.nid this record affects.';
+
+
+--
+-- Name: COLUMN node_access.gid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_access.gid IS 'The grant ID a user must possess in the specified realm to gain this row''s privileges on the node.';
+
+
+--
+-- Name: COLUMN node_access.realm; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_access.realm IS 'The realm in which the user must possess the grant ID. Each node access node can define one or more realms.';
+
+
+--
+-- Name: COLUMN node_access.grant_view; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_access.grant_view IS 'Boolean indicating whether a user with the realm/grant pair can view this node.';
+
+
+--
+-- Name: COLUMN node_access.grant_update; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_access.grant_update IS 'Boolean indicating whether a user with the realm/grant pair can edit this node.';
+
+
+--
+-- Name: COLUMN node_access.grant_delete; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_access.grant_delete IS 'Boolean indicating whether a user with the realm/grant pair can delete this node.';
+
+
+--
+-- Name: node_comment_statistics; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE node_comment_statistics (
+ nid bigint DEFAULT 0 NOT NULL,
+ cid integer DEFAULT 0 NOT NULL,
+ last_comment_timestamp integer DEFAULT 0 NOT NULL,
+ last_comment_name character varying(60),
+ last_comment_uid integer DEFAULT 0 NOT NULL,
+ comment_count bigint DEFAULT 0 NOT NULL,
+ CONSTRAINT node_comment_statistics_comment_count_check CHECK ((comment_count >= 0)),
+ CONSTRAINT node_comment_statistics_nid_check CHECK ((nid >= 0))
+);
+
+
+--
+-- Name: TABLE node_comment_statistics; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE node_comment_statistics IS 'Maintains statistics of node and comments posts to show "new" and "updated" flags.';
+
+
+--
+-- Name: COLUMN node_comment_statistics.nid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_comment_statistics.nid IS 'The node.nid for which the statistics are compiled.';
+
+
+--
+-- Name: COLUMN node_comment_statistics.cid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_comment_statistics.cid IS 'The comment.cid of the last comment.';
+
+
+--
+-- Name: COLUMN node_comment_statistics.last_comment_timestamp; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_comment_statistics.last_comment_timestamp IS 'The Unix timestamp of the last comment that was posted within this node, from comment.changed.';
+
+
+--
+-- Name: COLUMN node_comment_statistics.last_comment_name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_comment_statistics.last_comment_name IS 'The name of the latest author to post a comment on this node, from comment.name.';
+
+
+--
+-- Name: COLUMN node_comment_statistics.last_comment_uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_comment_statistics.last_comment_uid IS 'The user ID of the latest author to post a comment on this node, from comment.uid.';
+
+
+--
+-- Name: COLUMN node_comment_statistics.comment_count; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_comment_statistics.comment_count IS 'The total number of comments on this node.';
+
+
+--
+-- Name: node_nid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE node_nid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: node_nid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE node_nid_seq OWNED BY node.nid;
+
+
+--
+-- Name: node_revision; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE node_revision (
+ nid bigint DEFAULT 0 NOT NULL,
+ vid integer NOT NULL,
+ uid integer DEFAULT 0 NOT NULL,
+ title character varying(255) DEFAULT ''::character varying NOT NULL,
+ log text NOT NULL,
+ "timestamp" integer DEFAULT 0 NOT NULL,
+ status integer DEFAULT 1 NOT NULL,
+ comment integer DEFAULT 0 NOT NULL,
+ promote integer DEFAULT 0 NOT NULL,
+ sticky integer DEFAULT 0 NOT NULL,
+ CONSTRAINT node_revision_nid_check CHECK ((nid >= 0)),
+ CONSTRAINT node_revision_vid_check CHECK ((vid >= 0))
+);
+
+
+--
+-- Name: TABLE node_revision; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE node_revision IS 'Stores information about each saved version of a node.';
+
+
+--
+-- Name: COLUMN node_revision.nid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_revision.nid IS 'The node this version belongs to.';
+
+
+--
+-- Name: COLUMN node_revision.vid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_revision.vid IS 'The primary identifier for this version.';
+
+
+--
+-- Name: COLUMN node_revision.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_revision.uid IS 'The users.uid that created this version.';
+
+
+--
+-- Name: COLUMN node_revision.title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_revision.title IS 'The title of this version.';
+
+
+--
+-- Name: COLUMN node_revision.log; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_revision.log IS 'The log entry explaining the changes in this version.';
+
+
+--
+-- Name: COLUMN node_revision."timestamp"; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_revision."timestamp" IS 'A Unix timestamp indicating when this version was created.';
+
+
+--
+-- Name: COLUMN node_revision.status; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_revision.status IS 'Boolean indicating whether the node (at the time of this revision) is published (visible to non-administrators).';
+
+
+--
+-- Name: COLUMN node_revision.comment; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_revision.comment IS 'Whether comments are allowed on this node (at the time of this revision): 0 = no, 1 = closed (read only), 2 = open (read/write).';
+
+
+--
+-- Name: COLUMN node_revision.promote; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_revision.promote IS 'Boolean indicating whether the node (at the time of this revision) should be displayed on the front page.';
+
+
+--
+-- Name: COLUMN node_revision.sticky; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_revision.sticky IS 'Boolean indicating whether the node (at the time of this revision) should be displayed at the top of lists in which it appears.';
+
+
+--
+-- Name: node_revision_vid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE node_revision_vid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: node_revision_vid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE node_revision_vid_seq OWNED BY node_revision.vid;
+
+
+--
+-- Name: node_type; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE node_type (
+ type character varying(32) NOT NULL,
+ name character varying(255) DEFAULT ''::character varying NOT NULL,
+ base character varying(255) NOT NULL,
+ module character varying(255) NOT NULL,
+ description text NOT NULL,
+ help text NOT NULL,
+ has_title integer NOT NULL,
+ title_label character varying(255) DEFAULT ''::character varying NOT NULL,
+ custom smallint DEFAULT 0 NOT NULL,
+ modified smallint DEFAULT 0 NOT NULL,
+ locked smallint DEFAULT 0 NOT NULL,
+ disabled smallint DEFAULT 0 NOT NULL,
+ orig_type character varying(255) DEFAULT ''::character varying NOT NULL,
+ CONSTRAINT node_type_has_title_check CHECK ((has_title >= 0))
+);
+
+
+--
+-- Name: TABLE node_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE node_type IS 'Stores information about all defined node types.';
+
+
+--
+-- Name: COLUMN node_type.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.type IS 'The machine-readable name of this type.';
+
+
+--
+-- Name: COLUMN node_type.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.name IS 'The human-readable name of this type.';
+
+
+--
+-- Name: COLUMN node_type.base; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.base IS 'The base string used to construct callbacks corresponding to this node type.';
+
+
+--
+-- Name: COLUMN node_type.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.module IS 'The module defining this node type.';
+
+
+--
+-- Name: COLUMN node_type.description; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.description IS 'A brief description of this type.';
+
+
+--
+-- Name: COLUMN node_type.help; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.help IS 'Help information shown to the user when creating a node of this type.';
+
+
+--
+-- Name: COLUMN node_type.has_title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.has_title IS 'Boolean indicating whether this type uses the node.title field.';
+
+
+--
+-- Name: COLUMN node_type.title_label; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.title_label IS 'The label displayed for the title field on the edit form.';
+
+
+--
+-- Name: COLUMN node_type.custom; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.custom IS 'A boolean indicating whether this type is defined by a module (FALSE) or by a user via Add content type (TRUE).';
+
+
+--
+-- Name: COLUMN node_type.modified; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.modified IS 'A boolean indicating whether this type has been modified by an administrator; currently not used in any way.';
+
+
+--
+-- Name: COLUMN node_type.locked; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.locked IS 'A boolean indicating whether the administrator can change the machine name of this type.';
+
+
+--
+-- Name: COLUMN node_type.disabled; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.disabled IS 'A boolean indicating whether the node type is disabled.';
+
+
+--
+-- Name: COLUMN node_type.orig_type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN node_type.orig_type IS 'The original machine-readable name of this node type. This may be different from the current type name if the locked field is 0.';
+
+
+--
+-- Name: queue; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE queue (
+ item_id integer NOT NULL,
+ name character varying(255) DEFAULT ''::character varying NOT NULL,
+ data bytea,
+ expire integer DEFAULT 0 NOT NULL,
+ created integer DEFAULT 0 NOT NULL,
+ CONSTRAINT queue_item_id_check CHECK ((item_id >= 0))
+);
+
+
+--
+-- Name: TABLE queue; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE queue IS 'Stores items in queues.';
+
+
+--
+-- Name: COLUMN queue.item_id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN queue.item_id IS 'Primary Key: Unique item ID.';
+
+
+--
+-- Name: COLUMN queue.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN queue.name IS 'The queue name.';
+
+
+--
+-- Name: COLUMN queue.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN queue.data IS 'The arbitrary data for the item.';
+
+
+--
+-- Name: COLUMN queue.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN queue.expire IS 'Timestamp when the claim lease expires on the item.';
+
+
+--
+-- Name: COLUMN queue.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN queue.created IS 'Timestamp when the item was created.';
+
+
+--
+-- Name: queue_item_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE queue_item_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: queue_item_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE queue_item_id_seq OWNED BY queue.item_id;
+
+
+--
+-- Name: rdf_mapping; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE rdf_mapping (
+ type character varying(128) NOT NULL,
+ bundle character varying(128) NOT NULL,
+ mapping bytea
+);
+
+
+--
+-- Name: TABLE rdf_mapping; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE rdf_mapping IS 'Stores custom RDF mappings for user defined content types or overriden module-defined mappings';
+
+
+--
+-- Name: COLUMN rdf_mapping.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN rdf_mapping.type IS 'The name of the entity type a mapping applies to (node, user, comment, etc.).';
+
+
+--
+-- Name: COLUMN rdf_mapping.bundle; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN rdf_mapping.bundle IS 'The name of the bundle a mapping applies to.';
+
+
+--
+-- Name: COLUMN rdf_mapping.mapping; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN rdf_mapping.mapping IS 'The serialized mapping of the bundle type and fields to RDF terms.';
+
+
+--
+-- Name: registry; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE registry (
+ name character varying(255) DEFAULT ''::character varying NOT NULL,
+ type character varying(9) DEFAULT ''::character varying NOT NULL,
+ filename character varying(255) NOT NULL,
+ module character varying(255) DEFAULT ''::character varying NOT NULL,
+ weight integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE registry; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE registry IS 'Each record is a function, class, or interface name and the file it is in.';
+
+
+--
+-- Name: COLUMN registry.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN registry.name IS 'The name of the function, class, or interface.';
+
+
+--
+-- Name: COLUMN registry.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN registry.type IS 'Either function or class or interface.';
+
+
+--
+-- Name: COLUMN registry.filename; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN registry.filename IS 'Name of the file.';
+
+
+--
+-- Name: COLUMN registry.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN registry.module IS 'Name of the module the file belongs to.';
+
+
+--
+-- Name: COLUMN registry.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN registry.weight IS 'The order in which this module''s hooks should be invoked relative to other modules. Equal-weighted modules are ordered by name.';
+
+
+--
+-- Name: registry_file; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE registry_file (
+ filename character varying(255) NOT NULL,
+ hash character varying(64) NOT NULL
+);
+
+
+--
+-- Name: TABLE registry_file; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE registry_file IS 'Files parsed to build the registry.';
+
+
+--
+-- Name: COLUMN registry_file.filename; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN registry_file.filename IS 'Path to the file.';
+
+
+--
+-- Name: COLUMN registry_file.hash; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN registry_file.hash IS 'sha-256 hash of the file''s contents when last parsed.';
+
+
+--
+-- Name: role; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE role (
+ rid integer NOT NULL,
+ name character varying(64) DEFAULT ''::character varying NOT NULL,
+ weight integer DEFAULT 0 NOT NULL,
+ CONSTRAINT role_rid_check CHECK ((rid >= 0))
+);
+
+
+--
+-- Name: TABLE role; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE role IS 'Stores user roles.';
+
+
+--
+-- Name: COLUMN role.rid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN role.rid IS 'Primary Key: Unique role ID.';
+
+
+--
+-- Name: COLUMN role.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN role.name IS 'Unique role name.';
+
+
+--
+-- Name: COLUMN role.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN role.weight IS 'The weight of this role in listings and the user interface.';
+
+
+--
+-- Name: role_permission; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE role_permission (
+ rid bigint NOT NULL,
+ permission character varying(128) DEFAULT ''::character varying NOT NULL,
+ module character varying(255) DEFAULT ''::character varying NOT NULL,
+ CONSTRAINT role_permission_rid_check CHECK ((rid >= 0))
+);
+
+
+--
+-- Name: TABLE role_permission; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE role_permission IS 'Stores the permissions assigned to user roles.';
+
+
+--
+-- Name: COLUMN role_permission.rid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN role_permission.rid IS 'Foreign Key: role.rid.';
+
+
+--
+-- Name: COLUMN role_permission.permission; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN role_permission.permission IS 'A single permission granted to the role identified by rid.';
+
+
+--
+-- Name: COLUMN role_permission.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN role_permission.module IS 'The module declaring the permission.';
+
+
+--
+-- Name: role_rid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE role_rid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: role_rid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE role_rid_seq OWNED BY role.rid;
+
+
+--
+-- Name: search_dataset; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE search_dataset (
+ sid bigint DEFAULT 0 NOT NULL,
+ type character varying(16) NOT NULL,
+ data text NOT NULL,
+ reindex bigint DEFAULT 0 NOT NULL,
+ CONSTRAINT search_dataset_reindex_check CHECK ((reindex >= 0)),
+ CONSTRAINT search_dataset_sid_check CHECK ((sid >= 0))
+);
+
+
+--
+-- Name: TABLE search_dataset; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE search_dataset IS 'Stores items that will be searched.';
+
+
+--
+-- Name: COLUMN search_dataset.sid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_dataset.sid IS 'Search item ID, e.g. node ID for nodes.';
+
+
+--
+-- Name: COLUMN search_dataset.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_dataset.type IS 'Type of item, e.g. node.';
+
+
+--
+-- Name: COLUMN search_dataset.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_dataset.data IS 'List of space-separated words from the item.';
+
+
+--
+-- Name: COLUMN search_dataset.reindex; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_dataset.reindex IS 'Set to force node reindexing.';
+
+
+--
+-- Name: search_index; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE search_index (
+ word character varying(50) DEFAULT ''::character varying NOT NULL,
+ sid bigint DEFAULT 0 NOT NULL,
+ type character varying(16) NOT NULL,
+ score real,
+ CONSTRAINT search_index_sid_check CHECK ((sid >= 0))
+);
+
+
+--
+-- Name: TABLE search_index; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE search_index IS 'Stores the search index, associating words, items and scores.';
+
+
+--
+-- Name: COLUMN search_index.word; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_index.word IS 'The search_total.word that is associated with the search item.';
+
+
+--
+-- Name: COLUMN search_index.sid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_index.sid IS 'The search_dataset.sid of the searchable item to which the word belongs.';
+
+
+--
+-- Name: COLUMN search_index.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_index.type IS 'The search_dataset.type of the searchable item to which the word belongs.';
+
+
+--
+-- Name: COLUMN search_index.score; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_index.score IS 'The numeric score of the word, higher being more important.';
+
+
+--
+-- Name: search_node_links; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE search_node_links (
+ sid bigint DEFAULT 0 NOT NULL,
+ type character varying(16) DEFAULT ''::character varying NOT NULL,
+ nid bigint DEFAULT 0 NOT NULL,
+ caption text,
+ CONSTRAINT search_node_links_nid_check CHECK ((nid >= 0)),
+ CONSTRAINT search_node_links_sid_check CHECK ((sid >= 0))
+);
+
+
+--
+-- Name: TABLE search_node_links; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE search_node_links IS 'Stores items (like nodes) that link to other nodes, used to improve search scores for nodes that are frequently linked to.';
+
+
+--
+-- Name: COLUMN search_node_links.sid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_node_links.sid IS 'The search_dataset.sid of the searchable item containing the link to the node.';
+
+
+--
+-- Name: COLUMN search_node_links.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_node_links.type IS 'The search_dataset.type of the searchable item containing the link to the node.';
+
+
+--
+-- Name: COLUMN search_node_links.nid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_node_links.nid IS 'The node.nid that this item links to.';
+
+
+--
+-- Name: COLUMN search_node_links.caption; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_node_links.caption IS 'The text used to link to the node.nid.';
+
+
+--
+-- Name: search_total; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE search_total (
+ word character varying(50) DEFAULT ''::character varying NOT NULL,
+ count real
+);
+
+
+--
+-- Name: TABLE search_total; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE search_total IS 'Stores search totals for words.';
+
+
+--
+-- Name: COLUMN search_total.word; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_total.word IS 'Primary Key: Unique word in the search index.';
+
+
+--
+-- Name: COLUMN search_total.count; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN search_total.count IS 'The count of the word in the index using Zipf''s law to equalize the probability distribution.';
+
+
+--
+-- Name: semaphore; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE semaphore (
+ name character varying(255) DEFAULT ''::character varying NOT NULL,
+ value character varying(255) DEFAULT ''::character varying NOT NULL,
+ expire double precision NOT NULL
+);
+
+
+--
+-- Name: TABLE semaphore; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE semaphore IS 'Table for holding semaphores, locks, flags, etc. that cannot be stored as Drupal variables since they must not be cached.';
+
+
+--
+-- Name: COLUMN semaphore.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN semaphore.name IS 'Primary Key: Unique name.';
+
+
+--
+-- Name: COLUMN semaphore.value; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN semaphore.value IS 'A value for the semaphore.';
+
+
+--
+-- Name: COLUMN semaphore.expire; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN semaphore.expire IS 'A Unix timestamp with microseconds indicating when the semaphore should expire.';
+
+
+--
+-- Name: sequences; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE sequences (
+ value integer NOT NULL,
+ CONSTRAINT sequences_value_check CHECK ((value >= 0))
+);
+
+
+--
+-- Name: TABLE sequences; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE sequences IS 'Stores IDs.';
+
+
+--
+-- Name: COLUMN sequences.value; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN sequences.value IS 'The value of the sequence.';
+
+
+--
+-- Name: sequences_value_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE sequences_value_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: sequences_value_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE sequences_value_seq OWNED BY sequences.value;
+
+
+--
+-- Name: sessions; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE sessions (
+ uid bigint NOT NULL,
+ sid character varying(128) NOT NULL,
+ ssid character varying(128) DEFAULT ''::character varying NOT NULL,
+ hostname character varying(128) DEFAULT ''::character varying NOT NULL,
+ "timestamp" integer DEFAULT 0 NOT NULL,
+ cache integer DEFAULT 0 NOT NULL,
+ session bytea,
+ CONSTRAINT sessions_uid_check CHECK ((uid >= 0))
+);
+
+
+--
+-- Name: TABLE sessions; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE sessions IS 'Drupal''s session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated.';
+
+
+--
+-- Name: COLUMN sessions.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN sessions.uid IS 'The users.uid corresponding to a session, or 0 for anonymous user.';
+
+
+--
+-- Name: COLUMN sessions.sid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN sessions.sid IS 'A session ID. The value is generated by Drupal''s session handlers.';
+
+
+--
+-- Name: COLUMN sessions.ssid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN sessions.ssid IS 'Secure session ID. The value is generated by Drupal''s session handlers.';
+
+
+--
+-- Name: COLUMN sessions.hostname; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN sessions.hostname IS 'The IP address that last used this session ID (sid).';
+
+
+--
+-- Name: COLUMN sessions."timestamp"; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN sessions."timestamp" IS 'The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.';
+
+
+--
+-- Name: COLUMN sessions.cache; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN sessions.cache IS 'The time of this user''s last post. This is used when the site has specified a minimum_cache_lifetime. See cache_get().';
+
+
+--
+-- Name: COLUMN sessions.session; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN sessions.session IS 'The serialized contents of $_SESSION, an array of name/value pairs that persists across page requests by this session ID. Drupal loads $_SESSION from here at the start of each request and saves it at the end.';
+
+
+--
+-- Name: shortcut_set; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE shortcut_set (
+ set_name character varying(32) DEFAULT ''::character varying NOT NULL,
+ title character varying(255) DEFAULT ''::character varying NOT NULL
+);
+
+
+--
+-- Name: TABLE shortcut_set; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE shortcut_set IS 'Stores information about sets of shortcuts links.';
+
+
+--
+-- Name: COLUMN shortcut_set.set_name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN shortcut_set.set_name IS 'Primary Key: The menu_links.menu_name under which the set''s links are stored.';
+
+
+--
+-- Name: COLUMN shortcut_set.title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN shortcut_set.title IS 'The title of the set.';
+
+
+--
+-- Name: shortcut_set_users; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE shortcut_set_users (
+ uid bigint DEFAULT 0 NOT NULL,
+ set_name character varying(32) DEFAULT ''::character varying NOT NULL,
+ CONSTRAINT shortcut_set_users_uid_check CHECK ((uid >= 0))
+);
+
+
+--
+-- Name: TABLE shortcut_set_users; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE shortcut_set_users IS 'Maps users to shortcut sets.';
+
+
+--
+-- Name: COLUMN shortcut_set_users.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN shortcut_set_users.uid IS 'The users.uid for this set.';
+
+
+--
+-- Name: COLUMN shortcut_set_users.set_name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN shortcut_set_users.set_name IS 'The shortcut_set.set_name that will be displayed for this user.';
+
+
+--
+-- Name: system; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE system (
+ filename character varying(255) DEFAULT ''::character varying NOT NULL,
+ name character varying(255) DEFAULT ''::character varying NOT NULL,
+ type character varying(12) DEFAULT ''::character varying NOT NULL,
+ owner character varying(255) DEFAULT ''::character varying NOT NULL,
+ status integer DEFAULT 0 NOT NULL,
+ bootstrap integer DEFAULT 0 NOT NULL,
+ schema_version smallint DEFAULT (-1) NOT NULL,
+ weight integer DEFAULT 0 NOT NULL,
+ info bytea
+);
+
+
+--
+-- Name: TABLE system; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE system IS 'A list of all modules, themes, and theme engines that are or have been installed in Drupal''s file system.';
+
+
+--
+-- Name: COLUMN system.filename; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN system.filename IS 'The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.';
+
+
+--
+-- Name: COLUMN system.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN system.name IS 'The name of the item; e.g. node.';
+
+
+--
+-- Name: COLUMN system.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN system.type IS 'The type of the item, either module, theme, or theme_engine.';
+
+
+--
+-- Name: COLUMN system.owner; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN system.owner IS 'A theme''s ''parent'' . Can be either a theme or an engine.';
+
+
+--
+-- Name: COLUMN system.status; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN system.status IS 'Boolean indicating whether or not this item is enabled.';
+
+
+--
+-- Name: COLUMN system.bootstrap; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN system.bootstrap IS 'Boolean indicating whether this module is loaded during Drupal''s early bootstrapping phase (e.g. even before the page cache is consulted).';
+
+
+--
+-- Name: COLUMN system.schema_version; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN system.schema_version IS 'The module''s database schema version number. -1 if the module is not installed (its tables do not exist); 0 or the largest N of the module''s hook_update_N() function that has either been run or existed when the module was first installed.';
+
+
+--
+-- Name: COLUMN system.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN system.weight IS 'The order in which this module''s hooks should be invoked relative to other modules. Equal-weighted modules are ordered by name.';
+
+
+--
+-- Name: COLUMN system.info; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN system.info IS 'A serialized array containing information from the module''s .info file; keys can include name, description, package, version, core, dependencies, and php.';
+
+
+--
+-- Name: taxonomy_index; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE taxonomy_index (
+ nid bigint DEFAULT 0 NOT NULL,
+ tid bigint DEFAULT 0 NOT NULL,
+ sticky smallint DEFAULT 0,
+ created integer DEFAULT 0 NOT NULL,
+ CONSTRAINT taxonomy_index_nid_check CHECK ((nid >= 0)),
+ CONSTRAINT taxonomy_index_tid_check CHECK ((tid >= 0))
+);
+
+
+--
+-- Name: TABLE taxonomy_index; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE taxonomy_index IS 'Maintains denormalized information about node/term relationships.';
+
+
+--
+-- Name: COLUMN taxonomy_index.nid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_index.nid IS 'The node.nid this record tracks.';
+
+
+--
+-- Name: COLUMN taxonomy_index.tid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_index.tid IS 'The term ID.';
+
+
+--
+-- Name: COLUMN taxonomy_index.sticky; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_index.sticky IS 'Boolean indicating whether the node is sticky.';
+
+
+--
+-- Name: COLUMN taxonomy_index.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_index.created IS 'The Unix timestamp when the node was created.';
+
+
+--
+-- Name: taxonomy_term_data; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE taxonomy_term_data (
+ tid integer NOT NULL,
+ vid bigint DEFAULT 0 NOT NULL,
+ name character varying(255) DEFAULT ''::character varying NOT NULL,
+ description text,
+ format character varying(255),
+ weight integer DEFAULT 0 NOT NULL,
+ CONSTRAINT taxonomy_term_data_tid_check CHECK ((tid >= 0)),
+ CONSTRAINT taxonomy_term_data_vid_check CHECK ((vid >= 0))
+);
+
+
+--
+-- Name: TABLE taxonomy_term_data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE taxonomy_term_data IS 'Stores term information.';
+
+
+--
+-- Name: COLUMN taxonomy_term_data.tid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_term_data.tid IS 'Primary Key: Unique term ID.';
+
+
+--
+-- Name: COLUMN taxonomy_term_data.vid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_term_data.vid IS 'The taxonomy_vocabulary.vid of the vocabulary to which the term is assigned.';
+
+
+--
+-- Name: COLUMN taxonomy_term_data.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_term_data.name IS 'The term name.';
+
+
+--
+-- Name: COLUMN taxonomy_term_data.description; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_term_data.description IS 'A description of the term.';
+
+
+--
+-- Name: COLUMN taxonomy_term_data.format; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_term_data.format IS 'The filter_format.format of the description.';
+
+
+--
+-- Name: COLUMN taxonomy_term_data.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_term_data.weight IS 'The weight of this term in relation to other terms.';
+
+
+--
+-- Name: taxonomy_term_data_tid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE taxonomy_term_data_tid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: taxonomy_term_data_tid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE taxonomy_term_data_tid_seq OWNED BY taxonomy_term_data.tid;
+
+
+--
+-- Name: taxonomy_term_hierarchy; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE taxonomy_term_hierarchy (
+ tid bigint DEFAULT 0 NOT NULL,
+ parent bigint DEFAULT 0 NOT NULL,
+ CONSTRAINT taxonomy_term_hierarchy_parent_check CHECK ((parent >= 0)),
+ CONSTRAINT taxonomy_term_hierarchy_tid_check CHECK ((tid >= 0))
+);
+
+
+--
+-- Name: TABLE taxonomy_term_hierarchy; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE taxonomy_term_hierarchy IS 'Stores the hierarchical relationship between terms.';
+
+
+--
+-- Name: COLUMN taxonomy_term_hierarchy.tid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_term_hierarchy.tid IS 'Primary Key: The taxonomy_term_data.tid of the term.';
+
+
+--
+-- Name: COLUMN taxonomy_term_hierarchy.parent; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_term_hierarchy.parent IS 'Primary Key: The taxonomy_term_data.tid of the term''s parent. 0 indicates no parent.';
+
+
+--
+-- Name: taxonomy_vocabulary; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE taxonomy_vocabulary (
+ vid integer NOT NULL,
+ name character varying(255) DEFAULT ''::character varying NOT NULL,
+ machine_name character varying(255) DEFAULT ''::character varying NOT NULL,
+ description text,
+ hierarchy integer DEFAULT 0 NOT NULL,
+ module character varying(255) DEFAULT ''::character varying NOT NULL,
+ weight integer DEFAULT 0 NOT NULL,
+ CONSTRAINT taxonomy_vocabulary_hierarchy_check CHECK ((hierarchy >= 0)),
+ CONSTRAINT taxonomy_vocabulary_vid_check CHECK ((vid >= 0))
+);
+
+
+--
+-- Name: TABLE taxonomy_vocabulary; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE taxonomy_vocabulary IS 'Stores vocabulary information.';
+
+
+--
+-- Name: COLUMN taxonomy_vocabulary.vid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_vocabulary.vid IS 'Primary Key: Unique vocabulary ID.';
+
+
+--
+-- Name: COLUMN taxonomy_vocabulary.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_vocabulary.name IS 'Name of the vocabulary.';
+
+
+--
+-- Name: COLUMN taxonomy_vocabulary.machine_name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_vocabulary.machine_name IS 'The vocabulary machine name.';
+
+
+--
+-- Name: COLUMN taxonomy_vocabulary.description; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_vocabulary.description IS 'Description of the vocabulary.';
+
+
+--
+-- Name: COLUMN taxonomy_vocabulary.hierarchy; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_vocabulary.hierarchy IS 'The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)';
+
+
+--
+-- Name: COLUMN taxonomy_vocabulary.module; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_vocabulary.module IS 'The module which created the vocabulary.';
+
+
+--
+-- Name: COLUMN taxonomy_vocabulary.weight; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN taxonomy_vocabulary.weight IS 'The weight of this vocabulary in relation to other vocabularies.';
+
+
+--
+-- Name: taxonomy_vocabulary_vid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE taxonomy_vocabulary_vid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: taxonomy_vocabulary_vid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE taxonomy_vocabulary_vid_seq OWNED BY taxonomy_vocabulary.vid;
+
+
+--
+-- Name: tmp; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE tmp (
+ id integer NOT NULL,
+ col1 character varying,
+ col2 character varying,
+ col3 character varying,
+ col4 character varying
+);
+
+
+--
+-- Name: tmp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE tmp_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: tmp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE tmp_id_seq OWNED BY tmp.id;
+
+
+--
+-- Name: tripal_custom_tables; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE tripal_custom_tables (
+ table_id integer NOT NULL,
+ table_name character varying(255),
+ schema text,
+ mview_id integer,
+ CONSTRAINT tripal_custom_tables_table_id_check CHECK ((table_id >= 0))
+);
+
+
+--
+-- Name: tripal_custom_tables_table_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE tripal_custom_tables_table_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: tripal_custom_tables_table_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE tripal_custom_tables_table_id_seq OWNED BY tripal_custom_tables.table_id;
+
+
+--
+-- Name: tripal_jobs; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE tripal_jobs (
+ job_id integer NOT NULL,
+ uid bigint,
+ job_name character varying(255),
+ modulename character varying(50),
+ callback character varying(255),
+ arguments text,
+ progress bigint DEFAULT 0,
+ status character varying(50),
+ submit_date integer,
+ start_time integer,
+ end_time integer,
+ error_msg text,
+ pid bigint,
+ priority bigint DEFAULT 0::bigint,
+ mlock bigint,
+ lock bigint,
+ CONSTRAINT tripal_jobs_job_id_check CHECK ((job_id >= 0)),
+ CONSTRAINT tripal_jobs_lock_check CHECK ((lock >= 0)),
+ CONSTRAINT tripal_jobs_mlock_check CHECK ((mlock >= 0)),
+ CONSTRAINT tripal_jobs_pid_check CHECK ((pid >= 0)),
+ CONSTRAINT tripal_jobs_priority_check CHECK ((priority >= 0)),
+ CONSTRAINT tripal_jobs_progress_check CHECK ((progress >= 0)),
+ CONSTRAINT tripal_jobs_uid_check CHECK ((uid >= 0))
+);
+
+
+--
+-- Name: COLUMN tripal_jobs.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_jobs.uid IS 'The Drupal userid of the submitee';
+
+
+--
+-- Name: COLUMN tripal_jobs.modulename; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_jobs.modulename IS 'The module name that provides the callback for this job';
+
+
+--
+-- Name: COLUMN tripal_jobs.progress; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_jobs.progress IS 'a value from 0 to 100 indicating percent complete';
+
+
+--
+-- Name: COLUMN tripal_jobs.submit_date; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_jobs.submit_date IS 'UNIX integer submit time';
+
+
+--
+-- Name: COLUMN tripal_jobs.start_time; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_jobs.start_time IS 'UNIX integer start time';
+
+
+--
+-- Name: COLUMN tripal_jobs.end_time; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_jobs.end_time IS 'UNIX integer end time';
+
+
+--
+-- Name: COLUMN tripal_jobs.pid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_jobs.pid IS 'The process id for the job';
+
+
+--
+-- Name: COLUMN tripal_jobs.priority; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_jobs.priority IS 'The job priority';
+
+
+--
+-- Name: COLUMN tripal_jobs.mlock; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_jobs.mlock IS 'If set to 1 then all jobs for the module are held until this one finishes';
+
+
+--
+-- Name: COLUMN tripal_jobs.lock; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_jobs.lock IS 'If set to 1 then all jobs are held until this one finishes';
+
+
+--
+-- Name: tripal_jobs_job_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE tripal_jobs_job_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: tripal_jobs_job_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE tripal_jobs_job_id_seq OWNED BY tripal_jobs.job_id;
+
+
+--
+-- Name: tripal_mviews; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE tripal_mviews (
+ mview_id integer NOT NULL,
+ name character varying(255),
+ modulename character varying(50),
+ mv_table character varying(128),
+ mv_specs text,
+ mv_schema text,
+ indexed text,
+ query text,
+ special_index text,
+ last_update integer,
+ status text,
+ comment text,
+ CONSTRAINT tripal_mviews_mview_id_check CHECK ((mview_id >= 0))
+);
+
+
+--
+-- Name: COLUMN tripal_mviews.modulename; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_mviews.modulename IS 'The module name that provides the callback for this job';
+
+
+--
+-- Name: COLUMN tripal_mviews.last_update; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN tripal_mviews.last_update IS 'UNIX integer time';
+
+
+--
+-- Name: tripal_mviews_mview_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE tripal_mviews_mview_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: tripal_mviews_mview_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE tripal_mviews_mview_id_seq OWNED BY tripal_mviews.mview_id;
+
+
+--
+-- Name: tripal_node_variables; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE tripal_node_variables (
+ node_variable_id integer NOT NULL,
+ nid integer NOT NULL,
+ variable_id integer NOT NULL,
+ value text,
+ rank integer DEFAULT 0 NOT NULL
+);
+
+
+--
+-- Name: TABLE tripal_node_variables; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE tripal_node_variables IS 'This table is used for storing any type of variable such as a property or setting that should be associated with a Tripal managed Drupal node. This table is meant to store non-biological information only. All biological data should be housed in the Chado tables. Be aware that any data stored here will not be made visible through services such as Tripal Web Services and therefore can be a good place to hide application specific settings.';
+
+
+--
+-- Name: tripal_node_variables_node_variable_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE tripal_node_variables_node_variable_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: tripal_node_variables_node_variable_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE tripal_node_variables_node_variable_id_seq OWNED BY tripal_node_variables.node_variable_id;
+
+
+--
+-- Name: tripal_toc; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE tripal_toc (
+ toc_item_id integer NOT NULL,
+ node_type character varying(32) NOT NULL,
+ key character varying(255) NOT NULL,
+ title character varying(255),
+ weight integer,
+ hide smallint DEFAULT 0,
+ nid integer,
+ CONSTRAINT tripal_toc_toc_item_id_check CHECK ((toc_item_id >= 0))
+);
+
+
+--
+-- Name: tripal_toc_toc_item_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE tripal_toc_toc_item_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: tripal_toc_toc_item_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE tripal_toc_toc_item_id_seq OWNED BY tripal_toc.toc_item_id;
+
+
+--
+-- Name: tripal_token_formats; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE tripal_token_formats (
+ tripal_format_id integer NOT NULL,
+ content_type character varying(255) NOT NULL,
+ application character varying(255) NOT NULL,
+ format text NOT NULL,
+ tokens text NOT NULL,
+ CONSTRAINT tripal_token_formats_tripal_format_id_check CHECK ((tripal_format_id >= 0))
+);
+
+
+--
+-- Name: tripal_token_formats_tripal_format_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE tripal_token_formats_tripal_format_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: tripal_token_formats_tripal_format_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE tripal_token_formats_tripal_format_id_seq OWNED BY tripal_token_formats.tripal_format_id;
+
+
+--
+-- Name: tripal_variables; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE tripal_variables (
+ variable_id integer NOT NULL,
+ name character varying(255) NOT NULL,
+ description text NOT NULL
+);
+
+
+--
+-- Name: TABLE tripal_variables; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE tripal_variables IS 'This table houses a list of unique variable names that can be used in the tripal_node_variables table.';
+
+
+--
+-- Name: tripal_variables_variable_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE tripal_variables_variable_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: tripal_variables_variable_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE tripal_variables_variable_id_seq OWNED BY tripal_variables.variable_id;
+
+
+--
+-- Name: url_alias; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE url_alias (
+ pid integer NOT NULL,
+ source character varying(255) DEFAULT ''::character varying NOT NULL,
+ alias character varying(255) DEFAULT ''::character varying NOT NULL,
+ language character varying(12) DEFAULT ''::character varying NOT NULL,
+ CONSTRAINT url_alias_pid_check CHECK ((pid >= 0))
+);
+
+
+--
+-- Name: TABLE url_alias; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE url_alias IS 'A list of URL aliases for Drupal paths; a user may visit either the source or destination path.';
+
+
+--
+-- Name: COLUMN url_alias.pid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN url_alias.pid IS 'A unique path alias identifier.';
+
+
+--
+-- Name: COLUMN url_alias.source; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN url_alias.source IS 'The Drupal path this alias is for; e.g. node/12.';
+
+
+--
+-- Name: COLUMN url_alias.alias; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN url_alias.alias IS 'The alias for this path; e.g. title-of-the-story.';
+
+
+--
+-- Name: COLUMN url_alias.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN url_alias.language IS 'The language this alias is for; if ''und'', the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.';
+
+
+--
+-- Name: url_alias_pid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE url_alias_pid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: url_alias_pid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE url_alias_pid_seq OWNED BY url_alias.pid;
+
+
+--
+-- Name: users; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE users (
+ uid bigint DEFAULT 0 NOT NULL,
+ name character varying(60) DEFAULT ''::character varying NOT NULL,
+ pass character varying(128) DEFAULT ''::character varying NOT NULL,
+ mail character varying(254) DEFAULT ''::character varying,
+ theme character varying(255) DEFAULT ''::character varying NOT NULL,
+ signature character varying(255) DEFAULT ''::character varying NOT NULL,
+ signature_format character varying(255),
+ created integer DEFAULT 0 NOT NULL,
+ access integer DEFAULT 0 NOT NULL,
+ login integer DEFAULT 0 NOT NULL,
+ status smallint DEFAULT 0 NOT NULL,
+ timezone character varying(32),
+ language character varying(12) DEFAULT ''::character varying NOT NULL,
+ picture integer DEFAULT 0 NOT NULL,
+ init character varying(254) DEFAULT ''::character varying,
+ data bytea,
+ CONSTRAINT users_uid_check CHECK ((uid >= 0))
+);
+
+
+--
+-- Name: TABLE users; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE users IS 'Stores user data.';
+
+
+--
+-- Name: COLUMN users.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.uid IS 'Primary Key: Unique user ID.';
+
+
+--
+-- Name: COLUMN users.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.name IS 'Unique user name.';
+
+
+--
+-- Name: COLUMN users.pass; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.pass IS 'User''s password (hashed).';
+
+
+--
+-- Name: COLUMN users.mail; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.mail IS 'User''s e-mail address.';
+
+
+--
+-- Name: COLUMN users.theme; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.theme IS 'User''s default theme.';
+
+
+--
+-- Name: COLUMN users.signature; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.signature IS 'User''s signature.';
+
+
+--
+-- Name: COLUMN users.signature_format; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.signature_format IS 'The filter_format.format of the signature.';
+
+
+--
+-- Name: COLUMN users.created; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.created IS 'Timestamp for when user was created.';
+
+
+--
+-- Name: COLUMN users.access; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.access IS 'Timestamp for previous time user accessed the site.';
+
+
+--
+-- Name: COLUMN users.login; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.login IS 'Timestamp for user''s last login.';
+
+
+--
+-- Name: COLUMN users.status; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.status IS 'Whether the user is active(1) or blocked(0).';
+
+
+--
+-- Name: COLUMN users.timezone; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.timezone IS 'User''s time zone.';
+
+
+--
+-- Name: COLUMN users.language; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.language IS 'User''s default language.';
+
+
+--
+-- Name: COLUMN users.picture; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.picture IS 'Foreign key: file_managed.fid of user''s picture.';
+
+
+--
+-- Name: COLUMN users.init; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.init IS 'E-mail address used for initial account creation.';
+
+
+--
+-- Name: COLUMN users.data; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users.data IS 'A serialized array of name value pairs that are related to the user. Any form values posted during user edit are stored and are loaded into the $user object during user_load(). Use of this field is discouraged and it will likely disappear in a future version of Drupal.';
+
+
+--
+-- Name: users_roles; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE users_roles (
+ uid bigint DEFAULT 0 NOT NULL,
+ rid bigint DEFAULT 0 NOT NULL,
+ CONSTRAINT users_roles_rid_check CHECK ((rid >= 0)),
+ CONSTRAINT users_roles_uid_check CHECK ((uid >= 0))
+);
+
+
+--
+-- Name: TABLE users_roles; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE users_roles IS 'Maps users to roles.';
+
+
+--
+-- Name: COLUMN users_roles.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users_roles.uid IS 'Primary Key: users.uid for user.';
+
+
+--
+-- Name: COLUMN users_roles.rid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN users_roles.rid IS 'Primary Key: role.rid for role.';
+
+
+--
+-- Name: variable; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE variable (
+ name character varying(128) DEFAULT ''::character varying NOT NULL,
+ value bytea NOT NULL
+);
+
+
+--
+-- Name: TABLE variable; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE variable IS 'Named variable/value pairs created by Drupal core or any other module or theme. All variables are cached in memory at the start of every Drupal request so developers should not be careless about what is stored here.';
+
+
+--
+-- Name: COLUMN variable.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN variable.name IS 'The name of the variable.';
+
+
+--
+-- Name: COLUMN variable.value; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN variable.value IS 'The value of the variable.';
+
+
+--
+-- Name: views_display; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE views_display (
+ vid bigint DEFAULT 0 NOT NULL,
+ id character varying(64) DEFAULT ''::character varying NOT NULL,
+ display_title character varying(64) DEFAULT ''::character varying NOT NULL,
+ display_plugin character varying(64) DEFAULT ''::character varying NOT NULL,
+ "position" integer DEFAULT 0,
+ display_options text,
+ CONSTRAINT views_display_vid_check CHECK ((vid >= 0))
+);
+
+
+--
+-- Name: TABLE views_display; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE views_display IS 'Stores information about each display attached to a view.';
+
+
+--
+-- Name: COLUMN views_display.vid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_display.vid IS 'The view this display is attached to.';
+
+
+--
+-- Name: COLUMN views_display.id; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_display.id IS 'An identifier for this display; usually generated from the display_plugin, so should be something::text like page or page_1 or block_2, etc.';
+
+
+--
+-- Name: COLUMN views_display.display_title; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_display.display_title IS 'The title of the display, viewable by the administrator.';
+
+
+--
+-- Name: COLUMN views_display.display_plugin; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_display.display_plugin IS 'The type of the display. Usually page, block or embed, but is pluggable so may be other things.';
+
+
+--
+-- Name: COLUMN views_display."position"; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_display."position" IS 'The order in which this display is loaded.';
+
+
+--
+-- Name: COLUMN views_display.display_options; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_display.display_options IS 'A serialized array of options for this display; it contains options that are generally only pertinent to that display plugin type.';
+
+
+--
+-- Name: views_view; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE views_view (
+ vid integer NOT NULL,
+ name character varying(128) DEFAULT ''::character varying NOT NULL,
+ description character varying(255) DEFAULT ''::character varying,
+ tag character varying(255) DEFAULT ''::character varying,
+ base_table character varying(64) DEFAULT ''::character varying NOT NULL,
+ human_name character varying(255) DEFAULT ''::character varying,
+ core integer DEFAULT 0,
+ CONSTRAINT views_view_vid_check CHECK ((vid >= 0))
+);
+
+
+--
+-- Name: TABLE views_view; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE views_view IS 'Stores the general data for a view.';
+
+
+--
+-- Name: COLUMN views_view.vid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_view.vid IS 'The view ID of the field, defined by the database.';
+
+
+--
+-- Name: COLUMN views_view.name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_view.name IS 'The unique name of the view. This is the primary field views are loaded from, and is used so that views may be internal and not necessarily in the database. May only be alphanumeric characters plus underscores.';
+
+
+--
+-- Name: COLUMN views_view.description; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_view.description IS 'A description of the view for the admin interface.';
+
+
+--
+-- Name: COLUMN views_view.tag; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_view.tag IS 'A tag used to group/sort views in the admin interface';
+
+
+--
+-- Name: COLUMN views_view.base_table; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_view.base_table IS 'What table this view is based on, such as node, user, comment, or term.';
+
+
+--
+-- Name: COLUMN views_view.human_name; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_view.human_name IS 'A human readable name used to be displayed in the admin interface';
+
+
+--
+-- Name: COLUMN views_view.core; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN views_view.core IS 'Stores the drupal core version of the view.';
+
+
+--
+-- Name: views_view_vid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE views_view_vid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: views_view_vid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE views_view_vid_seq OWNED BY views_view.vid;
+
+
+--
+-- Name: watchdog; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE watchdog (
+ wid integer NOT NULL,
+ uid integer DEFAULT 0 NOT NULL,
+ type character varying(64) DEFAULT ''::character varying NOT NULL,
+ message text NOT NULL,
+ variables bytea NOT NULL,
+ severity integer DEFAULT 0 NOT NULL,
+ link character varying(255) DEFAULT ''::character varying,
+ location text NOT NULL,
+ referer text,
+ hostname character varying(128) DEFAULT ''::character varying NOT NULL,
+ "timestamp" integer DEFAULT 0 NOT NULL,
+ CONSTRAINT watchdog_severity_check CHECK ((severity >= 0))
+);
+
+
+--
+-- Name: TABLE watchdog; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON TABLE watchdog IS 'Table that contains logs of all system events.';
+
+
+--
+-- Name: COLUMN watchdog.wid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN watchdog.wid IS 'Primary Key: Unique watchdog event ID.';
+
+
+--
+-- Name: COLUMN watchdog.uid; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN watchdog.uid IS 'The users.uid of the user who triggered the event.';
+
+
+--
+-- Name: COLUMN watchdog.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN watchdog.type IS 'Type of log message, for example "user" or "page not found."';
+
+
+--
+-- Name: COLUMN watchdog.message; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN watchdog.message IS 'Text of log message to be passed into the t() function.';
+
+
+--
+-- Name: COLUMN watchdog.variables; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN watchdog.variables IS 'Serialized array of variables that match the message string and that is passed into the t() function.';
+
+
+--
+-- Name: COLUMN watchdog.severity; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN watchdog.severity IS 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)';
+
+
+--
+-- Name: COLUMN watchdog.link; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN watchdog.link IS 'Link to view the result of the event.';
+
+
+--
+-- Name: COLUMN watchdog.location; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN watchdog.location IS 'URL of the origin of the event.';
+
+
+--
+-- Name: COLUMN watchdog.referer; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN watchdog.referer IS 'URL of referring page.';
+
+
+--
+-- Name: COLUMN watchdog.hostname; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN watchdog.hostname IS 'Hostname of the user who triggered the event.';
+
+
+--
+-- Name: COLUMN watchdog."timestamp"; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN watchdog."timestamp" IS 'Unix timestamp of when event occurred.';
+
+
+--
+-- Name: watchdog_wid_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE watchdog_wid_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: watchdog_wid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE watchdog_wid_seq OWNED BY watchdog.wid;
+
+
+--
+-- Name: aid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY authmap ALTER COLUMN aid SET DEFAULT nextval('authmap_aid_seq'::regclass);
+
+
+--
+-- Name: crop_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY bims_crop ALTER COLUMN crop_id SET DEFAULT nextval('bims_crop_crop_id_seq'::regclass);
+
+
+--
+-- Name: file_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY bims_file ALTER COLUMN file_id SET DEFAULT nextval('bims_file_file_id_seq'::regclass);
+
+
+--
+-- Name: instruction_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY bims_instruction ALTER COLUMN instruction_id SET DEFAULT nextval('bims_instruction_instruction_id_seq'::regclass);
+
+
+--
+-- Name: job_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY bims_job ALTER COLUMN job_id SET DEFAULT nextval('bims_job_job_id_seq'::regclass);
+
+
+--
+-- Name: list_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY bims_list ALTER COLUMN list_id SET DEFAULT nextval('bims_list_list_id_seq'::regclass);
+
+
+--
+-- Name: location_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY bims_location ALTER COLUMN location_id SET DEFAULT nextval('bims_location_location_id_seq'::regclass);
+
+
+--
+-- Name: mview_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY bims_mview ALTER COLUMN mview_id SET DEFAULT nextval('bims_mview_mview_id_seq'::regclass);
+
+
+--
+-- Name: mview_type_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY bims_mview_type ALTER COLUMN mview_type_id SET DEFAULT nextval('bims_mview_type_mview_type_id_seq'::regclass);
+
+
+--
+-- Name: node_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY bims_node ALTER COLUMN node_id SET DEFAULT nextval('bims_node_node_id_seq'::regclass);
+
+
+--
+-- Name: relationship_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY bims_node_relationship ALTER COLUMN relationship_id SET DEFAULT nextval('bims_node_relationship_relationship_id_seq'::regclass);
+
+
+--
+-- Name: bid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY block ALTER COLUMN bid SET DEFAULT nextval('block_bid_seq'::regclass);
+
+
+--
+-- Name: bid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY block_custom ALTER COLUMN bid SET DEFAULT nextval('block_custom_bid_seq'::regclass);
+
+
+--
+-- Name: iid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY blocked_ips ALTER COLUMN iid SET DEFAULT nextval('blocked_ips_iid_seq'::regclass);
+
+
+--
+-- Name: cid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY comment ALTER COLUMN cid SET DEFAULT nextval('comment_cid_seq'::regclass);
+
+
+--
+-- Name: cid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY contact ALTER COLUMN cid SET DEFAULT nextval('contact_cid_seq'::regclass);
+
+
+--
+-- Name: dfid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY date_formats ALTER COLUMN dfid SET DEFAULT nextval('date_formats_dfid_seq'::regclass);
+
+
+--
+-- Name: group_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY do_group ALTER COLUMN group_id SET DEFAULT nextval('do_group_group_id_seq'::regclass);
+
+
+--
+-- Name: node_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY do_node ALTER COLUMN node_id SET DEFAULT nextval('do_node_node_id_seq'::regclass);
+
+
+--
+-- Name: relationship_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY do_node_relationship ALTER COLUMN relationship_id SET DEFAULT nextval('do_node_relationship_relationship_id_seq'::regclass);
+
+
+--
+-- Name: overview_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY do_overview ALTER COLUMN overview_id SET DEFAULT nextval('do_overview_overview_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY field_config ALTER COLUMN id SET DEFAULT nextval('field_config_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY field_config_instance ALTER COLUMN id SET DEFAULT nextval('field_config_instance_id_seq'::regclass);
+
+
+--
+-- Name: fid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY file_managed ALTER COLUMN fid SET DEFAULT nextval('file_managed_fid_seq'::regclass);
+
+
+--
+-- Name: fid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY flood ALTER COLUMN fid SET DEFAULT nextval('flood_fid_seq'::regclass);
+
+
+--
+-- Name: category_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_category ALTER COLUMN category_id SET DEFAULT nextval('gensas_category_category_id_seq'::regclass);
+
+
+--
+-- Name: db_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_db ALTER COLUMN db_id SET DEFAULT nextval('gensas_db_db_id_seq'::regclass);
+
+
+--
+-- Name: file_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_files ALTER COLUMN file_id SET DEFAULT nextval('gensas_files_file_id_seq'::regclass);
+
+
+--
+-- Name: group_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_group ALTER COLUMN group_id SET DEFAULT nextval('gensas_group_group_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_job ALTER COLUMN id SET DEFAULT nextval('gensas_job_id_seq'::regclass);
+
+
+--
+-- Name: library_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_library ALTER COLUMN library_id SET DEFAULT nextval('gensas_library_library_id_seq'::regclass);
+
+
+--
+-- Name: library_type_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_library_type ALTER COLUMN library_type_id SET DEFAULT nextval('gensas_library_type_library_type_id_seq'::regclass);
+
+
+--
+-- Name: param_group_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_param_group ALTER COLUMN param_group_id SET DEFAULT nextval('gensas_param_group_param_group_id_seq'::regclass);
+
+
+--
+-- Name: project_type_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_project_type ALTER COLUMN project_type_id SET DEFAULT nextval('gensas_project_type_project_type_id_seq'::regclass);
+
+
+--
+-- Name: resource_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_resource ALTER COLUMN resource_id SET DEFAULT nextval('gensas_resource_resource_id_seq'::regclass);
+
+
+--
+-- Name: seq_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_seq ALTER COLUMN seq_id SET DEFAULT nextval('gensas_seq_seq_id_seq'::regclass);
+
+
+--
+-- Name: seq_group_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_seq_group ALTER COLUMN seq_group_id SET DEFAULT nextval('gensas_seq_group_seq_group_id_seq'::regclass);
+
+
+--
+-- Name: tool_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_tool ALTER COLUMN tool_id SET DEFAULT nextval('gensas_tool_tool_id_seq'::regclass);
+
+
+--
+-- Name: tool_param_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_tool_param ALTER COLUMN tool_param_id SET DEFAULT nextval('gensas_tool_param_tool_param_id_seq'::regclass);
+
+
+--
+-- Name: tool_param_type_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_tool_param_type ALTER COLUMN tool_param_type_id SET DEFAULT nextval('gensas_tool_param_type_tool_param_type_id_seq'::regclass);
+
+
+--
+-- Name: tool_type_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY gensas_tool_type ALTER COLUMN tool_type_id SET DEFAULT nextval('gensas_tool_type_tool_type_id_seq'::regclass);
+
+
+--
+-- Name: ieid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY image_effects ALTER COLUMN ieid SET DEFAULT nextval('image_effects_ieid_seq'::regclass);
+
+
+--
+-- Name: isid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY image_styles ALTER COLUMN isid SET DEFAULT nextval('image_styles_isid_seq'::regclass);
+
+
+--
+-- Name: file_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY mcl_file ALTER COLUMN file_id SET DEFAULT nextval('mcl_file_file_id_seq'::regclass);
+
+
+--
+-- Name: job_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY mcl_job ALTER COLUMN job_id SET DEFAULT nextval('mcl_job_job_id_seq'::regclass);
+
+
+--
+-- Name: template_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY mcl_template ALTER COLUMN template_id SET DEFAULT nextval('mcl_template_template_id_seq'::regclass);
+
+
+--
+-- Name: template_type_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY mcl_template_type ALTER COLUMN template_type_id SET DEFAULT nextval('mcl_template_type_template_type_id_seq'::regclass);
+
+
+--
+-- Name: var_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY mcl_var ALTER COLUMN var_id SET DEFAULT nextval('mcl_var_var_id_seq'::regclass);
+
+
+--
+-- Name: mlid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY menu_links ALTER COLUMN mlid SET DEFAULT nextval('menu_links_mlid_seq'::regclass);
+
+
+--
+-- Name: nid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY node ALTER COLUMN nid SET DEFAULT nextval('node_nid_seq'::regclass);
+
+
+--
+-- Name: vid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY node_revision ALTER COLUMN vid SET DEFAULT nextval('node_revision_vid_seq'::regclass);
+
+
+--
+-- Name: item_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY queue ALTER COLUMN item_id SET DEFAULT nextval('queue_item_id_seq'::regclass);
+
+
+--
+-- Name: rid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY role ALTER COLUMN rid SET DEFAULT nextval('role_rid_seq'::regclass);
+
+
+--
+-- Name: value; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY sequences ALTER COLUMN value SET DEFAULT nextval('sequences_value_seq'::regclass);
+
+
+--
+-- Name: tid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY taxonomy_term_data ALTER COLUMN tid SET DEFAULT nextval('taxonomy_term_data_tid_seq'::regclass);
+
+
+--
+-- Name: vid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY taxonomy_vocabulary ALTER COLUMN vid SET DEFAULT nextval('taxonomy_vocabulary_vid_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY tmp ALTER COLUMN id SET DEFAULT nextval('tmp_id_seq'::regclass);
+
+
+--
+-- Name: table_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY tripal_custom_tables ALTER COLUMN table_id SET DEFAULT nextval('tripal_custom_tables_table_id_seq'::regclass);
+
+
+--
+-- Name: job_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY tripal_jobs ALTER COLUMN job_id SET DEFAULT nextval('tripal_jobs_job_id_seq'::regclass);
+
+
+--
+-- Name: mview_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY tripal_mviews ALTER COLUMN mview_id SET DEFAULT nextval('tripal_mviews_mview_id_seq'::regclass);
+
+
+--
+-- Name: node_variable_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY tripal_node_variables ALTER COLUMN node_variable_id SET DEFAULT nextval('tripal_node_variables_node_variable_id_seq'::regclass);
+
+
+--
+-- Name: toc_item_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY tripal_toc ALTER COLUMN toc_item_id SET DEFAULT nextval('tripal_toc_toc_item_id_seq'::regclass);
+
+
+--
+-- Name: tripal_format_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY tripal_token_formats ALTER COLUMN tripal_format_id SET DEFAULT nextval('tripal_token_formats_tripal_format_id_seq'::regclass);
+
+
+--
+-- Name: variable_id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY tripal_variables ALTER COLUMN variable_id SET DEFAULT nextval('tripal_variables_variable_id_seq'::regclass);
+
+
+--
+-- Name: pid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY url_alias ALTER COLUMN pid SET DEFAULT nextval('url_alias_pid_seq'::regclass);
+
+
+--
+-- Name: vid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY views_view ALTER COLUMN vid SET DEFAULT nextval('views_view_vid_seq'::regclass);
+
+
+--
+-- Name: wid; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY watchdog ALTER COLUMN wid SET DEFAULT nextval('watchdog_wid_seq'::regclass);
+
+
+--
+-- Name: actions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY actions
+ ADD CONSTRAINT actions_pkey PRIMARY KEY (aid);
+
+
+--
+-- Name: authmap_authname_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY authmap
+ ADD CONSTRAINT authmap_authname_key UNIQUE (authname);
+
+
+--
+-- Name: authmap_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY authmap
+ ADD CONSTRAINT authmap_pkey PRIMARY KEY (aid);
+
+
+--
+-- Name: batch_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY batch
+ ADD CONSTRAINT batch_pkey PRIMARY KEY (bid);
+
+
+--
+-- Name: bims_crop_organism_ukey_bims_crop_organism_crop_id_organism_id_; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_crop_organism
+ ADD CONSTRAINT bims_crop_organism_ukey_bims_crop_organism_crop_id_organism_id_ UNIQUE (crop_id, organism_id);
+
+
+--
+-- Name: bims_crop_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_crop
+ ADD CONSTRAINT bims_crop_pkey PRIMARY KEY (crop_id);
+
+
+--
+-- Name: bims_dataset_stats_ukey_bims_dataset_stats_project_id_cvterm_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_dataset_stats
+ ADD CONSTRAINT bims_dataset_stats_ukey_bims_dataset_stats_project_id_cvterm_id UNIQUE (project_id, cvterm_id);
+
+
+--
+-- Name: bims_descriptor_group_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_descriptor_group
+ ADD CONSTRAINT bims_descriptor_group_pkey PRIMARY KEY (cv_id);
+
+
+--
+-- Name: bims_descriptor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_descriptor
+ ADD CONSTRAINT bims_descriptor_pkey PRIMARY KEY (cvterm_id);
+
+
+--
+-- Name: bims_file_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_file
+ ADD CONSTRAINT bims_file_pkey PRIMARY KEY (file_id);
+
+
+--
+-- Name: bims_instruction_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_instruction
+ ADD CONSTRAINT bims_instruction_pkey PRIMARY KEY (instruction_id);
+
+
+--
+-- Name: bims_job_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_job
+ ADD CONSTRAINT bims_job_pkey PRIMARY KEY (job_id);
+
+
+--
+-- Name: bims_list_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_list
+ ADD CONSTRAINT bims_list_pkey PRIMARY KEY (list_id);
+
+
+--
+-- Name: bims_location_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_location
+ ADD CONSTRAINT bims_location_pkey PRIMARY KEY (location_id);
+
+
+--
+-- Name: bims_mview_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_mview
+ ADD CONSTRAINT bims_mview_pkey PRIMARY KEY (mview_id);
+
+
+--
+-- Name: bims_mview_type_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_mview_type
+ ADD CONSTRAINT bims_mview_type_pkey PRIMARY KEY (mview_type_id);
+
+
+--
+-- Name: bims_mview_type_ukey_bims_mview_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_mview_type
+ ADD CONSTRAINT bims_mview_type_ukey_bims_mview_name_key UNIQUE (type);
+
+
+--
+-- Name: bims_mview_ukey_bims_mview_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_mview
+ ADD CONSTRAINT bims_mview_ukey_bims_mview_name_key UNIQUE (name);
+
+
+--
+-- Name: bims_node_location_ukey_bims_node_location_node_id_location_id_; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_node_location
+ ADD CONSTRAINT bims_node_location_ukey_bims_node_location_node_id_location_id_ UNIQUE (node_id, location_id);
+
+
+--
+-- Name: bims_node_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_node
+ ADD CONSTRAINT bims_node_pkey PRIMARY KEY (node_id);
+
+
+--
+-- Name: bims_node_relationship_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_node_relationship
+ ADD CONSTRAINT bims_node_relationship_pkey PRIMARY KEY (relationship_id);
+
+
+--
+-- Name: bims_node_relationship_ukey_bims_node_relationship_parent_id_ch; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_node_relationship
+ ADD CONSTRAINT bims_node_relationship_ukey_bims_node_relationship_parent_id_ch UNIQUE (parent_id, child_id);
+
+
+--
+-- Name: bims_node_ukey_bims_node_name_root_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_node
+ ADD CONSTRAINT bims_node_ukey_bims_node_name_root_id_user_id_key UNIQUE (name, root_id, user_id);
+
+
+--
+-- Name: bims_program_member_ukey_bims_program_member_program_id_user_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_program_member
+ ADD CONSTRAINT bims_program_member_ukey_bims_program_member_program_id_user_id UNIQUE (program_id, user_id);
+
+
+--
+-- Name: bims_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY bims_user
+ ADD CONSTRAINT bims_user_pkey PRIMARY KEY (user_id);
+
+
+--
+-- Name: block_custom_info_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY block_custom
+ ADD CONSTRAINT block_custom_info_key UNIQUE (info);
+
+
+--
+-- Name: block_custom_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY block_custom
+ ADD CONSTRAINT block_custom_pkey PRIMARY KEY (bid);
+
+
+--
+-- Name: block_node_type_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY block_node_type
+ ADD CONSTRAINT block_node_type_pkey PRIMARY KEY (module, delta, type);
+
+
+--
+-- Name: block_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY block
+ ADD CONSTRAINT block_pkey PRIMARY KEY (bid);
+
+
+--
+-- Name: block_role_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY block_role
+ ADD CONSTRAINT block_role_pkey PRIMARY KEY (module, delta, rid);
+
+
+--
+-- Name: block_tmd_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY block
+ ADD CONSTRAINT block_tmd_key UNIQUE (theme, module, delta);
+
+
+--
+-- Name: blocked_ips_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY blocked_ips
+ ADD CONSTRAINT blocked_ips_pkey PRIMARY KEY (iid);
+
+
+--
+-- Name: book_nid_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY book
+ ADD CONSTRAINT book_nid_key UNIQUE (nid);
+
+
+--
+-- Name: book_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY book
+ ADD CONSTRAINT book_pkey PRIMARY KEY (mlid);
+
+
+--
+-- Name: cache_block_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_block
+ ADD CONSTRAINT cache_block_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_bootstrap_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_bootstrap
+ ADD CONSTRAINT cache_bootstrap_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_field_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_field
+ ADD CONSTRAINT cache_field_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_filter_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_filter
+ ADD CONSTRAINT cache_filter_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_form_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_form
+ ADD CONSTRAINT cache_form_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_image_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_image
+ ADD CONSTRAINT cache_image_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_menu_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_menu
+ ADD CONSTRAINT cache_menu_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_page_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_page
+ ADD CONSTRAINT cache_page_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_path_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_path
+ ADD CONSTRAINT cache_path_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache
+ ADD CONSTRAINT cache_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_update_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_update
+ ADD CONSTRAINT cache_update_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_views_data_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_views_data
+ ADD CONSTRAINT cache_views_data_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: cache_views_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY cache_views
+ ADD CONSTRAINT cache_views_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: comment_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY comment
+ ADD CONSTRAINT comment_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: contact_category_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY contact
+ ADD CONSTRAINT contact_category_key UNIQUE (category);
+
+
+--
+-- Name: contact_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY contact
+ ADD CONSTRAINT contact_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: ctools_css_cache_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY ctools_css_cache
+ ADD CONSTRAINT ctools_css_cache_pkey PRIMARY KEY (cid);
+
+
+--
+-- Name: ctools_object_cache_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY ctools_object_cache
+ ADD CONSTRAINT ctools_object_cache_pkey PRIMARY KEY (sid, obj, name);
+
+
+--
+-- Name: date_format_locale_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY date_format_locale
+ ADD CONSTRAINT date_format_locale_pkey PRIMARY KEY (type, language);
+
+
+--
+-- Name: date_format_type_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY date_format_type
+ ADD CONSTRAINT date_format_type_pkey PRIMARY KEY (type);
+
+
+--
+-- Name: date_formats_formats_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY date_formats
+ ADD CONSTRAINT date_formats_formats_key UNIQUE (format, type);
+
+
+--
+-- Name: date_formats_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY date_formats
+ ADD CONSTRAINT date_formats_pkey PRIMARY KEY (dfid);
+
+
+--
+-- Name: do_group_data_overview_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY do_group
+ ADD CONSTRAINT do_group_data_overview_name_key UNIQUE (name);
+
+
+--
+-- Name: do_group_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY do_group
+ ADD CONSTRAINT do_group_pkey PRIMARY KEY (group_id);
+
+
+--
+-- Name: do_node_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY do_node
+ ADD CONSTRAINT do_node_pkey PRIMARY KEY (node_id);
+
+
+--
+-- Name: do_node_relationship_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY do_node_relationship
+ ADD CONSTRAINT do_node_relationship_pkey PRIMARY KEY (relationship_id);
+
+
+--
+-- Name: do_node_relationship_ukey_do_node_relationship_parent_id_child_; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY do_node_relationship
+ ADD CONSTRAINT do_node_relationship_ukey_do_node_relationship_parent_id_child_ UNIQUE (parent_id, child_id);
+
+
+--
+-- Name: do_overview_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY do_overview
+ ADD CONSTRAINT do_overview_pkey PRIMARY KEY (overview_id);
+
+
+--
+-- Name: do_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY do_user
+ ADD CONSTRAINT do_user_pkey PRIMARY KEY (user_id);
+
+
+--
+-- Name: field_config_instance_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY field_config_instance
+ ADD CONSTRAINT field_config_instance_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: field_config_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY field_config
+ ADD CONSTRAINT field_config_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: field_data_body_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY field_data_body
+ ADD CONSTRAINT field_data_body_pkey PRIMARY KEY (entity_type, entity_id, deleted, delta, language);
+
+
+--
+-- Name: field_data_comment_body_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY field_data_comment_body
+ ADD CONSTRAINT field_data_comment_body_pkey PRIMARY KEY (entity_type, entity_id, deleted, delta, language);
+
+
+--
+-- Name: field_data_field_image_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY field_data_field_image
+ ADD CONSTRAINT field_data_field_image_pkey PRIMARY KEY (entity_type, entity_id, deleted, delta, language);
+
+
+--
+-- Name: field_data_field_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY field_data_field_tags
+ ADD CONSTRAINT field_data_field_tags_pkey PRIMARY KEY (entity_type, entity_id, deleted, delta, language);
+
+
+--
+-- Name: field_revision_body_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY field_revision_body
+ ADD CONSTRAINT field_revision_body_pkey PRIMARY KEY (entity_type, entity_id, revision_id, deleted, delta, language);
+
+
+--
+-- Name: field_revision_comment_body_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY field_revision_comment_body
+ ADD CONSTRAINT field_revision_comment_body_pkey PRIMARY KEY (entity_type, entity_id, revision_id, deleted, delta, language);
+
+
+--
+-- Name: field_revision_field_image_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY field_revision_field_image
+ ADD CONSTRAINT field_revision_field_image_pkey PRIMARY KEY (entity_type, entity_id, revision_id, deleted, delta, language);
+
+
+--
+-- Name: field_revision_field_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY field_revision_field_tags
+ ADD CONSTRAINT field_revision_field_tags_pkey PRIMARY KEY (entity_type, entity_id, revision_id, deleted, delta, language);
+
+
+--
+-- Name: file_managed_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY file_managed
+ ADD CONSTRAINT file_managed_pkey PRIMARY KEY (fid);
+
+
+--
+-- Name: file_managed_uri_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY file_managed
+ ADD CONSTRAINT file_managed_uri_key UNIQUE (uri);
+
+
+--
+-- Name: file_usage_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY file_usage
+ ADD CONSTRAINT file_usage_pkey PRIMARY KEY (fid, type, id, module);
+
+
+--
+-- Name: filter_format_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY filter_format
+ ADD CONSTRAINT filter_format_name_key UNIQUE (name);
+
+
+--
+-- Name: filter_format_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY filter_format
+ ADD CONSTRAINT filter_format_pkey PRIMARY KEY (format);
+
+
+--
+-- Name: filter_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY filter
+ ADD CONSTRAINT filter_pkey PRIMARY KEY (format, name);
+
+
+--
+-- Name: flood_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY flood
+ ADD CONSTRAINT flood_pkey PRIMARY KEY (fid);
+
+
+--
+-- Name: gensas_category_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_category
+ ADD CONSTRAINT gensas_category_pkey PRIMARY KEY (category_id);
+
+
+--
+-- Name: gensas_db_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_db
+ ADD CONSTRAINT gensas_db_pkey PRIMARY KEY (db_id);
+
+
+--
+-- Name: gensas_db_ukey_gensas_db_db_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_db
+ ADD CONSTRAINT gensas_db_ukey_gensas_db_db_name_key UNIQUE (db_name);
+
+
+--
+-- Name: gensas_expire_ukey_gensas_expire_uq1_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_expire
+ ADD CONSTRAINT gensas_expire_ukey_gensas_expire_uq1_key UNIQUE (task_id);
+
+
+--
+-- Name: gensas_gff3_job_id_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_gff3
+ ADD CONSTRAINT gensas_gff3_job_id_id_key UNIQUE (job_id, id);
+
+
+--
+-- Name: gensas_group_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_group
+ ADD CONSTRAINT gensas_group_pkey PRIMARY KEY (group_id);
+
+
+--
+-- Name: gensas_group_seq_ukey_gensas_group_seq_group_id_group_seq_id_ke; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_group_seq
+ ADD CONSTRAINT gensas_group_seq_ukey_gensas_group_seq_group_id_group_seq_id_ke UNIQUE (group_id, seq_id);
+
+
+--
+-- Name: gensas_group_task_ukey_gensas_group_task_group_id_task_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_group_task
+ ADD CONSTRAINT gensas_group_task_ukey_gensas_group_task_group_id_task_id_key UNIQUE (group_id, task_id);
+
+
+--
+-- Name: gensas_group_user_ukey_gensas_group_user_group_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_group_user
+ ADD CONSTRAINT gensas_group_user_ukey_gensas_group_user_group_id_user_id_key UNIQUE (group_id, user_id);
+
+
+--
+-- Name: gensas_job_cmd_ukey_gensas_job_cmd_id_index_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_job_cmd
+ ADD CONSTRAINT gensas_job_cmd_ukey_gensas_job_cmd_id_index_key UNIQUE (id, index);
+
+
+--
+-- Name: gensas_job_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_job
+ ADD CONSTRAINT gensas_job_pkey PRIMARY KEY (job_id);
+
+
+--
+-- Name: gensas_job_resource_ukey_gensas_job_resource_resource_id_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_job_resource
+ ADD CONSTRAINT gensas_job_resource_ukey_gensas_job_resource_resource_id_id_key UNIQUE (resource_id, job_id);
+
+
+--
+-- Name: gensas_job_stats_job_id_type_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_job_stats
+ ADD CONSTRAINT gensas_job_stats_job_id_type_key UNIQUE (job_id, type);
+
+
+--
+-- Name: gensas_library_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_library
+ ADD CONSTRAINT gensas_library_pkey PRIMARY KEY (library_id);
+
+
+--
+-- Name: gensas_library_type_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_library_type
+ ADD CONSTRAINT gensas_library_type_pkey PRIMARY KEY (library_type_id);
+
+
+--
+-- Name: gensas_library_type_ukey_gensas_library_type_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_library_type
+ ADD CONSTRAINT gensas_library_type_ukey_gensas_library_type_key UNIQUE (type);
+
+
+--
+-- Name: gensas_library_ukey_gensas_library_label_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_library
+ ADD CONSTRAINT gensas_library_ukey_gensas_library_label_key UNIQUE (name);
+
+
+--
+-- Name: gensas_param_group_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_param_group
+ ADD CONSTRAINT gensas_param_group_pkey PRIMARY KEY (param_group_id);
+
+
+--
+-- Name: gensas_param_group_ukey_param_group_name_tool_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_param_group
+ ADD CONSTRAINT gensas_param_group_ukey_param_group_name_tool_id_key UNIQUE (name, tool_id);
+
+
+--
+-- Name: gensas_project_type_ukey_gensas_project_type_project_type_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_project_type
+ ADD CONSTRAINT gensas_project_type_ukey_gensas_project_type_project_type_key UNIQUE (type);
+
+
+--
+-- Name: gensas_publish_ukey_gensas_publish_job_id_version_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_publish
+ ADD CONSTRAINT gensas_publish_ukey_gensas_publish_job_id_version_key UNIQUE (job_id, version);
+
+
+--
+-- Name: gensas_resource_library_ukey_gensas_resource_library_resource_i; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_resource_library
+ ADD CONSTRAINT gensas_resource_library_ukey_gensas_resource_library_resource_i UNIQUE (resource_id, library_id);
+
+
+--
+-- Name: gensas_resource_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_resource
+ ADD CONSTRAINT gensas_resource_pkey PRIMARY KEY (resource_id);
+
+
+--
+-- Name: gensas_resource_submit_ukey_gensas_resource_library_resource_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_resource_submit
+ ADD CONSTRAINT gensas_resource_submit_ukey_gensas_resource_library_resource_id UNIQUE (resource_id, hostname);
+
+
+--
+-- Name: gensas_resource_tool_ukey_gensas_resource_tool_resource_id_tool; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_resource_tool
+ ADD CONSTRAINT gensas_resource_tool_ukey_gensas_resource_tool_resource_id_tool UNIQUE (resource_id, tool_id);
+
+
+--
+-- Name: gensas_resource_ukey_gensas_resource_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_resource
+ ADD CONSTRAINT gensas_resource_ukey_gensas_resource_name_key UNIQUE (name);
+
+
+--
+-- Name: gensas_resource_ukey_gensas_resource_rank_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_resource
+ ADD CONSTRAINT gensas_resource_ukey_gensas_resource_rank_key UNIQUE (rank);
+
+
+--
+-- Name: gensas_seq_group_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_seq_group
+ ADD CONSTRAINT gensas_seq_group_pkey PRIMARY KEY (seq_group_id);
+
+
+--
+-- Name: gensas_seq_group_ukey_gensas_seq_group_user_id_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_seq_group
+ ADD CONSTRAINT gensas_seq_group_ukey_gensas_seq_group_user_id_name_key UNIQUE (user_id, name);
+
+
+--
+-- Name: gensas_seq_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_seq
+ ADD CONSTRAINT gensas_seq_pkey PRIMARY KEY (seq_id);
+
+
+--
+-- Name: gensas_seq_stats_job_id_seq_id_type_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_seq_stats
+ ADD CONSTRAINT gensas_seq_stats_job_id_seq_id_type_key UNIQUE (job_id, seq_id, type);
+
+
+--
+-- Name: gensas_task_files_ukey_gensas_task_files_task_id_file_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_task_files
+ ADD CONSTRAINT gensas_task_files_ukey_gensas_task_files_task_id_file_id_key UNIQUE (task_id, file_id);
+
+
+--
+-- Name: gensas_task_job_ukey_gensas_task_job_task_id_job_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_task_job
+ ADD CONSTRAINT gensas_task_job_ukey_gensas_task_job_task_id_job_id_key UNIQUE (task_id, job_id);
+
+
+--
+-- Name: gensas_task_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_task
+ ADD CONSTRAINT gensas_task_pkey PRIMARY KEY (task_id);
+
+
+--
+-- Name: gensas_task_seq_group_ukey_gensas_task_seq_group_task_id_seq_gr; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_task_seq_group
+ ADD CONSTRAINT gensas_task_seq_group_ukey_gensas_task_seq_group_task_id_seq_gr UNIQUE (task_id, seq_group_id);
+
+
+--
+-- Name: gensas_task_user_ukey_gensas_task_user_task_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_task_user
+ ADD CONSTRAINT gensas_task_user_ukey_gensas_task_user_task_id_user_id_key UNIQUE (task_id, user_id);
+
+
+--
+-- Name: gensas_tool_param_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_tool_param
+ ADD CONSTRAINT gensas_tool_param_pkey PRIMARY KEY (tool_param_id);
+
+
+--
+-- Name: gensas_tool_param_type_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_tool_param_type
+ ADD CONSTRAINT gensas_tool_param_type_pkey PRIMARY KEY (tool_param_type_id);
+
+
+--
+-- Name: gensas_tool_param_type_ukey_gensas_tool_param_type_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_tool_param_type
+ ADD CONSTRAINT gensas_tool_param_type_ukey_gensas_tool_param_type_key UNIQUE (type);
+
+
+--
+-- Name: gensas_tool_param_ukey_gensas_tool_param_param_elem_id_tool_id_; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_tool_param
+ ADD CONSTRAINT gensas_tool_param_ukey_gensas_tool_param_param_elem_id_tool_id_ UNIQUE (param_elem_id, tool_id);
+
+
+--
+-- Name: gensas_tool_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_tool
+ ADD CONSTRAINT gensas_tool_pkey PRIMARY KEY (tool_id);
+
+
+--
+-- Name: gensas_tool_type_ukey_gensas_tool_type_tid_ptid_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_tool_type
+ ADD CONSTRAINT gensas_tool_type_ukey_gensas_tool_type_tid_ptid_key UNIQUE (tool_id, project_type_id);
+
+
+--
+-- Name: gensas_user_tool_ukey_gensas_user_tool_user_id_tool_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY gensas_user_tool
+ ADD CONSTRAINT gensas_user_tool_ukey_gensas_user_tool_user_id_tool_id_key UNIQUE (user_id, tool_id);
+
+
+--
+-- Name: history_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY history
+ ADD CONSTRAINT history_pkey PRIMARY KEY (uid, nid);
+
+
+--
+-- Name: image_effects_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY image_effects
+ ADD CONSTRAINT image_effects_pkey PRIMARY KEY (ieid);
+
+
+--
+-- Name: image_styles_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY image_styles
+ ADD CONSTRAINT image_styles_name_key UNIQUE (name);
+
+
+--
+-- Name: image_styles_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY image_styles
+ ADD CONSTRAINT image_styles_pkey PRIMARY KEY (isid);
+
+
+--
+-- Name: masquerade_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY masquerade_users
+ ADD CONSTRAINT masquerade_users_pkey PRIMARY KEY (uid_from, uid_to);
+
+
+--
+-- Name: mcl_file_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY mcl_file
+ ADD CONSTRAINT mcl_file_pkey PRIMARY KEY (file_id);
+
+
+--
+-- Name: mcl_job_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY mcl_job
+ ADD CONSTRAINT mcl_job_pkey PRIMARY KEY (job_id);
+
+
+--
+-- Name: mcl_template_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY mcl_template
+ ADD CONSTRAINT mcl_template_pkey PRIMARY KEY (template_id);
+
+
+--
+-- Name: mcl_template_type_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY mcl_template_type
+ ADD CONSTRAINT mcl_template_type_pkey PRIMARY KEY (template_type_id);
+
+
+--
+-- Name: mcl_template_type_ukey_mcl_template_type_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY mcl_template_type
+ ADD CONSTRAINT mcl_template_type_ukey_mcl_template_type_key UNIQUE (type);
+
+
+--
+-- Name: mcl_template_ukey_mcl_template_template_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY mcl_template
+ ADD CONSTRAINT mcl_template_ukey_mcl_template_template_key UNIQUE (template);
+
+
+--
+-- Name: mcl_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY mcl_user
+ ADD CONSTRAINT mcl_user_pkey PRIMARY KEY (user_id);
+
+
+--
+-- Name: mcl_var_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY mcl_var
+ ADD CONSTRAINT mcl_var_pkey PRIMARY KEY (var_id);
+
+
+--
+-- Name: mcl_var_ukey_mcl_var_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY mcl_var
+ ADD CONSTRAINT mcl_var_ukey_mcl_var_name_key UNIQUE (name);
+
+
+--
+-- Name: menu_custom_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY menu_custom
+ ADD CONSTRAINT menu_custom_pkey PRIMARY KEY (menu_name);
+
+
+--
+-- Name: menu_links_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY menu_links
+ ADD CONSTRAINT menu_links_pkey PRIMARY KEY (mlid);
+
+
+--
+-- Name: menu_router_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY menu_router
+ ADD CONSTRAINT menu_router_pkey PRIMARY KEY (path);
+
+
+--
+-- Name: node_access_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY node_access
+ ADD CONSTRAINT node_access_pkey PRIMARY KEY (nid, gid, realm);
+
+
+--
+-- Name: node_comment_statistics_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY node_comment_statistics
+ ADD CONSTRAINT node_comment_statistics_pkey PRIMARY KEY (nid);
+
+
+--
+-- Name: node_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY node
+ ADD CONSTRAINT node_pkey PRIMARY KEY (nid);
+
+
+--
+-- Name: node_revision_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY node_revision
+ ADD CONSTRAINT node_revision_pkey PRIMARY KEY (vid);
+
+
+--
+-- Name: node_type_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY node_type
+ ADD CONSTRAINT node_type_pkey PRIMARY KEY (type);
+
+
+--
+-- Name: node_vid_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY node
+ ADD CONSTRAINT node_vid_key UNIQUE (vid);
+
+
+--
+-- Name: queue_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY queue
+ ADD CONSTRAINT queue_pkey PRIMARY KEY (item_id);
+
+
+--
+-- Name: rdf_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY rdf_mapping
+ ADD CONSTRAINT rdf_mapping_pkey PRIMARY KEY (type, bundle);
+
+
+--
+-- Name: registry_file_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY registry_file
+ ADD CONSTRAINT registry_file_pkey PRIMARY KEY (filename);
+
+
+--
+-- Name: registry_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY registry
+ ADD CONSTRAINT registry_pkey PRIMARY KEY (name, type);
+
+
+--
+-- Name: role_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY role
+ ADD CONSTRAINT role_name_key UNIQUE (name);
+
+
+--
+-- Name: role_permission_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY role_permission
+ ADD CONSTRAINT role_permission_pkey PRIMARY KEY (rid, permission);
+
+
+--
+-- Name: role_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY role
+ ADD CONSTRAINT role_pkey PRIMARY KEY (rid);
+
+
+--
+-- Name: search_dataset_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY search_dataset
+ ADD CONSTRAINT search_dataset_pkey PRIMARY KEY (sid, type);
+
+
+--
+-- Name: search_index_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY search_index
+ ADD CONSTRAINT search_index_pkey PRIMARY KEY (word, sid, type);
+
+
+--
+-- Name: search_node_links_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY search_node_links
+ ADD CONSTRAINT search_node_links_pkey PRIMARY KEY (sid, type, nid);
+
+
+--
+-- Name: search_total_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY search_total
+ ADD CONSTRAINT search_total_pkey PRIMARY KEY (word);
+
+
+--
+-- Name: semaphore_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY semaphore
+ ADD CONSTRAINT semaphore_pkey PRIMARY KEY (name);
+
+
+--
+-- Name: sequences_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY sequences
+ ADD CONSTRAINT sequences_pkey PRIMARY KEY (value);
+
+
+--
+-- Name: sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY sessions
+ ADD CONSTRAINT sessions_pkey PRIMARY KEY (sid, ssid);
+
+
+--
+-- Name: shortcut_set_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY shortcut_set
+ ADD CONSTRAINT shortcut_set_pkey PRIMARY KEY (set_name);
+
+
+--
+-- Name: shortcut_set_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY shortcut_set_users
+ ADD CONSTRAINT shortcut_set_users_pkey PRIMARY KEY (uid);
+
+
+--
+-- Name: system_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY system
+ ADD CONSTRAINT system_pkey PRIMARY KEY (filename);
+
+
+--
+-- Name: taxonomy_term_data_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY taxonomy_term_data
+ ADD CONSTRAINT taxonomy_term_data_pkey PRIMARY KEY (tid);
+
+
+--
+-- Name: taxonomy_term_hierarchy_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY taxonomy_term_hierarchy
+ ADD CONSTRAINT taxonomy_term_hierarchy_pkey PRIMARY KEY (tid, parent);
+
+
+--
+-- Name: taxonomy_vocabulary_machine_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY taxonomy_vocabulary
+ ADD CONSTRAINT taxonomy_vocabulary_machine_name_key UNIQUE (machine_name);
+
+
+--
+-- Name: taxonomy_vocabulary_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY taxonomy_vocabulary
+ ADD CONSTRAINT taxonomy_vocabulary_pkey PRIMARY KEY (vid);
+
+
+--
+-- Name: tripal_custom_tables_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_custom_tables
+ ADD CONSTRAINT tripal_custom_tables_pkey PRIMARY KEY (table_id);
+
+
+--
+-- Name: tripal_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_jobs
+ ADD CONSTRAINT tripal_jobs_pkey PRIMARY KEY (job_id);
+
+
+--
+-- Name: tripal_mviews_mv_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_mviews
+ ADD CONSTRAINT tripal_mviews_mv_name_key UNIQUE (name);
+
+
+--
+-- Name: tripal_mviews_mv_table_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_mviews
+ ADD CONSTRAINT tripal_mviews_mv_table_key UNIQUE (mv_table);
+
+
+--
+-- Name: tripal_mviews_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_mviews
+ ADD CONSTRAINT tripal_mviews_pkey PRIMARY KEY (mview_id);
+
+
+--
+-- Name: tripal_node_variables_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_node_variables
+ ADD CONSTRAINT tripal_node_variables_pkey PRIMARY KEY (node_variable_id);
+
+
+--
+-- Name: tripal_node_variables_tripal_node_variables_c1_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_node_variables
+ ADD CONSTRAINT tripal_node_variables_tripal_node_variables_c1_key UNIQUE (nid, variable_id, rank);
+
+
+--
+-- Name: tripal_toc_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_toc
+ ADD CONSTRAINT tripal_toc_pkey PRIMARY KEY (toc_item_id);
+
+
+--
+-- Name: tripal_toc_tripal_toc_uq1_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_toc
+ ADD CONSTRAINT tripal_toc_tripal_toc_uq1_key UNIQUE (node_type, key, nid);
+
+
+--
+-- Name: tripal_token_formats_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_token_formats
+ ADD CONSTRAINT tripal_token_formats_pkey PRIMARY KEY (tripal_format_id);
+
+
+--
+-- Name: tripal_token_formats_type_application_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_token_formats
+ ADD CONSTRAINT tripal_token_formats_type_application_key UNIQUE (content_type, application);
+
+
+--
+-- Name: tripal_variables_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_variables
+ ADD CONSTRAINT tripal_variables_pkey PRIMARY KEY (variable_id);
+
+
+--
+-- Name: tripal_variables_tripal_variables_c1_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY tripal_variables
+ ADD CONSTRAINT tripal_variables_tripal_variables_c1_key UNIQUE (name);
+
+
+--
+-- Name: url_alias_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY url_alias
+ ADD CONSTRAINT url_alias_pkey PRIMARY KEY (pid);
+
+
+--
+-- Name: users_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY users
+ ADD CONSTRAINT users_name_key UNIQUE (name);
+
+
+--
+-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY users
+ ADD CONSTRAINT users_pkey PRIMARY KEY (uid);
+
+
+--
+-- Name: users_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY users_roles
+ ADD CONSTRAINT users_roles_pkey PRIMARY KEY (uid, rid);
+
+
+--
+-- Name: variable_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY variable
+ ADD CONSTRAINT variable_pkey PRIMARY KEY (name);
+
+
+--
+-- Name: views_display_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY views_display
+ ADD CONSTRAINT views_display_pkey PRIMARY KEY (vid, id);
+
+
+--
+-- Name: views_view_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY views_view
+ ADD CONSTRAINT views_view_name_key UNIQUE (name);
+
+
+--
+-- Name: views_view_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY views_view
+ ADD CONSTRAINT views_view_pkey PRIMARY KEY (vid);
+
+
+--
+-- Name: watchdog_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY watchdog
+ ADD CONSTRAINT watchdog_pkey PRIMARY KEY (wid);
+
+
+--
+-- Name: authmap_uid_module_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX authmap_uid_module_idx ON authmap USING btree (uid, module);
+
+
+--
+-- Name: batch_token_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX batch_token_idx ON batch USING btree (token);
+
+
+--
+-- Name: block_list_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX block_list_idx ON block USING btree (theme, status, region, weight, module);
+
+
+--
+-- Name: block_node_type_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX block_node_type_type_idx ON block_node_type USING btree (type);
+
+
+--
+-- Name: block_role_rid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX block_role_rid_idx ON block_role USING btree (rid);
+
+
+--
+-- Name: blocked_ips_blocked_ip_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX blocked_ips_blocked_ip_idx ON blocked_ips USING btree (ip);
+
+
+--
+-- Name: book_bid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX book_bid_idx ON book USING btree (bid);
+
+
+--
+-- Name: cache_block_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_block_expire_idx ON cache_block USING btree (expire);
+
+
+--
+-- Name: cache_bootstrap_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_bootstrap_expire_idx ON cache_bootstrap USING btree (expire);
+
+
+--
+-- Name: cache_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_expire_idx ON cache USING btree (expire);
+
+
+--
+-- Name: cache_field_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_field_expire_idx ON cache_field USING btree (expire);
+
+
+--
+-- Name: cache_filter_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_filter_expire_idx ON cache_filter USING btree (expire);
+
+
+--
+-- Name: cache_form_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_form_expire_idx ON cache_form USING btree (expire);
+
+
+--
+-- Name: cache_image_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_image_expire_idx ON cache_image USING btree (expire);
+
+
+--
+-- Name: cache_menu_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_menu_expire_idx ON cache_menu USING btree (expire);
+
+
+--
+-- Name: cache_page_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_page_expire_idx ON cache_page USING btree (expire);
+
+
+--
+-- Name: cache_path_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_path_expire_idx ON cache_path USING btree (expire);
+
+
+--
+-- Name: cache_update_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_update_expire_idx ON cache_update USING btree (expire);
+
+
+--
+-- Name: cache_views_data_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_views_data_expire_idx ON cache_views_data USING btree (expire);
+
+
+--
+-- Name: cache_views_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX cache_views_expire_idx ON cache_views USING btree (expire);
+
+
+--
+-- Name: comment_comment_created_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX comment_comment_created_idx ON comment USING btree (created);
+
+
+--
+-- Name: comment_comment_nid_language_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX comment_comment_nid_language_idx ON comment USING btree (nid, language);
+
+
+--
+-- Name: comment_comment_num_new_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX comment_comment_num_new_idx ON comment USING btree (nid, status, created, cid, thread);
+
+
+--
+-- Name: comment_comment_status_pid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX comment_comment_status_pid_idx ON comment USING btree (pid, status);
+
+
+--
+-- Name: comment_comment_uid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX comment_comment_uid_idx ON comment USING btree (uid);
+
+
+--
+-- Name: contact_list_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX contact_list_idx ON contact USING btree (weight, category);
+
+
+--
+-- Name: ctools_object_cache_updated_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX ctools_object_cache_updated_idx ON ctools_object_cache USING btree (updated);
+
+
+--
+-- Name: date_format_type_title_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX date_format_type_title_idx ON date_format_type USING btree (title);
+
+
+--
+-- Name: field_config_active_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_config_active_idx ON field_config USING btree (active);
+
+
+--
+-- Name: field_config_deleted_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_config_deleted_idx ON field_config USING btree (deleted);
+
+
+--
+-- Name: field_config_field_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_config_field_name_idx ON field_config USING btree (field_name);
+
+
+--
+-- Name: field_config_instance_deleted_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_config_instance_deleted_idx ON field_config_instance USING btree (deleted);
+
+
+--
+-- Name: field_config_instance_field_name_bundle_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_config_instance_field_name_bundle_idx ON field_config_instance USING btree (field_name, entity_type, bundle);
+
+
+--
+-- Name: field_config_module_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_config_module_idx ON field_config USING btree (module);
+
+
+--
+-- Name: field_config_storage_active_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_config_storage_active_idx ON field_config USING btree (storage_active);
+
+
+--
+-- Name: field_config_storage_module_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_config_storage_module_idx ON field_config USING btree (storage_module);
+
+
+--
+-- Name: field_config_storage_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_config_storage_type_idx ON field_config USING btree (storage_type);
+
+
+--
+-- Name: field_config_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_config_type_idx ON field_config USING btree (type);
+
+
+--
+-- Name: field_data_body_body_format_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_body_body_format_idx ON field_data_body USING btree (body_format);
+
+
+--
+-- Name: field_data_body_bundle_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_body_bundle_idx ON field_data_body USING btree (bundle);
+
+
+--
+-- Name: field_data_body_deleted_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_body_deleted_idx ON field_data_body USING btree (deleted);
+
+
+--
+-- Name: field_data_body_entity_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_body_entity_id_idx ON field_data_body USING btree (entity_id);
+
+
+--
+-- Name: field_data_body_entity_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_body_entity_type_idx ON field_data_body USING btree (entity_type);
+
+
+--
+-- Name: field_data_body_language_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_body_language_idx ON field_data_body USING btree (language);
+
+
+--
+-- Name: field_data_body_revision_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_body_revision_id_idx ON field_data_body USING btree (revision_id);
+
+
+--
+-- Name: field_data_comment_body_bundle_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_comment_body_bundle_idx ON field_data_comment_body USING btree (bundle);
+
+
+--
+-- Name: field_data_comment_body_comment_body_format_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_comment_body_comment_body_format_idx ON field_data_comment_body USING btree (comment_body_format);
+
+
+--
+-- Name: field_data_comment_body_deleted_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_comment_body_deleted_idx ON field_data_comment_body USING btree (deleted);
+
+
+--
+-- Name: field_data_comment_body_entity_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_comment_body_entity_id_idx ON field_data_comment_body USING btree (entity_id);
+
+
+--
+-- Name: field_data_comment_body_entity_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_comment_body_entity_type_idx ON field_data_comment_body USING btree (entity_type);
+
+
+--
+-- Name: field_data_comment_body_language_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_comment_body_language_idx ON field_data_comment_body USING btree (language);
+
+
+--
+-- Name: field_data_comment_body_revision_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_comment_body_revision_id_idx ON field_data_comment_body USING btree (revision_id);
+
+
+--
+-- Name: field_data_field_image_bundle_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_image_bundle_idx ON field_data_field_image USING btree (bundle);
+
+
+--
+-- Name: field_data_field_image_deleted_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_image_deleted_idx ON field_data_field_image USING btree (deleted);
+
+
+--
+-- Name: field_data_field_image_entity_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_image_entity_id_idx ON field_data_field_image USING btree (entity_id);
+
+
+--
+-- Name: field_data_field_image_entity_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_image_entity_type_idx ON field_data_field_image USING btree (entity_type);
+
+
+--
+-- Name: field_data_field_image_field_image_fid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_image_field_image_fid_idx ON field_data_field_image USING btree (field_image_fid);
+
+
+--
+-- Name: field_data_field_image_language_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_image_language_idx ON field_data_field_image USING btree (language);
+
+
+--
+-- Name: field_data_field_image_revision_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_image_revision_id_idx ON field_data_field_image USING btree (revision_id);
+
+
+--
+-- Name: field_data_field_tags_bundle_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_tags_bundle_idx ON field_data_field_tags USING btree (bundle);
+
+
+--
+-- Name: field_data_field_tags_deleted_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_tags_deleted_idx ON field_data_field_tags USING btree (deleted);
+
+
+--
+-- Name: field_data_field_tags_entity_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_tags_entity_id_idx ON field_data_field_tags USING btree (entity_id);
+
+
+--
+-- Name: field_data_field_tags_entity_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_tags_entity_type_idx ON field_data_field_tags USING btree (entity_type);
+
+
+--
+-- Name: field_data_field_tags_field_tags_tid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_tags_field_tags_tid_idx ON field_data_field_tags USING btree (field_tags_tid);
+
+
+--
+-- Name: field_data_field_tags_language_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_tags_language_idx ON field_data_field_tags USING btree (language);
+
+
+--
+-- Name: field_data_field_tags_revision_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_data_field_tags_revision_id_idx ON field_data_field_tags USING btree (revision_id);
+
+
+--
+-- Name: field_revision_body_body_format_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_body_body_format_idx ON field_revision_body USING btree (body_format);
+
+
+--
+-- Name: field_revision_body_bundle_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_body_bundle_idx ON field_revision_body USING btree (bundle);
+
+
+--
+-- Name: field_revision_body_deleted_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_body_deleted_idx ON field_revision_body USING btree (deleted);
+
+
+--
+-- Name: field_revision_body_entity_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_body_entity_id_idx ON field_revision_body USING btree (entity_id);
+
+
+--
+-- Name: field_revision_body_entity_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_body_entity_type_idx ON field_revision_body USING btree (entity_type);
+
+
+--
+-- Name: field_revision_body_language_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_body_language_idx ON field_revision_body USING btree (language);
+
+
+--
+-- Name: field_revision_body_revision_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_body_revision_id_idx ON field_revision_body USING btree (revision_id);
+
+
+--
+-- Name: field_revision_comment_body_bundle_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_comment_body_bundle_idx ON field_revision_comment_body USING btree (bundle);
+
+
+--
+-- Name: field_revision_comment_body_comment_body_format_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_comment_body_comment_body_format_idx ON field_revision_comment_body USING btree (comment_body_format);
+
+
+--
+-- Name: field_revision_comment_body_deleted_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_comment_body_deleted_idx ON field_revision_comment_body USING btree (deleted);
+
+
+--
+-- Name: field_revision_comment_body_entity_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_comment_body_entity_id_idx ON field_revision_comment_body USING btree (entity_id);
+
+
+--
+-- Name: field_revision_comment_body_entity_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_comment_body_entity_type_idx ON field_revision_comment_body USING btree (entity_type);
+
+
+--
+-- Name: field_revision_comment_body_language_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_comment_body_language_idx ON field_revision_comment_body USING btree (language);
+
+
+--
+-- Name: field_revision_comment_body_revision_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_comment_body_revision_id_idx ON field_revision_comment_body USING btree (revision_id);
+
+
+--
+-- Name: field_revision_field_image_bundle_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_image_bundle_idx ON field_revision_field_image USING btree (bundle);
+
+
+--
+-- Name: field_revision_field_image_deleted_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_image_deleted_idx ON field_revision_field_image USING btree (deleted);
+
+
+--
+-- Name: field_revision_field_image_entity_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_image_entity_id_idx ON field_revision_field_image USING btree (entity_id);
+
+
+--
+-- Name: field_revision_field_image_entity_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_image_entity_type_idx ON field_revision_field_image USING btree (entity_type);
+
+
+--
+-- Name: field_revision_field_image_field_image_fid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_image_field_image_fid_idx ON field_revision_field_image USING btree (field_image_fid);
+
+
+--
+-- Name: field_revision_field_image_language_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_image_language_idx ON field_revision_field_image USING btree (language);
+
+
+--
+-- Name: field_revision_field_image_revision_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_image_revision_id_idx ON field_revision_field_image USING btree (revision_id);
+
+
+--
+-- Name: field_revision_field_tags_bundle_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_tags_bundle_idx ON field_revision_field_tags USING btree (bundle);
+
+
+--
+-- Name: field_revision_field_tags_deleted_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_tags_deleted_idx ON field_revision_field_tags USING btree (deleted);
+
+
+--
+-- Name: field_revision_field_tags_entity_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_tags_entity_id_idx ON field_revision_field_tags USING btree (entity_id);
+
+
+--
+-- Name: field_revision_field_tags_entity_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_tags_entity_type_idx ON field_revision_field_tags USING btree (entity_type);
+
+
+--
+-- Name: field_revision_field_tags_field_tags_tid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_tags_field_tags_tid_idx ON field_revision_field_tags USING btree (field_tags_tid);
+
+
+--
+-- Name: field_revision_field_tags_language_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_tags_language_idx ON field_revision_field_tags USING btree (language);
+
+
+--
+-- Name: field_revision_field_tags_revision_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX field_revision_field_tags_revision_id_idx ON field_revision_field_tags USING btree (revision_id);
+
+
+--
+-- Name: file_managed_status_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX file_managed_status_idx ON file_managed USING btree (status);
+
+
+--
+-- Name: file_managed_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX file_managed_timestamp_idx ON file_managed USING btree ("timestamp");
+
+
+--
+-- Name: file_managed_uid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX file_managed_uid_idx ON file_managed USING btree (uid);
+
+
+--
+-- Name: file_usage_fid_count_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX file_usage_fid_count_idx ON file_usage USING btree (fid, count);
+
+
+--
+-- Name: file_usage_fid_module_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX file_usage_fid_module_idx ON file_usage USING btree (fid, module);
+
+
+--
+-- Name: file_usage_type_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX file_usage_type_id_idx ON file_usage USING btree (type, id);
+
+
+--
+-- Name: filter_format_status_weight_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX filter_format_status_weight_idx ON filter_format USING btree (status, weight);
+
+
+--
+-- Name: filter_list_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX filter_list_idx ON filter USING btree (weight, module, name);
+
+
+--
+-- Name: flood_allow_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX flood_allow_idx ON flood USING btree (event, identifier, "timestamp");
+
+
+--
+-- Name: flood_purge_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX flood_purge_idx ON flood USING btree (expiration);
+
+
+--
+-- Name: gensas_expire_idx1_gensas_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_expire_idx1_gensas_expire_idx ON gensas_expire USING btree (task_id);
+
+
+--
+-- Name: gensas_gff3_landmark_job_id_id_key; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_gff3_landmark_job_id_id_key ON gensas_gff3 USING btree (job_id, id, landmark);
+
+
+--
+-- Name: gensas_job_cmd_idx_gensas_job_cmd_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_job_cmd_idx_gensas_job_cmd_id_idx ON gensas_job_cmd USING btree (id);
+
+
+--
+-- Name: gensas_job_resource_idx_gensas_job_resource_job_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_job_resource_idx_gensas_job_resource_job_id_idx ON gensas_job_resource USING btree (job_id);
+
+
+--
+-- Name: gensas_job_resource_idx_gensas_job_resource_resource_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_job_resource_idx_gensas_job_resource_resource_id_idx ON gensas_job_resource USING btree (resource_id);
+
+
+--
+-- Name: gensas_job_stats_idx_gensas_job_stats_job_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_job_stats_idx_gensas_job_stats_job_id_idx ON gensas_job_stats USING btree (job_id);
+
+
+--
+-- Name: gensas_project_type_idx_gensas_project_type_project_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_project_type_idx_gensas_project_type_project_type_idx ON gensas_project_type USING btree (type);
+
+
+--
+-- Name: gensas_publish_idx_gensas_publish_job_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_publish_idx_gensas_publish_job_id_idx ON gensas_publish USING btree (job_id);
+
+
+--
+-- Name: gensas_resource_idx_gensas_resource_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_resource_idx_gensas_resource_name_idx ON gensas_resource USING btree (name);
+
+
+--
+-- Name: gensas_resource_library_idx_gensas_resource_library_library_id_; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_resource_library_idx_gensas_resource_library_library_id_ ON gensas_resource_library USING btree (library_id);
+
+
+--
+-- Name: gensas_resource_library_idx_gensas_resource_library_resource_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_resource_library_idx_gensas_resource_library_resource_id ON gensas_resource_library USING btree (resource_id);
+
+
+--
+-- Name: gensas_resource_submit_idx_gensas_resource_submit_hostname_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_resource_submit_idx_gensas_resource_submit_hostname_idx ON gensas_resource_submit USING btree (hostname);
+
+
+--
+-- Name: gensas_resource_submit_idx_gensas_resource_submit_resource_id_i; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_resource_submit_idx_gensas_resource_submit_resource_id_i ON gensas_resource_submit USING btree (resource_id);
+
+
+--
+-- Name: gensas_resource_tool_idx_gensas_resource_tool_resource_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_resource_tool_idx_gensas_resource_tool_resource_id_idx ON gensas_resource_tool USING btree (resource_id);
+
+
+--
+-- Name: gensas_resource_tool_idx_gensas_resource_tool_tool_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_resource_tool_idx_gensas_resource_tool_tool_id_idx ON gensas_resource_tool USING btree (tool_id);
+
+
+--
+-- Name: gensas_seq_idx_gensas_seq_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_seq_idx_gensas_seq_name_idx ON gensas_seq USING btree (name);
+
+
+--
+-- Name: gensas_seq_idx_gensas_seq_seq_group_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_seq_idx_gensas_seq_seq_group_id_idx ON gensas_seq USING btree (seq_group_id);
+
+
+--
+-- Name: gensas_seq_stats_idx_gensas_job_stats_job_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_seq_stats_idx_gensas_job_stats_job_id_idx ON gensas_seq_stats USING btree (job_id);
+
+
+--
+-- Name: gensas_seq_stats_idx_gensas_job_stats_seq_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_seq_stats_idx_gensas_job_stats_seq_id_idx ON gensas_seq_stats USING btree (seq_id);
+
+
+--
+-- Name: gensas_task_files_idx_gensas_task_files_file_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_task_files_idx_gensas_task_files_file_id_idx ON gensas_task_files USING btree (file_id);
+
+
+--
+-- Name: gensas_task_files_idx_gensas_task_files_task_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_task_files_idx_gensas_task_files_task_id_idx ON gensas_task_files USING btree (task_id);
+
+
+--
+-- Name: gensas_task_job_idx_gensas_task_job_job_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_task_job_idx_gensas_task_job_job_id_idx ON gensas_task_job USING btree (job_id);
+
+
+--
+-- Name: gensas_task_job_idx_gensas_task_job_task_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_task_job_idx_gensas_task_job_task_id_idx ON gensas_task_job USING btree (task_id);
+
+
+--
+-- Name: gensas_task_seq_group_idx_gensas_task_seq_group_seq_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_task_seq_group_idx_gensas_task_seq_group_seq_id_idx ON gensas_task_seq_group USING btree (seq_group_id);
+
+
+--
+-- Name: gensas_task_seq_group_idx_gensas_task_seq_group_task_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_task_seq_group_idx_gensas_task_seq_group_task_id_idx ON gensas_task_seq_group USING btree (task_id);
+
+
+--
+-- Name: gensas_tool_type_idx_gensas_tool_type_project_type_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_tool_type_idx_gensas_tool_type_project_type_id_idx ON gensas_tool_type USING btree (project_type_id);
+
+
+--
+-- Name: gensas_tool_type_idx_gensas_tool_type_tool_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX gensas_tool_type_idx_gensas_tool_type_tool_id_idx ON gensas_tool_type USING btree (tool_id);
+
+
+--
+-- Name: history_nid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX history_nid_idx ON history USING btree (nid);
+
+
+--
+-- Name: image_effects_isid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX image_effects_isid_idx ON image_effects USING btree (isid);
+
+
+--
+-- Name: image_effects_weight_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX image_effects_weight_idx ON image_effects USING btree (weight);
+
+
+--
+-- Name: masquerade_sid_2_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX masquerade_sid_2_idx ON masquerade USING btree (sid, uid_as);
+
+
+--
+-- Name: masquerade_sid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX masquerade_sid_idx ON masquerade USING btree (sid, uid_from);
+
+
+--
+-- Name: menu_links_menu_parents_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX menu_links_menu_parents_idx ON menu_links USING btree (menu_name, p1, p2, p3, p4, p5, p6, p7, p8, p9);
+
+
+--
+-- Name: menu_links_menu_plid_expand_child_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX menu_links_menu_plid_expand_child_idx ON menu_links USING btree (menu_name, plid, expanded, has_children);
+
+
+--
+-- Name: menu_links_path_menu_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX menu_links_path_menu_idx ON menu_links USING btree (substr((link_path)::text, 1, 128), menu_name);
+
+
+--
+-- Name: menu_links_router_path_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX menu_links_router_path_idx ON menu_links USING btree (substr((router_path)::text, 1, 128));
+
+
+--
+-- Name: menu_router_fit_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX menu_router_fit_idx ON menu_router USING btree (fit);
+
+
+--
+-- Name: menu_router_tab_parent_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX menu_router_tab_parent_idx ON menu_router USING btree (substr((tab_parent)::text, 1, 64), weight, title);
+
+
+--
+-- Name: menu_router_tab_root_weight_title_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX menu_router_tab_root_weight_title_idx ON menu_router USING btree (substr((tab_root)::text, 1, 64), weight, title);
+
+
+--
+-- Name: node_comment_statistics_comment_count_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_comment_statistics_comment_count_idx ON node_comment_statistics USING btree (comment_count);
+
+
+--
+-- Name: node_comment_statistics_last_comment_uid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_comment_statistics_last_comment_uid_idx ON node_comment_statistics USING btree (last_comment_uid);
+
+
+--
+-- Name: node_comment_statistics_node_comment_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_comment_statistics_node_comment_timestamp_idx ON node_comment_statistics USING btree (last_comment_timestamp);
+
+
+--
+-- Name: node_language_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_language_idx ON node USING btree (language);
+
+
+--
+-- Name: node_node_changed_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_node_changed_idx ON node USING btree (changed);
+
+
+--
+-- Name: node_node_created_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_node_created_idx ON node USING btree (created);
+
+
+--
+-- Name: node_node_frontpage_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_node_frontpage_idx ON node USING btree (promote, status, sticky, created);
+
+
+--
+-- Name: node_node_status_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_node_status_type_idx ON node USING btree (status, type, nid);
+
+
+--
+-- Name: node_node_title_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_node_title_type_idx ON node USING btree (title, substr((type)::text, 1, 4));
+
+
+--
+-- Name: node_node_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_node_type_idx ON node USING btree (substr((type)::text, 1, 4));
+
+
+--
+-- Name: node_revision_nid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_revision_nid_idx ON node_revision USING btree (nid);
+
+
+--
+-- Name: node_revision_uid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_revision_uid_idx ON node_revision USING btree (uid);
+
+
+--
+-- Name: node_tnid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_tnid_idx ON node USING btree (tnid);
+
+
+--
+-- Name: node_translate_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_translate_idx ON node USING btree (translate);
+
+
+--
+-- Name: node_uid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX node_uid_idx ON node USING btree (uid);
+
+
+--
+-- Name: queue_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX queue_expire_idx ON queue USING btree (expire);
+
+
+--
+-- Name: queue_name_created_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX queue_name_created_idx ON queue USING btree (name, created);
+
+
+--
+-- Name: registry_hook_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX registry_hook_idx ON registry USING btree (type, weight, module);
+
+
+--
+-- Name: role_name_weight_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX role_name_weight_idx ON role USING btree (name, weight);
+
+
+--
+-- Name: role_permission_permission_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX role_permission_permission_idx ON role_permission USING btree (permission);
+
+
+--
+-- Name: search_index_sid_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_index_sid_type_idx ON search_index USING btree (sid, type);
+
+
+--
+-- Name: search_node_links_nid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX search_node_links_nid_idx ON search_node_links USING btree (nid);
+
+
+--
+-- Name: semaphore_expire_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX semaphore_expire_idx ON semaphore USING btree (expire);
+
+
+--
+-- Name: semaphore_value_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX semaphore_value_idx ON semaphore USING btree (value);
+
+
+--
+-- Name: sessions_ssid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX sessions_ssid_idx ON sessions USING btree (ssid);
+
+
+--
+-- Name: sessions_timestamp_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX sessions_timestamp_idx ON sessions USING btree ("timestamp");
+
+
+--
+-- Name: sessions_uid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX sessions_uid_idx ON sessions USING btree (uid);
+
+
+--
+-- Name: shortcut_set_users_set_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX shortcut_set_users_set_name_idx ON shortcut_set_users USING btree (set_name);
+
+
+--
+-- Name: system_system_list_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX system_system_list_idx ON system USING btree (status, bootstrap, type, weight, name);
+
+
+--
+-- Name: system_type_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX system_type_name_idx ON system USING btree (type, name);
+
+
+--
+-- Name: taxonomy_index_nid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX taxonomy_index_nid_idx ON taxonomy_index USING btree (nid);
+
+
+--
+-- Name: taxonomy_index_term_node_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX taxonomy_index_term_node_idx ON taxonomy_index USING btree (tid, sticky, created);
+
+
+--
+-- Name: taxonomy_term_data_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX taxonomy_term_data_name_idx ON taxonomy_term_data USING btree (name);
+
+
+--
+-- Name: taxonomy_term_data_taxonomy_tree_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX taxonomy_term_data_taxonomy_tree_idx ON taxonomy_term_data USING btree (vid, weight, name);
+
+
+--
+-- Name: taxonomy_term_data_vid_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX taxonomy_term_data_vid_name_idx ON taxonomy_term_data USING btree (vid, name);
+
+
+--
+-- Name: taxonomy_term_hierarchy_parent_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX taxonomy_term_hierarchy_parent_idx ON taxonomy_term_hierarchy USING btree (parent);
+
+
+--
+-- Name: taxonomy_vocabulary_list_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX taxonomy_vocabulary_list_idx ON taxonomy_vocabulary USING btree (weight, name);
+
+
+--
+-- Name: tripal_custom_tables_table_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_custom_tables_table_id_idx ON tripal_custom_tables USING btree (table_id);
+
+
+--
+-- Name: tripal_jobs_job_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_jobs_job_id_idx ON tripal_jobs USING btree (job_id);
+
+
+--
+-- Name: tripal_jobs_job_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_jobs_job_name_idx ON tripal_jobs USING btree (job_name);
+
+
+--
+-- Name: tripal_mviews_mview_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_mviews_mview_id_idx ON tripal_mviews USING btree (mview_id);
+
+
+--
+-- Name: tripal_node_variables_tripal_node_variables_idx1_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_node_variables_tripal_node_variables_idx1_idx ON tripal_node_variables USING btree (variable_id);
+
+
+--
+-- Name: tripal_toc_tripal_toc_idx1_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_toc_tripal_toc_idx1_idx ON tripal_toc USING btree (node_type, key);
+
+
+--
+-- Name: tripal_toc_tripal_toc_idx2_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_toc_tripal_toc_idx2_idx ON tripal_toc USING btree (node_type, key, nid);
+
+
+--
+-- Name: tripal_variables_tripal_variable_names_idx1_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX tripal_variables_tripal_variable_names_idx1_idx ON tripal_variables USING btree (variable_id);
+
+
+--
+-- Name: url_alias_alias_language_pid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX url_alias_alias_language_pid_idx ON url_alias USING btree (alias, language, pid);
+
+
+--
+-- Name: url_alias_source_language_pid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX url_alias_source_language_pid_idx ON url_alias USING btree (source, language, pid);
+
+
+--
+-- Name: users_access_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX users_access_idx ON users USING btree (access);
+
+
+--
+-- Name: users_created_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX users_created_idx ON users USING btree (created);
+
+
+--
+-- Name: users_mail_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX users_mail_idx ON users USING btree (mail);
+
+
+--
+-- Name: users_picture_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX users_picture_idx ON users USING btree (picture);
+
+
+--
+-- Name: users_roles_rid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX users_roles_rid_idx ON users_roles USING btree (rid);
+
+
+--
+-- Name: views_display_vid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX views_display_vid_idx ON views_display USING btree (vid, "position");
+
+
+--
+-- Name: watchdog_severity_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX watchdog_severity_idx ON watchdog USING btree (severity);
+
+
+--
+-- Name: watchdog_type_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX watchdog_type_idx ON watchdog USING btree (type);
+
+
+--
+-- Name: watchdog_uid_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX watchdog_uid_idx ON watchdog USING btree (uid);
+
+
+--
+-- Name: tripal_custom_tables_fk1; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY tripal_custom_tables
+ ADD CONSTRAINT tripal_custom_tables_fk1 FOREIGN KEY (mview_id) REFERENCES tripal_mviews(mview_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+
+--
+-- Name: public; Type: ACL; Schema: -; Owner: -
+--
+
+REVOKE ALL ON SCHEMA public FROM PUBLIC;
+REVOKE ALL ON SCHEMA public FROM postgres;
+GRANT ALL ON SCHEMA public TO postgres;
+GRANT ALL ON SCHEMA public TO PUBLIC;
+
+
+--
+-- PostgreSQL database dump complete
+--
+
diff --git a/schema/filter.drupal7.chado.mcl.txt b/schema/filter.drupal7.chado.mcl.txt
new file mode 100644
index 0000000..008f08f
--- /dev/null
+++ b/schema/filter.drupal7.chado.mcl.txt
@@ -0,0 +1,60 @@
+contact
+contactprop
+cv
+cvterm_relationship
+cvterm
+cvtermprop
+cvtermsynonym
+db
+dbxref
+dbxrefprop
+eimage
+eimageprop
+feature
+feature_cvterm
+feature_dbxref
+feature_genotype
+feature_iamge
+feature_project
+feature_pub
+feature_relationship
+feature_synonym
+featuremap
+featuremap_contact
+featuremap_organism
+featuremap_pub
+featuremap_stock
+featuremapprop
+featurepos
+featureposprop
+featureprop
+genotype
+library
+library_contact
+library_pub
+library_synonym
+libraryprop
+nd_experiment
+nd_experiment_genotype
+nd_experiment_phenotype
+nd_experiment_project
+nd_experiment_stock
+nd_experimentprop
+nd_geolocation
+nd_geolocationprop
+organism
+organism_dbxref
+organism_pub
+phenotype
+project
+project_contact
+project_pub
+project_relationship
+projectprop
+pub
+stock
+stock_dbxref
+stock_pub
+stock_relationship
+stockprop
+synonym
diff --git a/schema/filter.drupal7.public.bims.txt b/schema/filter.drupal7.public.bims.txt
new file mode 100644
index 0000000..2560202
--- /dev/null
+++ b/schema/filter.drupal7.public.bims.txt
@@ -0,0 +1,16 @@
+bims_crop
+bims_crop_organism
+bims_user
+bims_descriptor_group
+bims_descriptor
+bims_list
+bims_mview_type
+bims_mview
+bims_file
+bims_job
+bims_instruction
+bims_node
+bims_node_relationship
+bims_location
+bims_node_location
+bims_dataset_stats
diff --git a/schema/filter.drupal7.public.mcl.txt b/schema/filter.drupal7.public.mcl.txt
new file mode 100644
index 0000000..fafa551
--- /dev/null
+++ b/schema/filter.drupal7.public.mcl.txt
@@ -0,0 +1,6 @@
+mcl_file
+mcl_job
+mcl_template
+mcl_template_type
+mcl_user
+mcl_var
diff --git a/theme/css/mcl.css b/theme/css/mcl.css
new file mode 100644
index 0000000..d105a68
--- /dev/null
+++ b/theme/css/mcl.css
@@ -0,0 +1,3 @@
+fieldset legend {
+ width : 100%;
+}
\ No newline at end of file
diff --git a/theme/js/mcl.js b/theme/js/mcl.js
new file mode 100644
index 0000000..70a6b2d
--- /dev/null
+++ b/theme/js/mcl.js
@@ -0,0 +1,31 @@
+(function($) {
+
+ // Deals with functionality that integrates with Drupal.
+ Drupal.behaviors.mcl = {
+ attach: function (context, settings) {
+
+ // Adds a confirmation dialog before perform an ajax action.
+ $('.mcl-confirm').each(function() {
+ Drupal.ajax[this.id].beforeSend = function (xmlhttprequest, options) {
+ if(confirm('Please click "OK" to confirm this action?')) {
+ return true;
+ }
+ xmlhttprequest.abort();
+ }
+ });
+
+ // Loads the log file on the viewer.
+ $(".mcl_log").click(function() {
+ var id_viewer = '#' + $(this).attr("viewer-id");
+ $.ajax({
+ url : $(this).attr("log-file"),
+ dataType: "text",
+ success : function (data) {
+ $(id_viewer).html(data.replace(/\n/g, '
'));
+ }
+ });
+ });
+
+ } // End of attach.
+ }; // End of Drupal.behaviors.mcl
+})(jQuery);
\ No newline at end of file