This shows two ways of perturbing the inverse of a distance matrix so that its rows and columns each end up summing to zero. """ from StringIO import StringIO import numpy as np from SnippetUtil import HandlingError import MatrixUtil import Util import Form import FormOut import const g_data = const.read('20100730o') def get_form(): """ @return: the body of a form """ lines = Util.get_stripped_lines(g_data.splitlines()) D = np.array(MatrixUtil.read_matrix(lines)) form_objects = [ Form.Matrix('matrix', 'distance matrix', D, MatrixUtil.assert_predistance)] return form_objects def get_form_out(): return FormOut.Report()
import numpy as np from scipy import cluster from SnippetUtil import HandlingError import Form import FormOut import Util import Carbone import kmeans import const import RUtil g_tags = ['pca:misc'] g_default = const.read('20100709a') def get_form(): """ @return: the body of a form """ form_objects = [ Form.MultiLine('table', 'R table', g_default), Form.Sequence('axes', 'column labels of Euclidean axes', ('pc1', 'pc2', 'pc3')), Form.CheckGroup( 'options', 'more options', [Form.CheckItem('verbose', 'show calinski index values', True)]) ] return form_objects
from StringIO import StringIO import numpy as np from SnippetUtil import HandlingError import SnippetUtil import Util import MatrixUtil import iterutils from Form import RadioItem import Form import FormOut import const g_edge_data = const.read('20100730u') def get_form(): """ @return: a list of form objects """ # define the edges of the default sparse graph edge_lines = Util.get_stripped_lines(g_edge_data.splitlines()) # define the vertices to be removed by default vertices_to_be_removed = ['A', 'a'] # define the list of form objects form_objects = [ Form.MultiLine('graph', 'sparse graph with edge weights', '\n'.join(edge_lines)), Form.MultiLine('vertices', 'vertices to be removed', '\n'.join(vertices_to_be_removed)),
""" from StringIO import StringIO import numpy as np from SnippetUtil import HandlingError import Form import FormOut import MatrixUtil import NewickIO import FelTree import HtmlTable import const g_default_string = const.read("20100730q") # FIXME use library functions def get_form(): """ @return: a list of form objects """ # define the default tree string tree = NewickIO.parse(g_default_string, FelTree.NewickTree) formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60) # return the form objects form_objects = [Form.MultiLine("tree", "newick tree with branch lengths", formatted_tree_string)] return form_objects
from scipy import linalg import numpy as np import cairo from SnippetUtil import HandlingError import SnippetUtil import Form import FormOut import CairoUtil import MatrixUtil import Clustering import NewickIO import FelTree import const g_default_string = const.read('20100730q') def get_form(): """ @return: a list of form objects """ tree = NewickIO.parse(g_default_string, FelTree.NewickTree) formatted_default_tree_string = NewickIO.get_narrow_newick_string(tree, 60) # define the list of form objects form_objects = [ Form.MultiLine('tree', 'tree', formatted_default_tree_string), Form.CheckGroup( 'processing_options', 'processing options', [Form.CheckItem('internal', 'process internal nodes', True)]), Form.CheckGroup('visualization_options', 'visualization options', [
"""Sort the names in a non-interleaved phylip alignment. """ from SnippetUtil import HandlingError import Form import FormOut import Phylip import const g_tags = ['pca:misc'] g_default_data = const.read('20100625a') def get_form(): """ @return: the body of a form """ form_objects = [ Form.MultiLine('phylip', 'non-interleaved Phylip alignment', g_default_data) ] return form_objects def get_form_out(): return FormOut.Phylip() def get_response_content(fs): headers, sequences = Phylip.decode(fs.phylip.splitlines())
import numpy as np from scipy import cluster from SnippetUtil import HandlingError import Form import FormOut import Util import Carbone import kmeans import const import RUtil g_tags = ['pca:misc'] g_default = const.read('20100709a') def get_form(): """ @return: the body of a form """ form_objects = [ Form.MultiLine('table', 'R table', g_default), Form.Sequence('axes', 'column labels of Euclidean axes', ('pc1', 'pc2', 'pc3')), Form.CheckGroup('options', 'more options', [ Form.CheckItem('verbose', 'show calinski index values', True)])] return form_objects def get_form_out():
"""Given a newick tree, calculate weights for a subset of the tips. """ from SnippetUtil import HandlingError import Newick import LeafWeights import Util from Form import RadioItem import Form import FormOut import const g_ucsc_tree_string = const.read('20100730x') def get_form(): """ @return: the body of a form """ # define the default tree string tree_string = g_ucsc_tree_string tree = Newick.parse(tree_string, Newick.NewickTree) formatted_tree_string = Newick.get_narrow_newick_string(tree, 60) # default name selection default_name_selection = ('human_hg18', 'chimp_panTro1', 'rabbit_oryCun1') # define the form objects form_objects = [ Form.MultiLine('tree', 'newick tree', formatted_tree_string), Form.MultiLine('selection', 'selected tip names', '\n'.join(default_name_selection)), Form.RadioGroup('method', 'weighting method', [ RadioItem('stone', 'use the method of Stone and Sidow', True),
import os import cairo import numpy as np from SnippetUtil import HandlingError import Form import FormOut import CairoUtil import Euclid import BuildTreeTopology import SchurAlgebra import Util import const g_data = const.read('20100125a') def get_default_data(): lines = Util.get_stripped_lines(g_data.splitlines()) return '\n'.join(lines) class BorderInfo: def __init__(self, border_x, border_y): self.border_x = border_x self.border_y = border_y class AxisInfo: def __init__(self, flip_x, flip_y, show_x, show_y): self.flip_x = flip_x self.flip_y = flip_y self.show_x = show_x
""" from StringIO import StringIO import argparse from SnippetUtil import HandlingError import Form import FormOut import Util import RUtil import Carbone import const g_tags = ['pca:compute'] g_table = const.read('20100920a') g_factor = 'cluster' g_variable = 'temperature' def get_form(): """ @return: the body of a form """ form_objects = [ Form.MultiLine('table', 'R table', g_table), Form.SingleLine('factor', 'factor name', g_factor), Form.SingleLine('variable', 'variable name', g_variable)] return form_objects
import argparse import numpy as np from SnippetUtil import HandlingError import SnippetUtil import Form import FormOut import NewickIO import FelTree import Euclid import TreeSampler import Util import const g_D_abdi = const.read('20100730h') def get_form(): """ @return: a list of form objects """ # define the list of form objects form_objects = [] return form_objects def get_form_out(): return FormOut.Report() def process(): """ @return: a multi-line string that summarizes the results
MAPP stands for Multivariate Analysis of Protein Polymorphism. """ from StringIO import StringIO from SnippetUtil import HandlingError import SnippetUtil import Newick import Codon import Util import Form import FormOut import const g_mapp_output = const.read('20100730v') class ColumnDataError(Exception): pass class ColumnData: """ Define data associated with the column of an alignment. """ def __init__(self, gene, offset, wild, mutant): """ @param gene: the name of a gene @param offset: the integer offset indexed starting at 1
for Functional Genomic Inference". """ import math import numpy as np from SnippetUtil import HandlingError import SnippetUtil import Form import FormOut import Util import MatrixUtil import const g_karate_data = const.read("20090406a") def get_form(): """ @return: the body of a form """ # define the default observation lines default_observation_matrix = [ ["Gene/Observation", "Observation 1", "Observation 2", "Observation 3", "Observation 4", "Observation 5"], ["Gene 1", "4.1", "6.23", "3.141529", "8.008", "1.2"], ["Gene 2", "1.3", "7", "8.12", "1.1", "9.321"], ["Gene 3", "6.21", "9.001", "3.76", "6.18", "5"], ] default_observation_lines = [",\t".join(row) for row in default_observation_matrix] # define the default module lines
""" import numpy as np from SnippetUtil import HandlingError import Util import MatrixUtil import Clustering import NeighborhoodJoining import NewickIO import Form import FormOut import const # this is a perturbed distance matrix not an exact distance matrix g_d = const.read('20100730p') def get_form(): """ @return: the body of a form """ lines = Util.get_stripped_lines(g_d.splitlines()) D = np.array(MatrixUtil.read_matrix(lines)) labels = list('xyabcmnp') # define the form objects form_objects = [ Form.Matrix('matrix', 'distance matrix', D, MatrixUtil.assert_predistance), Form.MultiLine('labels', 'ordered labels', '\n'.join(labels)), Form.RadioGroup('recourse', 'recourse for degenerate partitions', [
"Maximum Likelihood Phylogenetic Estimation from DNA Sequences with Variable Rates over Sites: Approximate Methods" by Ziheng Yang in J Mol Evol 1994. """ from StringIO import StringIO from SnippetUtil import HandlingError import Fasta import F84 import PairLikelihood import Form import FormOut import const g_sample_fasta_string = const.read('20100730z') def get_form(): """ @return: the body of a form """ form_objects = [ Form.MultiLine('fasta', 'nucleotide sequence pair', g_sample_fasta_string.strip()) ] return form_objects def get_form_out(): return FormOut.Report()
""" from StringIO import StringIO import time import itertools import optparse import random from SnippetUtil import HandlingError import Util import Form import FormOut import Progress import const g_raw_matrix = const.read('20100730l').rstrip() def get_hamming_distance(a, b): """ @param a: a sequence of ones and zeros @param b: a sequence of ones and zeros @return: the hamming distance """ return Util.hamming_distance(a, b) def get_folded_distance(a, b): """ @param a: a sequence of ones and zeros @param b: a sequence of ones and zeros @return: a distance """
from SnippetUtil import HandlingError import FelTree import NewickIO import Codon import Fasta import Util import iterutils import Form import FormOut import const # TODO de-hardcode this path to the jar file g_mapp_jar_path = '/home/argriffi/mapp-analysis/MAPP.jar' g_default_csv_data = const.read('20100730t') g_default_tree_string = const.read('20100730s') def get_form(): """ @return: a list of form objects """ default_tree_string = '(a:2, b:2, (c:2, d:2):2);' form_objects = [ Form.MultiLine('data', 'raw data from a csv file', g_default_csv_data), Form.MultiLine('tree', 'a tree with branch lengths', g_default_tree_string)] return form_objects
import hmmus import scipy.misc from SnippetUtil import HandlingError import Form import FormOut import DGRP import ReadCoverageRef import Util import ExternalHMM import lineario import TransitionMatrix import const g_default_data = const.read('20100729a') g_default_params = [('x', '0.1'), ('y', '0.01'), ('z', '0.0001'), ('low', '2'), ('med', '20'), ('high', '1000'), ('seqerr', '.01'), ('nomcoverage', '20'), ('kmulticoverages', '4')] def get_form(): """ @return: the body of a form """ data_lines = ['\t'.join(str(x) for x in row) for row in g_default_data] form_objects = [ Form.Integer('region_size', 'expected region size', 10,
from StringIO import StringIO import math from math import sqrt import numpy as np import scipy from scipy import interpolate from scipy import optimize import Form import FormOut import Util import const g_tw1_csv = const.read('20120505a') g_m = 189 g_n = 2790 g_eigenvalues = """ 22.36 8.20 5.09 3.81 3.33 2.09 1.89 1.44 1.30
import math import os import cairo import numpy as np from SnippetUtil import HandlingError import Form import FormOut import CairoUtil import Euclid import BuildTreeTopology import Util import const g_data = const.read('20100125a') def get_default_data(): lines = Util.get_stripped_lines(g_data.splitlines()) return '\n'.join(lines) class BorderInfo: def __init__(self, border_x, border_y): self.border_x = border_x self.border_y = border_y class AxisInfo: def __init__(self, flip_x, flip_y, show_x, show_y): self.flip_x = flip_x self.flip_y = flip_y self.show_x = show_x
P: internal vertex principal submatrix (symmetric order p) X: off-diagonal upper right submatrix (pxq or qxp) """ import unittest import numpy as np import NewickIO import MatrixUtil import EigUtil import FelTree import iterutils import const g_tree_string = const.read('20100730g').rstrip() ############################################################ # block matrix helper functions def hrep(M, N): """ Horizontally stack N copies of M. @param M: a matrix @param N: stack this many copies """ return np.hstack([M]*N) def vrep(M, N): """
import hmmus import scipy.misc from SnippetUtil import HandlingError import Form import FormOut import DGRP import ReadCoverageRef import Util import ExternalHMM import lineario import TransitionMatrix import const g_default_data = const.read('20100729a') g_default_params = [ ('x', '0.1'), ('y', '0.01'), ('z', '0.0001'), ('low', '2'), ('med', '20'), ('high', '1000'), ('seqerr', '.01'), ('nomcoverage', '20'), ('kmulticoverages', '4')] def get_form(): """ @return: the body of a form
For example, this can be used for a city MDS plot. """ from StringIO import StringIO import math import cairo from SnippetUtil import HandlingError import Form import FormOut import CairoUtil import Util import const g_default_data = const.read('20100730d') class BorderInfo: def __init__(self, border_x, border_y): self.border_x = border_x self.border_y = border_y class AxisInfo: def __init__(self, flip_x, flip_y, show_x, show_y): self.flip_x = flip_x self.flip_y = flip_y self.show_x = show_x self.show_y = show_y class ImageInfo:
import numpy as np import scipy import Form import FormOut import tikz import latexutil import Ftree import FtreeIO import FtreeAux import MatrixUtil import Newick import const g_tree_string = const.read('20110616a').rstrip() def get_form(): """ @return: a list of form objects """ # reformat the tree string tree = Newick.parse(g_tree_string, Newick.NewickTree) formatted_tree_string = Newick.get_narrow_newick_string(tree, 75) # define the form objects form_objects = [ Form.MultiLine('tree_string', 'newick tree', formatted_tree_string), Form.Float('scaling_factor', 'figure scaling factor', 3.0, low_exclusive=0),
import sys import numpy as np from SnippetUtil import HandlingError import Form import FormOut import Progress import TransitionMatrix import ReadCoverage import FastHMM import iterutils import Util import const g_sample_data = const.read('20100730j') class TimeoutError(Exception): pass def get_form(): """ @return: the body of a form """ form_objects = [ Form.Integer('good_coverage', 'expected read coverage of informative positions', 20, low=1, high=1000), Form.Integer('bad_coverage', 'expected read coverage of overcovered positions', 100, low=1, high=1000), Form.Integer('nstickinesses',
"""Remove root branch length and internal labels from a tree, and unroot it. """ from StringIO import StringIO import os from SnippetUtil import HandlingError import Form import FormOut import NewickIO import FelTree import Newick import BuildTreeTopology import const g_tree_data = const.read('20090802d') def get_form(): """ @return: the body of a form """ # define the formatted tree string tree = NewickIO.parse(g_tree_data, Newick.NewickTree) formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60) # return the form objects form_objects = [ Form.MultiLine('tree', 'newick tree', formatted_tree_string) ] return form_objects
import math import cairo import numpy as np from SnippetUtil import HandlingError import Codon import Form import FormOut import CairoUtil import Util import Euclid import BuildTreeTopology import const g_default_data = const.read('20100730e') class ImageInfo: def __init__(self, total_width, total_height, border, image_format): """ @param total_width: total image width in pixels @param total_height: total image height in pixels @param border: image border size in pixels @param image_format: image format """ self.total_width = total_width self.total_height = total_height self.border = border self.image_format = image_format if self.get_drawable_width() < 1 or self.get_drawable_height < 1:
from scipy import optimize import numpy as np from SnippetUtil import HandlingError import SnippetUtil import Fasta import MatrixUtil import RateMatrix import Util import PairLikelihood import Form import FormOut import const g_fasta = const.read('20100730y') class Objective: def __init__(self, sequence_pair, rate_matrix): """ @param sequence_pair: a pair of sequences @param rate_matrix: a rate matrix object """ self.rate_matrix = rate_matrix self.sequence_pair = sequence_pair def __call__(self, branch_length): """ This will be called by a one dimensional minimizer. @param branch_length: the distance between the two aligned sequences
from StringIO import StringIO import numpy as np from SnippetUtil import HandlingError import SnippetUtil import Util import MatrixUtil import Euclid import SchurAlgebra import Form import FormOut import const g_data = const.read('20100730p') def get_form(): """ @return: the body of a form """ # define the default distance matrix # this is from figure two of a paper called why neighbor joining works D = MatrixUtil.read_matrix(Util.get_stripped_lines(g_data.splitlines())) states = list('xyabcmnp') # define some default strings ordered_label_string = '\n'.join(states) selected_label_string = '\n'.join(['m', 'n']) # define the sequence of form objects form_objects = [ Form.Matrix('matrix', 'distance matrix',
from StringIO import StringIO import math import numpy as np from SnippetUtil import HandlingError import Form import FormOut import NewickIO import Euclid import FelTree import SchurAlgebra import EigUtil import const g_tree_string = const.read("20100730g").rstrip() def get_form(): """ @return: a list of form objects """ # define the form objects form_objects = [ Form.MultiLine("tree_string", "newick tree", g_tree_string), Form.Float("strength", "duplicate node pair connection strength", 100), ] return form_objects def get_form_out():
""" from StringIO import StringIO import argparse from SnippetUtil import HandlingError import Form import FormOut import Util import RUtil import Carbone import const g_tags = ['pca:compute'] g_table = const.read('20100709a') g_independent_names = ['temperature', 'precipitation'] g_dependent_name = 'pc1' def get_form(): """ @return: the body of a form """ form_objects = [ Form.MultiLine('table', 'R table', g_table), Form.MultiLine('independent', 'names of independent variables', '\n'.join(g_independent_names)), Form.SingleLine('dependent', 'name of the dependent variable',
for Functional Genomic Inference". """ import math import numpy as np from SnippetUtil import HandlingError import SnippetUtil import Form import FormOut import Util import MatrixUtil import const g_karate_data = const.read('20090406a') def get_form(): """ @return: the body of a form """ # define the default observation lines default_observation_matrix = [[ 'Gene/Observation', 'Observation 1', 'Observation 2', 'Observation 3', 'Observation 4', 'Observation 5' ], ['Gene 1', '4.1', '6.23', '3.141529', '8.008', '1.2'], ['Gene 2', '1.3', '7', '8.12', '1.1', '9.321'], ['Gene 3', '6.21', '9.001', '3.76', '6.18', '5']] default_observation_lines = [ ',\t'.join(row) for row in default_observation_matrix
"""Sort the names in a non-interleaved phylip alignment. """ from SnippetUtil import HandlingError import Form import FormOut import Phylip import const g_tags = ['pca:misc'] g_default_data = const.read('20100625a') def get_form(): """ @return: the body of a form """ form_objects = [ Form.MultiLine('phylip', 'non-interleaved Phylip alignment', g_default_data)] return form_objects def get_form_out(): return FormOut.Phylip() def get_response_content(fs): headers, sequences = Phylip.decode(fs.phylip.splitlines()) new_pairs = sorted(zip(headers, sequences)) new_headers, new_sequences = zip(*new_pairs) return Phylip.encode(new_headers, new_sequences) + '\n'
import os import colorsys import argparse from SnippetUtil import HandlingError import Form import FormOut import Util import RUtil import Carbone import iterutils import const g_tags = ["pca:plot"] g_default = const.read("20100709a") g_colorbrewer_set1 = ["#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"] # FIXME multiple output types def rgb_floats_to_ints(rgb_floats): return tuple(int(round(x * 255)) for x in rgb_floats) def create_R_palette(n): """ @param n: make a list of this many colors @return: a list of R colors like #E41A1C """
from StringIO import StringIO import os import math import numpy as np from SnippetUtil import HandlingError import SnippetUtil import Util import Form import FormOut import GPS import Euclid import const g_mds_data = const.read('20100119b') def parse_lines(lines): """ The input lines have a special format. The first nonempty line is a header. The subsequent lines are whitespace separated values. The first value is the city name. The next four values are latitude and longitude minutes and degrees. @param lines: stripped input lines @return: (city, lat_deg, lat_min, lon_deg, lon_min) tuples """ lines = [line for line in lines if line] if not lines: raise HandlingError('no input was found')
corresponding to positions not represented in the input file) will have undefined count entries. They will probably be arbitrarily set to zero, but should be ignored. The input file should represent a single chromosome and a single strain. """ from StringIO import StringIO import optparse import sys from SnippetUtil import HandlingError import Form import FormOut import const g_sample_input = const.read('20100730i') class LineLimitError(Exception): pass def get_form(): """ @return: the body of a form """ form_objects = [ Form.MultiLine('multiline_input', 'input file lines', g_sample_input)] return form_objects def get_form_out(): return FormOut.Report()
from StringIO import StringIO import numpy as np import scipy import Form import FormOut import Ftree import FtreeIO import MatrixUtil import Newick import forest import const g_tree_string = const.read('20110616a').rstrip() def get_form(): """ @return: a list of form objects """ # reformat the tree string tree = Newick.parse(g_tree_string, Newick.NewickTree) formatted_tree_string = Newick.get_narrow_newick_string(tree, 75) # define the form objects form_objects = [ Form.MultiLine('tree_string', 'newick tree', formatted_tree_string) ] return form_objects
from SnippetUtil import HandlingError import Form import FormOut import Util import FelTree import Newick import NewickIO import MatrixUtil import HtmlTable import MAPP import Codon import LeafWeights import const g_annotation_data = const.read('20100526a') g_tree_data = const.read('20100526b') # TODO de-hardcode this path to the jar file g_mapp_jar_path = '/home/argriffi/mapp-analysis/MAPP.jar' g_ordered_taxon_names = [ 'hg18', 'rheMac2', 'mm9', 'canFam2', 'loxAfr2', 'monDom4', 'ornAna1', 'galGal3', 'anoCar1', 'xenTro2', 'gasAcu1' ] g_unordered_taxon_names = set(g_ordered_taxon_names) def get_reverse_complement(s): trans = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'}
"""Given a newick tree, calculate weights for a subset of the tips. """ from SnippetUtil import HandlingError import Newick import LeafWeights import Util from Form import RadioItem import Form import FormOut import const g_ucsc_tree_string = const.read('20100730x') def get_form(): """ @return: the body of a form """ # define the default tree string tree_string = g_ucsc_tree_string tree = Newick.parse(tree_string, Newick.NewickTree) formatted_tree_string = Newick.get_narrow_newick_string(tree, 60) # default name selection default_name_selection = ('human_hg18', 'chimp_panTro1', 'rabbit_oryCun1') # define the form objects form_objects = [ Form.MultiLine('tree', 'newick tree', formatted_tree_string), Form.MultiLine('selection', 'selected tip names', '\n'.join(default_name_selection)), Form.RadioGroup('method', 'weighting method', [
from SnippetUtil import HandlingError import Form import FormOut import Util import FelTree import Newick import NewickIO import MatrixUtil import HtmlTable import MAPP import Codon import LeafWeights import const g_annotation_data = const.read('20100526a') g_tree_data = const.read('20100526b') # TODO de-hardcode this path to the jar file g_mapp_jar_path = '/home/argriffi/mapp-analysis/MAPP.jar' g_ordered_taxon_names = [ 'hg18', 'rheMac2', 'mm9', 'canFam2', 'loxAfr2', 'monDom4', 'ornAna1', 'galGal3', 'anoCar1',
between pairs of aligned sequences using JC69. The rows and columns of the output distance matrix are ordered according to the sequence order in the alignment. The likelihood maximization can be done analytically because of the simplicity of the model. """ from SnippetUtil import HandlingError import Fasta import MatrixUtil import JC69 import Form import FormOut import const g_fasta = const.read('20100730y') def get_form(): """ @return: the body of a form """ # define the form objects form_objects = [ Form.MultiLine('fasta', 'aligned sequences without gaps', g_fasta.strip()), Form.Float('infinity', 'use this value for estimates of infinity', 100.0)] return form_objects def get_form_out(): return FormOut.Matrix()
import numpy as np from SnippetUtil import HandlingError import RateMatrix import Newick import Monospace import HeatMap import Fasta import SubModel import iterutils import Form import FormOut import const g_sample_alignment_string = const.read('20100731c') g_nt_matrix_a = np.array([[-3, 1, 1, 1], [1, -3, 1, 1], [1, 1, -3, 1], [1, 1, 1, -3]]) g_nt_matrix_b = np.array([[-3, 1, 1, 1], [1, -3, 1, 1], [1, 1, -3, 1], [1, 1, 1, -3]]) g_nt_matrix_c = np.array([[-3, 1, 1, 1], [10, -12, 1, 1], [10, 1, -12, 1], [10, 1, 1, -12]]) def get_form(): """ @return: the body of a form """ # define the tree string tree_string = '(((Human:0.1, Chimpanzee:0.2):0.8, Gorilla:0.3):0.7, Orangutan:0.4, Gibbon:0.5);'
import os import subprocess import argparse import numpy as np import Form import FormOut import const import mcmc import Util import Fasta import RUtil g_fasta_string = const.read('20120405a').strip() g_ntax = 12 g_nchar = 898 g_beast_root = os.path.expanduser('~/svn-repos/beast-mcmc-read-only') g_headers = ( 'sequence.length', 'mean.low', 'mean.mean', 'mean.high', 'var.low', 'var.mean', 'var.high', 'cov.low' ,'cov.mean', 'cov.high') #TODO use lxml #TODO use the beastut and beast modules g_xml_pre_alignment = """
from enthought.mayavi import mlab import numpy as np from StringIO import StringIO import math from itertools import product import NewickIO import Euclid import MatrixUtil import EigUtil import FelTree import ProofDecoration import const g_tree_string = const.read('20100730g').rstrip() g_plane_opacity = 0.1 g_crossing_opacity = 1.0 g_crossing_radius = 0.1 def add_yz_plane(): x = [0, 0, 0, 0] y = [-1, -1, 1, 1] z = [-1, 1, 1, -1] tris = [(0, 3, 2), (2, 1, 0)] mesh = mlab.triangular_mesh(x, y, z, tris,
import math from StringIO import StringIO import cairo from SnippetUtil import HandlingError import SnippetUtil import Newick import CairoUtil import Codon import Util import Form import FormOut import const g_mapp_output = const.read('20100730v') class ColumnDataError(Exception): pass class ColumnData: """ Define data associated with the column of an alignment. """ def __init__(self, gene, offset, wild, mutant): """ @param gene: the name of a gene @param offset: the integer offset indexed starting at 1
by Ziheng Yang in J Mol Evol 1994. """ from StringIO import StringIO import scipy.optimize from SnippetUtil import HandlingError import Fasta import F84 import PairLikelihood import Form import FormOut import const g_sample_fasta_string = const.read('20100730z') def get_form(): """ @return: the body of a form """ form_objects = [ Form.MultiLine('fasta', 'nucleotide sequence pair', g_sample_fasta_string.strip())] return form_objects def get_form_out(): return FormOut.Report() def get_response_content(fs): # get the alignment object
""" from StringIO import StringIO import random import os import subprocess import multiprocessing from multiprocessing import Pool import const import mcmc import Fasta import RUtil import Util g_fasta_string = const.read('20120405a').strip() g_nchar = 898 g_beast_root = os.path.expanduser('~/svn-repos/beast-mcmc-read-only') g_headers = ('sequence.length', 'midpoint', 'mean.low', 'mean.mean', 'mean.high', 'var.low', 'var.mean', 'var.high', 'cov.low', 'cov.mean', 'cov.high') g_xml_pre_alignment = """ <?xml version="1.0" standalone="yes"?> <beast> <!-- The list of taxa analyse (can also include dates/ages). --> <taxa id="taxa"> <taxon id="Tarsius_syrichta"/> <taxon id="Lemur_catta"/> <taxon id="Homo_sapiens"/>
""" from StringIO import StringIO import numpy as np from SnippetUtil import HandlingError import MatrixUtil import Form import FormOut import NewickIO import FelTree import Clustering import const g_default_string = const.read('20100730m') def get_form(): """ @return: the body of a form """ # define the default tree string tree = NewickIO.parse(g_default_string, FelTree.NewickTree) formatted_tree_string = NewickIO.get_narrow_newick_string(tree, 60) # define the form objects form_objects = [ Form.MultiLine('tree', 'newick tree with branch lengths', formatted_tree_string), Form.SingleLine('lhs_a', 'the first taxon on one side of the split', 'a'), Form.SingleLine('lhs_b',
The number of MCMC steps is also set. The web interface modifies the primates.xml from the BEAST tutorial. """ from StringIO import StringIO import argparse import sys from lxml import etree import Form import FormOut import const g_primates_xml = const.read('20120605a') def get_form(): form_objects = [ Form.IntegerInterval( 'start_pos', 'stop_pos', 'alignment interval', 1, 4263, low=1, high=4263), Form.Integer('nsteps', 'MCMC steps', 8000, low=1), Form.SingleLine('alignment_id', 'alignment id', 'alignment'), Form.SingleLine('mcmc_id', 'mcmc id', 'mcmc'), ] return form_objects def get_form_out(): return FormOut.BeastXml()
import NewickIO import FelTree import Newick import BuildTreeTopology import SchurAlgebra import Euclid import MatrixUtil from Form import CheckGroup from Form import CheckItem from Form import RadioGroup from Form import RadioItem import Form import FormOut import const g_archaea_data = const.read('20090802a') g_bacteria_data = const.read('20090802b') g_eukaryota_data = const.read('20090802c') g_full_data = const.read('20090802d') g_valid_domains = set(['archaea', 'bacteria', 'eukaryota']) #FIXME multiple output types def get_form(): """ @return: the body of a form """ form_objects = [ RadioGroup('distance_options', 'recursive matrix construction', [
import numpy as np from SnippetUtil import HandlingError import RateMatrix import Newick import Monospace import HeatMap import Fasta import SubModel import iterutils import Form import FormOut import const g_sample_alignment_string = const.read('20100731c') g_nt_matrix_a = np.array([ [-3, 1, 1, 1], [1, -3, 1, 1], [1, 1, -3, 1], [1, 1, 1, -3]]) g_nt_matrix_b = np.array([ [-3, 1, 1, 1], [1, -3, 1, 1], [1, 1, -3, 1], [1, 1, 1, -3]]) g_nt_matrix_c = np.array([ [-3, 1, 1, 1], [10, -12, 1, 1], [10, 1, -12, 1], [10, 1, 1, -12]]) def get_form(): """ @return: the body of a form """ # define the tree string tree_string = '(((Human:0.1, Chimpanzee:0.2):0.8, Gorilla:0.3):0.7, Orangutan:0.4, Gibbon:0.5);' tree = Newick.parse(tree_string, Newick.NewickTree)
from SnippetUtil import HandlingError import FelTree import NewickIO import Codon import Fasta import Util import iterutils import Form import FormOut import const # TODO de-hardcode this path to the jar file g_mapp_jar_path = '/home/argriffi/mapp-analysis/MAPP.jar' g_default_csv_data = const.read('20100730t') g_default_tree_string = const.read('20100730s') def get_form(): """ @return: a list of form objects """ default_tree_string = '(a:2, b:2, (c:2, d:2):2);' form_objects = [ Form.MultiLine('data', 'raw data from a csv file', g_default_csv_data), Form.MultiLine('tree', 'a tree with branch lengths', g_default_tree_string) ] return form_objects
""" from StringIO import StringIO import argparse from SnippetUtil import HandlingError import Form import FormOut import Util import RUtil import Carbone import const g_tags = ["pca:compute"] g_table = const.read("20100709a") g_independent_names = ["temperature", "precipitation"] g_dependent_name = "pc1" def get_form(): """ @return: the body of a form """ form_objects = [ Form.MultiLine("table", "R table", g_table), Form.MultiLine("independent", "names of independent variables", "\n".join(g_independent_names)), Form.SingleLine("dependent", "name of the dependent variable", g_dependent_name), ]
from StringIO import StringIO from scipy import optimize import numpy as np from SnippetUtil import HandlingError import Fasta import MatrixUtil import RateMatrix import Util import PairLikelihood import Form import FormOut import const g_fasta = const.read('20100731a') def get_form(): """ @return: the body of a form """ # define the default matrix # HKY simulation parameters are # transition/transversion ratio 2, C:4, G:4, A:1, T:1 R = np.array([ [-1.3, 0.4, 0.8, 0.1], [0.1, -0.7, 0.4, 0.2], [0.2, 0.4, -0.7, 0.1], [0.1, 0.8, 0.4, -1.3]]) # define the form objects form_objects = [