Adding links to search hits

Hi,

I just gave a first take on adding a link to search hits, linking to a JBrowse service. I’m a newbie with Ruby and something is not right. Any advice?

Here is the function added to link.rb

def jbrowse_view
hit_db = encode whichdb
accession = encode self.accession
segs = self.hsps

only use the first HSP coordinates

sstart = encode segs[0].sstart
send = encode seqs[0].send
url = “http://jbrowse.xxx.xxx/?data=data%2Fjson%2F#{hit_db}&loc=#{accession}%3A#{sstart}…#{send}&tracks=DNA&highlight=”
{
:order => 1,
:title => ‘JBrowse’,
:url => url,
:icon => ‘fa-eye’
}
end

I guess the problem is the line where I call the hsps from hit: segs = self.hsps. What is the correct way to get the HSPs?

Thanks!

Ke

Here is the error message:

I think it’s that you say ‘seqs’ instead of ‘segs’ when getting end coordinate.

(Not relevant to the issue, but I don’t think you need to encode the coordinates - they are numbers and thus won’t have any special character)

Priyam

Thanks for the help. In the end, I had to tweak a few other things to make it work. Below is the code that worked for me (if anyone is interested in similar linking functions):

def jbrowse_view
hit_dbs = whichdb
jbdb = encode hit_dbs[0].title
accession = encode self.accession
segs = self.hsps
sstart = segs[0].sstart
send = segs[0].send
#url = “http://jbrowse.xxx/?data=data%2Fjson%2F#{jbdb}&loc=#{accession}%3A#{sstart}…#{send}&tracks=DNA&highlight=”
{
:order => 1,
:title => ‘JBrowse’,
#:url => url,
:url => URI.encode(url),
:icon => ‘fa-external-link’
}
end