Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Problem with linking to jbrowse

92 views
Skip to first unread message

Alexandra Slonimsky

unread,
Jan 10, 2022, 4:32:20 AM1/10/22
to sequenceserver
Hi sequenceserver team, 

We started using s.server and we need help with adding links to our Jbrowse. 
Here is the links.rb file that was updated according to the example here:  https://jbrowse.org/docs/faq.html#how-can-i-link-blast-results-to-jbrowse

I still do not get the links... 
What do we miss???


LInks.rb file:


module SequenceServer
  # Module to contain methods for generating sequence retrieval links.
  module Links
    require 'erb'
        # Provide a method to URL encode _query parameters_. See [1].
    include ERB::Util
    #
    alias_method :encode, :url_encode
   
    NCBI_ID_PATTERN    = /gi\|(\d+)\|/
    UNIPROT_ID_PATTERN = /sp\|(\w+)\|/
    require 'json'
    # Link generators return a Hash like below.
    #
    # {
    #   # Required. Display title.
    #   :title => "title",
    #
    #   # Required. Generated url.
    #   :url => url,
    #
    #   # Optional. Left-right order in which the link should appear.
    #   :order => num,
    #
    #   # Optional. Classes, if any, to apply to the link.
    #   :class => "class1 class2",
    #
    #   # Optional. Class name of a FontAwesome icon to use.
    #   :icon => "fa-icon-class"
    # }
    #
    # If no url could be generated, return nil.
    #
    # Helper methods
    # --------------
    #
    # Following helper methods are available to help with link generation.
    #
    #   encode:
    #     URL encode query params.
    #
    #     Don't use this function to encode the entire URL. Only params.
    #
    #     e.g:
    #         sequence_id = encode sequence_id
    #         url = "http://www.ncbi.nlm.nih.gov/nucleotide/#{sequence_id}"
    #
    #   querydb:
    #     Returns an array of databases that were used for BLASTing.
    #
    #   whichdb:
    #     Returns the database from which the given hit came from.
    #
    #     e.g:
    #
    #         hit_database = whichdb
    #
    # Examples:
    # ---------
    # See methods provided by default for an example implementation.

    def sequence_viewer
      accession  = encode self.accession
      database_ids = encode querydb.map(&:id).join(' ')
      url = "get_sequence/?sequence_ids=#{accession}" \
            "&database_ids=#{database_ids}"

      {
        :order => 0,
        :url   => url,
        :title => 'Sequence',
        :class => 'view-sequence',
        :icon  => 'fa-eye'
      }
    end

    def fasta_download
      accession  = encode self.accession
      database_ids = encode querydb.map(&:id).join(' ')
      url = "get_sequence/?sequence_ids=#{accession}" \
            "&database_ids=#{database_ids}&download=fasta"

      {
        :order => 1,
        :title => 'FASTA',
        :url   => url,
        :class => 'download',
        :icon  => 'fa-download'
      }
    end

    def ncbi
      return nil unless id.match(NCBI_ID_PATTERN)
      ncbi_id = Regexp.last_match[1]
      ncbi_id = encode ncbi_id
      url = "http://www.ncbi.nlm.nih.gov/#{querydb.first.type}/#{ncbi_id}"
      {
        :order => 2,
        :title => 'NCBI',
        :url   => url,
        :icon  => 'fa-external-link'
      }
    end

    def uniprot
      return nil unless id.match(UNIPROT_ID_PATTERN)
      uniprot_id = Regexp.last_match[1]
      uniprot_id = encode uniprot_id
      url = "http://www.uniprot.org/uniprot/#{uniprot_id}"
      {
        :order => 2,
        :title => 'Uniprot',
        :url   => url,
        :icon  => 'fa-external-link'
      }
    end

    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)
           my_features = ERB::Util.url_encode(JSON.generate([{
               :seq_id => accession,
               :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://http://mysyte/pomegranate/>" \
                        "?loc=#{accession}:#{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

# [1]: https://stackoverflow.com/questions/2824126/whats-the-difference-between-uri-escape-and-cgi-escape


Thank you, 

Alex Slonimsky, PhD
Plant Sciences Institute
ARO Volcani
Israel  

Anurag Priyam

unread,
Jan 10, 2022, 1:30:44 PM1/10/22
to sequenceserver
Hi Alex,

Do you not see a ‘JBrowse’ link in the results page?

From your previous email:

You can edit links.rb file included in the sequenceserver installation, but that is generally not a good idea. You can place the file anywhere, including in /etc/sequenceserver, but you need to make sure two things. First, that the file is readable by the unix user that runs your sequenceserver instance. Second, tell sequenceserver to load this file by adding the following line to config file:

:require: ‘/path/to/links.rb'

I hope this helps. If not, you will have to give the mailing list more details, like what you tried, if there’s an error, etc.

Priyam

--
-- You received this message because you are subscribed to the Google Groups sequenceserver group. To post to this group, send email to sequenc...@googlegroups.com. To unsubscribe from this group, send email to sequenceserve...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/sequenceserver?hl=en
 
For more infomration on SequenceServer check https://sequenceserver.com
---
You received this message because you are subscribed to the Google Groups "sequenceserver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sequenceserve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sequenceserver/ede23958-56ff-4bf8-b0e5-b133a9ae4426n%40googlegroups.com.

Alexandra Slonimsky

unread,
Jan 11, 2022, 6:04:11 AM1/11/22
to sequenceserver
No, I do not see the "Jbrowse" link on the results page, no!
line ":require: ‘/path/to/links.rb'"  exists in the config file, and the file is readable!

I tried only the above really, and I do not see any error. Just no links on the sequenceserver. 
The screen that I see is attached. 

Alex
Screenshot from 2022-01-11 12-53-01.png

Anurag Priyam

unread,
Jan 12, 2022, 4:10:21 PM1/12/22
to sequenceserver
Hmm, and SequenceServer is reading databases directory, etc. from the same config file in which you put the :require: line? I ask because sometimes users don’t realise that Apache runs processes as another user, which means SequenceServer will look for the configuration file in that user’s home directory. It also influences how ~ and . in paths are expanded. To be sure, use absolute path with the :require: option.

You can try increasing verbosity of SequenceServer’s logger by setting RACK_ENV environment variable to development (maybe using SetEnv - https://httpd.apache.org/docs/2.4/mod/mod_env.html#setenv) and look for “Loading extension: /path/to/links.rb” in Apache’s logs to make sure the file is being loaded by SequenceServer.

It might be worth checking Apache’s log even otherwise to see if there is some relevant info there.

Priyam

To view this discussion on the web visit https://groups.google.com/d/msgid/sequenceserver/46d2e440-c306-4473-b08d-7ad2e3884d01n%40googlegroups.com.
<Screenshot from 2022-01-11 12-53-01.png>

Alexandra Slonimsky

unread,
Jan 13, 2022, 8:07:24 AM1/13/22
to sequenceserver
Hi,  yes. 

This is the conf file. It is in the /etc/sequenceserver/ directory:
As you see I use the absolute path...


:port: 7654
:host: 10.26.6.90
:database_dir: "/data/genome/Punica.granatum/wonderful/Index"
:num_threads: 8
:require_file: /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/lib/sequenceserver/links.rb


I also added the line  to config.ru which is in "/var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/"  and put the "links.rb"  in the same directory as well. 

When I load it  with sequenceserver -D database_dir -r links.rb I get the following:
The first lines kind of indicate that the file is loaded, isn't it?


/var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/lib/sequenceserver/links.rb:10: warning: already initialized constant SequenceServer::Links::NCBI_ID_PATTERN /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/links.rb:10: warning: previous definition of NCBI_ID_PATTERN was here /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/lib/sequenceserver/links.rb:11: warning: already initialized constant SequenceServer::Links::UNIPROT_ID_PATTERN /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/links.rb:11: warning: previous definition of UNIPROT_ID_PATTERN was here [2022-01-11 09:26:03] DEBUG Reading configuration file: /home/alex/.sequenceserver.conf. [2022-01-11 09:26:03] DEBUG Will use NCBI BLAST+ at: $PATH [2022-01-11 09:26:04] DEBUG Will use BLAST+ databases at: /data/genome/Punica.granatum/wonderful/V3/Draft [2022-01-11 09:26:04] DEBUG Found nucleotide database 'Chr0 v3' at '/data/genome/Punica.granatum/wonderful/V3/Draft/Chr0_v3.fasta' [2022-01-11 09:26:04] DEBUG Found nucleotide database 'wonderful v3' at '/data/genome/Punica.granatum/wonderful/V3/Draft/wonderful_v3.fasta' [2022-01-11 09:26:04] DEBUG Found nucleotide database 'wonderful v3 chr0' at '/data/genome/Punica.granatum/wonderful/V3/Draft/wonderful_v3_chr0.fasta' [2022-01-11 09:26:04] DEBUG Loading extension: /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/links.rb [2022-01-11 09:26:04] DEBUG Will use 1 threads to run BLAST. [2022-01-11 09:26:04] WARN Will listen on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--host option). [2022-01-11 09:26:04] INFO WEBrick 1.3.1 [2022-01-11 09:26:04] INFO ruby 2.3.1 (2016-04-26) [x86_64-linux-gnu] ** Could not bind to port 4567. Is SequenceServer already accessible at http://localhost:4567? No? Try running SequenceServer on another port, like so: sequenceserver -p 4570.

Anurag Priyam

unread,
Jan 14, 2022, 6:16:10 AM1/14/22
to sequenc...@googlegroups.com
Does it work if you change require_file to require in the config file?


On 13 Jan 2022, at 14:07, Alexandra Slonimsky <alsl...@gmail.com> wrote:

Hi,  yes. 

Alexandra Slonimsky

unread,
Jan 16, 2022, 2:48:44 AM1/16/22
to sequenceserver
No. No change. 

Anurag Priyam

unread,
Jan 16, 2022, 9:15:42 AM1/16/22
to sequenceserver
I am not sure what is happening then. You can try to debug what is happening - the file is clearly getting loaded, but why is the jbrowse method not getting called.

The methods in the links.rb file are called in line 27 of lib/sequenceserver/blast/hit.rb. You can put some puts statements there to see what’s going on. For example, ‘puts Links.instance_methods’ will show you which methods are being recognised. You will only get an output from this method when you run a BLAST search.

I would also suggest removing any ‘require’ statement that you may have put elsewhere (from your logs it looked like you put a require ‘path/to/links.rb’ somewhere in the code) and let sequenceserver load the file (using the :require: or -r option).

Priyam

Alexandra Slonimsky

unread,
Jan 17, 2022, 8:44:51 AM1/17/22
to sequenceserver
Hi 
I removed the links.rb from another place, and now I have it once and only in the folder that is mentioned in conf file. 
I load it successfully, but then, when blasting i get the following message:

  URI::InvalidURIError - bad URI(is not URI?): <10.26.6.90/pomegranate/>?loc=Chr8:18771420..18772420&addFeatures=%5B%7B%22seq_id%22%3A%22Chr8%22%2C%22start%22%3A18771920%2C%22end%22%3A20988172%2C%22type%22%3A%22match%22%2C%22subfeatures%22%3A%5B%7B%22start%22%3A18771920%2C%22end%22%3A18771933%2C%22type%22%3A%22match_part%22%7D%2C%7B%22start%22%3A20988172%2C%22end%22%3A20988185%2C%22type%22%3A%22match_part%22%7D%5D%7D%5D&addTracks=%5B%7B%22label%22%3A%22BLAST%22%2C%22key%22%3A%22BLAST%20hits%22%2C%22type%22%3A%22JBrowse%2FView%2FTrack%2FCanvasFeatures%22%2C%22store%22%3A%22url%22%2C%22glyph%22%3A%22JBrowse%2FView%2FFeatureGlyph%2FSegments%22%7D%5D&tracks=BLAST&highlight=Chr8:18771920..18771933: /usr/lib/ruby/2.3.0/uri/rfc3986_parser.rb:67:in `split' /usr/lib/ruby/2.3.0/uri/rfc3986_parser.rb:73:in `parse' /usr/lib/ruby/2.3.0/uri/common.rb:227:in `parse' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/lib/sequenceserver/routes.rb:75:in `absolute?' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/lib/sequenceserver/routes.rb:64:in `a' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/views/result.erb:101:in `block (4 levels) in singleton class' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/views/result.erb:100:in `each' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/views/result.erb:100:in `block (3 levels) in singleton class' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/views/result.erb:59:in `each' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/views/result.erb:59:in `block (2 levels) in singleton class' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/views/result.erb:5:in `each' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/views/result.erb:5:in `each_with_index' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/views/result.erb:5:in `block in singleton class' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/views/result.erb:-6:in `instance_eval' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/views/result.erb:-6:in `singleton class' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/views/result.erb:-9:in `__tilt_19800320' /var/lib/gems/2.3.0/gems/tilt-2.0.9/lib/tilt/template.rb:170:in `call' /var/lib/gems/2.3.0/gems/tilt-2.0.9/lib/tilt/template.rb:170:in `evaluate' /var/lib/gems/2.3.0/gems/tilt-2.0.9/lib/tilt/template.rb:109:in `render' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:823:in `render' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:667:in `erb' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/lib/sequenceserver/routes.rb:135:in `block in <class:Routes>' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1611:in `call' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1611:in `block in compile!' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:975:in `block (3 levels) in route!' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:994:in `route_eval' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:975:in `block (2 levels) in route!' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1015:in `block in process_route' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1013:in `catch' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1013:in `process_route' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:973:in `block in route!' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:972:in `each' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:972:in `route!' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1085:in `block in dispatch!' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `block in invoke' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `catch' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `invoke' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1082:in `dispatch!' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:907:in `block in call!' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `block in invoke' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `catch' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `invoke' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:907:in `call!' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:895:in `call' /var/lib/gems/2.3.0/gems/rack-1.6.11/lib/rack/head.rb:13:in `call' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:182:in `call' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:2013:in `call' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1487:in `block in call' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1787:in `synchronize' /var/lib/gems/2.3.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1487:in `call' /var/lib/gems/2.3.0/gems/sequenceserver-1.0.14/lib/sequenceserver.rb:96:in `call' /var/lib/gems/2.3.0/gems/rack-1.6.11/lib/rack/handler/webrick.rb:88:in `service' /usr/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service' /usr/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run' /usr/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'


What is the problem now?

Attached is my links.rb 


           url = "<10.26.6.90/pomegranate/>" \

                        "?loc=#{accession}:#{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




Many many thanks, 
Alex

Alexandra Slonimsky

unread,
Jan 18, 2022, 10:46:18 AM1/18/22
to sequenceserver
Hi, Priyam, 

I figured it out. It was the url that I set incorrectly in the links.rb together with the incorrect placement of the file itself  (that you pointed out in your last letter). 
It works fine now! 
Many thanks, 
Alex

Anurag Priyam

unread,
Jan 18, 2022, 3:07:49 PM1/18/22
to sequenceserver

Alexandra Slonimsky

unread,
Feb 7, 2022, 6:27:49 AM2/7/22
to sequenc...@googlegroups.com
Hi again, 


So it all worked well on v1.14  and than we've updated our sequenceserver to 2.0 and here is what happens:
I have the link to Jbrowse, but when i press it - i get the error:

Request-URI Too Long

The requested URL's length exceeds the capacity limit for this server.


Apache/2.4.29 (Ubuntu) Server at genome-srv.aro.local Port 80

Is there anything to do besides changing the conf files of the Apache?
Thanks again for your help, 

Alex


You received this message because you are subscribed to a topic in the Google Groups "sequenceserver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sequenceserver/gD7NN4qJOkA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sequenceserve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sequenceserver/FAA943FF-E27A-4010-9CA0-7A7FEA4D37A8%40gmail.com.


--


Kind regards, 

Alexandra Slonimsky

Anurag Priyam

unread,
Feb 9, 2022, 11:44:49 AM2/9/22
to sequenceserver
I am a bit surprised that you get this error on migrating to 2.0 and nothing else changed?

Priyam

Alexandra Slonimsky

unread,
Feb 9, 2022, 12:39:56 PM2/9/22
to sequenc...@googlegroups.com
Nothing changed. 
Any leads where and what should I do to fix?

Alex

Anurag Priyam

unread,
Feb 9, 2022, 12:50:49 PM2/9/22
to sequenc...@googlegroups.com
Not really. I would try Apache config, as suggested by yourself.

If anything comes to light that can explain this issue, please let me know.

Priyam

Reply all
Reply to author
Forward
0 new messages