-
Notifications
You must be signed in to change notification settings - Fork 0
/
cylinder.m
executable file
·68 lines (53 loc) · 1.39 KB
/
cylinder.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
%Created by Yao-Wang Li, at Aug. 04, for cylinder simulation.
BoxSizeInPixel = 256;
PixelSize = 1.32; %A/pixel
BoxSize = round(BoxSizeInPixel * PixelSize); %Box size in A
BoxHalf = BoxSize/2 ;
rise = 4.8;
BoxHalf = BoxHalf - mod(BoxHalf,rise);
D = 100;
r = D/2;
xy = zeros(1,2);
for i = [-r:5:r]
for j = [-r:5:r]
r_square = r*r;
if (i^2 + j^2 <= r_square)
xy = [xy;i,j];
else
continue;
end
end
end
xy(1,:) = [];
num = rows(xy);
z = zeros(num,1);
coors = [xy,z];
for i = [-BoxHalf:rise:BoxHalf]
if (i != 0)
z = zeros(num,1);
z(:) = i;
tmp = [xy,z];
coors = [coors;tmp];
else
continue;
end
end
scatter3(coors(:,1),coors(:,2),coors(:,3));
fid = fopen('cylinderCoors.txt', 'wt');
for i = 1:size(coors,1)
fprintf(fid, '%-0.4f \t', coors(i,:));
fprintf(fid, '\n');
end
fclose(fid);
%Create pdb file
Helixpdb = fopen('cylinder.pdb','w');
fprintf(Helixpdb, '%-6s\t %-40s\n', 'HEADER', 'GENERATED by Octave script.');
fprintf(Helixpdb, '%-6s\t %-40s\n', 'AUTHOR', 'YAO-WANG LI');
fprintf(Helixpdb, '%-6s\n', 'HEADER');
% the e2pdb2mrc.py read 12:14, 6:11, 22:26, 30:38, 38:46,46:54
for i = 1:rows(coors)
fprintf(Helixpdb,'%-5s%6d%3s%6s%1c%5d %-8.3f%-8.3f%-8.3f\n', 'ATOM', i, 'N', 'HIS', 'A', 1, coors(i,1), coors(i,2), coors(i,3));
fprintf(Helixpdb, '%-6s\n', 'TER');
end
fprintf(Helixpdb, '%-6s\n', 'END');
fclose(Helixpdb);