Comments (4)
Hi @bradfordcondon, sorry for not getting to this question in a timely manner! This cannot be altered through the UI and adding it would complicate the UI without adding a lot of value. That said, the suggestion of changing the track type to the more modern CanvasFeatures feels like a good generic update.
I see in the referenced issue that @almasaeed2010 has already fixed this issue in your site. Perhaps you would like to contribute the change back to the core module? That way you don't have to worry about maintenance complexity :-)
from tripal_blast.
Hello @laceysanderson
We simply changed the line where the track is defined to use CanvasFeatures as shown here
https://github.com/statonlab/tripal_blast_jbrowse/blob/master/tripal_blast_jbrowse.module#L158
$jbrowse_query['addTracks'] = 'addTracks=[{"label":"blast","key":"BLAST Result","type":"JBrowse/View/Track/CanvasFeatures","store":"url"}]';
In our case, we also wanted to specify the strand's direction by specifying -
or +
strands to display an arrow in JBrowse which had to be added to the main feature rather than sub features. So we altered the method as follows to make sure the arrow appears only if all the strands of the sub features have the same direction. Here is the full method:
function tripal_blast_generate_linkout_jbrowse($url_prefix, $hit, $info, $options = []) {
// First we need to collect the HSPs to define the ranges we want to
// display on the JBrowse.
$ranges = [];
// We also keep track of all the coordinates in order to later
// calculate the smallest and largest coordinate.
$coords = [];
$count = 0;
$strands = [];
foreach ($info['HSPs'] as $hsp) {
$count++;
$strand = '1';
$hsp_start = $hsp['Hsp_hit-from'];
$hsp_end = $hsp['Hsp_hit-to'];
// Handle alignments on the negative strand.
if (($hsp_end - $hsp_start) < 0) {
$strand = '-1';
$hsp_start = $hsp['Hsp_hit-to'];
$hsp_end = $hsp['Hsp_hit-from'];
}
$strands[] = $strand;
// Add both the start & stop to the coordinate list.
array_push($coords, $hsp['Hsp_hit-from'], $hsp['Hsp_hit-to']);
// Format the hsp for inclusion in the subfeatures section of the track later.
$hsp_def = format_string(
'{"start":!start,"end":!end,"strand":"!strand","type":"!type"}',
[
'!start' => $hsp_start,
'!end' => $hsp_end,
'!strand' => $strand,
'!type' => 'match_part',
]
);
array_push($ranges, $hsp_def);
}
// Calculate the minimum & maximum coordinates.
$min = min($coords);
$max = max($coords);
// We also want some white-space on either side of out hit
// 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 have 1/6 per side for white-space.
$buffer = round(($max - $min) / 6);
$screen_start = $min - $buffer;
$screen_end = $max + $buffer;
// Now we are finally ready to build the URL.
// First lets set the location of the hit so the JBrowse focuses in on the correct region.
$jbrowse_query = [];
$jbrowse_query['loc'] = format_string(
'loc=!ref:!start..!stop',
[
'!ref' => $hit->{'linkout_id'},
'!start' => $screen_start,
'!stop' => $screen_end,
]
);
$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]}]',
[
'!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]}]',
[
'!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.
$jbrowse_query['addTracks'] = 'addTracks=[{"label":"blast","key":"BLAST Result","type":"JBrowse/View/Track/CanvasFeatures","store":"url"}]';
$url_postfix = implode('&', $jbrowse_query);
$hit_url = $url_prefix . $url_postfix;
return l(
$hit->{'linkout_id'},
$hit_url,
['attributes' => ['target' => '_blank']]
);
}
We can create a PR if this implementation seems reasonable enough to you.
Thanks!
from tripal_blast.
Seems reasonable enough to me :-) A PR would be great
from tripal_blast.
Fixed by PRs
from tripal_blast.
Related Issues (20)
- Unable to set regex for linkouts HOT 6
- Update Test to use TripalTestSuite->actingAs() HOT 1
- Path to local db
- Blast UI jobs do not start HOT 3
- FASTA not validated properly HOT 1
- setting up blast functionality HOT 3
- non well formed numeric value HOT 22
- formatdb or makeblastdb? HOT 3
- Trimming database path HOT 1
- error loading file and segmentation fault HOT 4
- Make Tripal Gold-rated module. HOT 1
- Error - "File is not accessible" HOT 2
- max_target_seqs parameter HOT 3
- Overly aggressive regex to remove database extension in api/blast_ui.api.inc HOT 1
- Undefined variable HOT 1
- Trimming of input sequence HOT 1
- Issues with online docs HOT 2
- Blast analyses failed: "We encountered an error and are unable to load your BLAST results" HOT 4
- Upgrade to Tripal 4 + Drupal 9 HOT 10
- Progressive Display Controls HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tripal_blast.