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

feat: restyle foldseek table with more info #213

Merged
merged 10 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
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
21 changes: 15 additions & 6 deletions backend/src/api/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class SimilarProtein(CamelModel):
prob: float
evalue: float
description: str = ""
qstart: int
qend: int
alntmscore: int


class RangeFilter(CamelModel):
Expand Down Expand Up @@ -131,7 +134,6 @@ def search_proteins(body: SearchProteinsBody):
[text_query, text_query, text_query],
)
if entries_result is not None:
print(entries_result)
return SearchProteinsResults(
protein_entries=[
ProteinEntry(
Expand Down Expand Up @@ -201,14 +203,21 @@ def search_venome_similar(protein_name: str):
similar = easy_search(
stored_pdb_file_name(protein_name),
venome_folder,
out_format="target,prob,evalue",
)[1:]
out_format="target,prob,evalue,qstart,qend",
) # qend,qstart refer to alignment
formatted = [
SimilarProtein(name=name.rstrip(".pdb"), prob=prob, evalue=evalue)
for [name, prob, evalue] in similar
SimilarProtein(
name=name.rstrip(".pdb"),
prob=prob,
evalue=evalue,
qstart=qstart,
qend=qend,
alntmscore=0,
)
for [name, prob, evalue, qstart, qend] in similar
]
except Exception:
raise HTTPException(404, "Foldseek not found on the system")
raise HTTPException(404, "Error in 'foldseek easy-search' command")

try:
# populate protein descriptions for the similar proteins
Expand Down
2 changes: 1 addition & 1 deletion backend/src/foldseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def parse_easy_search_output(filepath: str) -> list[list]:
def easy_search(
query: str,
target: str,
out_format: str = "query, target, prob",
out_format: str = "query,target,prob",
print_loading_info=False,
) -> list[list]:
"""easy_search just calls foldseek easy-search under the hood
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"dependencies": {
"bibtex": "^0.9.0",
"d3": "^7.9.0",
"js-cookie": "^3.0.5",
"marked": "^12.0.0",
"svelte-routing": "^2.11.0"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ p {
}

a {
color: var(--lightblue);
color: var(--primary-600);
}

a:hover {
Expand Down
42 changes: 42 additions & 0 deletions frontend/src/lib/AlignBlock.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script lang="ts">
import * as d3 from "d3";

// query, 0 to ogLength
export let ogLength: number;
// alignment within query
export let qstart: number;
export let qend: number;
export let width: number;
export let height: number;

const alnToWidthScaler = d3
.scaleLinear()
.domain([1, ogLength])
.range([0, width]);
</script>

<svg {width} {height} id="aln" style="overflow: visible;">
<rect {width} {height} fill="var(--primary-100)" />
<line
x1={alnToWidthScaler(qstart)}
y1={height / 2}
x2={alnToWidthScaler(qend)}
y2={height / 2}
stroke-width={height}
stroke="var(--primary-700)"
/>
<text
x={alnToWidthScaler(qend) + 3}
y={height / 2 + 3}
style="font-size: 10px;"
text-anchor="start"
fill="var(--primary-700)">{qend}</text
>
<text
x={alnToWidthScaler(qstart) - 3}
y={height / 2 + 3}
style="font-size: 10px;"
text-anchor="end"
fill="var(--primary-700)">{qstart}</text
>
</svg>
7 changes: 6 additions & 1 deletion frontend/src/lib/DelayedSpinner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export let msDelay = 500;
export let spinnerProps = {};
export let text = "";
export let textRight = false;

let showSpinner = false;

Expand All @@ -15,5 +16,9 @@
</script>

{#if showSpinner}
{text} <Spinner {...spinnerProps} />
{#if textRight}
<Spinner {...spinnerProps} /> {text}
{:else}
{text} <Spinner {...spinnerProps} />
{/if}
{/if}
24 changes: 24 additions & 0 deletions frontend/src/lib/Dot.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script lang="ts">
export let maxColor: string;
export let normalizedValue: number;
export let diameter: number;
const radius = diameter / 2;
</script>

<div>
<svg width={diameter} height={diameter}>
<circle
cx={radius}
cy={radius}
r={radius}
opacity={normalizedValue}
fill={maxColor}
/>
</svg>
</div>

<style>
circle {
transition: opacity ease-in-out 400ms;
}
</style>
59 changes: 59 additions & 0 deletions frontend/src/lib/Molstar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<script lang="ts">
import { PDBeMolstarPlugin } from "../../venome-molstar/lib";

export let url = "";
export let format = "pdb";
export let bgColor = { r: 255, g: 255, b: 255 }; // white
export let binary = false;
export let width = 500;
export let height = 500;

let divEl: HTMLDivElement;
async function render() {
// @ts-ignore
const m = new PDBeMolstarPlugin(); // loaded through app.html
// some bs for the whole thing to rerender. TODO: fix this.
divEl.innerHTML = "";
const div = document.createElement("div");
divEl.appendChild(div);
await m.render(div, {
customData: {
url,
format,
binary,
},
bgColor,
subscribeEvents: false,
selectInteraction: true,
alphafoldView: true,
reactive: true,
sequencePanel: true,
hideControls: true,
hideCanvasControls: ["animation"],
});
}

$: {
if (url && divEl) {
render();
}
}
</script>

<div
bind:this={divEl}
id="myViewer"
style="width: {width}px; height: {height}px;"
/>

<style>
/* https://embed.plnkr.co/plunk/WlRx73uuGA9EJbpn */
.msp-plugin ::-webkit-scrollbar-thumb {
background-color: #474748 !important;
}
#myViewer {
float: left;
position: relative;
z-index: 997;
}
</style>
88 changes: 0 additions & 88 deletions frontend/src/lib/ProteinVis.svelte

This file was deleted.

Loading
Loading