Skip to content

Commit

Permalink
Update GensploreView.jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
theosanderson authored Feb 6, 2024
1 parent 2cd8196 commit 2898173
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions gensplore-component/src/components/GensploreView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,7 @@ function GensploreView({ genbankString, searchInput, setSearchInput, showLogo })
return;
}
console.log("strippedSequenceInput", strippedSequenceInput);
const matchingSequence = fullSequence.indexOf(strippedSequenceInput);

if(matchingSequence === -1) {
//toast.error("No matching sequence found");
setSequenceHits([]);

return;
}
// we want to find all locations that match and store them with setSequenceHits as [start,end]
const seqHits = [];
let start = 0;
Expand All @@ -293,7 +286,18 @@ function GensploreView({ genbankString, searchInput, setSearchInput, showLogo })
while (true) {
const hit1 = fullSequence.indexOf(strippedSequenceInput, start);
const hit2 = includeRC ? fullSequence.indexOf(rc, start) : -1;
const hit = hit1 === -1 ? hit2 : (hit2 === -1 ? hit1 : Math.min(hit1, hit2));
let hit;

if (hit1 === -1) {
// If hit1 is -1, use hit2 (regardless of what hit2 is)
hit = hit2;
} else if (hit2 === -1) {
// If hit1 is not -1 but hit2 is, use hit1
hit = hit1;
} else {
// If neither hit1 nor hit2 is -1, take the smaller of the two
hit = Math.min(hit1, hit2);
}

if (hit === -1) break;
seqHits.push([hit, hit + strippedSequenceInput.length]);
Expand Down

0 comments on commit 2898173

Please sign in to comment.