src/scripts/TranscriptsTrack.js
/**
   * Initialize a tile. Pulled out from the track so that it
   * can be modified without having to modify the track
   * object (e.g. in an Observable notebook)
   *
   * @param  {TranscriptsTrack} track   The track object
   * @param  {Object} tile    The tile to render
   * @param  {Object} options The track's options
   */
Initialize a tile. Pulled out from the track so that it
can be modified without having to modify the track
object

@param  {TranscriptsTrack} track   The track object
@param  {Object} tile    The tile to render
@param  {Object} options The track's options
Initialize a tile . Pulled out from the track so that it can be modified without having to modify the track object @param { TranscriptsTrack } track The track object @param { Object } tile The tile to render @param { Object } options The track ' s options
function externalInitTile(track, tile, options) {
    const { flipText, fontSize, fontFamily, maxTexts } = options;
    tile.texts = {};
    tile.textWidths = {};
    tile.textHeights = {};
    tile.rectGraphics = new HGC.libraries.PIXI.Graphics();
    tile.rectMaskGraphics = new HGC.libraries.PIXI.Graphics();
    tile.codonSeparatorGraphics = new HGC.libraries.PIXI.Graphics();
    tile.codonTextGraphics = new HGC.libraries.PIXI.Graphics();
    tile.labelBgGraphics = new HGC.libraries.PIXI.Graphics();
    tile.labelGraphics = new HGC.libraries.PIXI.Graphics();
    tile.graphics.addChild(tile.rectGraphics);
    tile.graphics.addChild(tile.rectMaskGraphics);
    tile.graphics.addChild(tile.codonSeparatorGraphics);
    tile.graphics.addChild(tile.codonTextGraphics);
    tile.graphics.addChild(tile.labelBgGraphics);
    tile.graphics.addChild(tile.labelGraphics);
    tile.rectGraphics.mask = tile.rectMaskGraphics;
    if (!tile.tileData.sort) return;
    tile.tileData.sort((a, b) => b.importance - a.importance);
    tile.tileData.forEach((td, i) => {
      const ts = td.fields;
      const tsFormatted = track.formatTranscriptData(ts);
      const transcriptName = tsFormatted.transcriptName;
      const transcriptId = tsFormatted.transcriptId;
      const strand = tsFormatted.strand;
      td["transcriptId"] = transcriptId;
      if (i >= maxTexts) return;
      const text = new HGC.libraries.PIXI.Text(transcriptName, {
        fontSize: `${fontSize}px`,
        fontFamily,
        fill: track.colors["labelFont"],
      });
      text.interactive = true;
      if (flipText) text.scale.x = -1;
      text.anchor.x = 0;
      text.anchor.y = 0.5;
      text.visible = false;
      tile.texts[transcriptId] = text; 
      tile.texts[transcriptId].strand = strand;
      tile.labelGraphics.addChild(text);
    });
    loadAminoAcidData(track, tile);
    tile.initialized = true;
  }
function externalInitTile ( track , tile , options ) { const { flipText , fontSize , fontFamily , maxTexts } = options ; tile . texts = { } ; tile . textWidths = { } ; tile . textHeights = { } ; tile . rectGraphics = new HGC . libraries . PIXI . Graphics ( ) ; tile . rectMaskGraphics = new HGC . libraries . PIXI . Graphics ( ) ; tile . codonSeparatorGraphics = new HGC . libraries . PIXI . Graphics ( ) ; tile . codonTextGraphics = new HGC . libraries . PIXI . Graphics ( ) ; tile . labelBgGraphics = new HGC . libraries . PIXI . Graphics ( ) ; tile . labelGraphics = new HGC . libraries . PIXI . Graphics ( ) ; tile . graphics . addChild ( tile . rectGraphics ) ; tile . graphics . addChild ( tile . rectMaskGraphics ) ; tile . graphics . addChild ( tile . codonSeparatorGraphics ) ; tile . graphics . addChild ( tile . codonTextGraphics ) ; tile . graphics . addChild ( tile . labelBgGraphics ) ; tile . graphics . addChild ( tile . labelGraphics ) ; tile . rectGraphics . mask = tile . rectMaskGraphics ; if ( ! tile . tileData . sort ) return ; tile . tileData . sort ( ( a , b ) => b . importance - a . importance ) ; tile . tileData . forEach ( ( td , i ) => { const ts = td . fields ; const tsFormatted = track . formatTranscriptData ( ts ) ; const transcriptName = tsFormatted . transcriptName ; const transcriptId = tsFormatted . transcriptId ; const strand = tsFormatted . strand ; td [ "transcriptId" ] = transcriptId ; if ( i >= maxTexts ) return ; const text = new HGC . libraries . PIXI . Text ( transcriptName , { fontSize : ` ${ fontSize } ` , fontFamily , fill : track . colors [ "labelFont" ] , } ) ; text . interactive = true ; if ( flipText ) text . scale . x = - 1 ; text . anchor . x = 0 ; text . anchor . y = 0.5 ; text . visible = false ; tile . texts [ transcriptId ] = text ; tile . texts [ transcriptId ] . strand = strand ; tile . labelGraphics . addChild ( text ) ; } ) ; loadAminoAcidData ( track , tile ) ; tile . initialized = true ; }
Initialize a tile.
Initialize a tile .
// create texts // don't draw texts for the latter entries in the tile // index by transcriptName