3 # The latest update : 11/02/96 at 23:15:49
5 #@(#) pdb2mrc2d ver 1.5
8 #@(#) Usage : pdb2mrc2d
13 static char __sccs_id[] = "@(#)pdb2mrc2d ver1.5; Date:96/11/02 @(#)";
28 Projection : x-y plane along z-axis
31 First Rotation : y-axis : Y: Y
32 Second Rotation : x-axis : O: Odd
33 Last Rotation : z-axis : Y: Same
43 #include "../inc/config.h"
45 #include "lpdb2mrcInfo.h"
54 #define HowToCreateImageBit (0x1)
55 #define HowToDrawMapBit (0x2)
58 main(int argc, char* argv[])
66 mrcImageParaTypeRealCoord to;
67 mrcImageParaTypeReal ix, iy;
68 pdbFileParaTypeReal rotx, roty, rotz, droty;
69 Map2DParaTypeInteger nrotx, nroty;
70 mrcImageParaTypeReal zsection;
73 argCheck(&info, argc, argv);
77 if(info.flagcudaDeviceID) {
78 eosCudaInit(info.cudaDeviceID);
82 linfo.dx = info.dx; linfo.dy = info.dy;
83 linfo.nx = info.nx; linfo.ny = info.ny;
85 if(info.flagsx && info.flagsy ) {
86 linfo.sx = info.sx; linfo.sy = info.sy;
88 linfo.sx = -1.0*info.dx*info.nx/2.0 ;
89 linfo.sy = -1.0*info.dy*info.ny/2.0 ;
91 linfo.Weight = info.Weight;
92 linfo.Sigma = info.Sigma;
94 if(!(info.flagOut|info.flagOut3D)) {
95 fprintf(stderr, "This program has no work for your request\n");
96 fprintf(stderr, "-o or -O option is required.\n");
100 pdbFileRead(info.fptIn, &pdb);
102 pdbRotationZXY(&pdb, info.srotx*RADIAN, -info.sroty*RADIAN, info.srotz*RADIAN);
104 if(info.flagsRotMode) {
105 pdbRotationFollowingEulerAngle(&pdb, info.sRotMode, info.sRot1*RADIAN, -info.sRot2*RADIAN, info.sRot3*RADIAN);
107 if(info.flagdRot1 && !info.flagrotnx) {
108 info.rotnx = (int)((info.maxRot1 - info.minRot1)/info.dRot1+0.5);
110 if(info.flagdRot2 && !info.flagrotny) {
111 info.rotny = (int)((info.maxRot2 - info.minRot2)/info.dRot2+0.5)*2;
114 out.HeaderN.x = info.rotnx*info.nx;
115 out.HeaderN.y = info.rotny*info.ny;
117 out.HeaderMode = mrcFloatImage;
118 out.HeaderLength.x = info.dx;
119 out.HeaderLength.y = info.dy;
120 out.HeaderLength.z = 0.0;
121 mrcInit(&out, (char*)NULL);
124 out3D.HeaderN.x = info.nx;
125 out3D.HeaderN.y = info.ny;
126 out3D.HeaderN.z = info.rotnx*info.rotny;
127 out3D.HeaderMode = mrcFloatImage;
128 out3D.HeaderLength.x = info.dx;
129 out3D.HeaderLength.y = info.dy;
130 out3D.HeaderLength.z = 0.0;
131 mrcInit(&out3D, NULL);
132 out3D.numTailer = out3D.HeaderN.z;
133 mrcTailerInit(&out3D, 0);
136 nrotx = info.rotny; /* Attention: x - y change */
139 for(ix=0; ix < nrotx ; ix++) {
140 if(nrotx/4 < ix && ix < nrotx/4*3) {
143 if(!info.flagRotMode) {
144 rotx = ((double)ix)/nrotx*2.0*M_PI;
146 rotx = ((double)ix)/nrotx*2.0*M_PI;
148 map2DParallelInfo(&nroty, &droty,
150 (info.mode&HowToCreateImageBit));
151 for(iy=0; iy < info.rotny; iy+= droty) {
152 DEBUGPRINT2("%g %g\n", ix, iy);
157 pdbFileNextAtom(&pdb);
158 DEBUGPRINT3("(x, y, z)=(%g, %g %g)\n", pdb.PDB->Coord.x, pdb.PDB->Coord.y, pdb.PDB->Coord.z);
162 if(!info.flagRotMode) {
163 roty = ((double)iy)/info.rotny*2.0*M_PI;
164 pdbRotationZXY(&pdb, rotx, -roty, -rotz);
166 roty = ((double)iy)/info.rotny*2.0*M_PI;
167 pdbRotationFollowingEulerAngle(&pdb, info.RotMode, -roty, rotx, -rotz);
173 pdbFileNextAtom(&pdb);
174 DEBUGPRINT3("(x, y, z)=(%g, %g %g)\n", pdb.PDB->Coord.x, pdb.PDB->Coord.y, pdb.PDB->Coord.z);
178 DEBUGPRINT3("rot: (%g %g %g) \n", rotx*DEGREE, roty*DEGREE, rotz*DEGREE);
180 lpdb2mrc2d(&mrc, &pdb, &linfo, 'z', 0);
185 sprintf(s, "/tmp/test.mrc.%03d", (int)zsection);
187 mrcFileWrite(&mrc, s, "tmp", 0);
191 if(!info.flagRotMode) {
192 pdbRotationYXZ(&pdb, -rotx, roty, rotz);
194 pdbRotationFollowingEulerAngleInverse(&pdb, info.RotMode, roty, -rotx, -rotz);
197 DEBUGPRINT3("%g %g %g\n", -roty*DEGREE, rotx*DEGREE, -rotz*DEGREE);
199 map2DCoordGet(&(to.x), &(to.y), roty, rotx, info.rotnx, info.rotny, ((info.mode&HowToDrawMapBit)>>1));
200 to.x = fmod(to.x*info.nx, out.HeaderN.x);
201 to.y = fmod(to.y*info.ny, out.HeaderN.y);
202 DEBUGPRINT2("map %f %f\n", to.x, to.y);
204 DEBUGPRINT3("to: %f %f %f\n", to.x, to.y, to.z);
205 lmrcImageCopy(&out, &mrc, to);
209 sprintf(s, "/tmp/test.2d.%03d", (int)zsection);
210 mrcFileWrite(&out, s, "tmp", 0);
218 out3D.Tailer[(int)zsection].Cont.Mode = mrcImageTailerMode2DProjection;
219 out3D.Tailer[(int)zsection].Cont.EulerAngleMode[0] = info.RotMode[0]; /* X or Y or Z */
220 out3D.Tailer[(int)zsection].Cont.EulerAngleMode[1] = info.RotMode[1]; /* E[ven] or O[dd] */
221 out3D.Tailer[(int)zsection].Cont.EulerAngleMode[2] = info.RotMode[2]; /* S[ame] or D[iff] */
222 out3D.Tailer[(int)zsection].Cont.EulerAngleMode[3] = info.RotMode[3]; /* S[tatic] or R[otating] */
223 out3D.Tailer[(int)zsection].Cont.Rot1 = -roty;
224 out3D.Tailer[(int)zsection].Cont.Rot2 = rotx;
225 out3D.Tailer[(int)zsection].Cont.Rot3 = -rotz;
226 DEBUGPRINT3("to: %f %f %f\n", to.x, to.y, to.z);
227 lmrcImageCopy(&out3D, &mrc, to);
230 mrcImageFree(&mrc, 0);
235 mrcStatDataSet(&out, 0);
236 mrcFileWrite(&out, info.Out, "in pdb2mrc2d Main Routine", 0);
239 out3D.HeaderN.z = zsection;
240 out3D.numTailer = zsection;
241 mrcHiddenDataSet(&out3D, 0);
242 mrcStatDataSet(&out3D, 0);
243 mrcFileWrite(&out3D, info.Out3D, "in pdb2mrc2d Main Routine", 0);
251 fprintf(stderr, "----- Attention1 -----\n");
252 fprintf(stderr, "If both of -s and -startEA, first -s and second -startEA will be performed\n");
253 fprintf(stderr, "----- Attention2 -----\n");
254 fprintf(stderr, "Bug fixed: rotation around x-axis. + is changed to - \n");
255 fprintf(stderr, "----- Mode -----\n");
256 fprintf(stderr, "%d: 0: equal angle 1: equal area\n", HowToCreateImageBit);
257 fprintf(stderr, "%d: 0: Mercatol 1: Morwide \n", HowToDrawMapBit);