Navigation Menu

Skip to content

Commit

Permalink
add --prec option to halPhlyoP to control number of digits to write i…
Browse files Browse the repository at this point in the history
…n wigs. default remains 3
  • Loading branch information
glennhickey committed Nov 1, 2013
1 parent eb49d71 commit d6e89da
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
6 changes: 5 additions & 1 deletion phyloP/halPhyloPMP.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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()

Expand Down
6 changes: 6 additions & 0 deletions phyloP/halTreePhyloP.py
Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down
4 changes: 0 additions & 4 deletions phyloP/impl/halPhyloP.cpp
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions phyloP/impl/halPhyloPMain.cpp
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -106,6 +108,7 @@ int main(int argc, char** argv)
subtree = optionsParser->getOption<string>("subtree");
std::transform(dupMask.begin(), dupMask.end(), dupMask.begin(), ::tolower);
refBedPath = optionsParser->getOption<string>("refBed");
prec = optionsParser->getOption<hal_size_t>("prec");
}
catch(exception& e)
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d6e89da

Please sign in to comment.