Skip to content

Instantly share code, notes, and snippets.

View danielecook's full-sized avatar
😀
Things are going good

Daniel E Cook danielecook

😀
Things are going good
View GitHub Profile
@danielecook
danielecook / check_bam_integrity.sh
Last active August 15, 2020 14:14
Check integrity of BAMs
function check_bam {
samtools quickcheck ${1}
if [ $? -ne "0" ]; then
echo ${1}
fi
}
export -f check_bam
parallel check_bam ::: *.bam
@danielecook
danielecook / read_gz.nim
Created April 12, 2019 11:38
Read gzipped file in nim
import
zlib, streams
type
GZipStream* = object of StreamObj
f: GzFile
GzipStreamRef* = ref GZipStream
proc fsClose(s: Stream) =
@danielecook
danielecook / extract_modules.sh
Last active March 29, 2019 13:34
Extract modules from scripts #camp
ag -w -o '[A-Za-z0-9\-\_\.]+\/[0-9]+[A-Za-z0-9\-\_\.]+' *.R | sort | uniq | tr ':' '\t' > software.txt
cat software.txt | cut -f 3 | sort | uniq > software.uniq.txt
@danielecook
danielecook / test_file.bash
Created March 29, 2019 10:48
Test whether file or directory do not exist
while read f; do
if [[ ! -f "${f}" && ! -d "${f}" ]]; then
echo "$f not found"
fi
done <file_paths.txt
@danielecook
danielecook / gist:627ca9593088a187428f73630d41096e
Last active March 29, 2019 11:20
Match file paths within files
# Replace /camp or /lab with volume names
ag -o -w "(/camp)[^\"\t '()$]+"
# Also works with rip grep
rg -w "(/camp)[^\"\t '()$]+"
@danielecook
danielecook / illegal_capture.nim
Created March 13, 2019 18:33
nim error illegal capture
import sugar
import argparse
import colorize
import strformat
import strutils
import tables
proc print_error*(msg: string) =
stderr.write_line "Error".bgWhite.fgRed & fmt": {msg}".fgRed
export PS1='\[\e[0;35m\][\t] 🍔 \[\e[m\] '
@danielecook
danielecook / callNimFromR.org
Created March 11, 2019 11:39 — forked from Vindaar/callNimFromR.org
How to call Nim code from R using `.C` interface

Calling Nim from R

A super short introduction how to call Nim code from R using the .C interface. I’m not an R user normally, so I googled and used this post as a reference: https://www.r-bloggers.com/three-ways-to-call-cc-from-r/

Writing our Nim procedure

Let’s define a simple procedure, which we want Nim to do:

@danielecook
danielecook / nextflow_cache.groovy
Created March 5, 2019 17:02
nextflow drops cache
align = design.combine([8,12,16]) // Cores
.combine([12,32,64]) // Memory (GB)
.combine([1,2,3,7,8,9]) // Method
process alignment {
/*
Alignment as performed identically to the old method
*/
@danielecook
danielecook / Compare Bams
Last active February 21, 2019 00:18
Compare hashes of bam files
function samtools_md5() {
md5=`samtools view ${1} | tr '\t' '\n' | sort | md5sum`
echo -e "${md5}\t${1}"
}
export -f samtools_md5
parallel --verbose -j 10 samtools_md5 {} ::: `ls *.bam` > hashes.txt