-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawrawtree.m
54 lines (51 loc) · 1.84 KB
/
drawrawtree.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
48
49
50
51
52
53
54
function monosacpos = drawrawtree(bondmap,distance,skiplist)
% DRAWRAWTREE: generate the initial monosaccharide positions of a glycan in
% the form of a tree structure
%
% Syntax:
% monosacpos = drawrawtree(bondmap,distance,skiplist)
%
% Input:
% bondmap: n x n matrix, the linkage map of glycan, n equals to the number
% of monosaccharides in the glycan. Element (M,N) marks the existence of
% glycosidic bond between Mth and Nth monosaccharide in the SGP2.0 sequence
% of the glycan, 1 means there exists a bond, 0 means no.
% distance: n x 1 numerical array. The distance of the monosaccharide from
% the first glycan in the sequence.
% skiplist: m x 1 numerical array, the serial number of the
% monosaccharide(s) not to be included in the position calculation process.
%
% Output:
% monosacpos: n x 2 numerical array. Calculated monosaccharide position.
%
% Note:
% DRAWRAWTREE creates the initial guess of monosaccharide position, needs to
% be further processed to create the final structure.
% The horizontal position of the monosaccharide is purely decided by its
% 'distance' value, the vertical position is decided by which branch it
% belongs to.
%
% Example:
% N/A. Set breakpoints in parent program.
%
% Children function:
% N/A
%
%
% DrawGlycan authors: Kai Cheng, Yusen Zhou, Sriram Neelamegham
%(c) 2019, Research Foundation for State University of New York. All rights reserved
%
monosacpos = zeros(length(distance),2);
vert = 0;
for i = 1:length(distance)
if ~ismember(i,skiplist)
isend = ~any(bondmap(i,:)); % zeros in bondmap means
% there is no other monosac connected to the current one,
% which means a branch is finished, need to start a new one.
monosacpos(i,:) = [distance(i) - 1,vert];
if isend
vert = vert + 1;
end
end
end
end