Commit eabdf4a4 authored by Carsten Kemena's avatar Carsten Kemena

[fixed] file access problem in parallel

parent da748db6
Pipeline #737 passed with stage
in 1 minute and 23 seconds
v. 2.3.3
- fixed: under certain circumstances when using multiple queries no matches were returned
- fixed: a promblem when using multi threading
v. 2.3.2
- fixed: query was uncollapsed for next target if collapse was activated
......
......@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 2.6)
project (RADS C CXX)
SET(MAJOR_VERSION 2)
SET(MINOR_VERSION 3)
SET(PATCH_VERSION 2)
SET(PATCH_VERSION 3)
SET(CMAKE_CXX_FLAGS_COVERAGE
......@@ -34,7 +34,7 @@ MARK_AS_ADVANCED(
CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wunused -pedantic")
set(CMAKE_CXX_FLAGS "-std=c++14 -Wall -Wextra -Wunused -pedantic")
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release CACHE STRING
......
No preview for this file type
......@@ -108,8 +108,10 @@ htmlhelp_basename = 'RADSdoc'
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
'sphinxsetup':'VerbatimColor={rgb}{0.87,0.87,0.87},verbatimwithframe=false',
'classoptions': ',openany'
'sphinxsetup':'VerbatimColor={rgb}{0.99,0.96,0.9},verbatimwithframe=false,warningBgColor={rgb}{1, 0.86,0.86},warningborder=2pt,warningBorderColor={rgb}{0.86, 0.08, 0.24},',
'classoptions': ',openany',
#'sphinxsetup':'VerbatimColor={rgb}{0.87,0.87,0.87},verbatimwithframe=false',
#'classoptions': ',openany'
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
......
......@@ -14,7 +14,7 @@ We try to keep the dependencies as few as possible. Current dependencies are:
* BioSeqDataLib (https://ebbgit.uni-muenster.de/domainWorld/BioSeqDataLib) (can be added via git submodule)
* boost (http://www.boost.org)
* SQLite (https://www.sqlite.org)
* compiler with c++11 and OpenMP support
* compiler with c++14 and OpenMP support
--------
Download
......
......@@ -25,28 +25,33 @@
using namespace std;
DBAccess::DBAccess(const fs::path &prefix)
DBAccess::DBAccess(const fs::path &prefix, size_t nThreads)
{
open(prefix);
open(prefix, nThreads);
}
void DBAccess::open(const fs::path &prefix)
void DBAccess::open(const fs::path &prefix, size_t nThreads)
{
// open connection to database
fs::path dbFile = prefix;
dbFile.replace_extension(".db");
index_.open(dbFile.string(), SQLITE_OPEN_READONLY);
dbFile.replace_extension(".da");
arrangementDB_.open(dbFile);
arrangementDBs_ = std::make_unique<AlgorithmPack::Input []>(nThreads);;
for (size_t i = 0; i<nThreads; ++i)
arrangementDBs_[i].open(dbFile);
}
void
DBAccess::readSequences_(std::vector<TargetSequence> &sequences, const std::vector<std::string> &domainNames)
{
auto threadNum = omp_get_thread_num();
size_t nDomains = domainNames.size();
std::string line;
while(getline(this->arrangementDB_, line))
while(getline(this->arrangementDBs_[threadNum], line))
{
if (line[0] =='>')
break;
......@@ -89,6 +94,7 @@ void
DBAccess::search(BSDL::AlignmentMatrix<int, BSDL::DSM> &matrix, bool all, bool collapse, int scoreThres,
RadsQueryResult &results)
{
auto threadNum = omp_get_thread_num();
auto &queryDA = results.queryDA;
if (collapse)
queryDA.collapse(true);
......@@ -112,9 +118,9 @@ DBAccess::search(BSDL::AlignmentMatrix<int, BSDL::DSM> &matrix, bool all, bool c
for (auto &pos : positions)
{
// get the domain arrangement at the given position
this->arrangementDB_.clear();
this->arrangementDB_.seekg(pos, std::ios_base::beg);
getline(this->arrangementDB_, line);
this->arrangementDBs_[threadNum].clear();
this->arrangementDBs_[threadNum].seekg(pos, std::ios_base::beg);
getline(this->arrangementDBs_[threadNum], line);
auto domains = BSDL::split(line, ">;");
BSDL::DomainArrangement<BSDL::Domain> targetDA;
for (auto &domain : domains)
......
......@@ -24,8 +24,10 @@
#define DBACCESS_HPP
#include <algorithm>
#include <vector>
#include <memory>
#include <vector>
#include <boost/filesystem.hpp>
#include <omp.h>
// BioSeqDataLib
#include "../libs/BioSeqDataLib/src/DomainModule.hpp"
......@@ -107,7 +109,7 @@ class DBAccess
{
private:
SQLiteDB index_; // The object used to connect to the sqlite database.
AlgorithmPack::Input arrangementDB_; // The file object containing the domain arrangements
std::unique_ptr<AlgorithmPack::Input[]> arrangementDBs_; // The file object containing the domain arrangements
void
readSequences_(std::vector<TargetSequence> &sequences, const std::vector<std::string> &vectorNames);
......@@ -127,7 +129,7 @@ class DBAccess
* @param prefix The prefix of the database path.
* @param matrix The filename of the DSM to be used.
*/
DBAccess(const fs::path &prefix);
DBAccess(const fs::path &prefix, size_t n_threads);
/**
* @brief Opens the database
......@@ -135,7 +137,7 @@ class DBAccess
* @param prefix The prefix of the database to open.
*/
void
open(const fs::path &prefix);
open(const fs::path &prefix, size_t n_threads);
/**
* @brief Searches in the database for matching sequences.
......@@ -147,8 +149,7 @@ class DBAccess
* @param results The results sorted by score
*/
void
search(BSDL::AlignmentMatrix<int, BSDL::DSM> &matrix, bool all, bool collapse, int scoreThres,
RadsQueryResult &results);
search(BSDL::AlignmentMatrix<int, BSDL::DSM> &matrix, bool all, bool collapse, int scoreThres, RadsQueryResult &results);
std::set<int>
db_versions();
......
......@@ -115,15 +115,15 @@ main(int argc, char *argv[])
bool listAlignments;
fs::path prefix;
vector<std::string> q, domains;
unsigned short nThreads;
unsigned short nThreads = 1;
po::options_description general("General options");
general.add_options()
("help,h", "Produces this help message")
("db,d", po::value<fs::path>(&prefix)->required()->value_name("FILE"), "The database prefix")
("out,o", po::value<fs::path>(&outFile)->value_name("FILE"), "The output file")
("list-alignments,l", po::value<bool>(&listAlignments)->default_value(false)->zero_tokens(), "List alignments")
//("threads,n", po::value<unsigned short>(&nThreads)->default_value(1)->value_name("INT"), "The number of threads to use")
("threads,n", po::value<unsigned short>(&nThreads)->default_value(1)->value_name("INT"), "The number of threads to use")
;
po::options_description queryOpts("Query options");
......@@ -211,7 +211,7 @@ main(int argc, char *argv[])
return EXIT_FAILURE;
}
DBAccess db(prefix);
DBAccess db(prefix, nThreads);
// check if db version is compative to program
auto db_versions = db.db_versions();
......
......@@ -37,7 +37,7 @@ namespace BSDL=BioSeqDataLib;
BOOST_AUTO_TEST_CASE( search_TEST)
{
DBAccess db("../tests/data/test");
DBAccess db("../tests/data/test", 1);
BSDL::Settings settings;
settings.readSettings();
auto matrixName = settings["dsm"] / "pfam-31.dsm";
......
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