Skip to content

Commit 3331223

Browse files
committed
Organism grounding tweaks
- Fixes dropdown mismatch - Saves manual GGP subtype overrides - Improves organism display - Increases default grounding query size
1 parent 4da0d6e commit 3331223

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

src/client/components/element-info/entity-info.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const MAX_FIXED_SYNONYMS = 5;
2020
const MAX_SYNONYMS_SHOWN = 10;
2121

2222
let associationCache = new WeakMap();
23+
let chosenTypeCache = new WeakMap();
2324
let nameNotificationCache = new SingleValueCache();
2425
let assocNotificationCache = new SingleValueCache();
2526

@@ -35,6 +36,8 @@ class EntityInfo extends DataComponent {
3536

3637
let assocNotification = initCache( assocNotificationCache, el, new Notification({ active: true }) );
3738

39+
let chosenType = initCache( chosenTypeCache, el, null );
40+
3841
this.debouncedUpdateMatches = _.debounce( (name, postStep = _.nop) => {
3942
this.updateMatches(name).then(postStep);
4043
}, defs.updateDelay );
@@ -53,6 +56,7 @@ class EntityInfo extends DataComponent {
5356
this.data = {
5457
element: el,
5558
name: el.name(),
59+
chosenType,
5660
oldName: el.name(),
5761
matches: assoc.matches,
5862
gettingMoreMatches: false,
@@ -131,6 +135,14 @@ class EntityInfo extends DataComponent {
131135
let s = this.data;
132136
let el = s.element;
133137

138+
if( s.chosenType && match.type !== 'chemical' ){
139+
match = Object.assign({}, match, {
140+
type: s.chosenType
141+
});
142+
143+
delete match.typeOfGene; // n.b. the model overrides via this field
144+
}
145+
134146
el.associate( match );
135147
el.complete();
136148

@@ -398,11 +410,15 @@ class EntityInfo extends DataComponent {
398410
name: 'entity-info-subtype-radio',
399411
id: `entity-info-subtype-radio-${typeVal}`,
400412
value: typeVal,
401-
defaultChecked: typeVal === m.type,
413+
checked: typeVal === m.type,
402414
onChange: e => {
403415
let newlySelectedType = e.target.value;
404416
let newMatch = Object.assign({}, m, { type: newlySelectedType });
405417

418+
this.setData({ chosenType: newlySelectedType });
419+
420+
chosenTypeCache.set(s.element, newlySelectedType);
421+
406422
this.associate(newMatch);
407423
}
408424
}),
@@ -434,8 +450,6 @@ class EntityInfo extends DataComponent {
434450
let isOrgMatch = m => isPerfectNameMatch(m) && !isChemicalMatch(m);
435451
let orgMatches = s.matches.filter(isOrgMatch);
436452
let orgToMatches = new Map();
437-
const selectedIndex = _.findIndex(orgMatches, match => match.id === m.id && match.namespace === m.namespace);
438-
const selectedOrg = assoc ? assoc.organism : null;
439453

440454
orgMatches.forEach(om => {
441455
let org = om.organism;
@@ -451,6 +465,11 @@ class EntityInfo extends DataComponent {
451465
arr.push(om);
452466
});
453467

468+
orgMatches = _.sortBy(orgMatches, m => m.organismName);
469+
470+
const selectedIndex = _.findIndex(orgMatches, match => match.id === m.id && match.namespace === m.namespace);
471+
const selectedOrg = assoc ? assoc.organism : null;
472+
454473
const getSelectDisplay = (om, includeName = false) => {
455474
// const matches = orgToMatches.get(om.organism) || [];
456475
// let count = matches.length;
@@ -463,7 +482,9 @@ class EntityInfo extends DataComponent {
463482
};
464483

465484
const getDisamtDisplay = (om) => {
466-
return `${om.name} : ` + om.synonyms.slice(0, 3).join(', ');
485+
const sortedSyns = _.sortBy(om.synonyms, syn => stringDistanceMetric(syn, s.name));
486+
487+
return `${om.name} : ` + sortedSyns.slice(0, 3).join(', ');
467488
};
468489

469490
organism = h('div.entity-info-section.entity-info-organism-refinement', [
@@ -503,14 +524,16 @@ class EntityInfo extends DataComponent {
503524
const needDisam = ambigGrs && ambigGrs.length > 1;
504525

505526
if( needDisam ){
527+
const selectedAmIndex = _.findIndex(ambigGrs, match => match.id === m.id && match.namespace === m.namespace);
528+
506529
disambiguation = h('div.entity-info-section.entity-info-organism-refinement', [
507530
h('span.entity-info-title', 'Which' + (s.name ? ` ${s.name}` : '') + ''),
508531
h('select.entity-info-organism-dropdown', {
509-
defaultValue: selectedIndex,
532+
defaultValue: selectedAmIndex,
510533
onChange: e => {
511534
const val = e.target.value;
512535
const index = parseInt(val);
513-
const om = orgMatches[index];
536+
const om = ambigGrs[index];
514537

515538
if( om ){
516539
this.associate(om);

src/client/defs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export const editAnimationDuration = 600;
33
export const editAnimationEasing = 'linear';
44
export const editAnimationColor = 'rgba(255, 255, 0, 0.5)';
55
export const editAnimationWhite = 'rgba(255, 255, 255, 0.5)';
6-
export const associationSearchLimit = 10;
6+
export const associationSearchLimit = 30;
77
export const tippyTopZIndex = 10001;
88
export const tippyDefaults = {
99
theme: 'light',

src/styles/base.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ button.button-toggle {
151151

152152
select {
153153
width: var(--defaultWidgetWidth);
154-
padding-right: 1em;
154+
padding-right: 2em;
155155
background-image: url('./image/fa-angle-down.svg');
156156
background-position: 100% 50%;
157157
background-position: calc(100% - 0.5em) 50%;

0 commit comments

Comments
 (0)