|
@@ -64,7 +64,7 @@ function blast_ui_blast_linkout_info() {
|
|
'require_regex' => FALSE,
|
|
'require_regex' => FALSE,
|
|
'require_db' => FALSE,
|
|
'require_db' => FALSE,
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
$types['link'] = array(
|
|
$types['link'] = array(
|
|
// Human-readable Type name to display to users in the BLAST Database
|
|
// Human-readable Type name to display to users in the BLAST Database
|
|
// create/edit form.
|
|
// create/edit form.
|
|
@@ -73,7 +73,7 @@ function blast_ui_blast_linkout_info() {
|
|
// This function will have full access to the blast hit and database
|
|
// This function will have full access to the blast hit and database
|
|
// prefix information and is expected to return a URL.
|
|
// prefix information and is expected to return a URL.
|
|
'process function' => 'tripal_blast_generate_linkout_link',
|
|
'process function' => 'tripal_blast_generate_linkout_link',
|
|
- // Help text to show in the BLAST Database create/edit form so that
|
|
|
|
|
|
+ // Help text to show in the BLAST Database create/edit form so that
|
|
// users will know how to use this link-out type. Specifically, info
|
|
// users will know how to use this link-out type. Specifically, info
|
|
// about your assumptions for the URL prefix are very helpful.
|
|
// about your assumptions for the URL prefix are very helpful.
|
|
// HTML is aloud but do not enclose in <p>.
|
|
// HTML is aloud but do not enclose in <p>.
|
|
@@ -197,13 +197,13 @@ function tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info, $option
|
|
// calculate the smallest and largest coordinate.
|
|
// calculate the smallest and largest coordinate.
|
|
$coords = array();
|
|
$coords = array();
|
|
foreach($info['HSPs'] as $hsp) {
|
|
foreach($info['HSPs'] as $hsp) {
|
|
-
|
|
|
|
|
|
+
|
|
$start = min($hsp['Hsp_hit-from'], $hsp['Hsp_hit-to']);
|
|
$start = min($hsp['Hsp_hit-from'], $hsp['Hsp_hit-to']);
|
|
$stop = max($hsp['Hsp_hit-from'], $hsp['Hsp_hit-to']);
|
|
$stop = max($hsp['Hsp_hit-from'], $hsp['Hsp_hit-to']);
|
|
-
|
|
|
|
|
|
+
|
|
// Format the hsp for inclusion in the new track later.
|
|
// Format the hsp for inclusion in the new track later.
|
|
array_push($ranges, "$start..$stop");
|
|
array_push($ranges, "$start..$stop");
|
|
-
|
|
|
|
|
|
+
|
|
// Add both the start & stop to the coordinate list.
|
|
// Add both the start & stop to the coordinate list.
|
|
array_push($coords, $start, $stop);
|
|
array_push($coords, $start, $stop);
|
|
}
|
|
}
|
|
@@ -228,7 +228,7 @@ function tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info, $option
|
|
'!hspcoords' => join ("," , $ranges),
|
|
'!hspcoords' => join ("," , $ranges),
|
|
)
|
|
)
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
// Highlight our newly added feature.
|
|
// Highlight our newly added feature.
|
|
$query['h_feat'] = 'BlastHit';
|
|
$query['h_feat'] = 'BlastHit';
|
|
|
|
|
|
@@ -236,16 +236,16 @@ function tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info, $option
|
|
$url = l(
|
|
$url = l(
|
|
$hit->{'linkout_id'},
|
|
$hit->{'linkout_id'},
|
|
$hit_url,
|
|
$hit_url,
|
|
- array(
|
|
|
|
|
|
+ array(
|
|
'query' => $query,
|
|
'query' => $query,
|
|
'attributes' => array('target' => '_blank')
|
|
'attributes' => array('target' => '_blank')
|
|
)
|
|
)
|
|
);
|
|
);
|
|
-
|
|
|
|
- // For some reason GBrowse expects semi-colons (;&) to delineate query paramters
|
|
|
|
|
|
+
|
|
|
|
+ // For some reason GBrowse expects semi-colons (;&) to delineate query paramters
|
|
// whereas Drupal throws ampherstands (&) in. This is to fix that.
|
|
// whereas Drupal throws ampherstands (&) in. This is to fix that.
|
|
$url = str_replace('&',';&', $url);
|
|
$url = str_replace('&',';&', $url);
|
|
-
|
|
|
|
|
|
+
|
|
return $url;
|
|
return $url;
|
|
|
|
|
|
}
|
|
}
|
|
@@ -259,7 +259,7 @@ function tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info, $option
|
|
* allow your default tracks to be visible and give contect to your blast hit. You
|
|
* allow your default tracks to be visible and give contect to your blast hit. You
|
|
* should include "blast" in your jbrowse.conf default track list to ensure your
|
|
* should include "blast" in your jbrowse.conf default track list to ensure your
|
|
* users can always see their hits. If you don't have access to the jbrowse.conf,
|
|
* users can always see their hits. If you don't have access to the jbrowse.conf,
|
|
- * you can place the tracks you want to see including 'blast' in the url prefix
|
|
|
|
|
|
+ * you can place the tracks you want to see including 'blast' in the url prefix
|
|
* (see example below under @param $url_prefix).
|
|
* (see example below under @param $url_prefix).
|
|
*
|
|
*
|
|
* @param $url_prefix
|
|
* @param $url_prefix
|
|
@@ -268,7 +268,7 @@ function tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info, $option
|
|
* For example,
|
|
* For example,
|
|
* http://myserver.com/jbrowse/databasica/?
|
|
* http://myserver.com/jbrowse/databasica/?
|
|
* http://myserver.com/jbrowse/databasica/?tracks=myfavtrack,anoktrack,blast&
|
|
* http://myserver.com/jbrowse/databasica/?tracks=myfavtrack,anoktrack,blast&
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param $hit
|
|
* @param $hit
|
|
* The blast XML hit object. This object has the following keys based on the
|
|
* The blast XML hit object. This object has the following keys based on the
|
|
* XML: Hit_num, Hit_id, Hit_def, Hit_accession, Hit_len and Hit_hsps.
|
|
* XML: Hit_num, Hit_id, Hit_def, Hit_accession, Hit_len and Hit_hsps.
|
|
@@ -297,20 +297,22 @@ function tripal_blast_generate_linkout_jbrowse($url_prefix, $hit, $info, $option
|
|
// calculate the smallest and largest coordinate.
|
|
// calculate the smallest and largest coordinate.
|
|
$coords = array();
|
|
$coords = array();
|
|
$count = 0;
|
|
$count = 0;
|
|
|
|
+ $strands = array();
|
|
foreach($info['HSPs'] as $hsp) {
|
|
foreach($info['HSPs'] as $hsp) {
|
|
$count++;
|
|
$count++;
|
|
-
|
|
|
|
|
|
+
|
|
$strand = '1';
|
|
$strand = '1';
|
|
$hsp_start = $hsp['Hsp_hit-from'];
|
|
$hsp_start = $hsp['Hsp_hit-from'];
|
|
$hsp_end = $hsp['Hsp_hit-to'];
|
|
$hsp_end = $hsp['Hsp_hit-to'];
|
|
-
|
|
|
|
|
|
+ $strands[] = $strand;
|
|
|
|
+
|
|
// Handle alignments on the negative strand.
|
|
// Handle alignments on the negative strand.
|
|
if (($hsp_end - $hsp_start) < 0) {
|
|
if (($hsp_end - $hsp_start) < 0) {
|
|
$strand = '-1';
|
|
$strand = '-1';
|
|
$hsp_start = $hsp['Hsp_hit-to'];
|
|
$hsp_start = $hsp['Hsp_hit-to'];
|
|
$hsp_end = $hsp['Hsp_hit-from'];
|
|
$hsp_end = $hsp['Hsp_hit-from'];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Add both the start & stop to the coordinate list.
|
|
// Add both the start & stop to the coordinate list.
|
|
array_push($coords,$hsp['Hsp_hit-from'] , $hsp['Hsp_hit-to'] );
|
|
array_push($coords,$hsp['Hsp_hit-from'] , $hsp['Hsp_hit-to'] );
|
|
|
|
|
|
@@ -329,8 +331,8 @@ function tripal_blast_generate_linkout_jbrowse($url_prefix, $hit, $info, $option
|
|
// Calculate the minimum & maximum coordinates.
|
|
// Calculate the minimum & maximum coordinates.
|
|
$min = min($coords);
|
|
$min = min($coords);
|
|
$max = max($coords);
|
|
$max = max($coords);
|
|
-
|
|
|
|
- // We also want some white-space on either side of out hit
|
|
|
|
|
|
+
|
|
|
|
+ // We also want some white-space on either side of out hit
|
|
// when we show it in the JBrowse. To make this generic,
|
|
// when we show it in the JBrowse. To make this generic,
|
|
// we want our blast hit to take up 2/3 of the screen thus
|
|
// we want our blast hit to take up 2/3 of the screen thus
|
|
// we have 1/6 per side for white-space.
|
|
// we have 1/6 per side for white-space.
|
|
@@ -350,19 +352,37 @@ function tripal_blast_generate_linkout_jbrowse($url_prefix, $hit, $info, $option
|
|
)
|
|
)
|
|
);
|
|
);
|
|
|
|
|
|
- // Next we want to add our BLAST hit to the JBrowse.
|
|
|
|
- $jbrowse_query['addFeatures'] = format_string(
|
|
|
|
- 'addFeatures=[{"seq_id":"!id","start":!min,"end":!max,"name":"!name","subfeatures":[!hspcoords]}]',
|
|
|
|
- array(
|
|
|
|
- '!id' => $hit->{'linkout_id'},
|
|
|
|
- '!name' => $info['query_name'] . ' Blast Hit',
|
|
|
|
- '!min' => $min,
|
|
|
|
- '!max' => $max,
|
|
|
|
- '!hspcoords' => join ("," , $ranges)
|
|
|
|
- ));
|
|
|
|
|
|
+ $unique_strands = array_unique($strands);
|
|
|
|
+ if (count($unique_strands) === 1) {
|
|
|
|
+ $strand = end($strands);
|
|
|
|
+ // Next we want to add our BLAST hit to the JBrowse.
|
|
|
|
+ $jbrowse_query['addFeatures'] = format_string(
|
|
|
|
+ 'addFeatures=[{"seq_id":"!id","start":!min,"end":!max,"name":"!name","strand":!strand,"subfeatures":[!hspcoords]}]',
|
|
|
|
+ array(
|
|
|
|
+ '!id' => $hit->{'linkout_id'},
|
|
|
|
+ '!name' => $info['query_name'] . ' Blast Hit',
|
|
|
|
+ '!min' => $min,
|
|
|
|
+ '!max' => $max,
|
|
|
|
+ '!hspcoords' => join(",", $ranges),
|
|
|
|
+ '!strand' => $strand,
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ $jbrowse_query['addFeatures'] = format_string(
|
|
|
|
+ 'addFeatures=[{"seq_id":"!id","start":!min,"end":!max,"name":"!name","subfeatures":[!hspcoords]}]',
|
|
|
|
+ array(
|
|
|
|
+ '!id' => $hit->{'linkout_id'},
|
|
|
|
+ '!name' => $info['query_name'] . ' Blast Hit',
|
|
|
|
+ '!min' => $min,
|
|
|
|
+ '!max' => $max,
|
|
|
|
+ '!hspcoords' => join(",", $ranges),
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
|
|
// Then add a track to display our new feature.
|
|
// Then add a track to display our new feature.
|
|
- $jbrowse_query['addTracks'] = 'addTracks=[{"label":"blast","key":"BLAST Result","type":"JBrowse/View/Track/HTMLFeatures","store":"url"}]';
|
|
|
|
|
|
+ $jbrowse_query['addTracks'] = 'addTracks=[{"label":"blast","key":"BLAST Result","type":"JBrowse/View/Track/CanvasFeatures","store":"url"}]';
|
|
|
|
|
|
$url_postfix = implode('&', $jbrowse_query);
|
|
$url_postfix = implode('&', $jbrowse_query);
|
|
|
|
|