From 9f435292c2df5b2843beddb3a4f36c72887de298 Mon Sep 17 00:00:00 2001 From: Sam Brightman Date: Wed, 7 Dec 2016 11:30:04 +0100 Subject: [PATCH] Use standard process and exponential functions on OS X --- src/BAFpileup.cpp | 12 ++++++------ src/GenomeCopyNumber.cpp | 4 ++-- src/SNPinGenome.cpp | 8 ++++---- src/myFunc.cpp | 16 ++++++++-------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/BAFpileup.cpp b/src/BAFpileup.cpp index 0b7d862..843901d 100644 --- a/src/BAFpileup.cpp +++ b/src/BAFpileup.cpp @@ -98,7 +98,7 @@ float BAFpileup::calculateFlankLength(std::string const& mateFileName, std::stri command = "gzip -c -d "+mateFileName; } stream = - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _popen(command.c_str(), "r"); #else popen(command.c_str(), "r"); @@ -143,7 +143,7 @@ float BAFpileup::calculateFlankLength(std::string const& mateFileName, std::stri fragmentLength = fragmentLength/j; float flanks = fragmentLength/2; if (zgOrbam) { - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _pclose(stream); #else pclose(stream); @@ -251,13 +251,13 @@ std::string BAFpileup::intersectWithBedtools(std::string makeminipileup, std::st string command = pathToBedtools_ +" intersect -a " + makeminipileup + " -b " + bedFileWithRegionsOfInterest + " > " + intersected; stream = - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _popen(command.c_str(), "w"); #else popen(command.c_str(), "w"); #endif - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _pclose(stream); #else pclose(stream); @@ -301,13 +301,13 @@ std::string BAFpileup::createPileUpFile(std::string outputDir, std::string samto } stream = - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _popen(command.c_str(), "w"); #else popen(command.c_str(), "w"); #endif - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _pclose(stream); #else pclose(stream); diff --git a/src/GenomeCopyNumber.cpp b/src/GenomeCopyNumber.cpp index db70e65..fd88cf1 100644 --- a/src/GenomeCopyNumber.cpp +++ b/src/GenomeCopyNumber.cpp @@ -320,7 +320,7 @@ void GenomeCopyNumber::fillMyHash(std::string const& mateFileName ,std::string c inputFormat = getInputFormat(myInputFormat); stream = -#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) +#if defined(_WIN32) _popen(command.c_str(), "r"); #else popen(command.c_str(), "r"); @@ -330,7 +330,7 @@ void GenomeCopyNumber::fillMyHash(std::string const& mateFileName ,std::string c count++; normalCount+=processRead(inputFormat,matesOrientation,line_buffer, bin,targetBed, mateFileName); } - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _pclose(stream); #else pclose(stream); diff --git a/src/SNPinGenome.cpp b/src/SNPinGenome.cpp index 6afc706..1356284 100644 --- a/src/SNPinGenome.cpp +++ b/src/SNPinGenome.cpp @@ -118,7 +118,7 @@ void SNPinGenome::readSNPs(std::string const& inFile) char buffer[MAX_BUFFER]; string command = "gzip -cd "+inFile; stream = - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _popen(command.c_str(), "r"); #else popen(command.c_str(), "r"); @@ -128,7 +128,7 @@ void SNPinGenome::readSNPs(std::string const& inFile) if (line_buffer[0] == '#') continue; count+=processSNPLine(ifVCF,line_buffer,myChr,index,previousPos); } - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _pclose(stream); #else pclose(stream); @@ -389,14 +389,14 @@ void SNPinGenome::assignValues(std::string const& inFile, string inputFormat, in if (inFile.substr(inFile.size()-3,3).compare(".gz")==0) { string command = "gzip -cd "+inFile; FILE* stream = - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _popen(command.c_str(), "r"); #else popen(command.c_str(), "r"); #endif readPileUP(stream, minimalTotalLetterCountPerPosition, minimalQualityPerPosition, p_genomeCopyNumber); - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _pclose(stream); #else pclose(stream); diff --git a/src/myFunc.cpp b/src/myFunc.cpp index 8244748..cb505c8 100644 --- a/src/myFunc.cpp +++ b/src/myFunc.cpp @@ -277,7 +277,7 @@ long getLineNumber(std::string const& fileName, const std::string& pathToSamtool if (fileName.substr(fileName.size()-3,3).compare(".gz")==0) { string command = "gzip -cd "+fileName; stream = - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _popen(command.c_str(), "r"); #else popen(command.c_str(), "r"); @@ -285,7 +285,7 @@ long getLineNumber(std::string const& fileName, const std::string& pathToSamtool while ( fgets(buffer, MAX_BUFFER, stream) != NULL ) { count++; } - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _pclose(stream); #else pclose(stream); @@ -305,7 +305,7 @@ long getLineNumber(std::string const& fileName, const std::string& pathToSamtool cout << "..samtools should be installed to be able to read BAM files\n"; } stream = - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _popen(command.c_str(), "r"); #else popen(command.c_str(), "r"); @@ -314,7 +314,7 @@ long getLineNumber(std::string const& fileName, const std::string& pathToSamtool while ( fgets(buffer, MAX_BUFFER, stream) != NULL ) { count++; } - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _pclose(stream); #else pclose(stream); @@ -353,7 +353,7 @@ long getReadNumberFromPileup(std::string const& fileName) { char buffer[MAX_BUFFER]; string command = "gzip -cd "+fileName; stream = - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _popen(command.c_str(), "r"); #else popen(command.c_str(), "r"); @@ -373,7 +373,7 @@ long getReadNumberFromPileup(std::string const& fileName) { } strs.clear(); } - #if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) + #if defined(_WIN32) _pclose(stream); #else pclose(stream); @@ -1224,7 +1224,7 @@ string pathAppend(const string& p1, const string& p2) { char sep = '/'; string tmp = p1; char sep2=sep; -#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) +#if defined(_WIN32) sep2 = '\\'; #endif char lastSymb= p1[p1.length( )-1]; @@ -2496,7 +2496,7 @@ void myReplace(std::string& str, const std::string& oldStr, const std::string& n } -#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) +#if defined(_WIN32) double expm1(double x) { if (fabs(x) < 1e-5) return x + 0.5*x*x;