Skip to content

Instantly share code, notes, and snippets.

View martinholub's full-sized avatar

Martin Holub martinholub

View GitHub Profile
# https://stevenmortimer.com/5-steps-to-change-github-default-branch-from-master-to-main/#step-3---point-head-to-main-branch
# Step 1
# create main branch locally, taking the history from master
git branch -m master main
# Step 2
# push the new local main branch to the remote repo (GitHub)
git push -u origin main
git push -d <remote_name> <branch_name>
git branch -d <branch_name>
@martinholub
martinholub / merge_branch.sh
Created June 8, 2020 08:42
Merge git branches
# https://stackoverflow.com/questions/449541/how-to-selectively-merge-or-pick-changes-from-another-branch-in-git
# merge branch SOURCE to DETINATION
git checkout DESTINATION
git merge --no-ff --no-commit SOURCE
# inspect and solve potential conflicts
git status
git diff --cached file1
@martinholub
martinholub / parse_args.sh
Created October 10, 2018 11:25
Parse arguments in bash
# Parse Arguments --------------------------------------------------------------
# reference: https://stackoverflow.com/a/14203146
POSITIONAL=()
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-v|--vcf)
vcf="$2"
shift # past argument
@martinholub
martinholub / transcript_snp.py
Last active October 10, 2018 11:18
Generating Transcriptomic SNV coordinates and annotation
class TranscriptomicSNP(object):
""" Generate a VCF file with transcriptomic coordinates
Gets transcriptomic snp loci in format <transc> <SNPpos> <additional_info...>.
# available:
# <chrom> <transc> <start> <end>
# <chrom> <SNVpos>
"""
@martinholub
martinholub / rm_ext.py
Created October 10, 2018 09:00
Utilites for handling lists and filenames
def rm_ext(fname, ext = None):
"""Removes extension from filename"""
if not ext:
ext = re.match(".*\.(.*)$", fname).group(1)
else:
ext = ext.strip(".")
return re.sub("\." + ext + "$","", fname)
@martinholub
martinholub / _gunzip.sh
Last active February 3, 2020 11:27
Downloading and validating files from ftp/http locations. Tested mainly with Ensembl.
for f in {input}
do
# mkdir --parents $f
[[ $f == *.gz ]] && gunzip --keep $f
done
@martinholub
martinholub / bioinformatics.md
Last active October 11, 2018 15:55
Bioinformaticians Toolbox

Bioinformatician's Toolbox

This document aggregates snippets that I found useful when working in bioinfromatics. It is work in progress and I will extend it as needed. It is mainly in form of toy examples or pseudcode. Please adjust it accodring to your needs.

MariaDB

mysql --user=root -p
/*get preview */
show databases;
USE <some_database>;
show tables;
@martinholub
martinholub / add_buffer_gps.cpp
Last active July 15, 2018 07:58
Talking Bytes with The Things Network
void add_buffer_gps(double lat, double lon){
// offset by 90(180) to make positive and scale to 0..1
latB = ((lat + 90) / 180.0) * pow(256,3);
lonB = ((lon + 180) / 360.0) * pow(256,3);
// byte shifting
dataBuffer[0] = ( latB >> 16 ) & 0xFF;
dataBuffer[1] = ( latB >> 8 ) & 0xFF;
dataBuffer[2] = latB & 0xFF;
@martinholub
martinholub / callbacks_examples.py
Last active July 14, 2018 10:42
Double Dueling Deep Q-Learning Network
from keras.callbacks import Callback as KerasCallback, CallbackList as KerasCallbackList
from keras.callbacks import TensorBoard
from keras.optimizers import Adam, RMSprop
import keras.backend as K
class SubTensorBoard(TensorBoard):
"""Subclassing of tensorboard to log and visualize custom metrics and others
Note that for this to work, you will have to define a way how to handle `on_episode_end`
calls.