This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import itertools | |
from ete3 import Tree | |
try: | |
t = Tree() | |
t.populate(int(sys.argv[1]), random_branches=True) | |
except ValueError: | |
print >>sys.stderr, 'loading', sys.argv[1] | |
t = Tree(sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from ete3 import SeqGroup, Tree | |
import sys | |
alg_file = sys.argv[1] # in fasta format | |
tree_file = sys.argv[2] # in newick format | |
alg = SeqGroup(alg_file) | |
for k,v in alg.name2id.items(): | |
# converts ilegal newick chars from alg names. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from ete3 import PhyloTree, TreeStyle, SeqMotifFace, TextFace, RectFace, AttrFace | |
alg = """ | |
>Dme_001 | |
MAEIPDETIQQFMALT---HNIAVQYLSEFGDLNEAL--YYASQTDDIKDRREEAH | |
>Dme_002 | |
MAEIPDATIQQFMALTNVSHNIAVQY--EFGDLNEALNSYYAYQTDDQKDRREEAH | |
>Cfa_001 | |
MAEIPDATIQ---ALTNVSHNIAVQYLSEFGDLNEALNSYYASQTDDQPDRREEAH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from ete3 import PhyloTree, TreeStyle, SeqMotifFace, TextFace, RectFace | |
alg = """ | |
>Dme_001 | |
MAEIPDETIQQFMALT---HNIAVQYLSEFGDLNEAL--YYASQTDDIKDRREEAH | |
>Dme_002 | |
MAEIPDATIQQFMALTNVSHNIAVQY--EFGDLNEALNSYYAYQTDDQKDRREEAH | |
>Cfa_001 | |
MAEIPDATIQ---ALTNVSHNIAVQYLSEFGDLNEALNSYYASQTDDQPDRREEAH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pp = painter | |
# node_links = a list of node links | |
# a = node a | |
# b = node b | |
# a_mode, b_mode: mode 0= node to node. mode 1: if node is internal cover also the descendants | |
# bg = background color | |
# lw = linewidth | |
# opa = opacity | |
# text, fsize, fcolor, ftype = defines text following the curve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
from collections import defaultdict | |
from ete2 import Tree | |
try: | |
t = Tree(sys.argv[1]) | |
except IndexError: | |
print >>sys.stderr, 'you need to provide a newick tree file as first argument\n\n' | |
print >>sys.stderr, 'Usage: Newick2FastTreeConstraints.py tree.nw > constraints.fa' | |
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
from ete2 import PhyloTree, orthoxml | |
import argparse | |
__DESCRIPTION__ = """ | |
etree2orthoxml is a python script that extracts evolutionary events | |
(speciation and duplication) from a newick tree and exports them as an | |
OrthoXML file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from ete2 import Tree | |
import random | |
def get_json(node): | |
# Read ETE tag for duplication or speciation events | |
if not hasattr(node, 'evoltype'): | |
dup = random.sample(['N','Y'], 1)[0] | |
elif node.evoltype == "S": | |
dup = "N" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_table(items, header=None, wrap=True, max_col_width=20, wrap_style="wrap", row_line=False, fix_col_width=False): | |
''' Prints a matrix of data as a human readable table. Matrix | |
should be a list of lists containing any type of values that can | |
be converted into text strings. | |
Two different column adjustment methods are supported through | |
the *wrap_style* argument: | |
wrap: it will wrap values to fit max_col_width (by extending cell height) | |
cut: it will strip values to max_col_width |