Skip to content

Instantly share code, notes, and snippets.

View williamrowell's full-sized avatar
🙃

Billy Rowell williamrowell

🙃
View GitHub Profile
@williamrowell
williamrowell / awk_oneline
Last active August 29, 2015 14:16
One-liners
HANDY ONE-LINE SCRIPTS FOR AWK 30 April 2008
Compiled by Eric Pement - eric [at] pement.org version 0.27
Latest version of this file (in English) is usually at:
http://www.pement.org/awk/awk1line.txt
This file will also be available in other languages:
Chinese - http://ximix.org/translation/awk1line_zh-CN.txt
USAGE:
@williamrowell
williamrowell / id3rename.sh
Created June 8, 2015 01:57
Rename mp3 file based on id3 tags using eyeD3
#!/bin/bash
eyeD3 --rename '$artist - $album - $track:num - $title' *.mp3
@williamrowell
williamrowell / remove_newlines.sh
Created June 8, 2015 02:00
remove all newlines from all files in folder
#!/bin/bash
# for all files in folder, remove newlines
for FILE in `ls`
do
tr -d '\n' < $FILE > ${FILE}.tmp
mv ${FILE}.tmp $FILE
done
@williamrowell
williamrowell / transcode_audio.sh
Created June 8, 2015 02:01
transcode all flac files into mp3
#!/bin/sh
mkdir mp3
for I in *.flac; do
flac -d --stdout "$I" | lame -V0 --vbr-new - mp3/"$I"
done
for J in *.flac; do
id3cp -2 "$J" mp3/"$J"
done
@williamrowell
williamrowell / secure_ports.sh
Created July 11, 2015 17:23
securing an ubuntu droplet
sudo apt-get install ufw fail2ban
ufw enable
sudo ufw enable
sudo ufw logging low
sudo ufw allow 80/tcp # http
sudo ufw allow 443/tcp # https
sudo ufw allow 64738 # mumble
sudo ufw limit 22/tcp # limit ssh attempts
sudo ufw status
@williamrowell
williamrowell / cellFromTextFile.m
Last active August 29, 2015 14:24
MATLAB helper functions
function cellArray = cellFromTextFile(fileName)
% Loads cell array of strings, 1xN character arrays, from the given text
% file.
if exist(fileName, 'file') == 0
error('unable to read file, %s, does not exist', fileName);
end
try
cellArray = textread(fileName, '%s');
catch ME
error('unable to read file, %s: %s', ME.message);
@williamrowell
williamrowell / error_jitter.m
Created September 1, 2015 14:45
scatter plots with error bars and jitter in MATLAB
function error_jitter(xvals, yvals, errvals)
%%ERROR_JITTER(xvals, yvals)
%
% xvals -> array of x positions
% yvals -> cell array of multiple y positions for each x position
% errvals -> cell array of multiple std/sem for each x position
% TODO: allow yvals/errvals to be ragged array
%
% author: William Rowell (rowellw@janelia.hhmi.org)
@williamrowell
williamrowell / mockingbird.py
Last active June 17, 2018 02:44
Download corpus of #tweets for user and generate new tweets.
#!/usr/bin/env python
"""Download corpus of tweets for user SCREEN_NAME and generate new tweets.
"""
import os
import sys
import json
import argparse
import twitter
import markovify
@williamrowell
williamrowell / dotplot workflow
Last active June 17, 2018 02:40
Make #dotplots of #ccs reads using either #gepard or #flexidot
module load smrtanalysis/mainline jre parallel
# extract fasta from ccs readset
bam2fasta -u -o consensusreadset consensusreadset.bam
# make dotplots with gepard
python split_ccs_fasta.py consensusreadset.fasta
## download gepard and prepare it
wget https://github.com/univieCUBE/gepard/archive/v1.40.0.zip
unzip v1.40.0.zip
@williamrowell
williamrowell / depth_mean_stddev.py
Last active February 13, 2024 16:49
Calculate the mean and standard deviation of a coverage depth distribution as if it were normally distributed.
#!/usr/bin/env python3
"""Coverage mean and standard deviation of autosomes
Estimate the mean and standard deviation from a mosdepth coverage BED for
positions with coverage in the range (0, 2 * non-zero mode). This estimate
behaves well for PacBio HiFi WGS of human germline aligned to either hs37d5 and
GRCh38, and may be useful for other situations as well.
$ bash mosdepth --threads 3 --no-per-base --by 500 -m "${BAM%.*}.median" "${BAM}"
$ tabix ${BAM%.*}.median.regions.bed.gz {1..22} | python depth_mean_stddev.py