Custom links per database name

Hi,

I’ve stitched together a def for links.rb that works great to generate a link to jbrowse for a single database:

`

def jbrowse

r_start = hsps.map(&:sstart).min

r_end = r_start + hsps.map(&:length).max

contig = encode self.accession

rest = encode self

url = “http://localhost/apollo/jbrowse/index.html?organism=1”\

“&highlight=#{contig}” “%3A#{r_start}…#{r_end}”\

“&loc=#{contig}” “%3A#{r_start}…#{r_end}” “&tracks=maker”

{

:order => 5,

:title => ‘View in JBrowse’,

:url => url,

:icon => ‘fa-share-square-o’

}

end

`

However, my ruby knowledge is very limited and I’m struggling to figure out how to make a custom URL dependent on the database from which the hit comes. Basically, I want to change organism=X in the example above according to a set of regular expressions that match the relevant database name. I’ve played around with whichdb (hit_database=whichdb) but get errors about arrays and structs when trying to match it.

Any chance you could suggest a solution?

Cheers,

Den

Database name is not provide by BLAST in it’s output. You can call out to whichdb (from your jbrowse method) to get a list of all databases that the hit could have come from. If your sequences have unique ids across all FASTA files / BLAST databases, you know that the only element in the list is the database that the hit came from.

SequenceServer::Database objects are returned. .name returns full path of db, .title returns the name of the db (sorry about that). (See database.rb for more info contained in database objects.)

whichdb is slow.

Alternative is to encode db info (a short name) in the sequence id, such as: Si_gnG.scaffold00002 and use regex matching to decide the value of X in organism=X.

— Priyam

Hi Priyam,

Thanks for the explanation, however, I’m not really sure how to do that. Could you suggest an example to choose between two databases using whichdb? I’m really stuck at the limit of my ruby knowledge here…

Cheers
Den

I hope this thread helps - https://groups.google.com/forum/#!searchin/sequenceserver/guy$20leonard/sequenceserver/RUOePKmK50g/t0FcGolIAQAJ