Skip to content

Instantly share code, notes, and snippets.

View winni2k's full-sized avatar

Winni Kretzschmar winni2k

View GitHub Profile

WSL 2 Cisco AnyConnect Networking Workaround

Overview

WSL 2 uses a Hyper-V Virtual Network adapter. Network connectivity works without any issue when a VPN is not in use. However when a Cisco AnyConnect VPN session is established Firewall Rules and Routes are added which breaks connectivity within the WSL 2 VM. This issue is tracked WSL/issues/4277

Below outline steps to automatically configure the Interface metric on VPN connect and update DNS settings (/etc/resolv.conf) on connect/disconnect.

Manual Configuration

Set Interface Metrics

@winni2k
winni2k / build.sh
Last active March 25, 2021 07:39
Trying to build conda package for crystal
mkdir -p $PREFIX/bin $PREFIX/lib $PREFIX/share
ls -lha
cp bin/* $PREFIX/bin/
cp -r lib/* $PREFIX/lib/
cp -r share/* $PREFIX/share/
@winni2k
winni2k / conda_environment.yml
Last active September 4, 2020 16:40
Run bcftools call in parallel across regions in a bed file
channels:
- conda-forge
- bioconda
dependencies:
- python>=3.7
- samtools=1.10
- bcftools=1.10
- pyyaml
- click
20 44564973 44564980 pilot
20 44564981 44565001 pilot
@winni2k
winni2k / split_bam_by_barcode.py
Last active March 31, 2024 08:37
Split a 10x barcoded sequencing file into barcode-specific BAMs
"""
MIT License
Copyright (c) 2020 Warren W. Kretzschmar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@winni2k
winni2k / effective_base_depth.py
Last active March 30, 2020 15:31
This is a script that sums up the bases at a position or region weighted by their base quality
import math
import yaml
import pysam
def main(samfile_name, chrom, start, end):
"""
:param samfile_name:
:param chrom: string
@winni2k
winni2k / mrbayes_prep.smk
Created March 23, 2020 16:57
Mrbayes preprocessing
rule prepare_out_mat_for_mrbayes:
input:
gt='results/shearwater/Shearwater_calls_FDR0.95_all_muts.gt{gt_num}.txt.gz',
output:
mat='results/mrbayes/shearwater.gt{gt_num, \d+}/Shearwater_calls_FDR0.95_all_muts.gt{gt_num}.mat.gz',
combined='results/mrbayes/shearwater.gt{gt_num, \d+}/Shearwater_calls_FDR0.95_all_muts.gt{gt_num}.sample_mat.txt',
shell:
"""
gzip -dc {input.gt} | cut -f 5-144 | sed 's/NA/?/g' | rs -c'\t' -C'\t' -T | sed 's/\t//g' | gzip -c > {output.mat}
set +o pipefail
@winni2k
winni2k / nextflow.nf
Created March 26, 2019 10:42
nextflow conda bug
params.in = "$baseDir/reads.fa"
sequences = file(params.in)
process test {
conda 'transabyss'
input:
file 'input.fa' from sequences
output:
file 'transcripts.fa' into results
from zipfile import ZipFile
text = b'hello world'
with ZipFile('spam.zip', 'w') as inzip:
with inzip.open('eggs.txt', 'w') as infile:
infile.write(text)
with ZipFile('spam.zip', 'r') as myzip:
with myzip.open('eggs.txt', 'r') as myfile:
@winni2k
winni2k / input.fasta
Last active October 8, 2018 15:16
Minimal example for mccortex threading bug
>0
CGTT
>1
CGTA