Skip to content

Instantly share code, notes, and snippets.

View audy's full-sized avatar
🔬

Austin Richardson audy

🔬
View GitHub Profile
@audy
audy / xml-to-dict.py
Created October 22, 2018 19:34
Convert nested XML data into dictionaries
#!/usr/bin/env python3
import xml.etree.ElementTree as ET
from pprint import pprint
import code
tree = ET.parse('biosample_result.xml')
def expand_blob(blob, attributes={}):
'''
@audy
audy / pretty-blastn.sh
Created July 23, 2024 14:32
pretty-blastn.sh
pretty-blastn () {
column_names=(qaccver saccver pident length mismatch gapopen qstart qend sstart send slen evalue bitscore)
column_names_string=$(IFS=' ' ; echo "${column_names[*]}")
header=$(IFS=',' ; echo "${column_names[*]}")
echo "${header}"
blastn \
-outfmt "10 delim=, ${column_names_string}" \
"${@}"
}
@audy
audy / Snakefile
Last active October 20, 2023 20:44
# Rule to count the number of lines in input.interleaved.fastq
rule count_lines:
input:
"input.interleaved.fastq"
output:
"line_count.txt"
shell:
"wc -l < {input} > {output}"
# Rule to convert paired-end FASTQ files to interleaved format
@audy
audy / ascii-to-dna.py
Created April 11, 2023 06:43
encode ascii text as DNA sequences
#!/usr/bin/env python3
from itertools import product
from typing import Dict, Tuple
import sys
def generate_codon_mapping(
dna_alphabet="GATC",
@audy
audy / download-assemblies-from-ncbi.py
Created April 3, 2023 02:30
quickly fetch assemblies from NCBI
#!/usr/bin/env python3
import os
import downloads
from joblib import Parallel, delayed
from itertools import islice
from tqdm import tqdm
def get_gbk_path(assembly) -> str:
"""
@audy
audy / barcodes.csv
Last active February 7, 2023 14:57
Demultiplex Ion Torrent Reads
1 CTAAGGTAA
2 TAAGGAGAA
3 AAGAGGATT
4 TACCAAGAT
5 CAGAAGGAA
6 CTGCAAGTT
7 TTCGTGATT
8 TTCCGATAA
9 TGAGCGGAA
10 CTGACCGAA
import taxonomy
tax = taxonomy.Taxonomy.from_ncbi("ncbi_taxdump/")
FULL_RANKS = [ 'superkingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species']
def get_scalar(d: dict, key: str):
if key in d:
vals = d[key]
if len(vals) == 1:
@audy
audy / gist:52215fc35ac163006f42
Last active March 29, 2022 16:38
dokku postgresql rsync nightly backup

dokku postgresql rsync nightly backup

This is a rough guide to automating a nightly 7-day rolling remote backup of your PostgreSQL database(s) for your dokku app(s). There is a slight difference if you are using an older version of Dokku.

This will save the comprssed output of pg_dump as well as the contents of the /home directory on your dokku machine (just in case).

You will need to create a shell script in /root and edit the cron file.

@audy
audy / shannon.py
Created January 17, 2011 17:28
Shannon Diversity Index
#!/usr/bin/env python
# Shannon Diversity Index
# http://en.wikipedia.org/wiki/Shannon_index
import sys
def sdi(data):
""" Given a hash { 'species': count } , returns the SDI
cellvibr.io
pelobact.er
shewane.la
myxococc.us
stigmate.la
cystobact.er
nannocyst.is
vitreosci.la
lysobact.er
simonsie.la