#include <pdbreader.h>
Public Types | |
| enum | Density2PointsArrayAlgorithm { PEAKS_SUB, PEAKS_DIV, KMEANS } |
Public Member Functions | |
| PDBReader () | |
| PDBReader (int nn) | |
| ~PDBReader () | |
| void | zero () |
| PDBReader * | copy () |
| PDBReader & | operator= (PDBReader &pa) |
| size_t | get_number_points () const |
| void | set_number_points (size_t nn) |
| bool | read_from_pdb (const char *file) |
| Reads and parses all information from file. | |
| void | save_to_pdb (const char *file) const |
| Saves all atom information into a pdb in the official format. | |
| double * | get_points_array () |
| Returns the double array of points. | |
| void | set_points_array (double *p) |
| Allows the user to set the double array of points. | |
| vector< float > | get_points () |
| Returns all x,y,z triplets packed into a vector<float>. | |
| void | right_transform (const Transform &transform) |
| Does Transform*v as opposed to v*Transform (as in the transform function). | |
| PointArray * | makePointArray (const PDBReader &p) |
| vector< float > | get_x () |
| vector< float > | get_y () |
| vector< float > | get_z () |
| vector< string > | get_atomName () |
| vector< string > | get_resName () |
| vector< int > | get_resNum () |
Private Attributes | |
| double * | points |
| vector< int > | pointInfo |
| vector< string > | pWords |
| vector< string > | atomName |
| vector< string > | residueName |
| vector< string > | chainId |
| vector< string > | elementSym |
| vector< string > | tail |
| vector< string > | head |
| vector< string > | lines |
| size_t | n |
| int | ter_stop |
| int | count_stop |
| vector< float > | x |
| vector< float > | y |
| vector< float > | z |
| vector< int > | resNum |
Definition at line 58 of file pdbreader.h.
|
|
Definition at line 61 of file pdbreader.h. 00062 {
00063 PEAKS_SUB, PEAKS_DIV, KMEANS
00064 };
|
|
|
Definition at line 46 of file pdbreader.cpp. Referenced by copy().
|
|
|
Definition at line 52 of file pdbreader.cpp. References n, points, and ter_stop. 00053 {
00054 n = nn;
00055 points = (double *) calloc(4 * n, sizeof(double));
00056 ter_stop = 0;
00057 }
|
|
|
Definition at line 59 of file pdbreader.cpp. References points. 00060 {
00061 if( points )
00062 {
00063 free(points);
00064 points = 0;
00065 }
00066 }
|
|
|
Definition at line 75 of file pdbreader.cpp. References atomName, chainId, elementSym, get_number_points(), get_points_array(), head, lines, PDBReader(), pointInfo, pWords, residueName, set_number_points(), and tail. 00076 {
00077 PDBReader *pa2 = new PDBReader();
00078 pa2->set_number_points(get_number_points());
00079 double *pa2data = pa2->get_points_array();
00080 memcpy(pa2data, get_points_array(), sizeof(double) * 4 * get_number_points());
00081 pa2->pWords = pWords;
00082 pa2->atomName = atomName;
00083 pa2->residueName = residueName;
00084 pa2->chainId = chainId;
00085 pa2->elementSym = elementSym;
00086 pa2->tail = tail;
00087 pa2->head = head;
00088 pa2->pointInfo = pointInfo;
00089 pa2->lines = lines;
00090 return pa2;
00091 }
|
|
|
Definition at line 153 of file pdbreader.cpp. 00153 {
00154 return atomName;
00155 }
|
|
|
Definition at line 103 of file pdbreader.cpp. Referenced by copy(), operator=(), and read_from_pdb(). 00104 {
00105 return n;
00106 }
|
|
|
Returns all x,y,z triplets packed into a vector<float>.
Definition at line 309 of file pdbreader.cpp. References points. 00309 {
00310 vector<float> ret;
00311 for (unsigned int i=0; i<n; i++) {
00312 ret.push_back((float)points[i*4]);
00313 ret.push_back((float)points[i*4+1]);
00314 ret.push_back((float)points[i*4+2]);
00315 }
00316
00317 return ret;
00318 }
|
|
|
Returns the double array of points.
Definition at line 117 of file pdbreader.cpp. Referenced by copy(), and operator=(). 00118 {
00119 return points;
00120 }
|
|
|
Definition at line 157 of file pdbreader.cpp. 00157 {
00158 return residueName;
00159 }
|
|
|
Definition at line 161 of file pdbreader.cpp. 00161 {
00162 return resNum;
00163 }
|
|
|
Definition at line 130 of file pdbreader.cpp. References atomName, count_stop, pointInfo, points, resNum, x, y, and z. 00130 {
00131 if (count_stop == 0) {count_stop = atomName.size();}
00132 for (int i=0; i<count_stop; i++) {
00133 x.push_back((float)points[4*i]);
00134 y.push_back((float)points[4*i + 1]);
00135 z.push_back((float)points[4*i + 2]);
00136 resNum.push_back(pointInfo[2*i+1]);
00137 }
00138
00139 return x;
00140 }
|
|
|
Definition at line 143 of file pdbreader.cpp. 00143 {
00144 //cout << y.size() << endl;
00145 return y;
00146 }
|
|
|
Definition at line 149 of file pdbreader.cpp. 00149 {
00150 return z;
00151 }
|
|
|
Definition at line 332 of file pdbreader.cpp. References EMAN::PointArray::read_from_pdb(), and save_to_pdb(). 00332 {
00333 PointArray* pArray = new PointArray;
00334 p.save_to_pdb("thisFile3.txt");
00335 pArray->read_from_pdb("thisFile3.txt");
00336 remove("thisFile3.txt");
00337
00338 return pArray;
00339 }
|
|
|
Definition at line 94 of file pdbreader.cpp. References get_number_points(), get_points_array(), and set_number_points(). 00095 {
00096 if (this != &pa) {
00097 set_number_points(pa.get_number_points());
00098 memcpy(get_points_array(), pa.get_points_array(), sizeof(double) * 4 * get_number_points());
00099 }
00100 return *this;
00101 }
|
|
|
Reads and parses all information from file.
Definition at line 167 of file pdbreader.cpp. References atomName, chainId, count_stop, elementSym, get_number_points(), head, lines, pointInfo, points, pWords, residueName, set_number_points(), tail, ter_stop, x, and y. 00168 {
00169
00170 pWords.clear();
00171 atomName.clear();
00172 residueName.clear();
00173 chainId.clear();
00174 elementSym.clear();
00175 tail.clear();
00176 head.clear();
00177 lines.clear();
00178 pointInfo.clear();
00179 ter_stop = 0;
00180 count_stop = 0;
00181
00182 struct stat filestat;
00183 stat(file, &filestat);
00184 set_number_points(( int)(filestat.st_size / 80 + 1)); //80 bytes per line
00185 #ifdef DEBUG
00186 printf("PDBReader::read_pdb(): try %4lu atoms first\n", get_number_points());
00187 #endif
00188
00189 FILE *fp = fopen(file, "r");
00190 if(!fp) {
00191 fprintf(stderr,"ERROR in PDBReader::read_pdb(): cannot open file %s\n",file);
00192 throw;
00193 }
00194 char s[200];
00195 size_t count = 0;
00196
00197 while ((fgets(s, 200, fp) != NULL)) {
00198 lines.push_back(s);
00199 if ((strncmp(s, "ENDMDL", 6) == 0) && (ter_stop==0)){
00200 ter_stop =1;
00201 count_stop = count;
00202 }
00203 if (strncmp(s, "END", 6) == 0){
00204 break;
00205 }
00206 //if ((strncmp(s, "TER", 3) == 0) && (ter_stop ==0)){
00207 //if (count !=0) {ter_stop = 1;}
00208 //count_stop = count;
00209 //}
00210 if (strncmp(s, "ATOM", 4) != 0) {
00211 if (count == 0) {head.push_back(s);}
00212 else {tail.push_back(s);}
00213 }
00214 else {
00215 pWords.push_back(s);
00216 atomName.push_back(pWords[count].substr(12,4));
00217 residueName.push_back(pWords[count].substr(17,3));
00218 chainId.push_back(pWords[count].substr(21,1));
00219 elementSym.push_back(pWords[count].substr(76,2));
00220
00221 float x, y, z, tf;
00222 int an, sn;
00223 sscanf(&s[6], "%d", &an);
00224 sscanf(&s[23], "%d %f %f %f %*f %f", &sn, &x, &y, &z, &tf);
00225
00226 if (count + 1 > get_number_points()) {
00227 set_number_points(2 * (count + 1));
00228 } //makes sure point array is big enough
00229
00230 points[4 * count] = x;
00231 points[4 * count + 1] = y;
00232 points[4 * count + 2] = z;
00233 points[4 * count + 3] = tf;
00234 pointInfo.push_back(an);
00235 pointInfo.push_back(sn);
00236 count++;
00237 }
00238 }
00239
00240 fclose(fp);
00241 set_number_points(count);
00242 return true;
00243 }
|
|
|
Does Transform*v as opposed to v*Transform (as in the transform function).
Definition at line 321 of file pdbreader.cpp. References points, EMAN::Transform::transpose(), v, and EMAN::Vec3f. 00321 {
00322 for ( unsigned int i = 0; i < 4 * n; i += 4) {
00323 Transform s = transform.transpose();
00324 Vec3f v((float)points[i],(float)points[i+1],(float)points[i+2]);
00325 v= s*v;
00326 points[i] =v[0];
00327 points[i+1]=v[1];
00328 points[i+2]=v[2];
00329 }
00330 }
|
|
|
Saves all atom information into a pdb in the official format.
Definition at line 281 of file pdbreader.cpp. References lines, pointInfo, points, and pWords. Referenced by makePointArray(). 00281 {
00282 FILE *fp = fopen(file, "w");
00283 int m = 0;
00284 for (size_t i =0; i< lines.size(); i++) {
00285 char liner [200];
00286 strcpy (liner, lines[i].c_str());
00287 if (strncmp(liner, "ATOM", 4) != 0) {
00288 fprintf (fp, liner);
00289 }
00290 else {
00291 string curr = pWords[m];
00292 string mid, final;
00293 mid = curr.substr(12, 10);
00294 final = curr.substr(76,2);
00295 char mid2 [12];
00296 strcpy(mid2, mid.c_str());
00297 char final2 [4];
00298 strcpy(final2, final.c_str());
00299 fprintf(fp, "ATOM %5d %10s%4d %8.3f%8.3f%8.3f 1.00%6.2f %2s\n", pointInfo[2*m], mid2, pointInfo[2*m +1], points[4 * m], points[4 * m + 1], points[4 * m + 2], points[4*m + 3], final2);
00300 m++;
00301 }
00302 }
00303 fclose(fp);
00304
00305 }
|
|
|
Definition at line 109 of file pdbreader.cpp. Referenced by copy(), operator=(), and read_from_pdb(). 00110 {
00111 if (n != nn) {
00112 n = nn;
00113 points = (double *) realloc(points, 4 * n * sizeof(double));
00114 }
00115 }
|
|
|
Allows the user to set the double array of points.
Definition at line 122 of file pdbreader.cpp. References points. 00123 {
00124 points = p;
00125 }
|
|
|
Definition at line 68 of file pdbreader.cpp. 00069 {
00070 memset((void *) points, 0, 4 * n * sizeof(double));
00071 }
|
|
|
Definition at line 124 of file pdbreader.h. Referenced by copy(), get_x(), and read_from_pdb(). |
|
|
Definition at line 126 of file pdbreader.h. Referenced by copy(), and read_from_pdb(). |
|
|
Definition at line 133 of file pdbreader.h. Referenced by get_x(), and read_from_pdb(). |
|
|
Definition at line 127 of file pdbreader.h. Referenced by copy(), and read_from_pdb(). |
|
|
Definition at line 129 of file pdbreader.h. Referenced by copy(), and read_from_pdb(). |
|
|
Definition at line 130 of file pdbreader.h. Referenced by copy(), read_from_pdb(), and save_to_pdb(). |
|
|
Definition at line 131 of file pdbreader.h. Referenced by PDBReader(), set_number_points(), and zero(). |
|
|
Definition at line 122 of file pdbreader.h. Referenced by copy(), get_x(), read_from_pdb(), and save_to_pdb(). |
|
|
Definition at line 121 of file pdbreader.h. Referenced by get_points(), get_x(), PDBReader(), read_from_pdb(), right_transform(), save_to_pdb(), set_number_points(), set_points_array(), zero(), and ~PDBReader(). |
|
|
Definition at line 123 of file pdbreader.h. Referenced by copy(), read_from_pdb(), and save_to_pdb(). |
|
|
Definition at line 125 of file pdbreader.h. Referenced by copy(), and read_from_pdb(). |
|
|
Definition at line 138 of file pdbreader.h. Referenced by get_x(). |
|
|
Definition at line 128 of file pdbreader.h. Referenced by copy(), and read_from_pdb(). |
|
|
Definition at line 132 of file pdbreader.h. Referenced by PDBReader(), and read_from_pdb(). |
|
|
Definition at line 135 of file pdbreader.h. Referenced by get_x(). |
|
|
Definition at line 136 of file pdbreader.h. Referenced by get_x(). |
|
|
Definition at line 137 of file pdbreader.h. Referenced by get_x(). |
1.3.9.1