Home > FR3DSource > xSuperimposeCandidates.m

xSuperimposeCandidates

PURPOSE ^

xSuperimposeCandidates(Model,Cand) returns the rotation matrix R and

SYNOPSIS ^

function [R,S,E] = xSuperimposeCandidates(Model,Cand,LocationWeight,AngleWeight)

DESCRIPTION ^

 xSuperimposeCandidates(Model,Cand) returns the rotation matrix R and
 shift vector S that will align the centers of nucleotides in Cand with
 those in Model.  It also returns E, the least-squares error.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % xSuperimposeCandidates(Model,Cand) returns the rotation matrix R and
0002 % shift vector S that will align the centers of nucleotides in Cand with
0003 % those in Model.  It also returns E, the least-squares error.
0004 
0005 function [R,S,E] = xSuperimposeCandidates(Model,Cand,LocationWeight,AngleWeight)
0006 
0007 L = length(Model);
0008 
0009 if nargin < 5,
0010   LocationWeight = ones(1,length(Model));
0011   AngleWeight    = ones(1,length(Model));
0012 else
0013   LocationWeight = L * LocationWeight / sum(LocationWeight);
0014 end
0015 
0016 if length(Model) ~= length(Cand),           % motif sizes must be the same
0017   R = [];
0018   S = [];
0019   E = [];
0020 else
0021 
0022 % ------------------------------
0023 
0024   ModelCenters        = cat(1,Model.Center);
0025   ModelWeightedCenter = LocationWeight * ModelCenters / L;
0026   MCC                 = ModelCenters-ones(L,1)*ModelWeightedCenter;
0027 
0028   CandCenters         = cat(1,Cand.Center);
0029   CandWeightedCenter  = LocationWeight * CandCenters / L;
0030   CC                  = CandCenters - ones(L,1) * CandWeightedCenter;
0031 
0032   if (L == 2),                                % two-nucleotide motif
0033 
0034     R = Model(1).Rot * Cand(1).Rot';
0035     S = Cand(1).Center;
0036     E = [];
0037 
0038   else                                        % more than two nucleotides
0039   
0040     R = zBestRotation(CC, diag(LocationWeight)*MCC);% candidate onto model
0041     S = CandWeightedCenter;
0042     E = LocationWeight * sum(((MCC - CC*R').^2)')'; % distances between centers
0043 
0044   end
0045 end

Generated on Fri 03-Apr-2009 09:52:35 by m2html © 2003