@datagrok/bio 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,16 +99,17 @@ export class PositionInfo {
99
99
  return Object.keys(this._freqs);
100
100
  }
101
101
 
102
+ public hasMonomer(m: string): boolean {
103
+ return m in this._freqs;
104
+ }
105
+
106
+ /** Creates empty PositionMonomerInfo for {@link m} key if missed in {@link _freqs}. */
102
107
  public getFreq(m: string): PositionMonomerInfo {
103
108
  let res: PositionMonomerInfo = this._freqs[m];
104
109
  if (!res) res = this._freqs[m] = new PositionMonomerInfo();
105
110
  return res;
106
111
  }
107
112
 
108
- public setFreq(m: string, value: PositionMonomerInfo): void {
109
-
110
- }
111
-
112
113
  getMonomerAt(calculatedX: number, y: number): string | undefined {
113
114
  const findRes = Object.entries(this._freqs)
114
115
  .find(([m, pmInfo]) => {
@@ -606,8 +607,11 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
606
607
  if (!this.seqCol)
607
608
  return;
608
609
 
609
- const maxLength = wu(this.unitsHandler!.splitted).map((mList) => mList ? mList.length : 0)
610
- .reduce((max, l) => Math.max(max, l), 0);
610
+ const dfFilter = this.filterSource === FilterSources.Filtered ? this.dataFrame.filter :
611
+ this.dataFrame.selection;
612
+ const maxLength = wu.enumerate(this.unitsHandler!.splitted).map(([mList, rowI]) => {
613
+ return dfFilter.get(rowI) && !!mList ? mList.length : 0;
614
+ }).reduce((max, l) => Math.max(max, l), 0);
611
615
 
612
616
  /** positionNames and positionLabel can be set up through the column's tags only */
613
617
  const positionNamesTxt = this.seqCol.getTag(wlTAGS.positionNames);
@@ -777,25 +781,12 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
777
781
  return '';
778
782
  }
779
783
 
780
- /** Helper function for remove empty positions */
781
- // TODO: use this function in from core
782
- protected removeWhere<T>(array: Array<T>, predicate: (item: T) => boolean): Array<any> {
783
- const length = array.length;
784
- let updateIterator = 0;
785
- for (let deleteIterator = 0; deleteIterator < length; deleteIterator++) {
786
- if (!predicate(array[deleteIterator])) {
787
- array[updateIterator] = array[deleteIterator];
788
- updateIterator++;
789
- }
790
- }
791
- array.length = updateIterator;
792
- return array;
793
- }
794
-
795
784
  /** Function for removing empty positions */
796
785
  protected _removeEmptyPositions() {
797
- if (this.skipEmptyPositions)
798
- this.removeWhere(this.positions, (item) => item?.getFreq('-')?.count === item?.rowCount);
786
+ if (this.skipEmptyPositions) {
787
+ this.positions = wu(this.positions)
788
+ .filter((pi) => !pi.hasMonomer('-') || pi.getFreq('-').count !== pi.rowCount).toArray();
789
+ }
799
790
  }
800
791
 
801
792
  private renderRequested: boolean = false;
@@ -824,14 +815,18 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
824
815
  }
825
816
 
826
817
  // 2022-05-05 askalkin instructed to show WebLogo based on filter (not selection)
827
- const selRowIndices = this.filter.getSelectedIndexes();
828
-
829
- for (const rowI of selRowIndices) {
830
- const seqMList: string[] = this.unitsHandler.splitted[rowI];
831
- for (let jPos = 0; jPos < length; ++jPos) {
832
- const m: string = seqMList[this.startPosition + jPos] || '-';
833
- const pmInfo = this.positions[jPos].getFreq(m);
834
- pmInfo.count++;
818
+ const dfFilter =
819
+ this.filterSource === FilterSources.Filtered ? this.dataFrame.filter : this.dataFrame.selection;
820
+ const dfRowCount = this.dataFrame.rowCount;
821
+ const splitted = this.unitsHandler.splitted;
822
+ for (let rowI = 0; rowI < dfRowCount; ++rowI) {
823
+ if (dfFilter.get(rowI)) {
824
+ const seqMList: string[] = splitted[rowI];
825
+ for (let jPos = 0; jPos < length; ++jPos) {
826
+ const m: string = seqMList[this.startPosition + jPos] || '-';
827
+ const pmInfo = this.positions[jPos].getFreq(m);
828
+ pmInfo.count++;
829
+ }
835
830
  }
836
831
  }
837
832
 
@@ -957,6 +952,9 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
957
952
  }
958
953
  }
959
954
 
955
+ private _lastWidth: number;
956
+ private _lastHeight: number;
957
+
960
958
  /** Calculate canvas size an positionWidth and updates properties */
961
959
  private calcSize() {
962
960
  if (!this.host) return;
@@ -1037,7 +1035,12 @@ export class WebLogoViewer extends DG.JsViewer implements IWebLogoViewer {
1037
1035
  this.host.style.setProperty('overflow-y', 'hidden', 'important');
1038
1036
  }
1039
1037
  }
1040
- this._onSizeChanged.next();
1038
+
1039
+ if (this._lastWidth !== this.root.clientWidth && this._lastHeight !== this.root.clientHeight) {
1040
+ this._lastWidth = this.root.clientWidth;
1041
+ this._lastHeight = this.root.clientHeight;
1042
+ this._onSizeChanged.next();
1043
+ }
1041
1044
  }
1042
1045
 
1043
1046
  public getAlphabetSize(): number {