From 95a40cd0031da456c064727fffbd3787bfd7257a Mon Sep 17 00:00:00 2001 From: Joe Zhu Date: Thu, 4 Aug 2016 16:57:38 +0100 Subject: [PATCH] by default, do no print out recombination probabilities --- src/dEploidIO.cpp | 3 +++ src/dEploidIO.hpp | 4 ++++ src/export/dEploidIOExport.cpp | 6 ++++-- tests/unittest/test_dEploidIO.cpp | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/dEploidIO.cpp b/src/dEploidIO.cpp index 7245a7f8..9c556928 100644 --- a/src/dEploidIO.cpp +++ b/src/dEploidIO.cpp @@ -63,6 +63,7 @@ void DEploidIO::core(int argc, char *argv[]) { void DEploidIO::init() { + this->setDoExportRecombProb ( false ); this->setRandomSeedWasSet( false ); this->initialPropWasGiven_ = false; this->initialProp.clear(); @@ -295,6 +296,8 @@ void DEploidIO::parse (){ if ( this->constRecombProb_ < 0 || this->constRecombProb_ > 1){ throw ( OutOfRange ("-recomb", *argv_i) ); } + } else if ( *argv_i == "-printRecomb" ) { + this->setDoExportRecombProb( true ); } else if ( *argv_i == "-forbidSame" ) { this->setForbidCopyFromSame( true ); } else if ( *argv_i == "-rate" ) { diff --git a/src/dEploidIO.hpp b/src/dEploidIO.hpp index 9d5e900d..7b74ddd8 100644 --- a/src/dEploidIO.hpp +++ b/src/dEploidIO.hpp @@ -138,6 +138,10 @@ class DEploidIO{ void setDoExportVcf( const bool exportVcf ){ this->doExportVcf_ = exportVcf; } bool doExportVcf() const { return this->doExportVcf_; } + bool doExportRecombProb_; + void setDoExportRecombProb( const bool exportRecombProb ){ this->doExportRecombProb_ = exportRecombProb; } + bool doExportRecombProb() const { return this->doExportRecombProb_; } + // Parameters double missCopyProb_; double averageCentimorganDistance_;// = 15000.0, diff --git a/src/export/dEploidIOExport.cpp b/src/export/dEploidIOExport.cpp index 8b756c62..84063e29 100644 --- a/src/export/dEploidIOExport.cpp +++ b/src/export/dEploidIOExport.cpp @@ -29,7 +29,7 @@ void DEploidIO::write( McmcSample * mcmcSample, Panel * panel ){ this->writeLLK( mcmcSample ); this->writeHap( mcmcSample ); this->writeVcf( mcmcSample ); - this->writeRecombProb( panel ); // issue $98 + this->writeRecombProb( panel ); // Get End time before writing the log this->getTime(false); @@ -42,7 +42,8 @@ void DEploidIO::write( McmcSample * mcmcSample, Panel * panel ){ } -void DEploidIO::writeRecombProb ( Panel * panel ){ // issue $98 +void DEploidIO::writeRecombProb ( Panel * panel ){ + if ( !doExportRecombProb() ) return; if ( panel != NULL ){ ofstreamExportRecombProb.open( strExportRecombProb.c_str(), ios::out | ios::app | ios::binary ); @@ -171,6 +172,7 @@ void DEploidIO::writeHap( McmcSample * mcmcSample ){ void DEploidIO::writeVcf( McmcSample * mcmcSample ){ + if ( !doExportVcf() ) return; ofstreamExportTmp.open( strExportVcf.c_str(), ios::out | ios::app | ios::binary ); // VCF HEADER diff --git a/tests/unittest/test_dEploidIO.cpp b/tests/unittest/test_dEploidIO.cpp index 77f579bf..d2234fec 100644 --- a/tests/unittest/test_dEploidIO.cpp +++ b/tests/unittest/test_dEploidIO.cpp @@ -40,6 +40,7 @@ class TestIO : public CppUnit::TestCase { void testInitialization(){ CPPUNIT_ASSERT_EQUAL( this->input_->randomSeedWasSet(), false ); + CPPUNIT_ASSERT_EQUAL( this->input_->doExportRecombProb(), false ); CPPUNIT_ASSERT_EQUAL( this->input_->initialPropWasGiven(), false ); CPPUNIT_ASSERT_EQUAL( this->input_->excludeSites() , false ); CPPUNIT_ASSERT( this->input_->excludedMarkers == NULL);