Skip to content

Instantly share code, notes, and snippets.

View PlethoraChutney's full-sized avatar

Rich PlethoraChutney

View GitHub Profile
@PlethoraChutney
PlethoraChutney / animate_vser.py
Created March 5, 2025 17:23
Record a movie of a ChimeraX vseries with color interpolation
#!/usr/bin/env python
from coloraide import Color
import pyperclip
import argparse
from pathlib import Path
def main(args):
vol_base, num_vols = args.num_vols.split(".")
vol_base = "#" + vol_base
num_vols = int(num_vols)
@PlethoraChutney
PlethoraChutney / fix-transcripts.py
Last active November 20, 2024 18:43
Offset timestamps in an .srt file
#!/usr/bin/env python
from pathlib import Path
import re
srt_timestamp_pattern = r"^(\d{2}):(\d{2}):(\d{2}),(\d{3}) --> (\d{2}):(\d{2}):(\d{2}),(\d{3})$"
def seconds_to_minsec(full_seconds:float) -> list[int, int, int, int]:
hours = full_seconds // 3600
full_seconds -= hours * 3600
minutes = full_seconds // 60
@PlethoraChutney
PlethoraChutney / myheader.py
Created April 4, 2024 20:55
Header to read 16-bit MRC files
#!/usr/bin/env python
import sys
import struct
with open(sys.argv[1], "rb") as f:
[nx, ny, nz] = [x[0] for x in struct.iter_unpack('i', f.read(12))]
# don't care about mode, start
_ = f.read(16)
#!/usr/bin/env python
from cryosparc.tools import CryoSPARC
import json
import argparse
import numpy as np
# you would need to enter your information for CryoSPARC here
with open('/u/rposert/instance-info.json', 'r') as f:
instance_info = json.load(f)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PlethoraChutney
PlethoraChutney / revert_symmexp_particles.py
Created October 5, 2023 19:51
Un-downsample a symmetry-expanded particle stack
from cryosparc.tools import CryoSPARC
import numpy as np
cs = CryoSPARC(
# you'll need env variables here, or just set stuff directly
)
cs.test_connection()
# we will filter fullsize_particles so that only the intersection with
# downsampled particles are retained. ctf, alignments, etc. will all