Skip to content

Instantly share code, notes, and snippets.

View clintval's full-sized avatar

Clint Valentine clintval

View GitHub Profile
################################################################################
# Update and install OS packages
# https://docs.anaconda.com/anaconda/install/silent-mode/#linux-macos
################################################################################
RUN curl --location --fail --remote-name \
https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh \
&& bash Miniforge3-Linux-x86_64.sh -b -p /opt/conda -u \
&& rm Miniforge3-Linux-x86_64.sh
###############################################################################
@clintval
clintval / hi.py
Created March 14, 2025 00:38
testme
print("Hello")
abuilder = SamBuilder(r1_len=20, r2_len=20)
(read1, read2) = builder.add_pair(
name="query",
chrom1="chr1",
start1=100,
bases1="A" * 10,
chrom2="chr1",
start2=200,
bases2="C" * 20,
)
FROM debian:bookworm-20250113-slim AS base
ENV LANG=C.UTF-8
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
gnupg \
@clintval
clintval / fetch-das.py
Created August 19, 2024 22:09
Fetch a DNA sequence from the UCSC Das web server
def dna_sequence_from_DAS(build: str, chrom: str, start: int, end: int) -> str:
"""
Return the DNA sequence along an interval for a reference sequence build.
Uses the DAS web server.
Args:
build: The UCSC genome build.
chrom: The reference sequence name.
start: The 1-based start locus.
class MethodType:
"""A Python-equivalent method type that binds type arguments to the calling class."""
def __init__(self, func: Callable, obj: object) -> None:
"""Initialize this method with the calling class and function."""
self.__func__ = func
self.__self__ = obj
self._generic_classmethod = False
def __call__(self, *args: object, **kwargs: object) -> object:
def is_classmethod(method: FunctionType) -> bool:
"""Determine if a method is a classmethod or not by searching for a classmethod sentinel."""
bound_to = getattr(method, "__self__", None)
if not isinstance(bound_to, type):
return False
name = method.__name__
for clazz in bound_to.__mro__:
descriptor = vars(clazz).get(name)
if descriptor is not None:
return isinstance(descriptor, classmethod)
@clintval
clintval / make-jar-executable.sh
Created April 3, 2024 21:47
Make a JAR executable
{
cat <<- EOM
#!/usr/bin/env sh
set -e
PROP_OPTS=()
MEM_OPTS=()
PASS_ARGS=()
DEFAULT_MEM_OPTS=('-Xms512m' '-XX:+AggressiveHeap')
@clintval
clintval / compile-nf-groovy.sh
Created January 8, 2024 16:41
Compile Nextflow library groovy code linked against Nextflow
#!/bin/bash
# Attempts to compile the groovy present in nextflow/lib/ with the groovy compiler and nextflow
# libararies properly linked (because they dont live in a place groovy can find them by default.)
#
# Must have a conda env with nextflow and groovy installed in order for this script to work.
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
@clintval
clintval / snakegraph.sh
Last active October 20, 2023 04:28
Render Snakemake DAGs in your terminal
# Convert DOT graph data into a terminal-ready visualization
function idot {
dot \
-Tpng -Gdpi=300 \
-Efontsize=18 -Efontname=sans -Nfontname=sans \
-Gbgcolor=black -Gcolor=white -Ecolor=white -Efontcolor=white -Ncolor=white -Nfontcolor=white \
| convert -trim -bordercolor black -border 20 -transparent black -resize "60%" - - \
| imgcat # Or swap with your favorite terminal image viewer
}