|
902 | 902 | let lo = Math.max(0, Math.min(a, b)); |
903 | 903 | let hi = Math.min((this.colOffsets && this.colOffsets.length > 0) ? this.colOffsets.length - 2 : Math.max(0, (a + b)), Math.max(a, b)); |
904 | 904 |
|
905 | | - if (this.codonMode || this.aminoAcidMode) { |
| 905 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
906 | 906 | lo = this.snapToCodonStart(lo); |
907 | 907 | hi = this.snapToCodonEnd(hi); |
908 | 908 | } |
|
915 | 915 | let lo = Math.max(0, Math.min(a, b)); |
916 | 916 | let hi = Math.min((this.colOffsets && this.colOffsets.length > 0) ? this.colOffsets.length - 2 : Math.max(0, (a + b)), Math.max(a, b)); |
917 | 917 |
|
918 | | - if (this.codonMode || this.aminoAcidMode) { |
| 918 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
919 | 919 | lo = this.snapToCodonStart(lo); |
920 | 920 | hi = this.snapToCodonEnd(hi); |
921 | 921 | } |
|
925 | 925 | this.expandColSelectionToInclude = (newPos) => { |
926 | 926 | // Expand column selection to include newPos |
927 | 927 | if (this.selectedCols.size === 0) { |
928 | | - if (this.codonMode || this.aminoAcidMode) { |
| 928 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
929 | 929 | const start = this.snapToCodonStart(newPos); |
930 | 930 | const end = this.snapToCodonEnd(newPos); |
931 | 931 | for (let c = start; c <= end; c++) this.selectedCols.add(c); |
|
939 | 939 | let lo = Math.max(0, Math.min(currentMin, newPos)); |
940 | 940 | let hi = Math.min((this.colOffsets && this.colOffsets.length > 0) ? this.colOffsets.length - 2 : Math.max(0, currentMax), Math.max(currentMax, newPos)); |
941 | 941 |
|
942 | | - if (this.codonMode || this.aminoAcidMode) { |
| 942 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
943 | 943 | lo = this.snapToCodonStart(lo); |
944 | 944 | hi = this.snapToCodonEnd(hi); |
945 | 945 | } |
|
956 | 956 | let chi = Math.min((this.colOffsets && this.colOffsets.length > 0) ? this.colOffsets.length - 2 : Math.max(c0, c1), Math.max(c0, c1)); |
957 | 957 |
|
958 | 958 | // Snap to codon boundaries in codon or amino acid mode |
959 | | - if (this.codonMode || this.aminoAcidMode) { |
| 959 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
960 | 960 | clo = this.snapToCodonStart(clo); |
961 | 961 | chi = this.snapToCodonEnd(chi); |
962 | 962 | } |
|
975 | 975 | let chi = Math.min((this.colOffsets && this.colOffsets.length > 0) ? this.colOffsets.length - 2 : Math.max(c0, c1), Math.max(c0, c1)); |
976 | 976 |
|
977 | 977 | // Snap to codon boundaries in codon or amino acid mode |
978 | | - if (this.codonMode || this.aminoAcidMode) { |
| 978 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
979 | 979 | clo = this.snapToCodonStart(clo); |
980 | 980 | chi = this.snapToCodonEnd(chi); |
981 | 981 | } |
|
1009 | 1009 | let col = (cb.colFromClientX ? cb.colFromClientX(e.clientX) : (cb.colFromClientXLocal ? cb.colFromClientXLocal(e.clientX) : null)) || _colFromClientXLocal(e.clientX, headerCanvas); |
1010 | 1010 |
|
1011 | 1011 | // Snap to codon boundary in codon or amino acid mode |
1012 | | - if (this.codonMode || this.aminoAcidMode) { |
| 1012 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
1013 | 1013 | col = this.snapToCodonStart(col); |
1014 | 1014 | } |
1015 | 1015 |
|
|
1030 | 1030 | // Already handled above |
1031 | 1031 | } else if (e.metaKey) { |
1032 | 1032 | // Cmd-click: toggle selection of codon (or single column in non-codon mode) |
1033 | | - if (this.codonMode || this.aminoAcidMode) { |
| 1033 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
1034 | 1034 | const codonStart = this.snapToCodonStart(col); |
1035 | 1035 | const codonEnd = this.snapToCodonEnd(col); |
1036 | 1036 | // Check if any part of the codon is selected |
|
1049 | 1049 | } else { |
1050 | 1050 | try { |
1051 | 1051 | this.selectedCols.clear(); |
1052 | | - if (this.codonMode || this.aminoAcidMode) { |
| 1052 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
1053 | 1053 | const codonEnd = this.snapToCodonEnd(col); |
1054 | 1054 | for (let c = col; c <= codonEnd; c++) this.selectedCols.add(c); |
1055 | 1055 | } else { |
|
1091 | 1091 | let col = (cb.colFromClientX ? cb.colFromClientX(e.clientX) : (cb.colFromClientXLocal ? cb.colFromClientXLocal(e.clientX) : null)) || _colFromClientXLocal(e.clientX, consensusCanvas); |
1092 | 1092 |
|
1093 | 1093 | // Snap to codon boundary in codon or amino acid mode |
1094 | | - if (this.codonMode || this.aminoAcidMode) { |
| 1094 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
1095 | 1095 | col = this.snapToCodonStart(col); |
1096 | 1096 | } |
1097 | 1097 |
|
|
1112 | 1112 | // Already handled above |
1113 | 1113 | } else if (e.metaKey) { |
1114 | 1114 | // Cmd-click: toggle selection of codon (or single column in non-codon mode) |
1115 | | - if (this.codonMode || this.aminoAcidMode) { |
| 1115 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
1116 | 1116 | const codonStart = this.snapToCodonStart(col); |
1117 | 1117 | const codonEnd = this.snapToCodonEnd(col); |
1118 | 1118 | const isSelected = this.selectedCols.has(codonStart) || this.selectedCols.has(codonStart + 1) || this.selectedCols.has(codonEnd); |
|
1128 | 1128 | } else { |
1129 | 1129 | try { |
1130 | 1130 | this.selectedCols.clear(); |
1131 | | - if (this.codonMode || this.aminoAcidMode) { |
| 1131 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
1132 | 1132 | const codonEnd = this.snapToCodonEnd(col); |
1133 | 1133 | for (let c = col; c <= codonEnd; c++) this.selectedCols.add(c); |
1134 | 1134 | } else { |
|
2852 | 2852 | headerCtx.save(); |
2853 | 2853 | headerCtx.fillStyle = this.HEADER_SELECTION; |
2854 | 2854 |
|
2855 | | - // In amino acid or codon mode, group selections by codon and draw entire codon boxes |
2856 | | - if (this.aminoAcidMode || this.codonMode) { |
| 2855 | + // In codon or translate mode, group selections by codon and draw entire codon boxes |
| 2856 | + if (this.displayMode === 'codon' || this.displayMode === 'translate') { |
2857 | 2857 | const drawnCodons = new Set(); |
2858 | 2858 |
|
2859 | 2859 | for (const c of selectedCols) { |
|
3481 | 3481 | let clo = Math.max(0, Math.min(rectStartCol, rectEndCol)); |
3482 | 3482 | let chi = Math.min(maxSeqLen - 1, Math.max(rectStartCol, rectEndCol)); |
3483 | 3483 |
|
3484 | | - // Snap visual rectangle to codon boundaries in amino acid or codon mode |
3485 | | - if (aminoAcidMode || codonMode) { |
| 3484 | + // Snap visual rectangle to codon boundaries in codon or translate mode |
| 3485 | + if (displayMode === 'codon' || displayMode === 'translate') { |
3486 | 3486 | clo = this.snapToCodonStart(clo); |
3487 | 3487 | chi = this.snapToCodonEnd(chi); |
3488 | 3488 | } |
|
0 commit comments