Skip to content

Instantly share code, notes, and snippets.

View kaczmarj's full-sized avatar

Jakub Kaczmarzyk kaczmarj

View GitHub Profile
@kaczmarj
kaczmarj / qupath_wsinfer_runtime.groovy
Created November 9, 2023 15:51
measure runtime of QuPath WSInfer extension
// groovy script to measure running time of wsinfer
import groovy.time.TimeCategory
qupath.ext.wsinfer.ui.WSInferPrefs.deviceProperty().setValue("cpu");
selectAnnotations()
def timeStart = new Date()
qupath.ext.wsinfer.WSInfer.runInference("kaczmarj/breast-tumor-resnet34.tcga-brca")
def timeStop = new Date()
duration = TimeCategory.minus(timeStop, timeStart)
println duration
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kaczmarj
kaczmarj / repair_tiff_resolution.py
Created February 13, 2023 23:47
Repair TIFF image metadata that have MPP in XResolution and YResolution fields.
"""Repair the TIFF metadata for images where XResolution and YResolution contain MPP.
This script updates the following tags:
- ResolutionUnit --> to centimeter
- XResolution --> from mppx to pixels per centimeter in x dimension
- YResolution --> from mppy to pixels per centimeter in y dimension
"""
import argparse
from pathlib import Path
@kaczmarj
kaczmarj / wsi_patch_on_the_fly.py
Created October 22, 2022 18:07
Example torch dataset for loading whole slide image patches on the fly.
"""Example torch Dataset for loading whole slide image patches on the fly."""
from pathlib import Path
import large_image
import pandas as pd
import torch
class PatchDataset(torch.utils.data.Dataset):
@kaczmarj
kaczmarj / inkscape.Singularity
Created January 13, 2022 17:41
Singularity recipe for Inkscape on Debian
BootStrap: docker
From: debian:bookworm-slim
%post
apt update -qq
apt install --yes inkscape
rm -rf /var/lib/apt/lists/*
%runscript
inkscape "$@"
conda create --name MYNAME -c pytorch -c conda-forge pytorch torchvision torchaudio cudatoolkit=11.3 openslide openslide-python
@kaczmarj
kaczmarj / submit-array-elzar.sh
Last active September 22, 2021 15:39
Submit an array job on Elzar (use qsub)
#!/bin/bash
#
#$ -cwd
#$ -q gpu_ded.q
#$ -w e
#$ -l gpu=1
#$ -l m_mem_free=32G
#
# To run this script, first create a file with each command you want to run. Each
# command must be on a separate line.
@kaczmarj
kaczmarj / findgpus.sh
Created August 25, 2021 21:09
Script to find available GPUs in nodes gpu001 through gpu010.
#!/usr/bin/env bash
set -u
echo "Searching for nodes with available GPUs..."
for suffix in {001..010}; do
remote="gpu${suffix}"
ssh "$remote" nvidia-smi | grep -q "No running processes found"
if [ $? -eq 0 ]; then

How to use ColabFold on Elzar

This guide demonstrates how to use Sergey's ColabFold notebooks on Cold Spring Harbor's Elzar cluster. The instructions can also be extended to any cluster that has a GPU and Singularity installed.

These instructions were only tested with Jakub Kaczmarzyk's AlphaFold2_advanced_notcolab.ipynb notebook, which is a minor modification of Sergey's original AlphaFold2_advanced.ipynb notebook. Even Amber relaxation is tested.

❗❗❗IMPORTANT: after finishing your work, be sure to terminate the GPU process. To do this, you can shutdown the jupyter notebook (this is not equivalent to closing the tab, you need to go to Kernel->Shutdown). And quit the singularity process as well. Exit the qrsh job when you are finished.

def to_png_with_metadata(img, path, **meta_kwds):
"""Write a PIL image to PNG with associated metadata.
Parameters
----------
img : PIL.Image.Image
Image to write.
path : str, pathlib.Path
Save the image to this path. The extension '.png' is added
if it is not present.