3.0, ); } /** * Implements hook_help(). * * Display help and module information * * @param * path which path of the site we're displaying help * @param * arg array that holds the current path as would be returned from arg() function * * @return * help text for the path * * @ingroup tripal_feature */ function tripal_feature_help($path, $arg) { $output = ''; switch ($path) { case "admin/help#tripal_feature": $output='
' . t("Displays links to nodes created on this date") . '
'; break; } return $output; } /** * Implements hook_permission(). * * Set the permission types that the chado module uses. Essentially we * want permissionis that protect creation, editing and deleting of chado * data objects * * @ingroup tripal_feature */ function tripal_feature_permission() { return array( /* 'access chado_feature content' => array( 'title' => t('View Features'), 'description' => t('Allow users to view feature pages.'), ), 'create chado_feature content' => array( 'title' => t('Create Features'), 'description' => t('Allow users to create new feature pages.'), ), 'delete chado_feature content' => array( 'title' => t('Delete Features'), 'description' => t('Allow users to delete feature pages.'), ), 'edit chado_feature content' => array( 'title' => t('Edit Features'), 'description' => t('Allow users to edit feature pages.'), ), 'administer tripal feature' => array( 'title' => t('Administer Features'), 'description' => t('Allow users to administer all features.'), ), */ ); } /** * Implements hook_menu(). * * Menu items are automatically added for the new node types created * by this module to the 'Create Content' Navigation menu item. This function * adds more menu items needed for this module. * * @ingroup tripal_feature */ function tripal_feature_menu() { $items = array(); // the administative settings menu $items['find/sequences'] = array( 'title' => 'Sequence Retrieval', 'description' => 'Download a file of sequences', 'page callback' => 'tripal_feature_seq_extract_page', 'access arguments' => array('access chado_feature content'), 'type' => MENU_CALLBACK, ); $items['find/sequences/ajax'] = array( 'title' => 'Sequence Retrieval', 'page callback' => 'tripal_feature_seq_extract_form_ahah_update', 'access arguments' => array('access chado_feature content'), 'type' => MENU_CALLBACK, ); // the menu link for addressing any feature (by name, uniquename, synonym) $items['feature/%'] = array( 'page callback' => 'tripal_feature_match_features_page', 'page arguments' => array(1), 'access arguments' => array('access chado_feature content'), 'type' => MENU_LOCAL_TASK, ); // the administative settings menu $items['admin/tripal/legacy/tripal_feature'] = array( 'title' => 'Features', 'description' => 'A biological sequence or a section of a biological sequence, or a collection of such sections.', 'page callback' => 'tripal_feature_admin_feature_view', 'access arguments' => array('administer tripal feature'), 'type' => MENU_NORMAL_ITEM, ); $items['admin/tripal/legacy/tripal_feature/delete'] = array( 'title' => ' Delete', 'description' => 'Delete multiple features from Chado', 'page callback' => 'drupal_get_form', 'page arguments' => array('tripal_feature_delete_form'), 'access arguments' => array('administer tripal feature'), 'type' => MENU_LOCAL_TASK, 'weight' => 2 ); $items['admin/tripal/legacy/tripal_feature/sync'] = array( 'title' => ' Sync', 'description' => 'Create pages on this site for features stored in Chado', 'page callback' => 'drupal_get_form', 'page arguments' => array('chado_node_sync_form', 'tripal_feature', 'chado_feature'), 'access arguments' => array('administer tripal feature'), 'type' => MENU_LOCAL_TASK, 'weight' => 1 ); $items['admin/tripal/legacy/tripal_feature/chado_feature_toc'] = array( 'title' => ' TOC', 'description' => 'Manage the table of contents for feature nodes.', 'page callback' => 'drupal_get_form', 'page arguments' => array('tripal_core_content_type_toc_form', 'chado_feature'), 'access arguments' => array('administer tripal feature'), 'type' => MENU_LOCAL_TASK, 'file' => 'includes/tripal_core.toc.inc', 'file path' => drupal_get_path('module', 'tripal_core'), 'weight' => 3 ); $items['admin/tripal/legacy/tripal_feature/configuration'] = array( 'title' => 'Settings', 'description' => 'Configure the Tripal Feature module.', 'page callback' => 'drupal_get_form', 'page arguments' => array('tripal_feature_admin'), 'access arguments' => array('administer tripal feature'), 'type' => MENU_LOCAL_TASK, 'weight' => 5 ); $items['admin/tripal/legacy/tripal_feature/help'] = array( 'title' => 'Help', 'description' => 'Help with the Tripal Feature module.', 'page callback' => 'theme', 'page arguments' => array('tripal_feature_help'), 'access arguments' => array('administer tripal feature'), 'type' => MENU_LOCAL_TASK, 'weight' => 10 ); // Enable admin view $items['admin/tripal/legacy/tripal_feature/views/features/enable'] = array( 'title' => 'Enable feature Administrative View', 'page callback' => 'tripal_enable_view', 'page arguments' => array('tripal_feature_admin_features', 'admin/tripal/legacy/tripal_feature'), 'access arguments' => array('administer tripal feature'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_search_biological_data_views(). * * Adds the described views to the "Search Data" Page created by Tripal Views */ function tripal_feature_search_biological_data_views() { return array( 'tripal_feature_user_features' => array( 'machine_name' => 'tripal_feature_user_features', 'human_name' => 'Features', 'description' => 'A biological sequence or a section of a biological sequence, or a collection of such sections.', 'link' => 'chado/feature' ), ); } /** * Implements hook_theme(). * * We need to let drupal know about our theme functions and their arguments. * We create theme functions to allow users of the module to customize the * look and feel of the output generated in this module * * @ingroup tripal_feature */ function tripal_feature_theme($existing, $type, $theme, $path) { $core_path = drupal_get_path('module', 'tripal_core'); // Feature Node Page Templates. $items = array( 'node__chado_feature' => array( 'template' => 'node--chado-generic', 'render element' => 'node', 'base hook' => 'node', 'path' => "$core_path/theme/templates", ), 'tripal_feature_alignments' => array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_alignments', 'path' => "$path/theme/templates", ), 'tripal_feature_analyses' => array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_analyses', 'path' => "$path/theme/templates", ), 'tripal_feature_base' => array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_base', 'path' => "$path/theme/templates", ), 'tripal_feature_sequence' => array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_sequence', 'path' => "$path/theme/templates", ), 'tripal_feature_proteins' => array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_proteins', 'path' => "$path/theme/templates", ), 'tripal_feature_publications' => array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_publications', 'path' => "$path/theme/templates", ), 'tripal_feature_synonyms' => array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_synonyms', 'path' => "$path/theme/templates", ), 'tripal_feature_references' => array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_references', 'path' => "$path/theme/templates", ), 'tripal_feature_properties' => array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_properties', 'path' => "$path/theme/templates", ), 'tripal_feature_terms' => array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_terms', 'path' => "$path/theme/templates", ), 'tripal_feature_relationships' => array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_relationships', 'path' => "$path/theme/templates", ), ); // Feature Node Teaser $items['tripal_feature_teaser'] = array( 'variables' => array('node' => NULL), 'template' => 'tripal_feature_teaser', 'path' => "$path/theme/templates", ); // Templates for other node pages. // Organism Feature Browser. $items['tripal_organism_feature_browser'] = array( 'variables' => array('node' => NULL), 'template' => 'tripal_organism_feature_browser', 'path' => "$path/theme/templates", ); $items['tripal_organism_feature_counts'] = array( 'variables' => array('node' => NULL), 'template' => 'tripal_organism_feature_counts', 'path' => "$path/theme/templates", ); // Administrative Help Template. $items['tripal_feature_help'] = array( 'template' => 'tripal_feature_help', 'variables' => array(NULL), 'path' => "$path/theme/templates" ); // Themed Forms $items['tripal_feature_seq_extract_form'] = array( 'arguments' => array('form'), ); // D3 Charts. // Feature Type/Organism Stacked Bar Chart. $items['tripal_feature_bar_chart_type_organism_summary'] = array( 'template' => 'tripal_feature_bar_chart_type_organism_summary', 'variables' => array(NULL), 'path' => "$path/theme/templates" ); return $items; } /** * Implements hook_job_describe_args() in order to describe the various feature jobs * to the tripal jobs interface. * * @ingroup tripal_feature */ function tripal_feature_job_describe_args($callback, $args) { $new_args = array(); if ($callback == 'tripal_feature_load_fasta') { $new_args['FASTA file'] = $args[0]; $organism = chado_select_record('organism', array('genus', 'species'), array('organism_id' => $args[1])); $new_args['Organism'] = $organism[0]->genus . " " . $organism[0]->species; $new_args['Sequence Type'] = $args[2]; $new_args['Name Match Type'] = $args[14]; $new_args['Name RE'] = $args[4]; $new_args['Unique Name RE'] = $args[5]; // add in the relationship arguments $new_args['Relationship Type'] = $args[8]; $new_args['Relationship Parent RE'] = $args[9]; $new_args['Relationship Parent Type'] = $args[10]; // add in the database reference arguments if ($args[7]) { $db = chado_select_record('db', array('name'), array('db_id' => $args[7])); } $new_args['Database Reference'] = $db[0]->name; $new_args['Accession RE'] = $args[6]; $new_args['Method'] = $args[11]; // add in the analysis if ($args[13]) { $analysis = chado_select_record('analysis', array('name'), array('analysis_id' => $args[13])); } $new_args['Analysis'] = $analysis[0]->name; } if ($callback == 'tripal_feature_delete_features') { if ($args[0]) { $organism = chado_select_record('organism', array('genus', 'species'), array('organism_id' => $args[0])); $new_args['Organism'] = $organism[0]->genus . " " . $organism[0]->species; } else { $new_args['Organism'] = ''; } if ($args[1]) { $analysis = chado_select_record('analysis', array('name'), array('analysis_id' => $args[1])); $new_args['Analysis'] = $analysis[0]->name; } else { $new_args['Analysis'] = ''; } $new_args['Sequence Type'] = $args[2]; $new_args['Is Unique Name'] = $args[3] ? 'Yes' : 'No'; $new_args['Features Names'] = $args[4]; } elseif ($callback == 'tripal_feature_load_gff3') { $new_args['GFF File'] = $args[0]; $organism = chado_select_record('organism', array('genus', 'species'), array('organism_id' => $args[1])); $new_args['Organism'] = $organism[0]->genus . " " . $organism[0]->species; $analysis = chado_select_record('analysis', array('name'), array('analysis_id' => $args[2])); $new_args['Analysis'] = $analysis[0]->name; $new_args['Use a Transaction'] = ($args[7] == 1) ? "Yes" : "No"; $new_args['Import only new features'] = ($args[3] == 1) ? "Yes" : "No"; $new_args['Import all and update'] = ($args[4] == 1) ? "Yes" : "No"; $new_args['Import all and replace'] = ($args[5] == 1) ? "Yes" : "No"; $new_args['Delete features'] = ($args[6] == 1) ? "Yes" : "No"; if ($args[8]) { $target_organism = chado_select_record('organism', array('genus', 'species'), array('organism_id' => $args[8])); $new_args['Target organism'] = $target_organism[0]->genus . " " . $target_organism[0]->species; } else { $new_args['Target organism'] = ''; } $new_args['Target type'] = $args[9]; $new_args['Create target'] = ($args[10] == 1) ? "Yes" : "No"; $new_args['Starting line'] = $args[11]; $new_args['Landmark Type'] = $args[12]; $new_args['Alternate ID attribute'] = $args[13]; $new_args['Create Organism'] = ($args[14] == 1) ? "Yes" : "No"; } return $new_args; } /** * Implements hook_coder_ignore(). * * Defines the path to the file (tripal_core.coder_ignores.txt) where ignore rules for * coder are stored * * @ingroup tripal_feature */ function tripal_feature_coder_ignore() { return array( 'path' => drupal_get_path('module', 'tripal_feature'), 'line prefix' => drupal_get_path('module', 'tripal_feature'), ); } /* * Uses the value provided in the $id argument to find all features that match * that ID by name, featurename or synonym. If it matches uniquenly to a single * feature it will redirect to that feature page, otherwise, a list of matching * features is shown. * * @ingroup tripal_feature */ function tripal_feature_match_features_page($id) { // first check to see if the URL (e.g. /feature/$id) is already // assigned to a node. If so, then just go there. Otherwise, // try to find the feature. $sql = " SELECT source FROM {url_alias} WHERE alias = :alias "; $match = db_query($sql, array(':alias' => "feature/$id"))->fetchObject(); if ($match) { drupal_goto($match->source); return; } $sql = " SELECT F.name, F.uniquename, F.feature_id, O.genus, O.species, O.organism_id, CVT.cvterm_id, CVT.name as type_name, CF.nid, array_agg(S.name) as synonyms FROM {feature} F INNER JOIN {organism} O on F.organism_id = O.organism_id INNER JOIN {cvterm} CVT on CVT.cvterm_id = F.type_id LEFT JOIN {feature_synonym} FS on FS.feature_id = F.feature_id LEFT JOIN {synonym} S on S.synonym_id = FS.synonym_id INNER JOIN {chado_feature} CF on CF.feature_id = F.feature_id WHERE F.uniquename = :uname or F.name = :fname or S.name = :sname GROUP BY F.name, F.uniquename, F.feature_id, O.genus, O.species, O.organism_id, CVT.cvterm_id, CVT.name, CF.nid "; $args = array(':uname' => $id, ':fname' => $id, ':sname' => $id); $results = chado_query($sql, $args); $num_matches = 0; // iterate through the matches and build the table for showing matches $header = array('Uniquename', 'Name', 'Type', 'Species', 'Synonyms'); $rows = array(); $curr_match; while ($match = $results->fetchObject()) { $curr_match = $match; $synonyms = $match->synonyms; $synonyms = preg_replace('/[\"\{\}]/', '', $synonyms); $rows[] = array( $match->uniquename, "nid) . "\">" . $match->name . "", $match->type_name, '' . $match->genus . ' ' . $match->species . '', $synonyms, ); $num_matches++; } // if we have more than one match then generate the table, otherwise, redirect // to the matched feature if ($num_matches == 1) { drupal_goto("node/" . $curr_match->nid); } if ($num_matches == 0) { return "No features matched the given name '$id'
"; } $table_attrs = array('class' => 'tripal-data-table'); $output = "The following features match the name '$id'.
"; $output .= theme_table($header, $rows, $table_attrs, $caption); return $output; } /** * Implementation of hook_form_alter() * * @param $form * @param $form_state * @param $form_id * * @ingroup tripal_feature */ function tripal_feature_form_alter(&$form, &$form_state, $form_id) { if ($form_id == "tripal_feature_seq_extract_form") { // updating the form through the ahah callback sets the action of // the form to the ahah callback URL. We need to set it back // to the normal form URL $form['#action'] = url("find/sequences"); } // turn off preview button for insert/updates if ($form_id == "chado_feature_node_form") { $form['actions']['preview']['#access'] = FALSE; //remove the body field unset($form['body']); } } /** * Implements hook_exclude_field_from_