Commit 88c93497 authored by David Rohr's avatar David Rohr
Browse files

get rid of max number of model points constant

parent 92a9eb72
......@@ -516,7 +516,7 @@ int bioem::createProjection(int iMap, mycomplex_t* mapFFT)
{
for(int j = 0; j < 3; j++)
{
RotatedPointsModel[n].pos[k] += rotmat[k][j] * Model.PointsModel[n].pos[j];
RotatedPointsModel[n].pos[k] += rotmat[k][j] * Model.points[n].point.pos[j];
}
}
}
......@@ -536,7 +536,7 @@ int bioem::createProjection(int iMap, mycomplex_t* mapFFT)
continue;
}
localproj[i * param.param_device.NumberPixels + j] += Model.densityPointsModel[n] / Model.NormDen;
localproj[i * param.param_device.NumberPixels + j] += Model.points[n].density / Model.NormDen;
}
// **** Output Just to check****
......
......@@ -41,7 +41,6 @@ typedef double myfloat_t;
typedef myfloat_t mycomplex_t[2];
#define BIOEM_FLOAT_3_PHYSICAL_SIZE 3 //Possible set to 4 for GPU
#define BIOEM_MODEL_SIZE 120000
struct myfloat3_t
{
......
......@@ -2,12 +2,21 @@
#define BIOEM_MODEL_H
#include "defs.h"
#include <boost/concept_check.hpp>
class bioem_model
{
public:
//bioem_model();
//~bioem_model();
class bioem_model_point
{
public:
myfloat3_t point;
myfloat_t radius;
myfloat_t density;
};
bioem_model();
~bioem_model();
int readModel(const char* filemodel);
......@@ -18,9 +27,7 @@ public:
myfloat_t NormDen;
int nPointsModel;
myfloat3_t PointsModel[BIOEM_MODEL_SIZE];
myfloat_t radiusPointsModel[BIOEM_MODEL_SIZE];
myfloat_t densityPointsModel[BIOEM_MODEL_SIZE];
bioem_model_point* points;
};
#endif
......@@ -17,6 +17,15 @@
using namespace std;
bioem_model::bioem_model()
{
points = NULL;
}
bioem_model::~bioem_model()
{
if (points) free(points);
}
int bioem_model::readModel(const char* filemodel)
{
......@@ -26,6 +35,8 @@ int bioem_model::readModel(const char* filemodel)
ofstream exampleReadCoor;
exampleReadCoor.open ("COORDREAD");
int allocsize = 0;
std::ifstream input(filemodel);
if(readPDB)
......@@ -96,21 +107,27 @@ int bioem_model::readModel(const char* filemodel)
if (strcmp(name, "CA") == 0)
{
if (numres >= BIOEM_MODEL_SIZE)
if (allocsize == 0)
{
cout << "BIOEM_MODEL_SIZE too small\n";
exit(1);
allocsize = 64;
points = (bioem_model_point*) mallocchk(sizeof(bioem_model_point) * allocsize);
}
else if (numres + 1 >= allocsize)
{
allocsize *= 2;
points = (bioem_model_point*) reallocchk(points, sizeof(bioem_model_point) * allocsize);
}
//Getting residue Radius and electron density
radiusPointsModel[numres] = getAminoAcidRad(resName);
densityPointsModel[numres] = getAminoAcidDensity(resName);
NormDen += densityPointsModel[numres];
points[numres].radius = getAminoAcidRad(resName);
points[numres].density = getAminoAcidDensity(resName);
NormDen += points[numres].density;
//Getting the coordinates
PointsModel[numres].pos[0] = (myfloat_t) x;
PointsModel[numres].pos[1] = (myfloat_t) y;
PointsModel[numres].pos[2] = (myfloat_t) z;
exampleReadCoor << "RESIDUE " << numres << " " << PointsModel[numres].pos[0] << " " << PointsModel[numres].pos[1] << " " << PointsModel[numres].pos[2] << " " << densityPointsModel[numres] << "\n";
points[numres].point.pos[0] = (myfloat_t) x;
points[numres].point.pos[1] = (myfloat_t) y;
points[numres].point.pos[2] = (myfloat_t) z;
exampleReadCoor << "RESIDUE " << numres << " " << points[numres].point.pos[0] << " " << points[numres].point.pos[1] << " " << points[numres].point.pos[2] << " " << points[numres].density << "\n";
numres++;
}
}
......@@ -133,27 +150,34 @@ int bioem_model::readModel(const char* filemodel)
}
while ( fgets ( line, sizeof line, file ) != NULL )
{
if (numres >= BIOEM_MODEL_SIZE)
if (allocsize == 0)
{
allocsize = 64;
points = (bioem_model_point*) mallocchk(sizeof(bioem_model_point) * allocsize);
}
else if (numres + 1 >= allocsize)
{
cout << "BIOEM_MODEL_SIZE too small\n";
exit(1);
allocsize *= 2;
points = (bioem_model_point*) reallocchk(points, sizeof(bioem_model_point) * allocsize);
}
float tmpval[5];
sscanf(line, "%f %f %f %f %f", &tmpval[0], &tmpval[1], &tmpval[2], &tmpval[3], &tmpval[4]);
PointsModel[numres].pos[0] = (myfloat_t) tmpval[0];
PointsModel[numres].pos[1] = (myfloat_t) tmpval[1];
PointsModel[numres].pos[2] = (myfloat_t) tmpval[2];
radiusPointsModel[numres] = (myfloat_t) tmpval[3];
densityPointsModel[numres] = (myfloat_t) tmpval[4];
exampleReadCoor << "RESIDUE " << numres << " " << PointsModel[numres].pos[0] << " " << PointsModel[numres].pos[1] << " " << PointsModel[numres].pos[2] << " " << densityPointsModel[numres] << "\n";
NormDen += densityPointsModel[numres];
points[numres].point.pos[0] = (myfloat_t) tmpval[0];
points[numres].point.pos[1] = (myfloat_t) tmpval[1];
points[numres].point.pos[2] = (myfloat_t) tmpval[2];
points[numres].radius = (myfloat_t) tmpval[3];
points[numres].density = (myfloat_t) tmpval[4];
exampleReadCoor << "RESIDUE " << numres << " " << points[numres].point.pos[0] << " " << points[numres].point.pos[1] << " " << points[numres].point.pos[2] << " " << points[numres].density << "\n";
NormDen += points[numres].density;
numres++;
}
fclose(file);
nPointsModel = numres;
cout << "Protein structure read from Standard File\n";
}
points = (bioem_model_point*) reallocchk(points, sizeof(bioem_model_point) * nPointsModel);
cout << "Total Number of Voxels " << nPointsModel ;
cout << "\n+++++++++++++++++++++++++++++++++++++++++ \n";
exampleReadCoor.close();
......@@ -165,18 +189,18 @@ int bioem_model::readModel(const char* filemodel)
for(int n = 0; n < nPointsModel; n++)
{
r_cm.pos[0] += PointsModel[n].pos[0];
r_cm.pos[1] += PointsModel[n].pos[1];
r_cm.pos[2] += PointsModel[n].pos[2];
r_cm.pos[0] += points[n].point.pos[0];
r_cm.pos[1] += points[n].point.pos[1];
r_cm.pos[2] += points[n].point.pos[2];
}
r_cm.pos[0] = r_cm.pos[0] / (myfloat_t) nPointsModel;
r_cm.pos[1] = r_cm.pos[1] / (myfloat_t) nPointsModel;
r_cm.pos[2] = r_cm.pos[2] / (myfloat_t) nPointsModel;
for(int n = 0; n < nPointsModel; n++)
{
PointsModel[n].pos[0] -= r_cm.pos[0];
PointsModel[n].pos[1] -= r_cm.pos[1];
PointsModel[n].pos[2] -= r_cm.pos[2];
points[n].point.pos[0] -= r_cm.pos[0];
points[n].point.pos[1] -= r_cm.pos[1];
points[n].point.pos[2] -= r_cm.pos[2];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment