Ensembl REST API

repository·release/116·Indexed 41 days ago

https://github.com/ensembl/ensembl-rest

A language-agnostic RESTful API providing programmatic access to Ensembl genomic data over HTTP. Includes tools for server management via server_control.pl and start_rest_server.sh, as well as CLI utilities for stable ID lookups using mysql_lookup.pl and lucy_index/lookup.pl.

Tokens
3.9K
Snippets
14
Records
18
Agent score
99%

What's inside Ensembl REST

  1. Access Ensembl data via the REST API

    release/116

    The Ensembl REST API provides language-agnostic, RESTful access to Ensembl data over HTTP. You can interact with the API by sending requests to the central REST server endpoint. This allows developers to programmatically retrieve genomic data using any programming language capable of making HTTP requests.

    http://rest.ensembl.org
  2. Quickstart: Use Highlight.js on a web page

    release/116

    To use Highlight.js on a web page, include the library and a CSS theme, then call hljs.initHighlightingOnLoad(). The library will automatically find and highlight code blocks within <pre><code> tags, attempting to auto-detect the language.

    If auto-detection fails, you can explicitly specify the language using the class attribute with the language- or lang- prefix (e.g., class="language-html").

    To prevent a specific block from being highlighted, use the no-highlight class.

    <link rel="stylesheet" href="/path/to/styles/default.css">
    <script src="/path/to/highlight.pack.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>
    
    <!-- Explicit language specification -->
    <pre><code class="html">...</code></pre>
    
    <!-- Disable highlighting for a block -->
    <pre><code class="no-highlight">...</code></pre>
  3. How to get the Highlight.js library

    release/116

    Highlight.js can be obtained in several ways:

    • Hosted or custom-build browser script: Available via the official download page.
    • Server module: For use in Node.js or other server-side environments.

    Note: The library cannot be used directly from the GitHub source; it must be built first. If the pre-packaged options do not meet your needs, you will need to follow the building documentation.

  4. Manually initialize highlighting with highlightBlock and configure

    release/116

    For more control over what and when to highlight, use hljs.highlightBlock(block) and hljs.configure(options). This allows you to target specific elements instead of relying on the automatic <pre><code> pattern.

    If you are using containers that do not preserve newlines (like <div>), you should configure Highlight.js to use <br> tags for line breaks using hljs.configure({useBR: true}).

    // Example: Manual initialization using jQuery
    $(document).ready(function() {
      $('pre code').each(function(i, block) {
        hljs.highlightBlock(block);
      });
    });
    
    // Example: Manual initialization with custom container and BR support
    hljs.configure({useBR: true});
    
    $('div.code').each(function(i, block) {
      hljs.highlightBlock(block);
    });
  5. Install Highlight.js

    release/116

    Highlight.js can be integrated in several ways:

    • CDN: Use a hosted version directly in the browser.
    • Download: Download a custom build from the official download page.
    • Server-side: Install it as a module for use in Node.js or other server environments.

    Note: The library is not intended to be used directly from the GitHub source code; it requires a specific build. If the provided builds do not meet your needs, you can follow the build documentation.

  6. Quick start with Highlight.js on a web page

    release/116

    To use Highlight.js with automatic language detection, link the library and a style sheet, then call hljs.initHighlightingOnLoad(). This method automatically finds and highlights code blocks contained within <pre><code> tags.

    If you want to manually specify a language instead of relying on automatic detection, add a class to the <code> element using the language name, or prefix it with language- or lang- (e.g., class="html" or class="language-html").

    To prevent a specific block from being highlighted, use the no-highlight class.

    <link rel="stylesheet" href="/path/to/styles/default.css">
    <script src="/path/to/highlight.pack.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>
    
    <!-- Manual language specification -->
    <pre><code class="html">...</code></pre>
    
    <!-- Disable highlighting for a specific block -->
    <pre><code class="no-highlight">...</code></pre>
  7. Custom initialization with highlightBlock and configure

    release/116

    For more control over when and what to highlight, use hljs.highlightBlock(block) and hljs.configure(options). This is useful if you are not using <pre><code> tags or if you need to trigger highlighting after specific events (like a DOM ready event).

    If your code containers do not preserve line breaks, you must configure the library to use <br> tags by setting useBR: true in the configure method.

    // Example: Manual highlighting using jQuery
    $(document).ready(function() {
      $('pre code').each(function(i, block) {
        hljs.highlightBlock(block);
      });
    });
    
    // Example: Custom configuration and non-standard containers
    hljs.configure({useBR: true});
    
    $('div.code').each(function(i, block) {
      hljs.highlightBlock(block);
    });
  8. Start the Ensembl REST server

    release/116

    Use the start_rest_server.sh script to launch the Ensembl REST server in a production environment. The script configures the environment, sets up Perl library paths, and uses starman as the application server managed by a daemon (typically start_server).

    Configuration via Environment Variables

    You can customize the server behavior using the following environment variables:

    • REST_PORT: Sets the port on which the server listens. Defaults to 5000 if not provided.

    Server Behavior

    • Restarting: If a PID file exists at $HOME/perl5/ensembl-rest.pid, the script will attempt to restart the existing server instead of starting a new one.
    • Daemonization: If the server is not running, the script uses start-stop-daemon to start the process in the background.
    • Default Settings: The script uses a production configuration located at configurations/production/ensrest.psgi and configurations/production/ensembl_rest.conf.
    # Start with default port 5000
    ./bin/production/start_rest_server.sh
    
    # Start on a specific port
    export REST_PORT=8080
    ./bin/production/start_rest_server.sh
  9. Run the Selenium test suite

    release/116

    The tests in this directory are designed in SeleniumIDE and tested in Firefox 19. To execute the full suite, follow these steps:

    1. Load the test suite: Open the TestSuite file in SeleniumIDE.
    2. Configure the environment: Edit the environment test case within the suite to set the CurrentEnvironment variable to your specific server installation URL.
    3. Execute: Run the test suite from within SeleniumIDE.
    1). Load the test suite file *TestSuite*
    2). Edit the environment test case to set the CurrentEnvironment to your server installation
    3). Run the test suite
  10. Reference: mysql_lookup.pl command line options

    release/116

    The following options are available for the mysql_lookup.pl CLI tool:

    --id=s        Specify a single stable ID to look up.
    --file=s      Specify a file containing a list of stable IDs (one per line).
    --type=s      Filter lookups by object type (e.g., gene, transcript).
    --repeats=i   Number of times to repeat the lookup (default: 1).
    --help        Display usage information.