Socket
Socket
Sign inDemoInstall

@ebi-wp/ebinocle-ng-rsclient

Package Overview
Dependencies
5
Maintainers
3
Versions
137
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @ebi-wp/ebinocle-ng-rsclient

EBI Search REST API interface client


Version published
Weekly downloads
34
decreased by-56.41%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

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);
  }
}

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>

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
  };
});
// ...

Keywords

FAQs

Last updated on 26 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc