Skip to content

Instantly share code, notes, and snippets.

Avatar

flashton2003

View GitHub Profile
View convert_gff3_to_ensembl_gff3.py
import sys
import gffutils
class PseudoFeature():
def __init__(self, chrom, start, stop, strand):
self.chrom = chrom
self.start = start
self.stop = stop
self.strand = strand
View parse_treebreaker.py
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
flashton2003 / process_disty_output.py
Created Mar 21, 2019
converts disty output from symetrical matrix to upper rectangular, one value per line
View process_disty_output.py
import fileinput
lines = []
for line in fileinput.input():
lines.append(line.strip())
lines = lines[1:]
lines = [x.split()[1:] for x in lines]
View midpoint_root_tree.py
from ete3 import Tree
import fileinput
lines = []
for line in fileinput.input():
lines.append(line.strip())
tree = Tree(lines[0])
View tb_cartogram.R
library(readr)
library(dplyr)
library(cartogram)
library(tmap)
library(maptools)
data(wrld_simpl)
all_tb_burden <- read_delim("~/all_tb_burden.tsv", "\t", escape_double = FALSE, trim_ws = TRUE)
y = '2016'
View infer_rearrangments.py
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):
View find_leaf_parent.py
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 = Phylo.read(tree_handle, 'newick')
res_dict = {}
for node in tree.find_clades():
## if the node is a leaf, the name will be in node.name
View default_dict_eg.py
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
flashton2003 / convert_distance_matrix.py
Created Jul 27, 2016
convert 2d matrix to flat three column
View convert_distance_matrix.py
### this script takes in a distance matrix produced by https://github.com/tseemann/nullarbor/blob/master/bin/afa-pairwise.pl 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
You can’t perform that action at this time.