123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- <?php
- require_once 'api/tripal_phylogeny.api.inc';
- require_once 'theme/tripal_phylogeny.theme.inc';
- require_once 'includes/tripal_phylogeny.admin.inc';
- require_once 'includes/tripal_phylogeny.chado_node.inc';
- require_once 'includes/tripal_phylogeny.import_tree.inc';
- require_once 'includes/tripal_phylogeny.taxonomy.inc';
- function tripal_phylogeny_permission() {
- return array(
- 'access chado_phylotree content' => array(
- 'title' => t('View Phylotrees'),
- 'description' => t('Allow users to view phylotree pages.'),
- ),
- 'administer tripal phylotree' => array(
- 'title' => t('Administer Phylotrees'),
- 'description' => t('Allow users to administer all phylotrees.'),
- ),
- );
- }
- function tripal_phylogeny_menu() {
- $items = array();
-
-
- $items['admin/tripal/legacy/tripal_phylogeny'] = array(
- 'title' => 'Phylogeny and Taxonomy',
- 'description' => 'Phylogenetic and taxonomic trees.',
- 'page callback' => 'tripal_phylogeny_admin_phylotrees_listing',
- 'access arguments' => array('administer tripal phylotree'),
- 'type' => MENU_NORMAL_ITEM,
- );
-
- $items['admin/tripal/legacy/tripal_phylogeny/help'] = array(
- 'title' => 'Help',
- 'description' => 'Basic Description of Tripal Phylotree Module Functionality',
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_phylogeny_help'),
- 'access arguments' => array('administer tripal phylotree'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 10
- );
-
- $items['admin/tripal/legacy/tripal_phylogeny/configuration'] = array(
- 'title' => 'Settings',
- 'description' => 'Configure the Tripal Phylotree module',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_phylogeny_admin'),
- 'access arguments' => array('administer tripal phylotree'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1
- );
- $items['admin/tripal/legacy/tripal_phylogeny/plots'] = array(
- 'title' => 'Plot Defaults',
- 'description' => 'Set defaults for the trees',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_phylogeny_default_plots_form'),
- 'access arguments' => array('administer tripal phylotree'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2
- );
-
- $items['admin/tripal/legacy/tripal_phylogeny/sync'] = array(
- 'title' => ' Sync',
- 'description' => 'Create pages on this site for phylotrees stored in Chado',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('chado_node_sync_form', 'tripal_phylogeny', 'chado_phylotree'),
- 'access arguments' => array('administer tripal phylotree'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 3
- );
-
- $items['admin/tripal/legacy/tripal_phylogeny/views/phylotree/enable'] = array(
- 'title' => 'Enable Phylotree Administrative View',
- 'page callback' => 'tripal_enable_view',
- 'page arguments' => array('tripal_phylogeny_admin_phylotree', 'admin/tripal/legacy/tripal_phylogeny'),
- 'access arguments' => array('administer tripal phylotree'),
- 'type' => MENU_CALLBACK,
- );
-
- $items['admin/tripal/loaders/newic_phylotree_loader'] = array(
- 'title' => 'Phylogenetic Trees (Newic format)',
- 'description' => 'Loads phylogenetic trees in Newic format. (Redirects to create a phylogenetic tree content type)',
- 'page callback' => 'drupal_goto',
- 'page arguments' => array('node/add/chado-phylotree'),
- 'access arguments' => array('administer tripal phylotree'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/loaders/ncbi_taxonomy_loader'] = array(
- 'title' => 'NCBI Taxonomy Loader',
- 'description' => 'Loads taxonomic details about installed organisms.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_phylogeny_taxonomy_load_form'),
- 'access arguments' => array('administer tripal phylotree'),
- 'file' => '/includes/tripal_phylogeny.taxonomy.inc',
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['taxonomy_view'] = array(
- 'title' => 'Taxonomy',
- 'description' => 'Taxonomic view of the species available on this site.',
- 'page callback' => 'tripal_phylogeny_taxonomy_view',
- 'access arguments' => array('access taxonomy content'),
- 'file' => '/includes/tripal_phylogeny.taxonomy.inc',
- 'type' => MENU_NORMAL_ITEM,
- );
-
- $items['ajax/chado_phylotree/%/json'] = array(
- 'page callback' => 'tripal_phylogeny_ajax_get_tree_json',
- 'page arguments' => array(2),
-
- 'access callback' => TRUE
- );
- return $items;
- }
- function tripal_phylogeny_search_biological_data_views() {
- return array(
- 'tripal_phylogeny_user_phylotree' => array(
- 'machine_name' => 'tripal_phylogeny_user_phylotree',
- 'human_name' => 'Phylogenetic Trees',
- 'description' => 'Gene trees, species trees, etc.',
- 'link' => 'chado/phylotree'
- ),
- );
- }
- function tripal_phylogeny_views_api() {
- return array(
- 'api' => 3.0,
- );
- }
- function tripal_phylogeny_theme($existing, $type, $theme, $path) {
- $core_path = drupal_get_path('module', 'tripal_core');
- $items = array(
-
- 'node__chado_phylotree' => array(
- 'template' => 'node--chado-generic',
- 'render element' => 'node',
- 'base hook' => 'node',
- 'path' => "$core_path/theme/templates",
- ),
-
- 'tripal_phylogeny_base' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_phylogeny_base',
- 'path' => "$path/theme/templates",
- ),
-
- 'tripal_phylogeny_phylogram' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_phylogeny_phylogram',
- 'path' => "$path/theme/templates",
- ),
-
- 'tripal_phylogeny_taxonomic_tree' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_phylogeny_taxonomic_tree',
- 'path' => "$path/theme/templates",
- ),
-
- 'tripal_phylogeny_organisms' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_phylogeny_organisms',
- 'path' => "$path/theme/templates",
- ),
-
- 'tripal_phylogeny_references' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_phylogeny_references',
- 'path' => "$path/theme/templates",
- ),
-
- 'tripal_phylogeny_analysis' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_phylogeny_analysis',
- 'path' => "$path/theme/templates",
- ),
-
- 'tripal_phylogeny_teaser' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_phylogeny_teaser',
- 'path' => "$path/theme/templates",
- ),
-
-
- 'tripal_phylogeny_admin_org_color_tables' => array(
- 'render element' => 'element',
- )
- );
- return $items;
- }
- function tripal_phylogeny_help ($path, $arg) {
- if ($path == 'admin/help#tripal_phylogeny') {
- return theme('tripal_phylogeny_help', array());
- }
- }
- function tripal_phylogeny_ajax_get_tree_json($phylotree_id) {
- $phylotree = chado_generate_var('phylotree', array('phylotree_id' => $phylotree_id));
-
-
-
-
-
-
-
- $sql = "
- SELECT
- n.phylonode_id, n.parent_phylonode_id, n.label AS name, n.distance AS length,
- f.feature_id, f.name AS feature_name,
- cvt.name AS cvterm_name,
- o.organism_id, o.common_name, o.abbreviation, o.genus, o.species,
- fo.organism_id AS fo_organism_id, fo.common_name AS fo_common_name,
- fo.abbreviation AS fo_abbreviation, fo.genus as fo_genus, fo.species AS fo_species,
- cf.nid AS feature_node_id,
- fco.nid AS fo_organism_node_id,
- co.nid AS organism_node_id
- FROM {phylonode} n
- LEFT OUTER JOIN {cvterm} cvt ON n.type_id = cvt.cvterm_id
- LEFT OUTER JOIN {feature} f ON n.feature_id = f.feature_id
- LEFT OUTER JOIN [chado_feature] cf ON cf.feature_id = f.feature_id
- LEFT OUTER JOIN {organism} fo ON f.organism_id = fo.organism_id
- LEFT OUTER JOIN [chado_organism] fco ON fco.organism_id = fo.organism_id
- LEFT OUTER JOIN {phylonode_organism} po ON po.phylonode_id = n.phylonode_id
- LEFT OUTER JOIN {organism} o ON PO.organism_id = o.organism_id
- LEFT OUTER JOIN [chado_organism] co ON co.organism_id = o.organism_id
- WHERE n.phylotree_id = :phylotree_id
- ";
- $args = array(':phylotree_id' => $phylotree_id);
- $result = chado_query($sql, $args);
-
-
-
- $phylonodes = array();
- $root_phylonode_ref = null;
- foreach ($result as $r) {
- $phylonode_id = (int) $r->phylonode_id;
-
- $node = array(
- 'phylonode_id' => $phylonode_id,
- 'parent_phylonode_id' => (int) $r->parent_phylonode_id,
- 'length' => (double) $r->length,
- 'cvterm_name' => $r->cvterm_name
- );
-
- if ($phylotree->type_id->name == 'taxonomy') {
- $node['length'] = 0.001;
- }
-
- if ($r->name) {
- $node['name'] = $r->name;
- }
-
- if ($r->feature_id) {
- $node['feature_id'] = (int) $r->feature_id;
- $node['feature_name'] = $r->feature_name;
- $node['feature_node_id'] = (int) $r->feature_node_id;
- }
-
-
- if ($r->organism_id) {
- $node['organism_id'] = (int) $r->organism_id;
- $node['common_name'] = $r->common_name;
- $node['abbreviation'] = $r->abbreviation;
- $node['genus'] = $r->genus;
- $node['species'] = $r->species;
- $node['organism_node_id'] = (int) $r->organism_node_id;
-
-
- if (!$r->name) {
- $node['name'] = $r->genus . ' ' . $r->species;
- }
- }
-
-
- if ($r->fo_organism_id) {
- $node['fo_organism_id'] = (int) $r->fo_organism_id;
- $node['fo_common_name'] = $r->fo_common_name;
- $node['fo_abbreviation'] = $r->fo_abbreviation;
- $node['fo_genus'] = $r->fo_genus;
- $node['fo_species'] = $r->fo_species;
- $node['fo_organism_node_id'] = (int) $r->fo_organism_node_id;
- }
-
- $phylonodes[$phylonode_id] = $node;
- }
-
- foreach ($phylonodes as $key => &$node) {
- if ($node['parent_phylonode_id'] !== 0) {
- $parent_ref = &$phylonodes[ $node['parent_phylonode_id']];
-
- $parent_ref['children'][] = &$node;
- }
- else {
- $root_phylonode_ref = &$node;
- }
- }
-
- drupal_json_output($root_phylonode_ref);
- }
|