forked from sumatrae/gatbx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrtbase.M
47 lines (43 loc) · 1.16 KB
/
crtbase.M
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
% CRTBASE.m - Create base vector
%
% This function creates a vector containing the base of the loci
% in a chromosome.
%
% Syntax: BaseVec = crtbase(Lind, Base)
%
% Input Parameters:
%
% Lind - A scalar or vector containing the lengths
% of the alleles. Sum(Lind) is the length of
% the corresponding chromosome.
%
% Base - A scalar or vector containing the base of
% the loci contained in the Alleles.
%
% Output Parameters:
%
% BaseVec - A vector whose elements correspond to the base
% of the loci of the associated chromosome structure.
%
% Author: Andrew Chipperfield
% Date: 19-Jan-94
%
% Tested under MATLAB v6 by Alex Shenfield (17-Jan-03)
function BaseVec = crtbase(Lind, Base)
[ml LenL] = size(Lind) ;
if nargin < 2
Base = 2 * ones(LenL,1) ; % default to base 2
end
[mb LenB] = size(Base) ;
% check parameter consistency
if ml > 1 | mb > 1
error( 'Lind or Base is not a vector') ;
elseif (LenL > 1 & LenB > 1 & LenL ~= LenB) | (LenL == 1 & LenB > 1 )
error( 'Vector dimensions must agree' ) ;
elseif LenB == 1 & LenL > 1
Base = Base * ones(LenL,1) ;
end
BaseVec = [] ;
for i = 1:LenL
BaseVec = [BaseVec, Base(i)*ones(Lind(i),1)'];
end