def get_form(): """ @return: the body of a form """ form_objects = [ Form.Integer('ntaxa', 'number of taxa for distance matrix sampling', 20, low=4, high=20), Form.Integer('seqlen', 'sequence length for distance matrix sampling', 200, low=100, high=10000), Form.Integer('nsamples', 'number of samples', 10, low=1, high=1000), Form.RadioGroup('tree_sampling', 'branch length distribution', [ Form.RadioItem('pachter_length', str(BranchLenSampler.Pachter()), True), Form.RadioItem('exponential_length', str(BranchLenSampler.Exponential())), Form.RadioItem('uniform_length_a', str( BranchLenSampler.UniformA())), Form.RadioItem('uniform_length_b', str( BranchLenSampler.UniformB())) ]) ] return form_objects
def get_form(): """ @return: the body of a form """ form_objects = [ Form.Integer('length', 'sequence length', 1000, low=10, high=20000), Form.Integer('ntaxa', 'number of taxa', 20, low=4, high=20), Form.RadioGroup('tree_sampling', 'branch length distribution', [ Form.RadioItem('pachter_length', str(BranchLenSampler.Pachter()), True), Form.RadioItem('exponential_length', str(BranchLenSampler.Exponential())), Form.RadioItem('uniform_length_a', str( BranchLenSampler.UniformA())), Form.RadioItem('uniform_length_b', str( BranchLenSampler.UniformB())) ]), Form.RadioGroup('first_method', 'first estimation method', [ Form.RadioItem('first_nj', 'neighbor joining', True), Form.RadioItem('first_modnj', 'modified neighbor joining'), Form.RadioItem('first_specnj', 'spectral reconstruction') ]), Form.RadioGroup('second_method', 'second estimation method', [ Form.RadioItem('second_nj', 'neighbor joining'), Form.RadioItem('second_modnj', 'modified neighbor joining'), Form.RadioItem('second_specnj', 'spectral', True) ]) ] return form_objects
def get_response_content(fs): nseconds = 2 ntaxa = fs.ntaxa # define the branch length sampler if fs.pachter_length: branch_length_sampler = BranchLenSampler.Pachter() elif fs.exponential_length: branch_length_sampler = BranchLenSampler.Exponential() elif fs.uniform_length_a: branch_length_sampler = BranchLenSampler.UniformA() elif fs.uniform_length_b: branch_length_sampler = BranchLenSampler.UniformB() return process(ntaxa, nseconds, branch_length_sampler) + '\n'
def main(options): assert 0 <= options.nseconds assert 4 <= options.ntaxa <= 20 assert 10 <= options.length <= 10000 branch_length_sampler = BranchLenSampler.Pachter() print process(options.ntaxa, options.length, options.nseconds, branch_length_sampler, True, True, True, True)
def get_response_content(fs): nseconds = 2 length = fs.length ntaxa = fs.ntaxa # define the branch length sampler if fs.pachter_length: branch_length_sampler = BranchLenSampler.Pachter() elif fs.exponential_length: branch_length_sampler = BranchLenSampler.Exponential() elif fs.uniform_length_a: branch_length_sampler = BranchLenSampler.UniformA() elif fs.uniform_length_b: branch_length_sampler = BranchLenSampler.UniformB() response_text = process(ntaxa, length, nseconds, branch_length_sampler, fs.nj, fs.modified_nj, fs.all_spectral, fs.one_spectral) return response_text + '\n'
def get_response_content(fs): nseconds = 2 length = fs.length ntaxa = fs.ntaxa # define the branch length sampler if fs.pachter_length: branch_length_sampler = BranchLenSampler.Pachter() elif fs.exponential_length: branch_length_sampler = BranchLenSampler.Exponential() elif fs.uniform_length_a: branch_length_sampler = BranchLenSampler.UniformA() elif fs.uniform_length_b: branch_length_sampler = BranchLenSampler.UniformB() # define the first builder if fs.first_nj: splitter = BuildTreeTopology.split_nj updater = BuildTreeTopology.update_nj first_builder = Builder(splitter, updater, 'nj') elif fs.first_modnj: splitter = BuildTreeTopology.split_nj updater = BuildTreeTopology.update_using_laplacian first_builder = Builder(splitter, updater, 'modnj') elif fs.first_specnj: splitter = BuildTreeTopology.split_using_eigenvector_with_nj_fallback updater = BuildTreeTopology.update_using_laplacian first_builder = Builder(splitter, updater, 'specnj') # define the second builder if fs.second_nj: splitter = BuildTreeTopology.split_nj updater = BuildTreeTopology.update_nj second_builder = Builder(splitter, updater, 'nj') elif fs.second_modnj: splitter = BuildTreeTopology.split_nj updater = BuildTreeTopology.update_using_laplacian second_builder = Builder(splitter, updater, 'modnj') elif fs.second_specnj: splitter = BuildTreeTopology.split_using_eigenvector_with_nj_fallback updater = BuildTreeTopology.update_using_laplacian second_builder = Builder(splitter, updater, 'specnj') builders = [first_builder, second_builder] response_text = process(ntaxa, length, nseconds, builders, branch_length_sampler) return response_text
def main(options): #FIXME use argparse and a nonnegative type instead of the assertion assert 0 <= options.nseconds sampling_function = BranchLenSampler.ShortAscii( options.allow_integers, options.allow_reciprocals) tree_search = SixLeafSearch() tree_search.informative_children = options.informative_children tree_search.force_difference = options.force_difference tree_search.informative_full_split = options.informative_full_split tree_search.invalid_dendrogram = options.invalid_dendrogram print do_tree_search(tree_search, options.nseconds, sampling_function)
def get_response_content(fs): # allow only two seconds for web access nseconds = 2 # read the options ntaxa = fs.ntaxa seqlen = fs.seqlen nsamples = fs.nsamples # define the branch length sampler if fs.pachter_length: branch_length_sampler = BranchLenSampler.Pachter() elif fs.exponential_length: branch_length_sampler = BranchLenSampler.Exponential() elif fs.uniform_length_a: branch_length_sampler = BranchLenSampler.UniformA() elif fs.uniform_length_b: branch_length_sampler = BranchLenSampler.UniformB() # return the response response_text = process(ntaxa, nseconds, seqlen, nsamples, branch_length_sampler, False) return response_text + '\n'
def get_form(): """ @return: the body of a form """ form_objects = [ Form.Integer('ntaxa', 'number of taxa for distance matrix sampling', 20, low=4, high=20), Form.Integer('nlengths', 'number of sequence lengths to consider (must be odd)', 9, low=3, high=99), Form.Integer('nsamples', 'number of samples per sequence length', 5, low=1, high=99), Form.RadioGroup('tree_sampling', 'branch length distribution', [ Form.RadioItem('pachter_length', str(BranchLenSampler.Pachter()), True), Form.RadioItem('exponential_length', str(BranchLenSampler.Exponential())), Form.RadioItem('uniform_length_a', str( BranchLenSampler.UniformA())), Form.RadioItem('uniform_length_b', str( BranchLenSampler.UniformB())) ]), Form.RadioGroup( 'distance_options', 'recursive matrix construction method', [ Form.RadioItem( 'pruning_like', 'go through the Laplacian, like Felsenstein pruning', True), Form.RadioItem( 'nj_like', 'directly use distances, like neighbor joining') ]) ] return form_objects
def main(): ntaxa = 20 length = 200 nseconds = 5 * 60 print ntaxa, 'taxa per tree' print length, 'nucleotides per sequence' print branch_length_samplers = (BranchLenSampler.Pachter(), BranchLenSampler.UniformB()) for i, branch_length_sampler in enumerate(branch_length_samplers): print 'group', i + 1 print branch_length_sampler print builders = [ Builder(BuildTreeTopology.split_nj, BuildTreeTopology.update_nj, 'nj'), Builder(BuildTreeTopology.split_using_eigenvector_with_nj_fallback, BuildTreeTopology.update_using_laplacian, 'specnj') ] print process(ntaxa, length, nseconds, builders, branch_length_sampler) print
def get_response_content(fs): nseconds = 2 sampling_function = BranchLenSampler.ShortAscii( fs.allow_integers, fs.allow_reciprocals) if fs.six_leaves: tree_search = SixLeafSearch() elif fs.seven_leaves: tree_search = SevenLeafSearch() tree_search.informative_children = fs.informative_children tree_search.force_difference = fs.force_difference tree_search.informative_full_split = fs.informative_full_split tree_search.invalid_dendrogram = fs.invalid_dendrogram return do_tree_search(tree_search, nseconds, sampling_function) + '\n'
def get_form(): """ @return: the body of a form """ form_objects = [ Form.Integer('length', 'sequence length for distance matrix sampling', 1000, low=10, high=20000), Form.Integer('ntaxa', 'number of taxa for distance matrix sampling', 20, low=4, high=20), Form.RadioGroup('tree_sampling', 'branch length distribution', [ Form.RadioItem('pachter_length', str(BranchLenSampler.Pachter()), True), Form.RadioItem('exponential_length', str(BranchLenSampler.Exponential())), Form.RadioItem('uniform_length_a', str( BranchLenSampler.UniformA())), Form.RadioItem('uniform_length_b', str( BranchLenSampler.UniformB())) ]), Form.CheckGroup('method_options', 'compare these methods', [ Form.CheckItem('nj', 'neighbor joining', True), Form.CheckItem('modified_nj', 'neighbor joining with laplacian updates', True), Form.CheckItem('all_spectral', 'spectral with laplacian updates and nj fallback', True), Form.CheckItem( 'one_spectral', 'an initial spectral split followed by neighbor joining', True) ]) ] return form_objects
def main(options): # validate the options assert 0 <= options.nseconds assert 4 <= options.ntaxa <= 30 assert 1 <= options.seqlen assert 1 <= options.nsamples branch_length_sampler = BranchLenSampler.UniformB() #branch_length_sampler = BranchLenSampler.Pachter() use_pbar = True try: print process(options.ntaxa, options.nseconds, options.seqlen, options.nsamples, branch_length_sampler, use_pbar) except HandlingError as e: print 'error:', e
def get_response_content(fs): # allow only two seconds for web access nseconds = 2 # read the options ntaxa = fs.ntaxa nlengths = fs.nlengths nsamples = fs.nsamples nj_like = fs.nj_like # do extra validation if nlengths % 2 == 0: raise HandlingError('the number of sequence lengths must be odd') # define the branch length sampler if fs.pachter_length: branch_length_sampler = BranchLenSampler.Pachter() elif fs.exponential_length: branch_length_sampler = BranchLenSampler.Exponential() elif fs.uniform_length_a: branch_length_sampler = BranchLenSampler.UniformA() elif fs.uniform_length_b: branch_length_sampler = BranchLenSampler.UniformB() # get the response response_text = process(ntaxa, nseconds, nlengths, nsamples, nj_like, branch_length_sampler, False) return response_text + '\n'
def __init__(self): self.components = [ BranchLenSampler.Pachter(), BranchLenSampler.Exponential(), BranchLenSampler.UniformA(), BranchLenSampler.UniformB()]