From a49157f77335262ae8768614d012cfc52284e3bf Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Fri, 28 Jul 2023 17:30:36 +0100 Subject: [PATCH] sequence search --- src/App.js | 100 +++++++++++++++++++++++++++++++++-- src/components/SingleRow.jsx | 41 ++++++++++++++ 2 files changed, 137 insertions(+), 4 deletions(-) diff --git a/src/App.js b/src/App.js index f4c93f1..0895141 100644 --- a/src/App.js +++ b/src/App.js @@ -18,7 +18,7 @@ import { useWindowVirtualizer } from "@tanstack/react-virtual"; import Slider, { Range } from "rc-slider"; import { AiOutlineZoomIn, AiOutlineZoomOut } from "react-icons/ai"; import { GiDna1 } from "react-icons/gi"; - +import {BsArrowRightCircleFill, BsArrowLeftCircleFill} from "react-icons/bs"; import { ToastContainer, toast } from "react-toastify"; import { useDebounce, useQueryState } from "./hooks"; import "react-toastify/dist/ReactToastify.css"; @@ -33,23 +33,37 @@ function SearchPanel({ setSearchInput, searchType, setSearchType, + curSeqHitIndex, + sequenceHits, + setCurSeqHitIndex }) { const handleInputChange = (event) => { + setCurSeqHitIndex(0); setSearchInput(event.target.value); + // if event.target.value has only ACGT characters, then set searchType to sequence // if event.target.value has non-numeric characters, then set searchType to annot - if (event.target.value.match(/[^0-9]/)) { + // if event.target.value has only numeric characters, then set searchType to nuc + if (/^[0-9]+$/.test(event.target.value)) { + setSearchType("nuc"); + } + else if (/^[ACGTacgt]+$/.test(event.target.value)) { + setSearchType("sequence"); + } + else if (/^[^0-9]+$/.test(event.target.value)) { setSearchType("annot"); - console.log("setting searchType to annot"); } + }; const searchOption = [ { value: "nuc", label: "nucleotide" }, { value: "annot", label: "annotation" }, + { value: "sequence", label: "sequence"} ]; return ( -
+
+
{searchPanelOpen ? ( <>