Skip to content

Instantly share code, notes, and snippets.

@mkweskin
mkweskin / conda-orffinder.sh
Created September 6, 2017 14:33
Use conda's libgcc for NCBI's ORFfinder
#Create new env with conda libgcc
conda create -n ORFfinder -c anaconda libgcc
source activate ORFfinder
#Setup scripts to set LD_LIBRARY_PATH
mkdir -p $CONDA_PREFIX/etc/conda/activate.d
mkdir -p $CONDA_PREFIX/etc/conda/deactivate.d
cat <<EOF >$CONDA_PREFIX/etc/conda/activate.d/LD_PATH.sh
export LD_LIBRARY_PATH_CONDA_BACKUP=$LD_LIBRARY_PATH
@mkweskin
mkweskin / gist:2b1a1daad1cc68707e77fe3f6a2729c5
Created September 7, 2018 18:58
Ping an ip every 5 seconds and log output. ping options work on Mac, not sure about other OS's
while [ 1 ]; do date; ping -o -q -t 3 x.x.x.x >/dev/null && echo PASS || echo FAIL; sleep 5; done >~/pinglog
@mkweskin
mkweskin / find.md
Last active November 8, 2018 19:02
Linux `find` basics

Linux find

find is used to find files based on their name or other attributes of the file.

  • It does not search inside files like the grep command
  • To find find examples for a speicific purpose, I do a web search for: linux find ...

Basic find command: search for a filename

find /path/to/dir -iname '*text*'

Dissecting this:

  • /path/to/dir: where you want to search, I often use . for my current directory
@mkweskin
mkweskin / merge-phyluce-matches.py
Created April 5, 2019 12:40
This will merge two databases that are output from the `phyluce_assembly_match_contigs_to_probes` step in phyluce.
#!/usr/bin/env python3
import sqlite3
import sys
import shutil
import os
#Existing DB
exist="probe.matches.sqlite"
#To be added DB
@mkweskin
mkweskin / featuretofasta.py
Last active July 18, 2019 11:56
Takes a tab-delimited BIOM feature table that lists sequences for each sample and a fasta file with all sequences for all samples. Outputs a separate fasta file for each sample containing only the sequences found in that sample. Optionally, you can specify a minimum count for each sequence for each sample and a minimum proportion (calculated wit…
#!/usr/bin/env python3
import pandas as pd
from Bio import SeqIO
import argparse
import os
import logging
import sys
import datetime
@mkweskin
mkweskin / gist:e531e65791c1d8036dd720ef3baf8af6
Created January 22, 2020 20:12
Github markdown to Jira/Confluence markup using pandoc
pandoc -f gfm -w jira -o outfile.jira infile.md
# To import converted file into Confluence:
# - Create new page
# - Click on the body of the page, click on the " + \/" dropdown in toolbar ("Insert more content") and select "Markup"
# - Paste the contents into the pop-up window (select "Confluence wiki" as the format)
# - Note: The "Markdown" option in the import pop-up doesn't seem to work for Github flavored markdown (gfm).
@mkweskin
mkweskin / putty.md
Last active February 22, 2020 21:37
My PuTTY settings

My preferred settings for PuTTY (0.71)

  • Terminal

    • Bell
      • Action to happen when a bell occurs : None (bell disabled)
  • Window

    • Lines of scrollback: 50000
    • Appearance
  • Font : Courier Std, 12 pt

@mkweskin
mkweskin / fasta-names-to-md5.py
Last active April 16, 2020 18:30
Python3 script to convert the sequence names in a FASTA file to the md5 hash of the sequence. Requires: Python3, biopython
#!/usr/bin/env python3
"""
Author: Matthew Kweskin, github: @mkweskin
This script converts the sequence names in a FASTA file
to the md5 hash of the sequence.
Notes:
- Gaps will automatically be removed by biopython
@mkweskin
mkweskin / batch-find-replace.py
Created April 16, 2020 18:32
A general utility to do a batch find/replace. Takes a translation file with the find/replace pairs and a file to be translated.
#!/usr/bin/env python3
"""
Author: Matthew Kweskin, github: @mkweskin
A general utility to read in a delimited translation file with two columns
and rename any text file with these values.
"""
import argparse
@mkweskin
mkweskin / viridal_def_file
Created December 17, 2021 15:22
VirIdAl singularity def file
Bootstrap: docker
From: continuumio/miniconda3
%post
/opt/conda/bin/conda config --add channels defaults
/opt/conda/bin/conda config --add channels bioconda
/opt/conda/bin/conda config --add channels conda-forge
/opt/conda/bin/conda config --add channels omnia
/opt/conda/bin/conda config --add channels plotly