def get_response_content(fs): # read the matrix C = fs.contrast_matrix # read the ordered labels ordered_labels = Util.get_stripped_lines(fs.labels.splitlines()) # validate the input if len(C) != len(ordered_labels): msg_a = 'the number of rows in the contrast matrix ' msg_b = 'should match the number of labels' raise HandlingError(msg_a + msg_b) # reconstruct the tree reconstructed_tree = Contrasts.contrast_matrix_to_tree(C, ordered_labels) # return the reponse return NewickIO.get_newick_string(reconstructed_tree) + '\n'
def get_form(): """ @return: the body of a form """ tree = NewickIO.parse( Contrasts.g_felsenstein_tree_string, FelTree.NewickTree) ordered_labels = ('a', 'b', 'c', 'd', 'e') C = Contrasts.get_contrast_matrix(tree, ordered_labels) # define the form objects form_objects = [ Form.Matrix('contrast_matrix', 'contrast matrix', C, Contrasts.assert_contrast_matrix), Form.MultiLine('labels', 'ordered labels', '\n'.join(ordered_labels))] return form_objects
def get_form(): """ @return: the body of a form """ tree = NewickIO.parse(Contrasts.g_felsenstein_tree_string, FelTree.NewickTree) ordered_labels = ('a', 'b', 'c', 'd', 'e') C = Contrasts.get_contrast_matrix(tree, ordered_labels) # define the form objects form_objects = [ Form.Matrix('contrast_matrix', 'contrast matrix', C, Contrasts.assert_contrast_matrix), Form.MultiLine('labels', 'ordered labels', '\n'.join(ordered_labels)) ] return form_objects
def get_response_content(fs): # get the tree tree = NewickIO.parse(fs.tree, FelTree.NewickTree) # read the ordered labels ordered_labels = Util.get_stripped_lines(fs.labels.splitlines()) # validate the input observed_label_set = set(node.get_name() for node in tree.gen_tips()) if set(ordered_labels) != observed_label_set: msg = 'the labels should match the labels of the leaves of the tree' raise HandlingError(msg) # get the matrix of pairwise distances among the tips C = Contrasts.get_contrast_matrix(tree, ordered_labels) # set elements with small absolute value to zero C[abs(C) < fs.epsilon] = 0 # return the reponse if fs.plain_format: return MatrixUtil.m_to_string(C) + '\n' elif fs.matlab_format: return MatrixUtil.m_to_matlab_string(C) + '\n' elif fs.r_format: return MatrixUtil.m_to_R_string(C) + '\n'
import Contrasts import HSVcounts root_train = 'E:/ImageDataset_AVA/train/' root_test = 'E:/ImageDataset_AVA/test/' paths_train, counts_train = getPath.getPath(root_train) paths_test, counts_test = getPath.getPath(root_test) root_trainhigh = 'E:/ImageDataset_AVA/train/train_high' root_trainlow = 'E:/ImageDataset_AVA/train/train_low' root_testhigh = 'E:/ImageDataset_AVA/test/test_high' root_testlow = 'E:/ImageDataset_AVA/test/test_low' paths_trainhigh, counts_trainhigh = getPath.getPath(root_trainhigh) paths_trainlow, counts_trainlow = getPath.getPath(root_trainlow) paths_testhigh, counts_testhigh = getPath.getPath(root_testhigh) paths_testlow, counts_testlow = getPath.getPath(root_testlow) layoutComposition.layout(paths_trainhigh, paths_testhigh, paths_trainlow, paths_testlow, paths_train, paths_test) edgeComposition.EC(paths_trainhigh, paths_testhigh, paths_trainlow, paths_testlow, paths_train, paths_test) GT_layout.GT_layout(paths_train, paths_test) GT_edge.GT_edge(paths_train, paths_test) blur.blur(paths_train, paths_test) dark.dark(paths_train, paths_test) Contrasts.contrast(paths_train, paths_test) HSVcounts.hsvcounts(paths_train, paths_test) #colorPalette.colorPalette(paths_train,paths_test)