123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <?php
- function blast_ui_blast_linkout_info() {
- $types = array();
- $types['link'] = array(
-
-
- 'name' => 'Generic Link',
-
-
-
- 'process function' => 'tripal_blast_generate_linkout_link',
- );
- $types['gbrowse'] = array(
- 'name' => 'GBrowse',
- 'process function' => 'tripal_blast_generate_linkout_gbrowse',
- );
- $types['jbrowse'] = array(
- 'name' => 'JBrowse',
- 'process function' => 'tripal_blast_generate_linkout_jbrowse',
- );
- return $types;
- }
- function tripal_blast_generate_linkout_link($url_prefix, $hit, $info, $options = array()) {
- if (isset($hit->{'linkout_id'})) {
- return $url_prefix . $hit->{'linkout_id'};
- }
- else {
- return FALSE;
- }
- }
- function tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info, $options = array()) {
- $ranges = array();
- $coords = array();
- foreach($info['HSPs'] as $hsp) {
- $start = min($hsp['Hsp_hit-from'], $hsp['Hsp_hit-to']);
- $stop = max($hsp['Hsp_hit-from'], $hsp['Hsp_hit-to']);
- array_push($ranges, "$start..$stop");
- array_push($coords, $start, $stop);
- }
- $min = min($coords);
- $max = max($coords);
- $joined_ranges = join ("," , $ranges);
- $track_name = $hit->{'hit_name'} . '_' . $info['query_name'] . '_' . $info['e-value'];
-
- $url_postfix = 'query=';
- $url_postfix .= 'start=' . $min . ';stop=' . $max;
- $url_protfix .= ';ref=' . $hit->{'hit_name'};
- $url_postfix .= ';add=' . $hit->{'hit_name'} . '+BLAST+Query+' . $joined_ranges;
- $url_postfix .= ';h_feat=Query';
- return $url_prefix . $url_postfix;
- }
- function tripal_blast_generate_linkout_jbrowse($url_prefix, $hit, $info, $options = array()) {
- $ranges = array();
- $coords = array();
- $hsps = array();
- foreach($info['HSPs'] as $hsp) {
- $hsp_start = $hsp['Hsp_hit-from'];
- $hsp_end = $hsp['Hsp_hit-to'] ;
- array_push($coords,$hsp['Hsp_hit-from'] , $hsp['Hsp_hit-to'] );
- array_push($ranges, '{"start":'.$hsp_start.',"end":'.$hsp_end.',"type":"match_part"}');
- }
- $min = min($coords);
- $max = max($coords);
- $url_postfix = '&addFeatures=[{"seq_id":"'.$hit->{'hit_name'}.'","score":"'.$info['e-value'].'","start":'.$min.',"end":'.$max.',"type":"match","name":"MyBLASTHit","subfeatures":[';
- $joined_ranges = join ("," , $ranges);
- $url_postfix = $url_postfix . $joined_ranges . ']}]&addTracks=[{"label":"BLAST","type":"JBrowse/View/Track/HTMLFeatures","store":"url"}]&loc='.$hit->{'hit_name'}.'&tracks=DNA%2CBLAST&highlight=';
- return $url_prefix . $url_postfix;
- }
|