Skip to content

Instantly share code, notes, and snippets.

@ferrolad
ferrolad / estimate-insert-sizes
Created October 25, 2022 06:16 — forked from rchikhi/estimate-insert-sizes
Quickly estimates insert sizes of read datasets, given some sequence(s) they can be mapped to. Requires BWA. Short usage: <reference> <*.fastq>
#!/usr/bin/env python
doc = """
Quickly estimates insert sizes of read datasets, given some sequence(s) they can be mapped to.
Author: Rayan Chikhi
short usage: <reference> <*.fastq>
example:
estimate-insert-sizes contigs.fa readsA_1.fq readsA_2.fq readsB_1.fq readsB_2.fq
@ferrolad
ferrolad / getinsertsize.py
Created October 25, 2022 06:15 — forked from davidliwei/getinsertsize.py
Estimating NGS paired-end read insert size (or fragment length) from SAM/BAM files
#!/usr/bin/env python
'''
Automatically estimate insert size of the paired-end reads for a given SAM/BAM file.
Usage: getinsertsize.py <SAM file> or samtools view <BAM file> | getinsertsize.py -
Author: Wei Li
Copyright (c) <2015> <Wei Li>
#! /usr/bin/env python
"""
extract_reads.py
Created by Tim Stuart
"""
import pysam
@ferrolad
ferrolad / mean_size.py
Created October 25, 2022 06:12 — forked from timoast/mean_size.py
Calculate paired-end insert size mean and standard deviation, excluding outliers.
#! /usr/local/bin/python2.7
"""
mean_size.py
Created by Tim Stuart
"""
import numpy as np
def get_data(inp):
#!/bin/bash
set -eo pipefail
# A small script to generate artemis comparison files (nucleic acid comparison)
# since all the webservers are apparently defunct!
# Script requires blastn (NOT LEGACY BLAST) and makeblastdb in path - check for existence:
command -v makeblastdb >/dev/null 2>&1 || { echo >&2 "makeblastdb doesn't appear to be installed. Aborting."; exit 1; }
command -v blastn >/dev/null 2>&1 || { echo >&2 "BLAST+ doesn't appear to be installed. Aborting."; exit 1; }
# This script will calculate Shannon entropy from a MSA.
# Dependencies:
# Biopython, Matplotlib [optionally], Math
"""
Shannon's entropy equation (latex format):
H=-\sum_{i=1}^{M} P_i\,log_2\,P_i
Entropy is a measure of the uncertainty of a probability distribution (p1, ..... , pM)
@ferrolad
ferrolad / rclone-backup-script.sh
Created January 19, 2018 01:42 — forked from donwilson/rclone-backup-script.sh
Back up WWW, MySQL DB and separate content folder to S3 using rclone
#!/bin/bash
###
# Backup Script
###
# Toggle debug mode for CLI output - "YES" or "NO"
DEBUG="YES"
# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013