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 / nextflow-bash.sh
Last active January 26, 2024 18:03
Useful nextflow bash functions
# Shortcut for going to work directories
# Usage: gw <workdir pattern>
# Replace the work directory below as needed
# Where workdir pattern is something like "ab/afedeu"
function gw {
path=`ls --color=none -d /path/to/work/directory/$1*`
cd $path
}
# Go work that fetches work dir from .nextflow.log
@danielecook
danielecook / Fetch_Grantham.R
Last active August 11, 2023 09:44
Grantham Matrix
grantham <- readr::read_tsv("https://gist.githubusercontent.com/danielecook/501f03650bca6a3db31ff3af2d413d2a/raw/5583a134b36b60762be6cd54002a0f4044338cd0/grantham.tsv") %>%
tidyr:: gather(SECOND,SCORE, -FIRST) %>% dplyr::filter(SCORE > 0)
calculate_grantham <- function(a1, a2) {
(grantham %>% dplyr::filter(FIRST == a1, SECOND == a2))$SCORE
}
@danielecook
danielecook / format_pubs.py
Created May 14, 2013 19:59
This script takes a csv containing authors and associated Pubmed identifiers (PMIDs) of their publications and outputs a formatted html document of their publications. The first row of the csv should contain the authors, and each row below their publications (as PMIDs). If you put something other than a PMID in it will simply be outputted - so y…
"""
Daniel E. Cook 2013
(danielecook.com)
This script takes a csv containing authors and associated Pubmed identifiers (PMIDs) of their publications and outputs a formatted html document of their publications.
The first row of the csv should contain the authors, and each row below their publications (as PMIDs). If you put something other than a PMID in it will simply be outputted -
so you can add publications that might not be in pubmed or that you want to display in a certain way.
This script might be useful for individuals who maintains publication lists for researchers at a university, for instance.
@danielecook
danielecook / lafitness.py
Last active October 11, 2022 18:20
Generates an ics (icalendar / ical) for an LA fitness club. You must know the club ID, which you can get by going through their website, finding your club, and going to the fitness classes page. It's at the end of the URL (clubid=...)
from pyquery import PyQuery as pq
from icalendar import Calendar, Event
import datetime
from datetime import date, timedelta
from dateutil.relativedelta import *
from dateutil.parser import *
from pprint import pprint as pp
clubid = 722
url = "https://www.lafitness.com/Pages/ClassSchedulePrintVersion.aspx?clubid=%s" % clubid
@danielecook
danielecook / cn.mops.R
Created March 24, 2015 19:55
Call cnvs using cn.mops #cluster
#!/usr/bin/Rscript
#SBATCH --job-name=mops
#SBATCH --output=../log/%j.txt
#SBATCH --error=../log/%j.out
#SBATCH --partition=compute
#SBATCH --nodelist=node3
@danielecook
danielecook / parallel_bcftools.sh
Last active March 18, 2022 07:46
parallel bcftools
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
function bam_chromosomes() {
# Fetch chromosomes from a bam file
samtools view -H $1 | \
grep -Po 'SN:(.*)\t' | \
cut -c 4-1000
}
@danielecook
danielecook / pyenv.sublime-build
Created May 2, 2018 20:15
pyenv sublime build system
{
"cmd": ["/usr/local/var/pyenv/shims/python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
@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 / bash-cheatsheet.sh
Created November 22, 2019 09:50 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@danielecook
danielecook / realign_bam.sh
Created August 7, 2021 00:49
Remapping an aligned bam
# Source: https://lh3.github.io/2021/07/06/remapping-an-aligned-bam
samtools collate -Oun128 in.bam | samtools fastq -OT RG,BC - \
| bwa mem -pt8 -CH <(samtools view -H in.bam|grep ^@RG) ref.fa - \
| samtools sort -@4 -m4g -o out.bam -