Skip to content
Snippets Groups Projects
Commit 8319c14e authored by Loraine Gueguen's avatar Loraine Gueguen
Browse files

Merge branch 'master_gitlab_inria_tripal_bipaa' into merge_upstream

# Conflicts:
#	template.php
#	templates/html.tpl.php
#	templates/page--front.tpl.php
#	templates/page.tpl.php
parents 5d746bfe 1c0c49e4
No related branches found
No related tags found
1 merge request!1Merge upstream
......@@ -92,7 +92,7 @@ function abims_process_page(&$variables) {
if ($variables['is_front']) {
$variables['page']['analyses'] = abims_get_analyses_from_chado();
}
$variables['page']['organisms'] = abims_get_organisms_from_chado();
$variables['page']['organisms'] = abims_get_organisms_with_versions_from_chado();
}
function abims_get_analyses_from_chado() {
......@@ -133,6 +133,9 @@ function abims_get_analyses_from_chado() {
if (preg_match('/.*\s\(?(OGS\s?[0-9.]+)\)?\b.*/i', $an->name, $m) && count($m) == 2) {
$an->guessed_version = str_replace(' ', '', $m[1]);
}
else if (preg_match('/.*\s\(?v([0-9.]+)\)?\b.*/i', $an->name, $m) && count($m) == 2) {
$an->guessed_version = str_replace(' ', '', $m[1]);
}
else if (preg_match('/.*\s\(?v?([0-9.]+)\)?\b.*/i', $an->name, $m) && count($m) == 2) {
$an->guessed_version = str_replace(' ', '', $m[1]);
}
......@@ -250,6 +253,51 @@ function abims_get_organisms_from_chado() {
return $organism_list;
}
function abims_get_organisms_with_versions_from_chado() {
$organism_list = array();
$csql = "SELECT * FROM {organism} ORDER BY genus, species";
$organisms = chado_query($csql);
$csql = "SELECT name FROM {analysis} order by analysis_id desc";
$analyses = chado_query($csql);
$versions = array();
foreach ($analyses as $an) {
if ((preg_match('/assembly/i', $an->name) || preg_match('/genome/i', $an->name)) && !preg_match('/transcriptome/i', $an->name)) {
if (preg_match('/([A-Za-z0-9]+ [A-Za-z0-9]+).+v\.?([0-9.]+)/', $an->name, $matches)) {
if (!array_key_exists($matches[1], $versions) || version_compare($matches[2], $versions[$matches[1]], '>')) {
$versions[$matches[1]] = $matches[2];
}
}
if (preg_match('/([A-Za-z0-9]+ [A-Za-z0-9]+ [A-Za-z0-9]+).+v\.?([0-9.]+)/', $an->name, $matches)) {
if (!array_key_exists($matches[1], $versions) || version_compare($matches[2], $versions[$matches[1]], '>')) {
$versions[$matches[1]] = $matches[2];
}
}
if (preg_match('/v\.?([0-9.]+).+ ([A-Za-z0-9]+ [A-Za-z0-9]+ [A-Za-z0-9]+)$/', $an->name, $matches)) {
if (!array_key_exists($matches[2], $versions) || version_compare($matches[1], $versions[$matches[2]], '>')) {
$versions[$matches[2]] = $matches[1];
}
}
if (preg_match('/v\.?([0-9.]+).+ ([A-Za-z0-9]+ [A-Za-z0-9]+)$/', $an->name, $matches)) {
if (!array_key_exists($matches[2], $versions) || version_compare($matches[1], $versions[$matches[2]], '>')) {
$versions[$matches[2]] = $matches[1];
}
}
}
}
foreach ($organisms as $organism) {
if (array_key_exists($organism->genus . ' ' . $organism->species, $versions)) {
$organism->version = $versions[$organism->genus . ' ' . $organism->species];
}
$organism_list[$organism->organism_id] = $organism;
}
return $organism_list;
}
/**
* Implements hook_preprocess_maintenance_page().
*/
......
......@@ -157,7 +157,7 @@
<?php if (getenv('ENABLE_JBROWSE')): ?>
<?php
if (getenv('ENABLE_JBROWSE') == "1")
$url = '/jbrowse';
$url = '/jbrowse/';
else
$url = getenv('ENABLE_JBROWSE');
?>
......@@ -165,14 +165,29 @@
<?php endif; ?>
<?php if (getenv('ENABLE_APOLLO')): ?>
<?php
if (getenv('ENABLE_APOLLO') == "1")
$url = '/apollo';
else
if (getenv('ENABLE_APOLLO') == "1") {
$url = $GLOBALS['base_url'] . '/apollo';
$url_report = $GLOBALS['base_url'] . '/apollo_report';
}
else {
$url = getenv('ENABLE_APOLLO');
$url_report = $url . 'report';
}
foreach ($page['organisms'] as $org_id => $org) {
if (isset($org->version)) {
$apollo_org = $org->genus . ' ' . $org->species . ' ' . $org->version;
if (strpos($url, '?') !== false)
$url .= '&organism=' . $apollo_org;
else
$url .= 'annotator/loadLink?organism=' . $apollo_org;
break;
}
}
?>
<li id="menu-item-46" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-46"><a href="<?php echo $GLOBALS['base_url'].$url; ?>">Apollo</a>
<li id="menu-item-46" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-46"><a href="<?php echo $url; ?>">Apollo</a>
<!-- <ul class="sub-menu">
<li id="menu-item-43" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-43"><a href="<?php echo $GLOBALS['base_url'].'/apollo_report'; ?>">Annotation report</a></li>
<li id="menu-item-43" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-43"><a href="<?php echo $url_report; ?>">Annotation report</a></li>
</ul>-->
</li>
<?php endif; ?>
......
......@@ -171,7 +171,7 @@ if (isset($node) && $node->type == "chado_feature") {
<?php if (getenv('ENABLE_JBROWSE')): ?>
<?php
if (getenv('ENABLE_JBROWSE') == "1")
$url = '/jbrowse';
$url = '/jbrowse/';
else
$url = getenv('ENABLE_JBROWSE');
?>
......@@ -179,14 +179,29 @@ if (isset($node) && $node->type == "chado_feature") {
<?php endif; ?>
<?php if (getenv('ENABLE_APOLLO')): ?>
<?php
if (getenv('ENABLE_APOLLO') == "1")
$url = '/apollo';
else
if (getenv('ENABLE_APOLLO') == "1") {
$url = $GLOBALS['base_url'] . '/apollo';
$url_report = $GLOBALS['base_url'] . '/apollo_report';
}
else {
$url = getenv('ENABLE_APOLLO');
$url_report = $url . 'report';
}
foreach ($page['organisms'] as $org_id => $org) {
if (isset($org->version)) {
$apollo_org = $org->genus . ' ' . $org->species . ' ' . $org->version;
if (strpos($url, '?') !== false)
$url .= '&organism=' . $apollo_org;
else
$url .= 'annotator/loadLink?organism=' . $apollo_org;
break;
}
}
?>
<li id="menu-item-46" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-46"><a href="<?php echo $GLOBALS['base_url'].$url; ?>">Apollo</a>
<li id="menu-item-46" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-46"><a href="<?php echo $url; ?>">Apollo</a>
<!--<ul class="sub-menu">
<li id="menu-item-43" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-43"><a href="<?php echo $GLOBALS['base_url'].'/apollo_report'; ?>">Annotation report</a></li>
<li id="menu-item-43" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-43"><a href="<?php echo $url_report; ?>">Annotation report</a></li>
</ul>-->
</li>
<?php endif; ?>
......
......@@ -56,6 +56,7 @@
*/
$feature = $variables['node']->feature;
$alignments = $feature->all_featurelocs;
$genome_versions = bipaa_get_organisms_with_versions_from_chado();
if(count($alignments) > 0){ ?>
<div class="tripal_feature-data-block-desc tripal-data-block-desc">The following features are aligned</div><?php
......@@ -71,6 +72,17 @@ if(count($alignments) > 0){ ?>
// https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
$rows = array();
if (getenv('ENABLE_APOLLO') == "1")
$url_apollo_base = $GLOBALS['base_url'] . '/apollo/annotator/loadLink?';
else {
// Some url was given
$url_apollo_base = getenv('ENABLE_APOLLO');
if (strpos($url_apollo_base, '?') !== false)
$url_apollo_base .= '&';
else
$url_apollo_base .= 'annotator/loadLink?';
}
foreach ($alignments as $alignment){
$feature_name = $alignment->name;
if (property_exists($alignment, 'nid')) {
......@@ -110,7 +122,7 @@ if(count($alignments) > 0){ ?>
foreach ($dlist as $delem) {
$d = explode('>', $delem);
if ($cur_org === $d[0] || substr($alignment->name, 0, strlen($d[0])) === $d[0]) {
$url = "/jbrowse?data=data/".$d[1]."&";
$url = "/jbrowse/?data=data/".$d[1]."&";
$found_link = true;
break;
}
......@@ -119,7 +131,7 @@ if(count($alignments) > 0){ ?>
if (!$found_link) {
if (getenv('ENABLE_JBROWSE') == "1")
$url = '/jbrowse?';
$url = '/jbrowse/?';
else {
// Some url was given
$url = getenv('ENABLE_JBROWSE');
......@@ -144,7 +156,7 @@ if(count($alignments) > 0){ ?>
foreach ($dlist as $delem) {
$d = explode('>', $delem);
if ($cur_org === $d[0] || substr($alignment->name, 0, strlen($d[0])) === $d[0]) {
$url = "/apollo/annotator/loadLink?organism=".$d[1]."&";
$url = $url_apollo_base."organism=".$d[1]."&";
$found_link = true;
break;
}
......@@ -152,19 +164,15 @@ if(count($alignments) > 0){ ?>
}
if (!$found_link) {
if (getenv('ENABLE_APOLLO') == "1")
$url = '/apollo/annotator/loadLink?';
else {
// Some url was given
$url = getenv('ENABLE_APOLLO');
if (strpos($url, '?') !== false)
$url .= '&';
else
$url .= '?';
$org_name = $feature->organism_id->genus . ' ' . $feature->organism_id->species;
$apollo_org = "&organism=" . $org_name;
if (array_key_exists($feature->organism_id->organism_id, $genome_versions)) {
$apollo_org .= ' ' . $genome_versions[$feature->organism_id->organism_id]->version;
}
$url = $url_apollo_base.$apollo_org;
}
$feature_loc .= " &nbsp;&nbsp; View in <a href='".$GLOBALS['base_url'].$url."loc=".$alignment->name."%3A".($alignment->fmin + 1)."..".$alignment->fmax."'>Apollo</a>";
$feature_loc .= " &nbsp;&nbsp; View in <a href='".$url."loc=".$alignment->name."%3A".($alignment->fmin + 1)."..".$alignment->fmax.$apollo_org."'>Apollo</a>";
}
$rows[] = array(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment