Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate correct links to polypeptide feature pages for phylotr... #1

Open
wants to merge 3 commits into
base: abims
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions includes/tripal_linkout.inc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function gene_linkout_json($gene) {
$result = chado_query($sql, $args);
$fields = $result->fetchAssoc();


// Get mRNA from gene
$sql = "SELECT f2.uniquename AS mrna_uniquename, f2.feature_id AS mrna_id
FROM chado.feature f, chado.feature_relationship fr, chado.feature f2
Expand Down Expand Up @@ -52,7 +51,7 @@ function gene_linkout_json($gene) {
$fields['pep_uniquename'] = $new_fields['pep_uniquename'];
$fields['pep_name'] = $new_fields['pep_name'];

full_gene_linkout_json($fields['genus'], $fields['species'], $fields['pep_name'], $fields['pep_uniquename'], $fields['mrna_uniquename'], $gene, FALSE, $fields['organism_id']);
full_gene_linkout_json($fields['genus'], $fields['species'], $fields['species_split'], $fields['pep_name'], $fields['pep_uniquename'], $fields['mrna_uniquename'], $gene, FALSE, $fields['organism_id']);
}

function family_representative_linkout_json($genus, $species, $family_representative) {
Expand Down Expand Up @@ -89,7 +88,7 @@ function family_representative_linkout_json($genus, $species, $family_representa
full_gene_linkout_json($genus, $species, $fields['pep_name'], $fields['pep_uniquename'], $family_representative, $fields['gene_uniquename'], TRUE, $fields['organism_id']);
}

function full_gene_linkout_json($genus, $species, $pep_name, $pep_uniquename, $transcript_name, $gene_name, $show_gcv=TRUE, $organism_id=NULL) {
function full_gene_linkout_json($genus, $species, $species_split, $pep_name, $pep_uniquename, $transcript_name, $gene_name, $show_gcv=FALSE, $organism_id=NULL) {
$link = [];
global $base_url;

Expand All @@ -105,10 +104,13 @@ function full_gene_linkout_json($genus, $species, $pep_name, $pep_uniquename, $t
if(getenv("MAIN_TRIPAL_URL")){
$gogepp_url = getenv("MAIN_TRIPAL_URL");
} else {
$gogepp_url = 'https://'.$current_gogepp.'.genouest.org';
$gogepp_url = 'https://'.$current_gogepp.'.genouest.org'; // change for production?
}

$species = str_replace(' ', '-', $species);
// Split species var to get only the first part of the string (containing only the "species" name)
$species_exploded = explode("-", $species);
$species_split = $species_exploded[0];

$sp_links = array();
$sp_links['bombyx_mori'] = array('http://sgp.dna.affrc.go.jp/KAIKObase/keyword_search.php?keyword=%pep_uniquename%&field=all&chr_id=all&scaf_id=&data_set%5B%5D=gene&graph_view=on');
Expand Down Expand Up @@ -145,38 +147,33 @@ function full_gene_linkout_json($genus, $species, $pep_name, $pep_uniquename, $t
'%genus%' => $genus,
'%lower_genus%' => strtolower($genus),
'%species%' => $species,
'%species_split%' => $species_split,
'%pep_name%' => $pep_name,
'%pep_uniquename%' => $pep_uniquename,
'%pep_uniquename_noPA%' => $pep_uniquename_noPA,
'%gene_name%' => $gene_name,
'%transcript_name%' => $transcript_name,
);

if (array_key_exists($org_str, $sp_links)) {
foreach ($sp_links[$org_str] as $key => $linkstr) {
$link[] = array(
'href' => str_replace(array_keys($replacements), $replacements, $linkstr),
'text' => 'View page for: ' . $pep_uniquename,
);
}
}
else if (! in_array($org_str, $no_links)) {
if (isset($pep_uniquename)) {
$default_url = $gogepp_url . '/sp/%lower_genus%_%species%/feature/%genus%/%species%/polypeptide/%pep_uniquename%';
$link[] = array(
'href' => str_replace(array_keys($replacements), $replacements, $default_url),
'text' => 'View page for: ' . $pep_uniquename,
);
}
if (isset($pep_uniquename)) {
$default_url = $gogepp_url . '/sp/%lower_genus%_%species_split%/feature/%genus%/%species%/polypeptide/%pep_name%';
$link[] = array(
'href' => str_replace(array_keys($replacements), $replacements, $default_url),
'text' => 'View page for: ' . $pep_uniquename,
);
}

// Don't display gcv link
$show_gcv = False;


if (!empty($gene_name) && $show_gcv) {
$org = '';
if (!empty($organism_id)) {
$org = "/$organism_id";
}
if (substr($base_url, -6) === 'tripal')
$default_url = $base_url . '/../gcv/#/search/'.$current_gogepp.$org.'/%gene_name%';
$default_url = $base_url . '/../gcv#/search/'.$current_gogepp.$org.'/%gene_name%';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this removal necessary or a mistake ?

else
$default_url = $base_url . '/gcv/#/search/'.$current_gogepp.$org.'/%gene_name%';

Expand Down