Skip to content

Instantly share code, notes, and snippets.

View peterk87's full-sized avatar

Peter Kruczkiewicz peterk87

  • Canadian Food Inspection Agency
  • Canada
View GitHub Profile
@peterk87
peterk87 / mist_json_parse.py
Last active August 29, 2015 13:56
Python: MIST JSON to CSV parser
#!/usr/bin/env python
import argparse
import textwrap
import os
import sys
import json
import re
@peterk87
peterk87 / README.md
Last active August 29, 2015 13:57
TSV: Salmonella enterica named serovar O- and H-antigens cross reference table
@peterk87
peterk87 / get_core_SNP_matrix_from_MSAs_parallel.R
Created March 27, 2014 20:46
R: Get SNP distance matrix from multiple MSAs
#! /usr/bin/Rscript --vanilla
library(getopt)
spec <- matrix(c(
'msa_dir_path','d',1,'character','MSA directory path (required)'
,'msa_file_ext','e',2,'character','MSA file extension (optional; default: "aln")'
,'out','o',2,'character','Output core SNP matrix CSV filename (optional; default: "core_distance_matrix.csv")'
,'n_cores','c',2,'integer','Number of cores to use for computation (optional; default: 2)'
,'dna_distance_model','m',2,'character','DNA distance model (default: "N").
@peterk87
peterk87 / .tmux.conf
Last active November 1, 2019 15:37
My personal .tmux.conf
#######################################################################
# tmux.conf #
#######################################################################
#######################################################################
# Setting the prefix from C-b to C-a #
#######################################################################
set -g prefix C-a
#######################################################################
@peterk87
peterk87 / Adjusted-Wallace-coeff-in-numpy.ipynb
Created May 8, 2017 22:32
Implementing Adjusted Wallace Coefficient in Python with Numpy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@peterk87
peterk87 / to_excel.py
Created February 9, 2018 15:39
Write multiple tabular files to an Excel XLSX file
import argparse
import re
import logging
import pandas as pd
import numpy as np
import sys
from utils import init_console_logger
PROGRAM_NAME = 'to_excel'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@peterk87
peterk87 / ont-guppy-barcode-demux.py
Created January 29, 2019 19:31
Demultiplex Guppy basecalled and barcoded reads
#!/usr/bin/env python
# coding: utf-8
import os
import logging
from glob import glob
from io import StringIO
import click
import pandas as pd
from Bio import SeqIO
@peterk87
peterk87 / gbk2tbl.py
Created February 26, 2019 16:44
Modified gbk2tbl.py from https://github.com/wanyuac/BINF_toolkit/#gbk2tbl to work with Python 3+
#!/usr/bin/env python
'''
This script converts a GenBank file (.gbk or .gb) from Stdin into a Sequin feature table (.tbl), which is an input file of tbl2asn used for creating an ASN.1 file (.sqn).
Package requirement: BioPython and argparse
Usage:
Simple command:
python gbk2tbl.py --mincontigsize 200 --prefix any_prefix --modifiers modifier_file.txt < annotation.gbk
cat annotation.gbk | python gbk2tbl.py --mincontigsize 200 --prefix any_prefix --modifiers modifier_file.txt # pipeline form
@peterk87
peterk87 / conda-bash-completions.sh
Created September 5, 2019 14:52
Basic Conda Bash completions
_conda(){
if (( ${#COMP_WORDS[@]} < 3 )); then
COMPREPLY=( $(compgen -W "activate deactivate clean config create help info init install list package remove uninstall run search update upgrade env -h --help -V --version" -- $2 ) );
else
if [[ $3 == "activate" ]]; then
local cur="${COMP_WORDS[COMP_CWORD]}";
local envs=( $(ls "$HOME/miniconda3/envs/") );
COMPREPLY=( $(compgen -W "${envs[*]}" -- $cur) );
elif [[ $3 == "env" ]]; then
local cur="${COMP_WORDS[COMP_CWORD]}";