Commit 9768552f authored by Pilar Cossio's avatar Pilar Cossio
Browse files

Correcting bug accessing ilegal memory in CC mat & tidying up

parent 19bc6d4d
...@@ -6,7 +6,7 @@ option (INCLUDE_CUDA "Build BioEM with CUDA support" ON) ...@@ -6,7 +6,7 @@ option (INCLUDE_CUDA "Build BioEM with CUDA support" ON)
option (INCLUDE_OPENMP "Build BioEM with OpenMP support" ON) option (INCLUDE_OPENMP "Build BioEM with OpenMP support" ON)
option (INCLUDE_MPI "Build BioEM with MPI support" ON) option (INCLUDE_MPI "Build BioEM with MPI support" ON)
option (PRINT_CMAKE_VARIABLES "List all CMAKE Variables" OFF) option (PRINT_CMAKE_VARIABLES "List all CMAKE Variables" OFF)
option (CUDA_FORCE_GCC "Force GCC as host compiler for CUDA part (If standard host compiler is incompatible with CUDA)" OFF) option (CUDA_FORCE_GCC "Force GCC as host compiler for CUDA part (If standard host compiler is incompatible with CUDA)" ON)
###Set up general variables ###Set up general variables
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
...@@ -18,9 +18,9 @@ set (BIOEM_ICC_FLAGS "-xHost -O3 -fno-alias -fno-fnalias -unroll -g0 -ipo") ...@@ -18,9 +18,9 @@ set (BIOEM_ICC_FLAGS "-xHost -O3 -fno-alias -fno-fnalias -unroll -g0 -ipo")
set (BIOEM_GCC_FLAGS "-O3 -march=native -fweb -mfpmath=sse -frename-registers -minline-all-stringops -ftracer -funroll-loops -fpeel-loops -fprefetch-loop-arrays -ffast-math -ggdb") set (BIOEM_GCC_FLAGS "-O3 -march=native -fweb -mfpmath=sse -frename-registers -minline-all-stringops -ftracer -funroll-loops -fpeel-loops -fprefetch-loop-arrays -ffast-math -ggdb")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BIOEM_ICC_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BIOEM_ICC_FLAGS}")
else() else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BIOEM_GCC_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BIOEM_GCC_FLAGS}")
endif() endif()
set (BIOEM_SOURCE_FILES "bioem.cpp" "main.cpp" "map.cpp" "model.cpp" "param.cpp" "cmodules/timer.cpp") set (BIOEM_SOURCE_FILES "bioem.cpp" "main.cpp" "map.cpp" "model.cpp" "param.cpp" "cmodules/timer.cpp")
...@@ -43,93 +43,94 @@ include_directories(${Boost_INCLUDE_DIRS}) ...@@ -43,93 +43,94 @@ include_directories(${Boost_INCLUDE_DIRS})
###Find CUDA ###Find CUDA
set (BIOEM_CUDA_STATUS "Disabled") set (BIOEM_CUDA_STATUS "Disabled")
if (INCLUDE_CUDA) if (INCLUDE_CUDA)
set (BIOEM_CUDA_STATUS "Not Found") set (BIOEM_CUDA_STATUS "Not Found")
find_package(CUDA) find_package(CUDA)
endif() endif()
if (CUDA_FOUND) if (CUDA_FOUND)
if (CUDA_FORCE_GCC) if (CUDA_FORCE_GCC)
cmake_minimum_required(VERSION 2.8.10.1) cmake_minimum_required(VERSION 2.8.10.1)
#Use GCC as host compiler for CUDA even though host compiler for other files is not GCC #Use GCC as host compiler for CUDA even though host compiler for other files is not GCC
set (CUDA_HOST_COMPILER gcc) set (CUDA_HOST_COMPILER gcc)
endif() endif()
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};--use_fast_math;-ftz=true;-O4;-Xptxas -O4") set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};--use_fast_math;-ftz=true;-O4;-Xptxas -O4")
list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_13,code=sm_13") list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_13,code=sm_13")
list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_20,code=sm_20") list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_20,code=sm_20")
list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_20,code=sm_21") list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_20,code=sm_21")
list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_30,code=sm_30") list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_30,code=sm_30")
list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_35,code=sm_35") list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_35,code=sm_35")
list(APPEND CUDA_NVCC_FLAGS "-gencode=arch=compute_52,code=sm_52")
add_definitions(-DWITH_CUDA) add_definitions(-DWITH_CUDA)
set (BIOEM_CUDA_STATUS "Found") set (BIOEM_CUDA_STATUS "Found")
endif() endif()
###Find OpenMP ###Find OpenMP
set (BIOEM_OPENMP_STATUS "Disabled") set (BIOEM_OPENMP_STATUS "Disabled")
if (INCLUDE_OPENMP) if (INCLUDE_OPENMP)
set (BIOEM_OPENMP_STATUS "Not Found") set (BIOEM_OPENMP_STATUS "Not Found")
find_package(OpenMP) find_package(OpenMP)
endif() endif()
if(OPENMP_FOUND) if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
add_definitions(-DWITH_OPENMP) add_definitions(-DWITH_OPENMP)
set (BIOEM_OPENMP_STATUS "Found") set (BIOEM_OPENMP_STATUS "Found")
endif() endif()
###Find MPI ###Find MPI
set (BIOEM_MPI_STATUS "Disabled") set (BIOEM_MPI_STATUS "Disabled")
if (INCLUDE_MPI) if (INCLUDE_MPI)
set (BIOEM_MPI_STATUS "Not Found") set (BIOEM_MPI_STATUS "Not Found")
find_package(MPI) find_package(MPI)
endif() endif()
if (MPI_FOUND) if (MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH}) include_directories(${MPI_INCLUDE_PATH})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_COMPILE_FLAGS} ${MPI_LINK_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_COMPILE_FLAGS} ${MPI_LINK_FLAGS}")
add_definitions(-DWITH_MPI) add_definitions(-DWITH_MPI)
set (BIOEM_MPI_STATUS "Found") set (BIOEM_MPI_STATUS "Found")
endif() endif()
###Build Executable ###Build Executable
if (CUDA_FOUND) if (CUDA_FOUND)
set(BIOEM_TMP_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) set(BIOEM_TMP_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
if (CUDA_FORCE_GCC) if (CUDA_FORCE_GCC)
#Hack to use GCC flags for GCC host compiler during NVCC compilation, although host compiler is in fact not GCC for other files #Hack to use GCC flags for GCC host compiler during NVCC compilation, although host compiler is in fact not GCC for other files
set(CMAKE_CXX_FLAGS ${BIOEM_GCC_FLAGS}) set(CMAKE_CXX_FLAGS ${BIOEM_GCC_FLAGS})
endif() endif()
cuda_add_executable(bioEM ${BIOEM_SOURCE_FILES} bioem_cuda.cu) cuda_add_executable(bioEM ${BIOEM_SOURCE_FILES} bioem_cuda.cu)
set(CMAKE_CXX_FLAGS ${BIOEM_TMP_CMAKE_CXX_FLAGS}) set(CMAKE_CXX_FLAGS ${BIOEM_TMP_CMAKE_CXX_FLAGS})
else() else()
add_executable(bioEM ${BIOEM_SOURCE_FILES}) add_executable(bioEM ${BIOEM_SOURCE_FILES})
endif() endif()
#Additional CXX Flags not used by CUDA compiler
#Additional CXX Flags not used by CUDA compiler #Additional CXX Flags not used by CUDA compiler
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic")
else() else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-vla -Wno-unused-result -Wno-unused-local-typedefs -pedantic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-vla -Wno-long-long -Wall -pedantic")
endif()
if (NOT OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
endif() endif()
###Add Libraries ###Add Libraries
if (CUDA_FOUND) if (CUDA_FOUND)
cuda_add_cufft_to_target(bioEM) cuda_add_cufft_to_target(bioEM)
target_link_libraries(bioEM ${CUDA_CUDA_LIBRARY}) #set(CUDA_LIBRARIES "/afs/ipp/.cs/cuda/6.5-gtx9/amd64_sles11/lib64/stubs/libcuda.so")
#cuda_add_library()
target_link_libraries(bioEM ${CUDA_CUDA_LIBRARY})
# target_link_libraries(bioEM ${CUDA_LIBRARIES})
endif() endif()
if (FFTWF_LIBRARIES) if (FFTWF_LIBRARIES)
target_link_libraries(bioEM ${FFTWF_LIBRARIES}) target_link_libraries(bioEM ${FFTWF_LIBRARIES})
else() else()
target_link_libraries(bioEM -L${FFTW_LIBDIR} -lfftw3 -lfftw3f) target_link_libraries(bioEM -L${FFTW_LIBDIR} -lfftw3 -lfftw3f)
endif() endif()
target_link_libraries(bioEM -L${Boost_LIBRARY_DIRS} -lboost_program_options) target_link_libraries(bioEM -L${Boost_LIBRARY_DIRS} -lboost_program_options)
if (MPI_FOUND) if (MPI_FOUND)
target_link_libraries(bioEM ${MPI_LIBRARIES}) target_link_libraries(bioEM ${MPI_LIBRARIES})
endif() endif()
###Show Status ###Show Status
...@@ -137,14 +138,16 @@ message(STATUS "Build Status") ...@@ -137,14 +138,16 @@ message(STATUS "Build Status")
message(STATUS "FFTW library: ${FFTW_LIBDIR}") message(STATUS "FFTW library: ${FFTW_LIBDIR}")
message(STATUS "Boost directory: ${Boost_LIBRARY_DIRS}") message(STATUS "Boost directory: ${Boost_LIBRARY_DIRS}")
message(STATUS "FFTW includedir: ${FFTW_INCLUDEDIR}") message(STATUS "FFTW includedir: ${FFTW_INCLUDEDIR}")
message(STATUS "CUDA libraries: ${CUDA_CUDA_LIBRARY}")
message(STATUS "CUDA libraries: ${CUDA_LIBRARIES}")
message(STATUS "CUDA: ${BIOEM_CUDA_STATUS}") message(STATUS "CUDA: ${BIOEM_CUDA_STATUS}")
message(STATUS "OpenMP: ${BIOEM_OPENMP_STATUS}") message(STATUS "OpenMP: ${BIOEM_OPENMP_STATUS}")
message(STATUS "MPI: ${BIOEM_MPI_STATUS}") message(STATUS "MPI: ${BIOEM_MPI_STATUS}")
if (PRINT_CMAKE_VARIABLES) if (PRINT_CMAKE_VARIABLES)
get_cmake_property(_variableNames VARIABLES) get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames}) foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}") message(STATUS "${_variableName}=${${_variableName}}")
endforeach() endforeach()
endif() endif()
This diff is collapsed.
This diff is collapsed.
...@@ -5,6 +5,12 @@ ...@@ -5,6 +5,12 @@
See license statement for terms of distribution. See license statement for terms of distribution.
Note: This program contains subroutine "read_MRC" of the Situs 2.7.2 program.
Ref: Willy Wriggers. Using Situs for the Integration of Multi-Resolution Structures.
Biophysical Reviews, 2010, Vol. 2, pp. 21-27.
with a GPL lisences version XX.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#include <fstream> #include <fstream>
...@@ -35,6 +41,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap) ...@@ -35,6 +41,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
int allocsize = 0; int allocsize = 0;
if (param.loadMap) if (param.loadMap)
{ {
//************** Loading Map from Binary file *******
FILE* fp = fopen("maps.dump", "rb"); FILE* fp = fopen("maps.dump", "rb");
if (fp == NULL) if (fp == NULL)
{ {
...@@ -50,12 +57,14 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap) ...@@ -50,12 +57,14 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
} }
else if(readMRC) else if(readMRC)
{ {
//************** Reading MRC file *******
ntotRefMap=0; ntotRefMap=0;
if(readMultMRC) if(readMultMRC)
{ {
cout << "Opening File with MRC list names: " << filemap << "\n"; //************** Reading Multiple MRC files *************
cout << "Opening File with MRC list names: " << filemap << "\n";
ifstream input(filemap); ifstream input(filemap);
if (!input.good()) if (!input.good())
...@@ -74,9 +83,9 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap) ...@@ -74,9 +83,9 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
input.getline(line,511); input.getline(line,511);
char tmpVals[100] = {0}; char tmpVals[100] = {0};
string strline(line); string strline(line);
// cout << "MRC File name:" << strline << "\n"; // cout << "MRC File name:" << strline << "\n";
strncpy (tmpVals,line,99); strncpy (tmpVals,line,99);
...@@ -87,10 +96,10 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap) ...@@ -87,10 +96,10 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
if(strcmp(tmpm,"XXX")!=0) if(strcmp(tmpm,"XXX")!=0)
{ {
indifile=strline.c_str(); indifile=strline.c_str();
size_t foundpos= strline.find("mrc"); // size_t foundpos= strline.find("mrc");
size_t endpos = strline.find_last_not_of(" \t"); // size_t endpos = strline.find_last_not_of(" \t");
//Reading Multiple MRC //Reading Multiple MRC
...@@ -106,15 +115,15 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap) ...@@ -106,15 +115,15 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
else else
{ {
string strfilename(filemap); string strfilename(filemap);
size_t foundpos= strfilename.find("mrc"); size_t foundpos= strfilename.find("mrc");
size_t endpos = strfilename.find_last_not_of(" \t"); size_t endpos = strfilename.find_last_not_of(" \t");
if(foundpos > endpos){ if(foundpos > endpos){
cout << "Warining:::: mrc extension NOT dectected in file name::" << filemap <<" \n"; cout << "Warining:::: mrc extension NOT dectected in file name::" << filemap <<" \n";
cout << "Warining:::: Are you sure you want to read an MRC? \n"; cout << "Warining:::: Are you sure you want to read an MRC? \n";
} }
read_MRC(filemap,param); read_MRC(filemap,param);
cout << "\n++++++++++++++++++++++++++++++++++++++++++ \n"; cout << "\n++++++++++++++++++++++++++++++++++++++++++ \n";
...@@ -123,6 +132,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap) ...@@ -123,6 +132,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
} }
else else
{ {
//************** Reading Text file *************
int nummap = -1; int nummap = -1;
int lasti = 0; int lasti = 0;
int lastj = 0; int lastj = 0;
...@@ -201,7 +211,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap) ...@@ -201,7 +211,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
maps[nummap * refMapSize + i * numPixels + j] = (myfloat_t) z; maps[nummap * refMapSize + i * numPixels + j] = (myfloat_t) z;
lasti = i; lasti = i;
lastj = j; lastj = j;
// cout << countpix << " " << param.param_device.NumberPixels*param.param_device.NumberPixels << "\n"; // cout << countpix << " " << param.param_device.NumberPixels*param.param_device.NumberPixels << "\n";
} }
else else
{ {
...@@ -221,20 +231,21 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap) ...@@ -221,20 +231,21 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
cout << "Particle Maps read from Standard File: " << ntotRefMap << "\n"; cout << "Particle Maps read from Standard File: " << ntotRefMap << "\n";
} }
//Dumping Maps //************* If Dumping Maps *********************
if (param.dumpMap) if (param.dumpMap)
{ {
FILE* fp = fopen("maps.dump", "w+b"); FILE* fp = fopen("maps.dump", "w+b");
if (fp == NULL) if (fp == NULL)
{ {
cout << "Error opening dump file\n"; cout << "Error opening dump file\n";
exit(1); exit(1);
} }
fwrite(&ntotRefMap, sizeof(ntotRefMap), 1, fp); fwrite(&ntotRefMap, sizeof(ntotRefMap), 1, fp);
fwrite(maps, sizeof(myfloat_t) * refMapSize, ntotRefMap, fp); fwrite(maps, sizeof(myfloat_t) * refMapSize, ntotRefMap, fp);
fclose(fp); fclose(fp);
} }
//*********** To Debug with few Maps ********************
if (getenv("BIOEM_DEBUG_NMAPS")) if (getenv("BIOEM_DEBUG_NMAPS"))
{ {
...@@ -250,7 +261,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap) ...@@ -250,7 +261,7 @@ int bioem_RefMap::readRefMaps(bioem_param& param, const char* filemap)
int bioem_RefMap::PreCalculateMapsFFT(bioem_param& param) int bioem_RefMap::PreCalculateMapsFFT(bioem_param& param)
{ {
// ************************************************************************************** // **************************************************************************************
// ********** Routine that pre-calculates Kernels for Convolution ********************** // ********** Routine that pre-calculates Reference maps FFT for Convolution/ Comparison **********************
// ************************************************************************************ // ************************************************************************************
RefMapsFFT = new mycomplex_t[ntotRefMap * param.FFTMapSize]; RefMapsFFT = new mycomplex_t[ntotRefMap * param.FFTMapSize];
...@@ -320,17 +331,19 @@ int bioem_RefMap::precalculate(bioem_param& param, bioem& bio) ...@@ -320,17 +331,19 @@ int bioem_RefMap::precalculate(bioem_param& param, bioem& bio)
void bioem_Probability::init(size_t maps, size_t angles, size_t cc, bioem& bio) void bioem_Probability::init(size_t maps, size_t angles, size_t cc, bioem& bio)
{ {
//********** Initializing pointers *******************
nMaps = maps; nMaps = maps;
nAngles = angles; nAngles = angles;
nCC = cc; nCC = cc;
ptr = bio.malloc_device_host(get_size(maps, angles, cc, bio.param.param_device.writeAngles, bio.param.param_device.writeCC)); ptr = bio.malloc_device_host(get_size(maps, angles, cc, bio.param.param_device.writeAngles, bio.param.param_device.writeCC));
cout << "Allocation #Maps " << maps << " #Angles " << angles << " #cross.cor " << cc << "\n"; cout << "Allocation #Maps " << maps << " #Angles " << angles << " #cross.cor " << cc << "\n";
//<< " == " << get_size(maps, angles, cc, bio.param.param_device.writeAngles, bio.param.param_device.writeCC)<< "\n"; //<< " == " << get_size(maps, angles, cc, bio.param.param_device.writeAngles, bio.param.param_device.writeCC)<< "\n";
set_pointers(); set_pointers();
} }
void bioem_Probability::copyFrom(bioem_Probability* from, bioem& bio) void bioem_Probability::copyFrom(bioem_Probability* from, bioem& bio)
{ {
bioem_Probability_map& pProbMap = getProbMap(0); bioem_Probability_map& pProbMap = getProbMap(0);
bioem_Probability_map& pProbMapFrom = from->getProbMap(0); bioem_Probability_map& pProbMapFrom = from->getProbMap(0);
memcpy(&pProbMap, &pProbMapFrom, from->nMaps * sizeof(bioem_Probability_map)); memcpy(&pProbMap, &pProbMapFrom, from->nMaps * sizeof(bioem_Probability_map));
...@@ -358,6 +371,12 @@ void bioem_Probability::copyFrom(bioem_Probability* from, bioem& bio) ...@@ -358,6 +371,12 @@ void bioem_Probability::copyFrom(bioem_Probability* from, bioem& bio)
int bioem_RefMap::read_MRC(const char* filename,bioem_param& param) int bioem_RefMap::read_MRC(const char* filename,bioem_param& param)
{ {
/* subroutine "read_MRC" of the Situs 2.7.2 program.
Ref: Willy Wriggers. Using Situs for the Integration of Multi-Resolution Structures.
Biophysical Reviews, 2010, Vol. 2, pp. 21-27.*/
myfloat_t st,st2; myfloat_t st,st2;
unsigned long count; unsigned long count;
FILE *fin; FILE *fin;
...@@ -453,7 +472,7 @@ int bioem_RefMap::read_MRC(const char* filename,bioem_param& param) ...@@ -453,7 +472,7 @@ int bioem_RefMap::read_MRC(const char* filename,bioem_param& param)
if(nr!=param.param_device.NumberPixels || nc!=param.param_device.NumberPixels ) if(nr!=param.param_device.NumberPixels || nc!=param.param_device.NumberPixels )
{ {
cout << "PROBLEM INCONSISTENT NUMBER OF PIXELS IN MAPS AND INPUTFILE ( " << param.param_device.NumberPixels << ", i " << nc << ", j " << nr << ")" << "\n"; cout << "PROBLEM INCONSISTENT NUMBER OF PIXELS IN MAPS AND INPUTFILE ( " << param.param_device.NumberPixels << ", i " << nc << ", j " << nr << ")" << "\n";
if(!param.notsqure) exit(1); if(!param.notsqure) exit(1);
} }
if (ntotRefMap == 0) if (ntotRefMap == 0)
...@@ -498,25 +517,25 @@ int bioem_RefMap::read_MRC(const char* filename,bioem_param& param) ...@@ -498,25 +517,25 @@ int bioem_RefMap::read_MRC(const char* filename,bioem_param& param)
} }
else else
{ {
if(!param.notsqure){ if(!param.notsqure){
maps[(nmap + ntotRefMap) * refMapSize + i * numPixels + j] = (myfloat_t) currfloat; maps[(nmap + ntotRefMap) * refMapSize + i * numPixels + j] = (myfloat_t) currfloat;
st += currfloat; st += currfloat;
st2 += currfloat*currfloat; st2 += currfloat*currfloat;
} else { } else {
if( i > 595 && i < 675 && j > 1250 && j< 1330 && nmap >230 && nmap <310)cout << "map1: " << i << " "<< j << " " << nmap << " " << currfloat <<"\n"; if( i > 595 && i < 675 && j > 1250 && j< 1330 && nmap >230 && nmap <310)cout << "map1: " << i << " "<< j << " " << nmap << " " << currfloat <<"\n";
} }
} }
} }
if(param.notsqure)exit(1); if(param.notsqure)exit(1);
//Normaling maps to zero mean and unit standard deviation //Normaling maps to zero mean and unit standard deviation
if(!param.notnormmap){ if(!param.notnormmap){
st /= float(nr*nc); st /= float(nr*nc);
st2 = sqrt(st2 / float(nr * nc) - st * st); st2 = sqrt(st2 / float(nr * nc) - st * st);
for ( int j = 0 ; j < nr ; j ++ ) for ( int i = 0 ; i < nc ; i ++ ){ for ( int j = 0 ; j < nr ; j ++ ) for ( int i = 0 ; i < nc ; i ++ ){
maps[(nmap + ntotRefMap) * refMapSize + i * numPixels + j] = maps[(nmap + ntotRefMap) * refMapSize + i * numPixels + j] / st2 - st/st2; maps[(nmap + ntotRefMap) * refMapSize + i * numPixels + j] = maps[(nmap + ntotRefMap) * refMapSize + i * numPixels + j] / st2 - st/st2;
//cout <<"MAP:: " << i << " " << j << " " << maps[(nmap + ntotRefMap) * refMapSize + i * numPixels + j] << "\n"; //cout <<"MAP:: " << i << " " << j << " " << maps[(nmap + ntotRefMap) * refMapSize + i * numPixels + j] << "\n";
} }
} }
} }
ntotRefMap += ns ; ntotRefMap += ns ;
// cout << ntotRefMap << "\n"; // cout << ntotRefMap << "\n";
......
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
< BioEM software for Bayesian inference of Electron Microscopy images> < BioEM software for Bayesian inference of Electron Microscopy images>
Copyright (C) 2014 Pilar Cossio, David Rohr and Gerhard Hummer. Copyright (C) 2014 Pilar Cossio, David Rohr and Gerhard Hummer.
Max Planck Institute of Biophysics, Frankfurt, Germany. Max Planck Institute of Biophysics, Frankfurt, Germany.
See license statement for terms of distribution. See license statement for terms of distribution.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
...@@ -20,289 +20,291 @@ using namespace std; ...@@ -20,289 +20,291 @@ using namespace std;
bioem_model::bioem_model() bioem_model::bioem_model()
{ {
points = NULL; points = NULL;
} }
bioem_model::~bioem_model() bioem_model::~bioem_model()
{ {
if (points) free(points); if (points) free(points);
} }
int bioem_model::readModel(bioem_param& param, const char* filemodel) int bioem_model::readModel(bioem_param& param, const char* filemodel)
{ {
// ************************************************************************************** // **************************************************************************************
// ***************Reading reference Models either PDB or x,y,z,r,d format**************** // ***************Reading reference Models either PDB or x,y,z,r,d format****************
// ************************************************************************************** // **************************************************************************************
ofstream exampleReadCoor; ofstream exampleReadCoor;
exampleReadCoor.open ("COORDREAD"); exampleReadCoor.open ("COORDREAD");
exampleReadCoor << "Text --- Number ---- x ---- y ---- z ---- radius ---- density\n"; exampleReadCoor << "Text --- Number ---- x ---- y ---- z ---- radius ---- number of electron\n";
int allocsize = 0; int allocsize = 0;
std::ifstream input(filemodel); std::ifstream input(filemodel);
if(readPDB) if(readPDB)
{ {
ifstream input(filemodel); //************** Reading PDB files **********************
if (!input.good())
{
cout << "PDB Failed to open file" << endl ; // pdbfilename << " ("<<filename<<")\n";
exit(0);
}
char line[512] = {0};
char tmpLine[512] = {0};
int numres = 0;
NormDen = 0.0;
string strfilename(filemodel);
size_t foundpos= strfilename.find(".pdb"); ifstream input(filemodel);
size_t endpos = strfilename.find_last_not_of(" \t"); if (!input.good())
{
cout << "PDB Failed to open file" << endl ; // pdbfilename << " ("<<filename<<")\n";
exit(0);