Commit a85081cc authored by karius's avatar karius

fixed query loading

parent 849f588e
......@@ -24,8 +24,10 @@ FittingProtocol::FittingProtocol() {
}
void FittingProtocol::addQueryFromPdb(const char * file_name){
Query query = Query::fromPdb(file_name);
queries.push_back(query);
if (file_exists(file_name)){
Query query = Query::fromPdb(file_name);
queries.push_back(query);
}
}
void FittingProtocol::loadTarget(int gpu_index){
......@@ -74,7 +76,4 @@ void FittingProtocol::setFileTarget(const char * file_name){
if (file_exists(file_name)){
target = Target::fromMrc(file_name);
}
else {
std::cout << "File " << file_name << " is not found ..." << std::endl;
}
}
......@@ -12,8 +12,11 @@ std::map<std::string,AtomType> atom_symbol_to_type = {{"H",AtomType::H},{"C",Ato
PdbReader::PdbReader(const char * path){
std::ifstream ifs;
ifs.open(path, std::ifstream::in);
_path = path;
scan_file(ifs);
ifs.close();
}
PdbReader::~PdbReader() {}
......@@ -46,8 +49,8 @@ float4 PdbReader::get_atom(std::string & line){
int PdbReader::atom_coords_to_device(float4 * d_coords, int gpu_index){
RecordType type;
std::string line;
ifs.clear();
ifs.seekg(0,std::ios::beg);
std::ifstream ifs;
ifs.open(_path, std::ifstream::in);
int c = 0;
assert(cudaSuccess == cudaSetDevice(gpu_index));
float4 current_atom;
......@@ -60,6 +63,7 @@ int PdbReader::atom_coords_to_device(float4 * d_coords, int gpu_index){
c++;
}
}
ifs.close();
return error;
}
......
......@@ -369,7 +369,7 @@ private:
void scan_file(std::ifstream & ifs);
AtomType get_atom_type(std::string & line);
float4 get_atom(std::string & line);
std::ifstream ifs;
const char * _path;
size_t atom_count{0};
};
#endif /* PDBREADER_H_ */
......
......@@ -55,25 +55,24 @@ int Query::initGpu(int gpu_index){
int Query::toGpu(int gpu_index){
int ret = 0;
if (_source_type == PDB){
ret += int(cudaSuccess != cudaSetDevice(gpu_index));
ret += _particles.pdb_readers[0]->atom_coords_to_device(_particles.d_data,gpu_index);
}
return ret;
}
int Query::loadToGpu(int gpu_index){
int ret = 0;
int error = 0;
if (!_cpu_initiated){
ret += initCpu();
error += initCpu();
}
assert(ret != 0);
assert(error == 0);
if (!_gpu_initiated){
ret += initGpu(gpu_index);
error += initGpu(gpu_index);
}
assert(ret != 0);
assert(error == 0);
toGpu(gpu_index);
assert(ret != 0);
return ret;
assert(error == 0);
return error;
}
int Query::fromGpu(){return 0;}
......@@ -22,18 +22,18 @@ size_t Target::getCpuMem(){
}
int Target::loadToGpu(int gpu_index){
int ret = 0;
int error = 0;
if (!_cpu_initiated){
ret += initCpu();
error += initCpu();
}
assert(ret != 0);
assert(error == 0);
if (!_gpu_initiated){
ret += initGpu(gpu_index);
error += initGpu(gpu_index);
}
assert(ret != 0);
ret += toGpu(gpu_index);
assert(ret != 0);
return ret;
assert(error == 0);
error += toGpu(gpu_index);
assert(error == 0);
return error;
}
int Target::initCpu(){
......
......@@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE(fitting_protocol)
protocol.printGPUInfo();
protocol.setFileTarget("test/TauA_3.47A_map.mrc");
protocol.loadTarget(0);
protocol.addQueryFromPdb("test/TauA.pdb");
protocol.addQueryFromPdb("test/tauA.pdb");
protocol.loadQueries(0);
// std::pair<float3,float3> effective_translational_shift;
// effective_translational_shift.first = {0,0,0};
......
......@@ -52,6 +52,7 @@ inline bool file_exists (const std::string& name) {
fclose(file);
return true;
} else {
std::cout << "File " << name << " is not found ..." << std::endl;
return false;
}
}
......
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