Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCRUM-4529 more undefined checks #1372

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/components/OrthologPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,13 @@ const OrthologPicker =({
}
let selectedOrthologs = [];
if (checkboxValue) {
selectedOrthologs = orthology.data.results
.sort(compareBySpeciesThenAlphabetical)
selectedOrthologs = orthology.data.results?.sort(compareBySpeciesThenAlphabetical)
.filter(o => geneHasData(getOrthologId(o)));
if (stringency) {
selectedOrthologs = selectedOrthologs.filter(byStringency(stringency.value));
selectedOrthologs = selectedOrthologs?.filter(byStringency(stringency.value));
}
if (selectedSpecies.length) {
selectedOrthologs = selectedOrthologs.filter(bySpecies(selectedSpecies));
selectedOrthologs = selectedOrthologs?.filter(bySpecies(selectedSpecies));
}
}
onChange(selectedOrthologs);
Expand Down Expand Up @@ -194,15 +193,13 @@ const OrthologPicker =({
if (!geneHasDataTest) {
return true;
}
return orthology.data.results
.filter(bySpecies([species]))
return orthology.data.results?.filter(bySpecies([species]))
.map(getOrthologId)
.some(geneHasData);
};

const speciesHasOrthologsMeetingStringency = (species) => {
return orthology.data.results
.filter(bySpecies([species]))
return orthology.data.results?.filter(bySpecies([species]))
.filter(o => stringency ? orthologyMeetsStringency(o, stringency.value) : true)
.some(o => geneHasData(getOrthologId(o)));
};
Expand Down Expand Up @@ -299,7 +296,7 @@ const OrthologPicker =({
.filter(species => focusTaxonId ? species.taxonId !== focusTaxonId : true)
.map(species => {
const checkId = id + makeId(species.taxonId);
const hasOrthologs = orthology.data.results.findIndex(o => getOrthologSpeciesId(o) === species.taxonId) >= 0;
const hasOrthologs = orthology.data.results?.findIndex(o => getOrthologSpeciesId(o) === species.taxonId) >= 0;
const hasOrthologsWithData = speciesHasOrthologsWithData(species);
const hasOrthologsMeetingStringency = speciesHasOrthologsMeetingStringency(species);
const disabled = !hasOrthologs || !hasOrthologsWithData || !hasOrthologsMeetingStringency;
Expand Down