npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ebi-wp/ebinocle-ng-rsclient

v4.11.11

Published

EBI Search REST API interface client

Downloads

247

Readme

ebinocle-ng-rsclient

EBI Search Angular REST client

Documentation

The documentation can be found at: http://ebi-wp.gitdocs.ebi.ac.uk/ebinocle-ng-rsclient

Install

npm i @ebi-wp/ebinocle-ng-rsclient

Usage example

The following example, creates a SearchRequest object, sets the domain and query. Then it gets the search results using that object.

import { Component } from '@angular/core';
import { Configuration, SearchRequest, SearchService } from '@ebi-wp/ebinocle-ng-rsclient';

@Component({
  selector: 'app-search',
  templateUrl: './search.component.html'
})
export class SearchComponent {
  constructor(private readonly searchService: SearchService) {}

  public search() {
    const searchRequest = new SearchRequest(new Configuration());
    searchRequest.setDB('embl');
    searchRequest.query = 'mouse';

    return this.searchService.getSearchResults(searchRequest);
  }
}

Simple search

In the following example we use the SearchService to submit a search to the embl domain with the query "mouse".

import { Component, OnInit } from '@angular/core';
import { Configuration, SearchRequest, SearchResults, SearchService } from '@ebi-wp/ebinocle-ng-rsclient';
import { Observable } from 'rxjs';

@Component({
  selector: 'app-search',
  templateUrl: './search.component.html'
})
export class SearchComponent implements OnInit {
  public searchResults: SearchResults;

  constructor(private readonly searchService: SearchService) {}

  public ngOnInit(): void {
    this.search().subscribe((searchResults) => {
      this.searchResults = searchResults;
    });
  }

  public search(): Observable<SearchResults> {
    const searchRequest = new SearchRequest(new Configuration());
    searchRequest.setDB('embl');
    searchRequest.query = 'mouse';

    return this.searchService.getSearchResults(searchRequest);
  }
}

Then in the HTML template:

<ng-container *ngIf="searchResults && searchResults.hitCount > 0">
  <div *ngFor="let entry of searchResults.entries">
    <p>{{ entry.id }}</p>
    <p>{{ entry.fields.description[0] }}</p>
  </div>
</ng-container>

Faceted search

To get facets along with a search result, the query and facetcount parameters are needed:

// ...
public search(): Observable<SearchResults> {
  const searchRequest = new SearchRequest(new Configuration());
  searchRequest.setDB('embl');
  searchRequest.query = 'mouse';
  searchRequest.facetcount = 10;

  return this.searchService.getSearchResults(searchRequest);
}
// ...

To extract the facets use:

// ...
this.search().subscribe((searchResults) => {
  this.facets = searchResults.facets;
});
// ...

To filter out by a list of selected facet values, the facets parameter can help. The value format for the parameter is a comma separated list of facet id:facet value:

// ...
public search(): Observable<SearchResults> {
  const searchRequest = new SearchRequest(new Configuration());
  searchRequest.setDB('embl');
  searchRequest.query = 'plantae';
  searchRequest.facetcount = 10;
  searchRequest.facets = 'taxonomy:1842';

  return this.searchService.getSearchResults(searchRequest);
}
// ...

Cross reference searching

Finding domains referred by an entry

Given a source domain and an entry we want to retrieve the referenced (target) domains:

// ...
public search(): Observable<SearchResults> {
  return this.searchService.getReferencedDomains('uniprot', 'Q9BYF1');
}
// ...

To extract the results:

// ...
this.search().subscribe((searchResults) => {
  for (const domain of searchResults.domains) {
    console.log(`Referenced domain ${domain.id} with ${domain.referenceEntryCount} entries`);
  }
});
// ...

Cross reference searching

To find entries in a target domain (europepmc in this case) referred to by a source domain (uniprot) and entry (Q9BYF1) use the following:

// ...
public search(): Observable<SearchResults> {
  return this.searchService.getReferencedEntries(
    'uniprot',
    'Q9BYF1',
    'europepmc',
    1
  );
}

// ...

To extract the results:

// ...
this.search().subscribe((searchResults) => {
  const reference = this.searchResults.entries[0];

  this.referencesResult = {
    hitCount: reference?.referenceCount,
    entries: reference?.references
  };
});
// ...