Skip to content

Instantly share code, notes, and snippets.

View jeetsukumaran's full-sized avatar

Jeet Sukumaran jeetsukumaran

View GitHub Profile
@jeetsukumaran
jeetsukumaran / insert.cpp
Created February 18, 2010 03:32
Comparison of performance of std::copy() vs. insert()
#include <iostream>
#include <vector>
int main(int, char* []) {
std::vector<int> a(10000000, 10);
std::vector<int> b;
b.reserve(10000000);
b.insert(b.end(), a.begin(), a.end());
}
@jeetsukumaran
jeetsukumaran / cfgcommand.sh
Created February 18, 2010 23:00
autoconf / build tools bootstrap and configure command
#! /bin/sh
BUILD_TYPE="release"
PROGRAM_LABEL=""
for arg in $@
do
if [[ $arg = debug ]]
then
BUILD_TYPE="debug"
elif [[ $arg = profil* ]]
@jeetsukumaran
jeetsukumaran / dendropy_beast_tree.py
Created August 6, 2010 21:55
Processing BEAST Trees --- Node heights and lengths (mean, median, 95% HPD, and range)
#! /usr/bin/env python
import re
import dendropy as dpy
BEAST_NODE_INFO_PATTERN = re.compile(r'(.+?)=({.+?,.+?}|.+?)(,|$)')
BEAST_SUMMARY_TREE_NODE_FIELDS = [
'height',
'height_median',
#! /usr/bin/env python
import dendropy
from dendropy import treesplit
from dendropy.interop import paup
trees = dendropy.TreeList.get_from_path('smallwt.nex', 'nexus')
taxa = trees.taxon_set
tax_labels, bipartitions, bipartition_counts, bipartition_freqs = paup.bipartitions("weightedtrees.taxa.nex", "weightedtrees.nex", use_tree_weights=True)
split_dists_paup = paup.build_split_distribution(bipartition_counts,
@jeetsukumaran
jeetsukumaran / vim-plugin-installer.sh
Created September 15, 2010 05:30 — forked from anonymous/vim-plugin-installer.sh
Script to install Vim plugin from its development source
#! /bin/bash
if [[ -z $1 ]]
then
if [[ -z $VIMRUNTIME ]]
then
VIMRUNTIME=$HOME/.vim
fi
else
VIMRUNTIME="$1"
@jeetsukumaran
jeetsukumaran / reduce_to_common_taxa_and_merge.py
Created May 24, 2011 01:48
Using DendroPy to Consolidate Multimarker Data to a Single Combined Dataset Consisting Only of Taxa with Full Representation
#! /usr/bin/env python
###############################################################################
##
## Copyright 2011 Jeet Sukumaran.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
@jeetsukumaran
jeetsukumaran / download_wobbegong_gb.py
Created May 24, 2011 01:52
Using DendroPy to Download GenBank Data
#! /usr/bin/env python
from dendropy.interop import ncbi
entrez = ncbi.Entrez(generate_labels=True,
label_num_desc_components=2,
label_separator='_',
exclude_gbnum_from_label=True,
sort_taxa_by_label=True)
@jeetsukumaran
jeetsukumaran / split_nexus_charsets.py
Created June 9, 2011 01:52
Using DendroPy to split a NEXUS character matrix into separate files based on 'charset' statements
#! /usr/bin/env python
import os
import sys
import dendropy
src_filepath = sys.argv[1]
full_data = dendropy.DnaCharacterMatrix.get_from_path(src_filepath, 'nexus')
items = full_data.character_subsets.items()
basename = os.path.splitext(os.path.basename(src_filepath))[0]
@jeetsukumaran
jeetsukumaran / create-sate-src-dist.sh
Created July 7, 2011 21:32
Create a SATe Source Distribution Bundle
#! /bin/bash
if [[ -z $1 ]]
then
echo "require version number (e.g. "2.2.4") as argument"
exit
fi
VERSION="$1"
NOW=$(date +"%Y%b%d")
SRC="satesrc-v$VERSION-$NOW"
@jeetsukumaran
jeetsukumaran / git-makedist
Created July 7, 2011 21:17
BASH script to create distributable archives of a Git repository
#! /bin/bash
compose_name() {
if [[ $(which git 2> /dev/null) ]]
then
STATUS=$(git status 2>/dev/null)
if [[ -z $STATUS ]]
then
return
fi