Skip to content
Snippets Groups Projects
Select Git revision
  • 302c7a4f84212b8771fb14019be3de33c1d30213
  • master default protected
  • dev
  • master_gitlab_inria_tripal_bipaa
  • u_pinnafitida
5 results

tripal_aphidcyc_links.tpl.php

Blame
  • tripal_aphidcyc_links.tpl.php 3.19 KiB
    <?php
    $feature = $variables['node']->feature;
    $aphidcyc_url = "http://aphidcyc.cycadsys.org/__species__/NEW-IMAGE?type=GENE&object=__feat_id__";
    
    $orgs = array(
        'pisum' => 'ACYPI',
        'glycines' => 'APHGL',
        'phylloxera' => 'DAKVI',
        'noxia' => 'DIUNO',
        'cerasi' => 'MYZCE',
        'G006' => 'MYZPE_CLONE_G006',
        'persicae' => 'MYZPE_CLONE_O',
        'padi' => 'RHOPA',
        'citrus' => 'ACYPI',
    );
    
    $current_org = strtolower($feature->organism_id->genus . ' ' . $feature->organism_id->species);
    
    foreach ($orgs as $needle => $url_chunk) {
        if (preg_match("/.*$needle.*/", $current_org) >= 1) {
            $aphidcyc_url = str_replace('__species__', $url_chunk, $aphidcyc_url);
        }
    }
    
    if (preg_match('/__species__/', $aphidcyc_url) >= 1) {
        echo 'No metabolic data available at <a href="http://aphidcyc.cycadsys.org">AphidCyc</a> for this feature.';
    }
    else if (preg_match('/pisum/', $current_org) >= 1 && preg_match('/NCBI/', $feature->analysisfeature[0]->analysis_id->name) >= 1) {
        echo 'No metabolic data available at <a href="http://aphidcyc.cycadsys.org">AphidCyc</a> for this feature.';
    }
    else if ($feature->type_id->name == 'polypeptide') {
        foreach ($feature->feature_relationship->subject_id as $rel) {
            if ($rel->object_id->type_id->name == 'mRNA') {
                $mrna_feat = chado_expand_var($rel->object_id, 'table', 'feature_relationship');
    
                if (count($mrna_feat->feature_relationship->subject_id) == 0) {
                    // In some cases we might only have mRNA with no genes (brassica napus or transcriptomes
                    $url = str_replace('__feat_id__', $mrna_feat->uniquename, $aphidcyc_url);
                    echo '<a href="' . $url . '">View metabolic data for ' . $feature->uniquename . ' on AphidCyc</a>';
                    break;
                }
                foreach ($mrna_feat->feature_relationship->subject_id as $rel_g) {
                    if ($rel_g->type_id->name == 'gene') {
                        $url = str_replace('__feat_id__', $rel_g->uniquename, $aphidcyc_url);
                        echo '<a href="' . $url . '">View metabolic data for ' . $feature->uniquename . ' on AphidCyc</a>';
                        break;
                    }
                }
            }
        }
    }
    else if ($feature->type_id->name == 'mRNA') {
        if (count($feature->feature_relationship->subject_id) == 0) {
            // In some cases we might only have mRNA with no genes (brassica napus or transcriptomes)
            $target_id = $feature->uniquename;
            $url = str_replace('__feat_id__', $feature->uniquename, $aphidcyc_url);
            echo '<a href="' . $url . '">View metabolic data for ' . $feature->uniquename . ' on AphidCyc</a>';
        }
        foreach ($feature->feature_relationship->subject_id as $rel) {
            if ($rel->object_id->type_id->name == 'gene') {
                $url = str_replace('__feat_id__', $rel->object_id->uniquename, $aphidcyc_url);
                echo '<a href="' . $url . '">View metabolic data for ' . $feature->uniquename . ' on AphidCyc</a>';
                break;
            }
        }
    }
    else if ($feature->type_id->name == 'gene') {
        $url = str_replace('__feat_id__', $feature->uniquename, $aphidcyc_url);
        echo '<a href="' . $url . '">View data from metabolic model for ' . $feature->uniquename . '</a>';
    }