Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'json'
- module SequenceServer
- module Links
- def jbrowse
- qstart = hsps.map(&:qstart).min
- sstart = hsps.map(&:sstart).min
- qend = hsps.map(&:qend).max
- send = hsps.map(&:send).max
- first_hit_start = hsps.map(&:sstart).at(0)
- first_hit_end = hsps.map(&:send).at(0)
- organism = accession.partition('-').first
- sequence_id = accession.partition('-').last
- my_features = ERB::Util.url_encode(JSON.generate([{
- :seq_id => sequence_id,
- :start => sstart,
- :end => send,
- :type => "match",
- :subfeatures => hsps.map {
- |hsp| {
- :start => hsp.send < hsp.sstart ? hsp.send : hsp.sstart,
- :end => hsp.send < hsp.sstart ? hsp.sstart : hsp.send,
- :type => "match_part"
- }
- }
- }]))
- my_track = ERB::Util.url_encode(JSON.generate([
- {
- :label => "BLAST",
- :key => "BLAST hits",
- :type => "JBrowse/View/Track/CanvasFeatures",
- :store => "url",
- :glyph => "JBrowse/View/FeatureGlyph/Segments"
- }
- ]))
- url = "<http://10.150.2.3/jbrowse1>" \
- "?data=#{organism}" \
- "&loc=#{sequence_id}:#{first_hit_start-500}..#{first_hit_start+500}" \
- "&addFeatures=#{my_features}" \
- "&addTracks=#{my_track}" \
- "&tracks=BLAST" \
- "&highlight=#{accession}:#{first_hit_start}..#{first_hit_end}"
- {
- :order => 2,
- :title => 'JBrowse',
- :url => url,
- :icon => 'fa-external-link'
- }
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment