Download frontend/src/components/Modifications.tsx from omaib/MuSProt: direct link, hf CLI and curl.
- Browser
- Download file 2.45 kB
-
https://huggingface.co/spaces/omaib/MuSProt/resolve/main/frontend/src/components/Modifications.tsx
- Command line
-
hf download hf://spaces/omaib/MuSProt/frontend/src/components/Modifications.tsx
-
curl -L -o Modifications.tsx https://huggingface.co/spaces/omaib/MuSProt/resolve/main/frontend/src/components/Modifications.tsx
2.45 kB
| /** Modified residues (phosphorylation, methylation, …) of an observation. */ | |
| /** '197:TPO' or {pos, comp} -> label like 'T197 · TPO' using the canonical sequence letter. */ | |
| function label(pos: number, comp: string, sequence?: string) { | |
| const aa = sequence?.[pos - 1]; | |
| return `${aa ?? ''}${pos} · ${comp}`; | |
| } | |
| function parse(items: string[] = []) { | |
| return items | |
| .map((s) => { | |
| const [p, comp] = s.split(':'); | |
| return { pos: Number(p), comp, key: s }; | |
| }) | |
| .filter((m) => Number.isFinite(m.pos) && m.comp); | |
| } | |
| /** Chips for one chain; with `home`, sites missing there are marked gained and its extra sites counted as lost. */ | |
| export function ModChips({ | |
| mods = [], | |
| sequence, | |
| home, | |
| max = 8, | |
| }: { | |
| mods?: string[]; | |
| sequence?: string; | |
| home?: string[]; | |
| max?: number; | |
| }) { | |
| const homeSet = home ? new Set(home) : null; | |
| const lost = home ? home.filter((k) => !mods.includes(k)) : []; | |
| const list = parse(mods); | |
| if (!list.length && !lost.length) return <span className="muted">—</span>; | |
| return ( | |
| <span | |
| className="pchips pchips--stacked" | |
| title={lost.length ? `Modified in this chain but not here: ${parse(lost).map((m) => label(m.pos, m.comp, sequence)).join(', ')}` : undefined} | |
| > | |
| {list.slice(0, max).map((m) => ( | |
| <span key={m.key} className={`pchip pchip--mod ${homeSet && !homeSet.has(m.key) ? 'is-gained' : ''}`}> | |
| {label(m.pos, m.comp, sequence)} | |
| </span> | |
| ))} | |
| {list.length > max && <span className="pchip pchip--more">+{list.length - max}</span>} | |
| {!list.length && <span className="muted small">none</span>} | |
| {lost.length > 0 && <span className="pchip pchip--lost">−{lost.length}</span>} | |
| </span> | |
| ); | |
| } | |
| /** Inline list for the chain page: types, then every site. */ | |
| export function ModificationList({ | |
| mods, | |
| types, | |
| sequence, | |
| }: { | |
| mods: Array<{ pos: number; comp: string }>; | |
| types: string[]; | |
| sequence: string; | |
| }) { | |
| if (!mods.length) return null; | |
| return ( | |
| <div className="mods"> | |
| <span className="mods__head"> | |
| Modified residues <span className="muted">({types.join(', ')})</span> | |
| </span> | |
| <span className="mods__list"> | |
| {mods.map((m) => ( | |
| <span key={`${m.pos}${m.comp}`} className="pchip pchip--mod" title={`SEQRES position ${m.pos}, residue ${m.comp}`}> | |
| {label(m.pos, m.comp, sequence)} | |
| </span> | |
| ))} | |
| </span> | |
| </div> | |
| ); | |
| } | |