How to use protvista-utils - 3 common examples

To help you get started, we’ve selected a few protvista-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ebi-webcomponents / nightingale / packages / protvista-coloured-sequence / src / protvista-coloured-sequence.js View on Github external
refresh() {
    if (this.seq_g) {
      const scale = this.getScaleFromAttribute();
      if (scale === null) {
        console.error("The attribute scale is not valid.");
        return;
      }
      const colorScale = scaleLinear();
      this.colorScale = defaultScale;
      if (this._color_range) {
        this.colorScale = ColorScaleParser(this._color_range);
      }
      colorScale.domain(this.colorScale.domain).range(this.colorScale.range);

      const ftWidth = this.getSingleBaseWidth();
      const first = Math.round(Math.max(0, this._displaystart - 2));
      const last = Math.round(
        Math.min(this.sequence.length, this._displayend + 1)
      );
      const bases = this.sequence
        .slice(first, last)
        .split("")
        .map((aa, i) => {
          // use 0 if the base is not in the given scale
          const value = aa.toUpperCase() in scale ? scale[aa.toUpperCase()] : 0;
          return {
            start: 1 + first + i,
github ebi-webcomponents / nightingale / packages / protvista-zoomable / src / protvista-zoomable.js View on Github external
// this.bindEvents = this.bindEvents(this);
    let aboutToApply = false;
    // Postponing the zoom translation to the next frame.
    // This helps in case several attributes are changed almost at the same time,
    // in this way, only one refresh will be called.
    this.applyZoomTranslation = () => {
      if (aboutToApply) return;
      aboutToApply = true;
      requestAnimationFrame(() => {
        aboutToApply = false;
        this._applyZoomTranslation();
      });
    };
    this._onResize = this._onResize.bind(this);
    this._listenForResize = this._listenForResize.bind(this);
    this.trackHighlighter = new TrackHighlighter({ element: this, min: 1 });
  }
github ebi-webcomponents / nightingale / packages / protvista-coloured-sequence / src / protvista-coloured-sequence.js View on Github external
return hydroInterfaceScale;
        case "isoelectric-point-scale":
          return isoelectricPointScale;
        case "hydrophobicity-octanol-scale":
          return hydroOctanoleScale;
        default:
          return null;
      }
    }
    if (
      /([ILFVMPWHTEQCYASNDRGK]:-?\d+\.?\d*)(,[ILFVMPWHTEQCYASNDRGK]:-?\d+\.?\d*)*/.test(
        this._scale
      )
    ) {
      try {
        scale = String2Object(this._scale, {
          keyFormatter: x => x.toUpperCase(),
          valueFormatter: x => parseFloat(x)
        });
      } catch (error) {
        console.error(`Couldn't parse the given scale ${this._scale}`, error);
      }
    }
    return scale;
  }

protvista-utils

Collection of utilities for ProtVista components

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis