Skip to content

Commit

Permalink
Merge pull request #100 from mcveanlab/issue98
Browse files Browse the repository at this point in the history
Issue98
  • Loading branch information
shajoezhu authored Aug 4, 2016
2 parents 9db56f5 + 95a40cd commit baf3286
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/dEploidIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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" ) {
Expand Down
4 changes: 4 additions & 0 deletions src/dEploidIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions src/export/dEploidIOExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 );
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/unittest/test_dEploidIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit baf3286

Please sign in to comment.