Commit a6eeccc8 authored by Carsten Kemena's avatar Carsten Kemena

restructure code, correct test

parent 2f27c049
......@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.6)
project (RADS C CXX)
SET(MAJOR_VERSION 2)
SET(MINOR_VERSION 2)
SET(MINOR_VERSION 3)
SET(PATCH_VERSION 0)
......
......@@ -53,6 +53,60 @@ namespace po = boost::program_options;
namespace fs = boost::filesystem;
namespace BSDL = BioSeqDataLib;
void
printResult(const RadsQueryResult &results, AP::Output &outS, bool listAlignments)
{
// results are written to a buffer first to reduce time in critical section
std::stringstream buf, alnbuf;
buf << "# -------------------------------------------------------------------\n";
buf << "Results for: " << results.queryName << "\n";
buf << "Domain arrangement:";
for (auto const domain : results.queryDA)
buf << " " << domain.accession();
buf << "\n\n";
buf << "# score | normalized | SeqID | sequence length | domain arrangement";
if (listAlignments)
buf << " | aln";
buf << "\n";
buf << "# -------------------------------------------------------------------\n";
buf.setf(ios::fixed, ios::floatfield);
buf.precision(2);
size_t alnNumber = 0;
for (auto &hit : results.targets)
{
++alnNumber;
if (listAlignments)
alnbuf << std::to_string(alnNumber) + ")\n Query DA: " + hit.alnStringQuery + "\nTarget DA: " + hit.alnStringTarget + "\n\n";
for (auto &seq : hit.targetSequences)
{
buf << hit.score << "\t" << hit.normalized << "\t" << seq.targetName << "\t" << seq.length << "\t";
const auto &da = seq.da;
size_t len = da.size();
buf << da[0].accession() << " " << da[0].start() << " " << da[0].end();
for (size_t i = 1; i<len; ++i)
buf << " " << da[i].accession() << " " << da[i].start() << " " << da[i].end();
if (listAlignments)
buf << "\t" << alnNumber;
buf << "\n";
}
}
buf << "\n\n";
#pragma omp critical(print_ouptut)
{
outS << buf.rdbuf();
if (listAlignments)
{
outS << "# -------------------------------------------------------------------\n";
outS << "List of alignments:\n";
outS << "# -------------------------------------------------------------------\n\n";
outS << alnbuf.rdbuf();
}
}
}
int
main(int argc, char *argv[])
{
......@@ -88,7 +142,7 @@ main(int argc, char *argv[])
("matrix,m", po::value<fs::path>(&matrixName)->value_name("FILE"), "The domain similarity matrix")
("gop", po::value<int>(&gop)->default_value(-50)->value_name("INT"), "Gap opening costs")
("gep", po::value<int>(&gep)->default_value(-10)->value_name("INT"), "Gap extension costs")
("collapse,c", po::value<bool>(&collapse)->default_value(false)->zero_tokens(), "Collapse consecutive identical domains")
("collapse,c", po::value<bool>(&collapse)->default_value(false)->zero_tokens(), "Collapse consecutive identical domains (use is recommended)")
;
bool all;
......@@ -218,58 +272,10 @@ main(int argc, char *argv[])
for (size_t j=0; j<i; ++j)
++it;
RadsQueryResult results;
results.queryName = it->first;
results.queryDA = it->second;
db.search(matrices[omp_get_thread_num()], all, collapse, minScore, results);
// results are written to a buffer first to reduce time in critical section
std::stringstream buf, alnbuf;
buf << "# -------------------------------------------------------------------\n";
buf << "Results for: " << it->first << "\n";
buf << "Domain arrangement:";
for (auto const domain : it->second)
buf << " " << domain.accession();
buf << "\n\n";
buf << "# score | normalized | SeqID | sequence length | domain arrangement";
if (listAlignments)
buf << " | aln";
buf << "\n";
buf << "# -------------------------------------------------------------------\n";
buf.setf(ios::fixed, ios::floatfield);
buf.precision(2);
size_t alnNumber = 0;
for (auto &hit : results.targets)
{
++alnNumber;
if (listAlignments)
alnbuf << std::to_string(alnNumber) + ")\nQuery DA: " + hit.alnStringQuery + "\nTarget DA: " + hit.alnStringTarget + "\n\n";
for (auto &seq : hit.targetSequences)
{
//const auto &hit = result.;
buf << hit.score << "\t" << hit.normalized << "\t" << seq.targetName << "\t" << seq.length << "\t";
const auto &da = seq.da;
size_t len = da.size();
buf << da[0].accession() << " " << da[0].start() << " " << da[0].end();
for (size_t i = 1; i<len; ++i)
buf << " " << da[i].accession() << " " << da[i].start() << " " << da[i].end();
if (listAlignments)
buf << "\t" << alnNumber;
buf << "\n";
}
}
buf << "\n\n";
#pragma omp critical(print_ouptut)
{
outS << buf.rdbuf();
if (listAlignments)
{
outS << "# -------------------------------------------------------------------\n";
outS << "List of alignments:\n";
outS << "# -------------------------------------------------------------------\n\n";
outS << alnbuf.rdbuf();
}
}
printResult(results, outS, listAlignments);
}
......
# RADS version 2.2.0
# RADS Output v1
# run at Tue Jun 26 11:18:33 2018
# run at Tue Jun 26 13:39:03 2018
#
# query file: -
# database: /local/home/ckeme_01/projects/domainWorld/RADS/tests/integrationTests/interPro-test
......@@ -28,14 +28,14 @@ List of alignments:
# -------------------------------------------------------------------
1)
Query DA: PF00001 PF00002 PF00003
Query DA: PF00001 PF00002 PF00003
Target DA: PF00001 PF00002 PF00003
2)
Query DA: PF00001 PF00002 PF00003
Query DA: PF00001 PF00002 PF00003
Target DA: ******* PF00002 PF00003
3)
Query DA: ******* PF00001 PF00002 PF00003
Query DA: ******* PF00001 PF00002 PF00003
Target DA: PF00001 PF00002 PF00002 *******
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