Skip to content

Commit

Permalink
Add slider for allowed gappyness
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 8, 2024
1 parent f1c2fcf commit 1914a80
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 10 deletions.
19 changes: 19 additions & 0 deletions lib/src/components/dialogs/SettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ const MSASettings = observer(function MSASettings({
bgColor,
contrastLettering,
colWidth,
allowedGappyness,
drawMsaLetters,
colorSchemeName,
hideGaps,
rowHeight,
} = model

Expand All @@ -142,6 +144,11 @@ const MSASettings = observer(function MSASettings({
onChange={() => model.setContrastLettering(!contrastLettering)}
label="Use contrast lettering"
/>
<Checkbox2
checked={hideGaps}
onChange={() => model.setHideGaps(!hideGaps)}
label={`Hide columns that are ${100 - allowedGappyness}% gaps`}
/>

<div className={classes.flex}>
<Typography>Column width ({colWidth}px)</Typography>
Expand All @@ -163,6 +170,18 @@ const MSASettings = observer(function MSASettings({
onChange={(_, val) => model.setRowHeight(val as number)}
/>
</div>
{hideGaps ? (
<div className={classes.flex}>
<Typography>Allowed gappyness ({100 - allowedGappyness}%)</Typography>
<Slider
className={classes.field}
min={1}
max={100}
value={allowedGappyness}
onChange={(_, val) => model.setAllowedGappyness(val as number)}
/>
</div>
) : null}

<TextField
select
Expand Down
23 changes: 22 additions & 1 deletion lib/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ function stateModelFactory() {
* #property
*/
showDomains: false,
/**
* #property
*/
allowedGappyness: 100,
/**
* #property
*/
Expand All @@ -123,6 +127,10 @@ function stateModelFactory() {
* #property
*/
drawMsaLetters: true,
/**
* #property
*/
hideGaps: true,

/**
* #property
Expand Down Expand Up @@ -320,6 +328,18 @@ function stateModelFactory() {
| Record<string, InterProScanResults>,
}))
.actions(self => ({
/**
* #action
*/
setHideGaps(arg: boolean) {
self.hideGaps = arg
},
/**
* #action
*/
setAllowedGappyness(arg: number) {
self.allowedGappyness = arg
},
/**
* #action
*/
Expand Down Expand Up @@ -669,6 +689,7 @@ function stateModelFactory() {
* #getter
*/
get blanks() {
const { allowedGappyness } = self
const blanks = []
const strs = this.leaves
.map(leaf => this.MSA?.getRow(leaf.data.name))
Expand All @@ -681,7 +702,7 @@ function stateModelFactory() {
counter++
}
}
if (counter === strs.length) {
if (counter / strs.length >= allowedGappyness / 100) {
blanks.push(i)
}
}
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1535,9 +1535,9 @@ callsites@^3.0.0:
integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==

caniuse-lite@^1.0.30001646:
version "1.0.30001650"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001650.tgz#dd1eba0938e39536d184c3c99b2569a13788bc16"
integrity sha512-fgEc7hP/LB7iicdXHUI9VsBsMZmUmlVJeQP2qqQW+3lkqVhbmjEU8zp+h5stWeilX+G7uXuIUIIlWlDw9jdt8g==
version "1.0.30001651"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz#52de59529e8b02b1aedcaaf5c05d9e23c0c28138"
integrity sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==

canvas-sequencer@^3.1.0:
version "3.1.0"
Expand Down Expand Up @@ -2291,9 +2291,9 @@ for-each@^0.3.3:
is-callable "^1.1.3"

foreground-child@^3.1.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.2.1.tgz#767004ccf3a5b30df39bed90718bab43fe0a59f7"
integrity sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==
version "3.3.0"
resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.3.0.tgz#0ac8644c06e431439f8561db8ecf29a7b5519c77"
integrity sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==
dependencies:
cross-spawn "^7.0.0"
signal-exit "^4.0.1"
Expand Down Expand Up @@ -3909,9 +3909,9 @@ synckit@^0.9.1:
tslib "^2.6.2"

terser@^5.17.4:
version "5.31.4"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.31.4.tgz#60274c4d3e20eb9a6468526a8878aba8e8428c5f"
integrity sha512-3OU03GgblDgu0g+sdnsVzhBPxnjV+WJuMmocN1qBBZDQ3ia7jZQSAkePeKbPlYAejGXUTYe1CmSaUeV51mvaIw==
version "5.31.5"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.31.5.tgz#e48b7c65f32d2808e7dad803e4586a0bc3829b87"
integrity sha512-YPmas0L0rE1UyLL/llTWA0SiDOqIcAQYLeUj7cJYzXHlRTAnMSg9pPe4VJ5PlKvTrPQsdVFuiRiwyeNlYgwh2Q==
dependencies:
"@jridgewell/source-map" "^0.3.3"
acorn "^8.8.2"
Expand Down

0 comments on commit 1914a80

Please sign in to comment.