// Species selection with a searchable (auto-completing) text box.
// Species can be preselected with a URL parameter, e.g. ?species=Equisetum_arvense
viewof speciesInput = {
const initial = new URLSearchParams(location.search).get("species");
const start = explorer.species.includes(initial)
? initial
: explorer.species[0];
const MAX = 10;
const input = html`<input type="text" value="${start}" class="form-control"
placeholder="Start typing a species name" autocomplete="off"
role="combobox" aria-label="Species" aria-expanded="false">`;
const menu = html`<ul class="list-group shadow-sm" role="listbox"
style="display:none; margin-top:2px; max-height:20em;
overflow-y:auto"></ul>`;
const wrap = html`<div style="max-width:28em"
>${input}${menu}</div>`;
wrap.value = start;
let matches = [];
let active = -1;
const find = (q) => {
q = q.trim().toLowerCase().replace(/ /g, "_");
if (!q) return [];
const starts = [], contains = [];
for (const s of explorer.species) {
const l = s.toLowerCase();
if (l.startsWith(q)) starts.push(s);
else if (l.includes(q)) contains.push(s);
if (starts.length >= MAX) break;
}
return starts.concat(contains).slice(0, MAX);
};
const close = () => { menu.style.display = "none"; active = -1;
input.setAttribute("aria-expanded", "false"); };
const choose = (s) => {
input.value = s;
close();
wrap.value = s;
wrap.dispatchEvent(new CustomEvent("input"));
};
const render = () => {
menu.replaceChildren(...matches.map((s, i) => {
const li = html`<li class="list-group-item list-group-item-action py-1"
role="option" style="cursor:pointer">${s}</li>`;
if (i === active) li.classList.add("active");
li.addEventListener("mousedown", (e) => { e.preventDefault(); choose(s); });
return li;
}));
const open = matches.length > 0;
menu.style.display = open ? "block" : "none";
input.setAttribute("aria-expanded", String(open));
};
input.addEventListener("input", (e) => {
e.stopPropagation();
matches = find(input.value);
active = -1;
render();
});
input.addEventListener("keydown", (e) => {
if (e.key === "ArrowDown") { active = Math.min(active + 1, matches.length - 1); render(); e.preventDefault(); }
else if (e.key === "ArrowUp") { active = Math.max(active - 1, 0); render(); e.preventDefault(); }
else if (e.key === "Enter") {
const pick = active >= 0 ? matches[active]
: explorer.species.includes(input.value) ? input.value : matches[0];
if (pick) choose(pick);
e.preventDefault();
} else if (e.key === "Escape") close();
});
input.addEventListener("focus", () => input.select());
// On leaving the box, restore the current valid species if the text is not one
input.addEventListener("blur", () => { close(); input.value = wrap.value; });
return wrap;
}Select a species to see its GenBank accessions, specimen voucher, and taxonomy in FTOL v1.10.0 (GenBank release 274). You can type into the search box to auto-complete.
Accession
Voucher
Taxonomy
Start by selecting a species from the search box. Species names are shown with underscores in place of spaces, as in the tree. Clicking a GenBank accession or an NCBI taxonomic ID opens a new browser tab for that record.
Accession
One row per accession for the selected species.
- locus: Name of locus (gene or region)
- accession: GenBank accession number
- seq_len: Length of the sequence in basepairs
Voucher
Only one row.
- join_by: Method used to join sequences across loci within the species.
- specimen_voucher: Specimen voucher, converted to all lowercase and with spaces and punctuation removed to allow for matching.
- publication: Publication for the accession(s).
- outgroup: TRUE if species is in outgroup (non-ferns); FALSE if not (ferns)
Taxonomy
May have just one row if the data are the same for all accessions, or one row per accession if different accessions have different data.
The reference taxonomy is the Pteridophyte Phylogeny Group (PPG) taxonomy, version 2.0.0 (release notes). NCBI names are matched to PPG names, and synonyms are resolved to the accepted name in PPG.
- accession: GenBank accession number. Only appears if different accessions have different data.
- ncbi_taxid: NCBI taxonomic ID for the accession (or species).
- query: NCBI species name of accession used as query for name resolution.
- matched_name: Name matched by taxastand when querying the NCBI name against the PPG taxonomic database.
- resolved_name: The name ultimately used for FTOL; if the match was a synonym, the resolved name is the accepted name.
- matched_status: Taxonomic status of the matched name (typically, either “accepted” or “synonym”).
- match_type: Type of match. For more information, see the taxastand vignette.