Skip to content
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
212 changes: 211 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ cargo run --release

(Bevy uses Metal; no Vulkan needed.)

### Performance

```bash
just bench
# or
cargo bench -p vizmat-core --bench bond_cache
```

## wasm

It require rustc target `wasm32-unknown-unknown` installed.
Expand Down
40 changes: 37 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,53 @@
set shell := ["bash", "-eu", "-o", "pipefail", "-c"]

check-pdb path:
@if rg -n -i "^[[:space:]]*<!doctype|^[[:space:]]*<html|^[[:space:]]*<head|^[[:space:]]*<body" {{path}} >/dev/null; then \
echo "ERROR: {{path}} looks like HTML, not PDB"; \
exit 1; \
fi
@if ! rg -n "^(ATOM |HETATM)" {{path}} >/dev/null; then \
echo "ERROR: {{path}} has no ATOM/HETATM records"; \
exit 1; \
fi

clean-broken-proteins:
rm -f vizmat-app/assets/proteins/4V6F.pdb vizmat-app/assets/proteins/4V6F.xyz
rm -f vizmat-app/assets/proteins/7K00.pdb vizmat-app/assets/proteins/7K00.xyz
ls -1 vizmat-app/assets/proteins

verify-proteins:
@for f in vizmat-app/assets/proteins/*.pdb; do \
just check-pdb "$f"; \
done
@for f in vizmat-app/assets/proteins/*.xyz; do \
n="$(head -n 1 "$f" | tr -d '\r')"; \
if ! [[ "$n" =~ ^[0-9]+$ ]] || [ "$n" -eq 0 ]; then \
echo "ERROR: $f has invalid/zero atom count in line 1: '$n'"; \
exit 1; \
fi; \
done
echo "Protein files verify OK"

protein-4hhb:
mkdir -p vizmat-app/assets/proteins
curl -L "https://files.rcsb.org/download/4HHB.pdb" -o vizmat-app/assets/proteins/4HHB.pdb
curl -fL "https://files.rcsb.org/download/4HHB.pdb" -o vizmat-app/assets/proteins/4HHB.pdb
just check-pdb vizmat-app/assets/proteins/4HHB.pdb
awk 'function trim(s){ gsub(/^ +| +$/, "", s); return s } BEGIN{ n=0 } /^(ATOM |HETATM)/ { n++; x=substr($0,31,8)+0; y=substr($0,39,8)+0; z=substr($0,47,8)+0; el=trim(substr($0,77,2)); if (el=="") { name=trim(substr($0,13,4)); el=substr(name,1,1) } elem[n]=el; xs[n]=x; ys[n]=y; zs[n]=z } END{ out="vizmat-app/assets/proteins/4HHB.xyz"; print n > out; print "4HHB hemoglobin (from PDB ATOM/HETATM records)" >> out; for(i=1;i<=n;i++) printf "%s %.5f %.5f %.5f\n", elem[i], xs[i], ys[i], zs[i] >> out }' vizmat-app/assets/proteins/4HHB.pdb
wc -l vizmat-app/assets/proteins/4HHB.xyz
head -n 5 vizmat-app/assets/proteins/4HHB.xyz

protein-6vxx:
mkdir -p vizmat-app/assets/proteins
curl -L "https://files.rcsb.org/download/6VXX.pdb" -o vizmat-app/assets/proteins/6VXX.pdb
curl -fL "https://files.rcsb.org/download/6VXX.pdb" -o vizmat-app/assets/proteins/6VXX.pdb
just check-pdb vizmat-app/assets/proteins/6VXX.pdb
awk 'function trim(s){ gsub(/^ +| +$/, "", s); return s } BEGIN{ n=0 } /^(ATOM |HETATM)/ { n++; x=substr($0,31,8)+0; y=substr($0,39,8)+0; z=substr($0,47,8)+0; el=trim(substr($0,77,2)); if (el=="") { name=trim(substr($0,13,4)); el=substr(name,1,1) } elem[n]=el; xs[n]=x; ys[n]=y; zs[n]=z } END{ out="vizmat-app/assets/proteins/6VXX.xyz"; print n > out; print "6VXX structure (from PDB ATOM/HETATM records)" >> out; for(i=1;i<=n;i++) printf "%s %.5f %.5f %.5f\n", elem[i], xs[i], ys[i], zs[i] >> out }' vizmat-app/assets/proteins/6VXX.pdb
wc -l vizmat-app/assets/proteins/6VXX.xyz
head -n 5 vizmat-app/assets/proteins/6VXX.xyz

protein-3j3a:
mkdir -p vizmat-app/assets/proteins
curl -L "https://files.rcsb.org/download/3J3A.pdb" -o vizmat-app/assets/proteins/3J3A.pdb
curl -fL "https://files.rcsb.org/download/3J3A.pdb" -o vizmat-app/assets/proteins/3J3A.pdb
just check-pdb vizmat-app/assets/proteins/3J3A.pdb
awk 'function trim(s){ gsub(/^ +| +$/, "", s); return s } BEGIN{ n=0 } /^(ATOM |HETATM)/ { n++; x=substr($0,31,8)+0; y=substr($0,39,8)+0; z=substr($0,47,8)+0; el=trim(substr($0,77,2)); if (el=="") { name=trim(substr($0,13,4)); el=substr(name,1,1) } elem[n]=el; xs[n]=x; ys[n]=y; zs[n]=z } END{ out="vizmat-app/assets/proteins/3J3A.xyz"; print n > out; print "3J3A ribosome (from PDB ATOM/HETATM records)" >> out; for(i=1;i<=n;i++) printf "%s %.5f %.5f %.5f\n", elem[i], xs[i], ys[i], zs[i] >> out }' vizmat-app/assets/proteins/3J3A.pdb
test "$(head -n 1 vizmat-app/assets/proteins/3J3A.xyz)" -gt 0
test "$(wc -l < vizmat-app/assets/proteins/3J3A.xyz)" -eq "$(( $(head -n 1 vizmat-app/assets/proteins/3J3A.xyz) + 2 ))"
Expand All @@ -27,6 +58,9 @@ protein-3j3a:
watch:
cargo watch -x "run"

bench:
cargo bench -p vizmat-core --bench bond_cache

wasm:
rustup target add wasm32-unknown-unknown --toolchain nightly-aarch64-apple-darwin
cd vizmat-app && PATH="$HOME/.cargo/bin:$PATH" NO_COLOR=false trunk serve --port 8082
Expand Down
Loading