Skip to content

Instantly share code, notes, and snippets.

@etal
etal / joinAdjacentSNPs.py
Created July 20, 2016 19:11
Combine nearby SNVs into a single MNV
"""Find adjacent SNPs/MNPs in a VCF, and look in the BAM file to see if these
should be joined into a larger variant.
This script can only handle up to 2 internal compound ALT alleles for every
stretch of adjacent SNPs. This script is not designed to test all possible
combinations of internal joined SNPs for SNP stretches longer than 3.
This script also cannot handle multiallelic variants or indels.
"ALERT" will be added to VCF INFO columns for cases that are too complex.
"""
@etal
etal / flatten_reference.py
Created February 17, 2016 18:42
Flatten a pooled CNVkit reference (hg19)
#!/usr/bin/env python
from __future__ import print_function
import sys
import numpy as np
import pandas as pd
import cnvlib
@etal
etal / cnv_segment_stats.py
Created May 18, 2015 21:42
CNVkit segment confidence values & weighted segment mean
from __future__ import print_function
import sys
import numpy as np
import cnvlib
from cnvlib.metrics import biweight_location
cnr, cns = sys.argv[1:]
@etal
etal / gist:5016162
Last active December 14, 2015 02:49
Extract well-supported clades from a phylogenetic tree as sequence clusters.
#!/usr/bin/env python
"""Extract well-supported clades from a phylogenetic tree as sequence clusters."""
import os.path
import subprocess
import sys
import tempfile
from cStringIO import StringIO
@etal
etal / phylo-benchmark.py
Created June 23, 2012 21:24
Benchmark some operations on large trees in Bio.Phylo
#!/usr/bin/env python
"""Benchmark several different operations."""
from time import time
from contextlib import contextmanager
try:
from cStringIO import StringIO
BytesIO = StringIO
except ImportError:
# Python 3
@etal
etal / demo_tasks.py
Created January 16, 2012 21:25
tasks.py & a demo script (use your own FASTA files)
#!/usr/bin/env python
"""Demo for tasks.py."""
import os
import sys
from glob import glob
from Bio import SeqIO
from tasks import Task, ext, sh
@etal
etal / go1981.py
Created September 11, 2011 17:08
Create a Gō plot of residue-to-residue distances in a protein structure.
#!/usr/bin/env python
# -*- coding:utf-8 -*-
u"""Gō plot of residue-to-residue distances in a protein structure.
Usage:
go1981.py <PDB_file> [<chain_ID>] [<junction_position> ...]
Example:
./go1981.py 3ONZ.pdb B 30 68 104
@etal
etal / gettysburg.txt
Created November 3, 2010 22:59
Demo program from the Python workshop at UGA 11/2/2010. Try running it with the sample text: python wordcount.py gettysburg.txt
Four score and seven years ago our fathers brought forth on this continent, a
new nation, conceived in Liberty, and dedicated to the proposition that all men
are created equal.
Now we are engaged in a great civil war, testing whether that nation, or any
nation so conceived and so dedicated, can long endure. We are met on a great
battle-field of that war. We have come to dedicate a portion of that field, as a
final resting place for those who here gave their lives that that nation might
live. It is altogether fitting and proper that we should do this.