Skip to content

Instantly share code, notes, and snippets.

View dwinter's full-sized avatar
🐢
I may be slow to respond.

David Winter dwinter

🐢
I may be slow to respond.
View GitHub Profile
@dwinter
dwinter / coverage.sh
Last active July 31, 2019 01:39
three column cov to windows
tail cov.tsv -n1 | cut -f1,2 > spp.genome
bedtools makewindows -g spp.genome -w 1000 > spp_1kw.bed
awk -v OFS='\t' '{print $1,($2 -1),$2,$3 }' cov.tsv > cov.bed
bedtools map -a spp_1kw.bed -b cov.bed -c 4 -o mean
@dwinter
dwinter / ortho.py
Last active November 21, 2019 00:51
from collections import defaultdict
from Bio import SeqIO
class Orthologs:
def __init__(self, ortho_file, seq_map_file):
"""Store information on orthologs from another of strains """
self.ortholog_map = defaultdict(lambda: defaultdict(list))
with open(ortho_file) as infile:
$include /etc/inputrc
"\e[A":history-search-backward
"\e[B":history-search-forward
export HISTSIZE=1000000
export HISTFILESIZE=1000000000
export HISTIGNORE='pwd:ls:history:'
def base_consensus(alignment, base_index):
""" """
# get the bases at this position, store in case we want to come back
# and assign the first one as th winner
#n_seqs = len(alignment)
bases = [r[base_index].upper() for r in alignment]
base_c = Counter(bases)
max_count = max(base_c.values())
most_common_base = [b for b in base_c.items() if b[1] == max_count]
if len(most_common_base) == 1:
@dwinter
dwinter / .block
Last active November 2, 2022 10:27
voc_map
license: cc-by-4.0
height: 1800
scrolling: no
border: yes
library(lubridate)
library(dplyr)
#fake data as an example, just 4 ranodm dates in the last month
set.seed(123)
fake_data_a <- data.frame(date = today() - sample(30,4), value_a=rnorm(4))
fake_data_b <- data.frame(date = today() - sample(30,4), value_b=rnorm(4))
#find all the dates in the window dfeine by fake_data_a
all_dates <- data.frame(date = seq(min(fake_data_a$date), max(fake_data_a$date), by=1))