Skip to content

Instantly share code, notes, and snippets.

View janxkoci's full-sized avatar

Jeňa Kočí janxkoci

View GitHub Profile
@janxkoci
janxkoci / plinkmds2tsv.sh
Last active March 25, 2022 12:10
A simple script for converting Plink MDS (with messy whitespace) to TSV format. Another one for generic tables (it's the same but with better name).
#!/bin/bash
# Script for converting plink MDS (with space-aligned columns) into TSV format.
INFILE=$1
NCOL=$(head -1 $INFILE | wc -w) # 5
COLS=$(echo '$'$(seq 1 $NCOL) | sed 's/ /,$/g') # $1,$2,$3,$4,$5
awk 'BEGIN {OFS="\t"} {print '"$COLS"'}' $INFILE
@janxkoci
janxkoci / revcomp_bioawk.sh
Last active August 17, 2020 09:35
Get a reverse complement of any sequence, given as a parameter. Great for quick searching of primers, adapters, etc.
#!/bin/bash
# USAGE:
# revcomp_bioawk.sh actgactg
# requires bioawk, which can be installed with conda:
# conda install -c conda-forge -c bioconda bioawk
seq=$1
@janxkoci
janxkoci / nightmode_bookmarklets.js
Last active January 18, 2021 19:47
NightMode bookmarklets (copy one or all)
// this one inverts colours on a page; second click reverts it (because it's exact negative)
javascript:(function(){function RGBtoHSL(RGBColor){with(Math){var R,G,B;var cMax,cMin;var sum,diff;var Rdelta,Gdelta,Bdelta;var H,L,S;R=RGBColor[0];G=RGBColor[1];B=RGBColor[2];cMax=max(max(R,G),B);cMin=min(min(R,G),B);sum=cMax+cMin;diff=cMax-cMin;L=sum/2;if(cMax==cMin){S=0;H=0;}else{if(L<=(1/2))S=diff/sum;else S=diff/(2-sum);Rdelta=R/6/diff;Gdelta=G/6/diff;Bdelta=B/6/diff;if(R==cMax)H=Gdelta-Bdelta;else if(G==cMax)H=(1/3)+Bdelta-Rdelta;else H=(2/3)+Rdelta-Gdelta;if(H<0)H+=1;if(H>1)H-=1;}return[H,S,L];}}function getRGBColor(node,prop){var rgb=getComputedStyle(node,null).getPropertyValue(prop);var r,g,b;if(/rgb\((\d+),\s(\d+),\s(\d+)\)/.exec(rgb)){r=parseInt(RegExp.$1,10);g=parseInt(RegExp.$2,10);b=parseInt(RegExp.$3,10);return[r/255,g/255,b/255];}return rgb;}function hslToCSS(hsl){return "hsl("+Math.round(hsl[0]*360)+", "+Math.round(hsl[1]*100)+"%, "+Math.round(hsl[2]*100)+"%)";}var props=["color","background-color","b
@janxkoci
janxkoci / mendeley_bookmarklet.js
Created July 19, 2020 18:01
Mendeley bookmarklet for browsers such as Safari and Epiphany.
javascript:document.getElementsByTagName("body")[0].appendChild(document.createElement("script")).setAttribute("src","https://static.mendeley.com/bin/extensions/bookmarklet.js");
@janxkoci
janxkoci / convert_compress_jpg.sh
Last active May 27, 2022 09:43
bunch of helper scripts from my home bin folder..
#!/bin/bash
IN=$1
OUT=$2
# uses ImageMagick convert command
convert $IN \
-sampling-factor 4:2:0 \
-strip \
-quality 85 \
@janxkoci
janxkoci / PushBulletBookmarklet.js
Created April 1, 2020 15:57 — forked from rpavlik/PushBulletBookmarklet.js
PushBullet Bookmarklet
(function() {
var API_KEY = "YOUR_API_KEY_GOES_HERE";
// code for IE7+, Firefox, Chrome, Opera, Safari - forget IE6
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "https://api.pushbullet.com/v2/pushes", true);
xmlhttp.setRequestHeader('Content-Type', 'application/json');
xmlhttp.setRequestHeader('Authorization', "Bearer " + API_KEY);
/// @todo needs oauth2 update? ugh.
@janxkoci
janxkoci / pylab.yml
Last active January 21, 2021 13:51
Conda environment with Jupyter, Scientific Python, and ToyPlot
name: pylab
channels:
- conda-forge
dependencies:
- python=3
- jupyter
- jupyterthemes
- scipy
- numpy
- pandas
@janxkoci
janxkoci / jupyteR_data_science.md
Last active April 14, 2020 07:56
Jupyter and R for Scientists

Comments: Jupyter and R for Scientists

This is a place to share comments about the post Jupyter and R for Scientists I published on my blog.

Contributing

If you'd like to improve the post, you can fork it on Github and submit a pull request.

Comments

@janxkoci
janxkoci / melt_table.sh
Last active October 20, 2023 09:41
Script takes output of GATK's VariantsToTable tool and melts it for better processing (with mysql or awk)
#!/bin/bash
## USAGE:
# bash melt_table.sh INFILE.tsv > OUTPUT.tsv
# set variables
outfile=/dev/stdout
tot_ncol=$(head -1 $1 | wc -w)
nsample=$(head -1 $1 | cut -f 3- | sed 's/\.[A-Z][A-Z]\>//g' | tr "\t" "\n" | uniq | wc -l)
ncol=$(expr $(expr $tot_ncol - 2) / $nsample)
@janxkoci
janxkoci / awk_vcf_anim_chrom_pos.sh
Last active November 17, 2018 22:22
AWK script to parse info on a single sample and position from a VCF file
#!/bin/bash
# bash awk_vcf_anim_chrom_pos.sh in.vcf sample chrom pos
echo vcf: "$1"
echo sample: "$2"
echo chrom: "$3"
echo pos: "$4"
awk -v sample=$2 -v chrom="$3" -v pos=$4 \