Skip to content

Instantly share code, notes, and snippets.

View jasonsahl's full-sized avatar

Jason Sahl jasonsahl

  • Northern Arizona University
View GitHub Profile
@jasonsahl
jasonsahl / mlst_blast_assemblies.py
Last active November 1, 2018 18:02
Uses BLAST to perform MLST typing on genome assemblies
#!/usr/bin/env python
"""calculates MLST types from assemblies using BLAST.
If the gene is truncated, it will report a "T" and if
the gene has no blast hit, it will report a "X".
Your reference allele names must all end in "fasta"
and must contain a "_" between gene name and number.
The only external dependency is blast+ - tested version
is 2.2.31"""
@jasonsahl
jasonsahl / parse_kmer_frequencies.py
Last active March 5, 2020 18:13
Parse Kmer frequencies from a Kmer matrix
#!/usr/bin/env python
"""parse frequencies from a Kmer matrix"""
from __future__ import division
import sys
import os
import optparse
from optparse import OptionParser
from collections import deque
@jasonsahl
jasonsahl / mashPy.py
Last active February 17, 2022 15:57
Create a distance dendrogram from MASH distances
#!/usr/bin/env python
#A python implementation of building clusters from MASH distances
import optparse
import sys
from optparse import OptionParser
try:
from scipy.cluster.hierarchy import weighted
import scipy.spatial.distance as ssd
@jasonsahl
jasonsahl / transpose_matrix.py
Created March 29, 2021 16:19
transpose a BSR matrix
#!/usr/bin/env python
import sys
from sys import argv
try:
out_matrix = open("transposed_matrix.matrix", "w")
reduced = []
with open(argv[1]) as my_file:
for line in my_file: