From d6e89da0b1466623a945146a5512108112131c4e Mon Sep 17 00:00:00 2001 From: Glenn Hickey Date: Fri, 1 Nov 2013 09:00:37 -0700 Subject: [PATCH] add --prec option to halPhlyoP to control number of digits to write in wigs. default remains 3 --- phyloP/halPhyloPMP.py | 6 +++++- phyloP/halTreePhyloP.py | 6 ++++++ phyloP/impl/halPhyloP.cpp | 4 ---- phyloP/impl/halPhyloPMain.cpp | 7 +++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/phyloP/halPhyloPMP.py b/phyloP/halPhyloPMP.py index 1c63d0ed..18ce6daa 100755 --- a/phyloP/halPhyloPMP.py +++ b/phyloP/halPhyloPMP.py @@ -53,7 +53,8 @@ def getHalPhyloPCmd(options): opt == 'dupMask' or opt == 'step' or opt == 'refBed' or - opt == 'subtree')): + opt == 'subtree' or + opt == 'prec')): if val is not True: cmd += ' --%s %s' % (opt, str(val)) else: @@ -270,6 +271,9 @@ def main(argv=None): hppGrp.add_argument("--subtree", help="Subtree root for lineage-specific acceleration/conservation", default=None) + hppGrp.add_argument("--prec", + help="Number of decimal places in wig output", type=int, + default=None) args = parser.parse_args() diff --git a/phyloP/halTreePhyloP.py b/phyloP/halTreePhyloP.py index 5adc1812..c4dd7758 100644 --- a/phyloP/halTreePhyloP.py +++ b/phyloP/halTreePhyloP.py @@ -58,6 +58,8 @@ def computeTreePhyloP(args): args.hal, genome, args.mod, bedFlags, args.numProc, wigFile) if args.subtree is not None: cmd += " --subtree %s" % args.subtree + if args.prec is not None: + cmd += " --prec %d" % args.prec runShellCommand(cmd) @@ -117,6 +119,10 @@ def main(argv=None): parser.add_argument("--subtree", help="Run clade-specific acceleration/conservation on subtree below this node", default=None) + parser.add_argument("--prec", + help="Number of decimal places in wig output", type=int, + default=None) + # need phyloP options here: args = parser.parse_args() diff --git a/phyloP/impl/halPhyloP.cpp b/phyloP/impl/halPhyloP.cpp index 546dd9f7..f4bf728b 100644 --- a/phyloP/impl/halPhyloP.cpp +++ b/phyloP/impl/halPhyloP.cpp @@ -54,10 +54,6 @@ void PhyloP::init(AlignmentConstPtr alignment, const string& modFilePath, _softMaskDups = (int)softMaskDups; _outStream = outStream; - // set float precision to 3 places to be consistent with non-hal phyloP - _outStream->setf(ios::fixed, ios::floatfield); - _outStream->precision(3); - if (dupType == "ambiguous") { _maskAllDups = 0; diff --git a/phyloP/impl/halPhyloPMain.cpp b/phyloP/impl/halPhyloPMain.cpp index a9078179..5765de67 100644 --- a/phyloP/impl/halPhyloPMain.cpp +++ b/phyloP/impl/halPhyloPMain.cpp @@ -70,6 +70,7 @@ static CLParserPtr initParser() "leading up to this node), and test for " "conservation/acceleration in this subtree " "relative to the rest of the tree", "\"\""); + optionsParser->addOption("prec", "Number of decimal places in wig output", 3); optionsParser->setDescription("Make PhyloP wiggle plot for a genome."); return optionsParser; @@ -90,6 +91,7 @@ int main(int argc, char** argv) hal_size_t length; hal_size_t step; string refBedPath; + hal_size_t prec; try { optionsParser->parseOptions(argc, argv); @@ -106,6 +108,7 @@ int main(int argc, char** argv) subtree = optionsParser->getOption("subtree"); std::transform(dupMask.begin(), dupMask.end(), dupMask.begin(), ::tolower); refBedPath = optionsParser->getOption("refBed"); + prec = optionsParser->getOption("prec"); } catch(exception& e) { @@ -169,6 +172,10 @@ int main(int argc, char** argv) } } + // set the precision of floating point output + outStream.setf(ios::fixed, ios::floatfield); + outStream.precision(prec); + PhyloP phyloP; phyloP.init(alignment, modPath, &outStream, dupMask == "soft" , dupType, "CONACC", subtree);