Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block flashton2003

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
import dendropy as dpy
tree = dpy.Tree.get_from_path('/path/to/tree.nxs', 'nexus')
for nd in tree.postorder_node_iter():
if nd.is_internal():
nd_annot = nd.annotations.values_as_dict()
print nd_annot
flashton2003 /
Created Mar 21, 2019
converts disty output from symetrical matrix to upper rectangular, one value per line
import fileinput
lines = []
for line in fileinput.input():
lines = lines[1:]
lines = [x.split()[1:] for x in lines]
from ete3 import Tree
import fileinput
lines = []
for line in fileinput.input():
tree = Tree(lines[0])
View tb_cartogram.R
all_tb_burden <- read_delim("~/all_tb_burden.tsv", "\t", escape_double = FALSE, trim_ws = TRUE)
y = '2016'
from __future__ import division
from Bio import SeqIO
import pprint
import glob
import os
import sys
import itertools
class Contigs():
def __init__(self, contig_handle):
from Bio import Phylo
I want to get a dictionary where the keys are every leaf name
and the value is the parental (internal) node of that leaf
tree =, 'newick')
res_dict = {}
for node in tree.find_clades():
## if the node is a leaf, the name will be in
from collections import Counter, defaultdict
food = [{'date':'2014', 'address':'sesame street'},{'date':'2012', 'address':'eversholt street'},{'date':'2013', 'address':'eversholt street'},{'date':'2014', 'address':'eversholt street'},{'date':'2012', 'address':'sesame street'},{'date':'2013', 'address':'sesame street'},{'date':'2014', 'address':'sesame street'},{'date':'2014', 'address':'eversholt street'},{'date':'2014', 'address':'sesame street'}]
def short_way(food):
## a default dict sets the value type to the
by_year = defaultdict(Counter)
for row in food:
# print by_year
## simultaneously adds the date as a key to the dict and incremements the counter value for the address to += 1
flashton2003 /
Created Jul 27, 2016
convert 2d matrix to flat three column
### this script takes in a distance matrix produced by which is a 2d matrix
# a b c
# a 0 1 2
# b 1 0 1
# c 2 1 0
# and prints out the half matrix in three column format, with no self-self comparisons
# a b 1
View amazon_book_info_example.txt
Order detailsOrdered on 30 October 2014 (1 item)
The Forest Unseen: A Year's Watch in Nature (Kindle Books)
Haskell, David George
Sold by: Amazon Media EU Sarl
Order detailsOrdered on 27 October 2014 (1 item)
The Psychopath Test (Kindle Books)
Ronson, Jon
Sold by: Amazon Media EU Sarl
View amazon_plot_book_info.R
# from
books <- c("All the Light We Cannot See", "13 Things That Don t Make Sense", "Why The Allies Won", "The Third Policeman", "Just Kids", "Hackers", "The Black Swan", "Prisoners of Geography", "Benjamin Franklin - Biography", "Stuff Matters", "Pale Fire", "Use Of Weapons", "Lustrum", "Microbe Hunters", "Perfume", "Winston s War", "Being Mortal", "The Man Who Mistook His Wife for a Hat", "The Life You Can Save", "The Ghost Map", "Hyperion", "Chaos - Making a New Science", "The Realm", "A Scientist in Wonderland", "Good Omens", "White Teeth", "The Sports Gene", "The Inimitable Jeeves", "The Illustrated Man", "How We Got to Now", "Gone Girl", "A Dance With Dragons", "H is for Hawk", "Green Mars", "Pompeii - Life of a Roman Town", "The Grapes of Wrath", "The Forest Unseen", "The Psychopath Test", "The Selfish Gene", "The Difference Engine", "Managing Your Boss", "Empire - How Britain Made the M
You can’t perform that action at this time.