summaryrefslogtreecommitdiffstats
path: root/test/entropy/GenomeAlignments.m (plain)
blob: be565709da428d25110bb61dee91085b8dc29fa4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function [ALIGN inds] = GenomeAlignments(IN_GENOMES, DIST_MAT)
%   GenomeAlignments
%       This will align all of the protein segments in the genome structure
%       and return a cell-array.  Each cell is the alignment of one
%       protein.  If the protein is missing then the distance is NaN.
%

[tree inds] = MakeTree(DIST_MAT);
ALIGN = malign(tree, inds);

    function align=malign(tree, inds)
        seqs = arrayfun(@(x)(x.Sequence), IN_GENOMES(inds), 'uniformoutput', false);
        align = multialign(seqs, tree);
    end



    function [tree_obj inds]=MakeTree(dist_mat)
        %   MakeTree
        %       Takes a distance matrix and returns a tree object and the indicies
        %       to the rows that are in the tree.
        %

        inds = find(~all(isnan(dist_mat)|isinf(dist_mat)|dist_mat==0));
        dvec = squareform(dist_mat(inds, inds));
        dvec(dvec <= 0) = rand(nnz(dvec <= 0),1)*min(dvec(dvec>0));
        tree_obj = seqlinkage(dvec);

    end

end

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.