/usr/lib/python2.7/dist-packages/pbalign/options.py is in python-pbalign 0.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | #!/usr/bin/env python
###############################################################################
# Copyright (c) 2011-2013, Pacific Biosciences of California, Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Pacific Biosciences nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
# THIS LICENSE. THIS SOFTWARE IS PROVIDED BY PACIFIC BIOSCIENCES AND ITS
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PACIFIC BIOSCIENCES OR
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
# Author:Yuan Li
"""This scripts defines functions for parsing PBAlignRunner options."""
from __future__ import absolute_import
import argparse
import logging
from copy import copy
from pbcommand.models import FileTypes, SymbolTypes, ResourceTypes, get_pbparser
from pbcommand.common_options import add_debug_option, add_base_options
from pbalign.__init__ import get_version
log = logging.getLogger(__name__)
class Constants(object):
TOOL_ID = "pbalign.tasks.pbalign"
INPUT_FILE_TYPE = FileTypes.DS_SUBREADS
OUTPUT_FILE_TYPE = FileTypes.DS_ALIGN
OUTPUT_FILE_NAME = "mapped"
ALGORITHM_OPTIONS_ID = "pbalign.task_options.algorithm_options"
ALGORITHM_OPTIONS_DEFAULT = "--minMatch 12 --bestn 10 --minPctSimilarity 70.0"
MIN_ACCURACY_ID = "pbalign.task_options.min_accuracy"
MIN_LENGTH_ID = "pbalign.task_options.min_length"
NO_SPLIT_ID = "pbalign.task_options.no_split_subreads"
CONCORDANT_ID = "pbalign.task_options.concordant"
HIT_POLICY_ID = "pbalign.task_options.hit_policy"
DRIVER_EXE = "pbalign --resolved-tool-contract "
VERSION = get_version()
PARSER_DESC = """\
Mapping PacBio sequences to references using an algorithm selected from a
selection of supported command-line alignment algorithms. Input can be a
fasta, pls.h5, bas.h5 or ccs.h5 file or a fofn (file of file names). Output
can be in SAM or BAM format. If output is BAM format, aligner can
only be blasr and QVs will be loaded automatically.
NOTE that pbalign no longer supports CMP.H5 in 3.0."""
# The first candidate 'blasr' is the default.
ALGORITHM_CANDIDATES = ('blasr', 'bowtie', 'gmap')
# The first candidate 'randombest' is the default.
HITPOLICY_CANDIDATES = ('randombest', 'allbest', 'random', 'all', 'leftmost')
# The first candidate 'aligner' is the default.
SCOREFUNCTION_CANDIDATES = ('alignerscore', 'editdist',
#'blasrscore', 'userscore')
'blasrscore')
DEFAULT_METRICS = ("DeletionQV", "DeletionTag", "InsertionQV",
"MergeQV", "SubstitutionQV")
# Default values of arguments
DEFAULT_OPTIONS = {"regionTable": None,
"configFile": None,
# Choose an aligner
"algorithm": ALGORITHM_CANDIDATES[0],
# Aligner options
"maxHits": 10,
"minAnchorSize": 12,
"maxMatch": 30,
"noSplitSubreads": False,
"concordant": False,
"unaligned": None,
"algorithmOptions": None,
"useccs": None,
# Filter options
"maxDivergence": 30.0,
"minAccuracy": 70.0,
"minLength": 50,
#"scoreFunction": SCOREFUNCTION_CANDIDATES[0],
"scoreCutoff": None,
"hitPolicy": HITPOLICY_CANDIDATES[0],
"filterAdapterOnly": False,
# Cmp.h5 writer options
"readType": "standard",
"forQuiver": False,
"loadQVs": False,
"byread": False,
"metrics": str(",".join(DEFAULT_METRICS)),
# Miscellaneous options
"nproc": 8,
"seed": 1,
"tmpDir": "/tmp"}
def constructOptionParser(parser, C=Constants, ccs_mode=False):
"""
Add PBAlignRunner arguments to the parser.
"""
# save reference to PbParser
p = parser
tcp = p.tool_contract_parser
parser = parser.arg_parser.parser
#parser.argument_default = argparse.SUPPRESS
parser.formatter_class = argparse.ArgumentDefaultsHelpFormatter
add_debug_option(parser)
# Optional input.
input_group = parser.add_argument_group("Optional input arguments")
input_group.add_argument("--regionTable",
dest="regionTable",
type=str,
default=None,
action="store",
help="Specify a region table for filtering reads.")
input_group.add_argument("--configFile",
dest="configFile",
default=None,
type=str,
action="store",
help="Specify a set of user-defined argument values.")
helpstr = "When input reads are in fasta format and output is a cmp.h5\n" + \
"this option can specify pls.h5 or bas.h5 or \n" + \
"FOFN files from which pulse metrics can be loaded for Quiver."
input_group.add_argument("--pulseFile",
dest="pulseFile",
default=None,
type=str,
action="store",
help=helpstr)
# Chose an aligner.
align_group = parser.add_argument_group("Alignment options")
helpstr = "Select an aligorithm from {0}.\n".format(ALGORITHM_CANDIDATES)
align_group.add_argument("--algorithm",
dest="algorithm",
type=str,
action="store",
choices=ALGORITHM_CANDIDATES,
default=ALGORITHM_CANDIDATES[0],
help=helpstr)
# Aligner options.
helpstr = "The maximum number of matches of each read to the \n" + \
"reference sequence that will be evaluated."
align_group.add_argument("--maxHits",
dest="maxHits",
type=int,
default=None, # Set as None instead of a real number.
action="store",
help=helpstr)
helpstr = "The minimum anchor size defines the length of the read\n" + \
"that must match against the reference sequence."
align_group.add_argument("--minAnchorSize",
dest="minAnchorSize",
type=int,
default=None, # Set as None to avoid conflicts with
# --algorithmOptions
action="store",
help=helpstr)
helpstr = "BLASR maxMatch option. (Will be overriden if is also set in algorithmOptions)"
align_group.add_argument("--maxMatch", dest="maxMatch", type=int,
default=DEFAULT_OPTIONS["maxMatch"],
action="store", help=helpstr)
# Aligner options: Use ccs or not?
helpstr = "Map the ccsSequence to the genome first, then align\n" + \
"subreads to the interval that the CCS reads mapped to.\n" + \
" useccs: only maps subreads that span the length of\n" + \
" the template.\n" + \
" useccsall: maps all subreads.\n" + \
" useccsdenovo: maps ccs only."
align_group.add_argument("--useccs",
type=str,
choices=["useccs", "useccsall", "useccsdenovo"],
action="store",
default=None,
help=helpstr)
helpstr = "Do not split reads into subreads even if subread \n" + \
"regions are available."
align_group.add_argument("--noSplitSubreads",
dest="noSplitSubreads",
default=DEFAULT_OPTIONS["noSplitSubreads"],
action="store_true",
help=helpstr)
if not ccs_mode:
tcp.add_boolean(C.NO_SPLIT_ID, "noSplitSubreads",
default=DEFAULT_OPTIONS["noSplitSubreads"],
name="Align unsplit polymerase reads",
description=helpstr)
helpstr = "Map subreads of a ZMW to the same genomic location.\n"
align_group.add_argument("--concordant",
dest="concordant",
default=DEFAULT_OPTIONS["concordant"],
action="store_true",
help=helpstr)
if not ccs_mode:
tcp.add_boolean(C.CONCORDANT_ID, "concordant",
default=DEFAULT_OPTIONS["concordant"],
name="Concordant alignment",
description="Map subreads of a ZMW to the same genomic location")
helpstr = "Number of threads."
align_group.add_argument("--nproc",
type=int,
dest="nproc",
default=DEFAULT_OPTIONS["nproc"],
#default=15,
action="store",
help=helpstr)
align_group.add_argument("--algorithmOptions",
type=str,
dest="algorithmOptions",
default=None,
action="append",
help="Pass alignment options through.")
# XXX the arguments used in SMRTpipe 2.3 are different from the defaults
# for the command line tool
tcp.add_str(C.ALGORITHM_OPTIONS_ID, "algorithmOptions",
default=C.ALGORITHM_OPTIONS_DEFAULT,
name="Algorithm options",
description="List of space-separated arguments passed to BLASR")
# Filtering criteria and hit policy.
filter_group = parser.add_argument_group("Filter criteria options")
helpstr = "The maximum allowed percentage divergence of a read \n" + \
"from the reference sequence."
filter_group.add_argument("--maxDivergence",
dest="maxDivergence",
type=float,
default=DEFAULT_OPTIONS["maxDivergence"],
#default=30,
action="store",
help=helpstr)
helpstr = "The minimum concordance of alignments that\n" + \
"will be evaluated."
filter_group.add_argument("--minAccuracy",
dest="minAccuracy",
type=float,
default=DEFAULT_OPTIONS["minAccuracy"],
#default=70,
action="store",
help=helpstr)
tcp.add_float(C.MIN_ACCURACY_ID, "minAccuracy",
default=DEFAULT_OPTIONS["minAccuracy"],
name="Min. concordance",
description="Minimum required alignment concordance")
helpstr = "The minimum aligned read length of alignments that\n" + \
"will be evaluated."
filter_group.add_argument("--minLength",
dest="minLength",
type=int,
default=DEFAULT_OPTIONS["minLength"],
action="store",
help=helpstr)
tcp.add_int(C.MIN_LENGTH_ID, "minLength",
default=DEFAULT_OPTIONS["minLength"],
name="Min. length",
description="Minimum required alignment length")
#helpstr = "Specify a score function for evaluating alignments.\n"
#helpstr += " alignerscore : aligner's score in the SAM tag 'as'.\n"
#helpstr += " editdist : edit distance between read and reference.\n"
#helpstr += " blasrscore : blasr's default score function.\n"
#helpstr += "Default value is {0}.".format(DEFAULT_OPTIONS["scoreFunction"])
#filter_group.add_argument("--scoreFunction",
# dest="scoreFunction",
# type=str,
# choices=SCOREFUNCTION_CANDIDATES,
# default=DEFAULT_OPTIONS["scoreFunction"],
# action="store",
# help=helpstr)
#" userscore : user-defined score matrix (by -scoreMatrix).\n")
#parser.add_argument("--scoreMatrix",
# dest="scoreMatrix",
# type=str,
# default=None,
# help=
# "Specify a user-defined score matrix for "
# "scoring reads.The matrix\n"+\
# "is in the format\n"
# " ACGTN\n"
# " A abcde\n"
# " C fghij\n"
# " G klmno\n"
# " T pqrst\n"
# " N uvwxy\n"
# ". The values a...y should be input as a "
# "quoted space separated\n"
# "string: "a b c ... y". Lower scores are better,"
# "so matches\n"
# "should be less than mismatches e.g. a,g,m,s "
# "= -5 (match),\n"
# "mismatch = 6.\n")
filter_group.add_argument("--scoreCutoff",
dest="scoreCutoff",
type=int,
default=None,
action="store",
help="The worst score to output an alignment.\n")
helpstr = "Specify a policy for how to treat multiple hit\n" + \
" random : selects a random hit.\n" + \
" all : selects all hits.\n" + \
" allbest : selects all the best score hits.\n" + \
" randombest: selects a random hit from all best score hits.\n" + \
" leftmost : selects a hit which has the best score and the\n" + \
" smallest mapping coordinate in any reference.\n"
filter_group.add_argument("--hitPolicy",
dest="hitPolicy",
type=str,
choices=HITPOLICY_CANDIDATES,
default=DEFAULT_OPTIONS["hitPolicy"],
action="store",
help=helpstr)
tcp.add_str(C.HIT_POLICY_ID, "hitPolicy",
default=DEFAULT_OPTIONS["hitPolicy"],
name="Hit policy",
description=helpstr)
helpstr = "If specified, do not report adapter-only hits using\n" + \
"annotations with the reference entry."
filter_group.add_argument("--filterAdapterOnly",
dest="filterAdapterOnly",
default=DEFAULT_OPTIONS["filterAdapterOnly"],
action="store_true",
help=helpstr)
# Output.
# CMP H5 output has been deprecated, let's hide associated options.
cmph5_group = parser.add_argument_group("Options for cmp.h5")
helpstr = "Specify the ReadType attribute in the cmp.h5 output.\n"
cmph5_group.add_argument("--readType",
dest="readType",
type=str,
action="store",
default=DEFAULT_OPTIONS["readType"],
help=argparse.SUPPRESS)
helpstr = "The output cmp.h5 file which will be sorted, loaded\n" + \
"with pulse QV information, and repacked, so that it \n" + \
"can be consumed by quiver directly. This requires\n" + \
"the input file to be in PacBio bas/pls.h5 format,\n" + \
"and --useccs must be None."
cmph5_group.add_argument("--forQuiver",
dest="forQuiver",
action="store_true",
default=DEFAULT_OPTIONS["forQuiver"],
help=argparse.SUPPRESS)
helpstr = "Similar to --forQuiver, the only difference is that \n" + \
"--useccs can be specified."
cmph5_group.add_argument("--loadQVs",
dest="loadQVs",
action="store_true",
default=DEFAULT_OPTIONS["loadQVs"],
help=argparse.SUPPRESS)
helpstr = "Load pulse information using -byread option instead\n" + \
"of -bymetric. Only works when --forQuiver or \n" + \
"--loadQVs are set."
cmph5_group.add_argument("--byread",
dest="byread",
action="store_true",
default=DEFAULT_OPTIONS["byread"],
help=argparse.SUPPRESS)
helpstr = "Load the specified (comma-delimited list of) metrics\n" + \
"instead of the default metrics required by quiver.\n" + \
"This option only works when --forQuiver or \n" + \
"--loadQVs are set."
cmph5_group.add_argument("--metrics",
dest="metrics",
type=str,
action="store",
default=DEFAULT_OPTIONS["metrics"],
help=argparse.SUPPRESS)
# Miscellaneous.
misc_group = parser.add_argument_group("Miscellaneous options")
helpstr = "Output names of unaligned reads to specified file."
misc_group.add_argument("--unaligned",
dest="unaligned",
type=str,
action="store",
default=DEFAULT_OPTIONS["unaligned"],
help=helpstr)
helpstr = "Initialize the random number generator with a none-zero \n" + \
"integer. Zero means that current system time is used.\n"
misc_group.add_argument("--seed",
dest="seed",
type=int,
default=DEFAULT_OPTIONS["seed"],
action="store",
help=helpstr)
helpstr = "Specify a directory for saving temporary files.\n"
misc_group.add_argument("--tmpDir",
dest="tmpDir",
type=str,
action="store",
default=DEFAULT_OPTIONS["tmpDir"],
help=helpstr)
# Keep all temporary & intermediate files.
misc_group.add_argument("--keepTmpFiles",
dest="keepTmpFiles",
action="store_true",
default=False,
help=argparse.SUPPRESS)
return parser
def importConfigOptions(options):
"""
Import options from options.configFile if the file exists, and
overwrite a copy of the incoming options with options imported
from the config file. Finally, return the new options and an
info message.
"""
newOptions = copy(options)
# No config file exists.
if 'configFile' not in options or options.configFile is None:
return newOptions, ""
# There exists a config file
optionsDictView = vars(newOptions)
configFile = options.configFile
infoMsg = "ConfigParser: Import options from a config file {0}: "\
.format(configFile)
# The following arguments are defined in PBToolRunner, and may
# not exist in the input options (if the input options is parsed
# by a parser created in constructOptionParser).
specialArguments = ("--version", "--configFile", "--verbose",
"--debug", "--profile", "-v", "-vv", "-vvv",
"--keepTmpFiles")
try:
with open(configFile, 'r') as cf:
for line in cf:
line = line.strip()
errMsg = ""
# First parse special arguments and comments
if (line.startswith("#") or line == "" or
line in specialArguments):
pass
else: # Parse binary arguments
try:
k, v = line.split("=")
k = k.lstrip().lstrip('-').strip()
v = v.strip().strip('\"').strip('\'')
except ValueError as e:
errMsg = "ConfigParser: could not find '=' when " + \
"parsing {0}.".format(line)
raise ValueError(errMsg)
# Always use options' values from the configFile.
if k not in optionsDictView:
errMsg = "{k} is an invalid option.".format(k=k)
raise ValueError(errMsg)
else:
infoMsg += "{k}={v}, ".format(k=k, v=v)
optionsDictView[k] = v
except IOError as e:
errMsg = "ConfigParser: Could not open a config file {0}.\n".\
format(configFile)
raise IOError(errMsg + str(e))
return newOptions, infoMsg
def importDefaultOptions(parsedOptions, additionalDefaults=DEFAULT_OPTIONS):
"""Import default options and return (update_options, an_info_message).
After parsing the arguments and resolving algorithmOptions, we need
to patch the default pbalign options, if they have not been overwritten
on the command-line nor in the config file nor within algorithmOptions.
"""
newOptions = copy(parsedOptions)
infoMsg = "Importing default options: "
optionsDictView = vars(newOptions)
for k, v in additionalDefaults.iteritems():
if (k not in optionsDictView) or (optionsDictView[k] is None):
infoMsg += "{k}={v}, ".format(k=optionsDictView[k], v=v)
optionsDictView[k] = v
return newOptions, infoMsg.rstrip(', ')
class _ArgParser(argparse.ArgumentParser):
"""
Substitute for the standard argument parser, where parse_args is
extended to facilitate the use of config files.
"""
def parse_args(self, args=None, namespace=None):
options = super(_ArgParser, self).parse_args(args=args,
namespace=namespace)
# Import options from the specified config file, if it exists.
configOptions, infoMsg = importConfigOptions(options)
# Parse argumentList for the second time in order to
# overwrite config options with options in argumentList.
newOptions = copy(configOptions)
newOptions.algorithmOptions = None
newOptions = super(_ArgParser, self).parse_args(namespace=newOptions,
args=args)
# Overwrite config algorithmOptions if it is specified in argumentList
if newOptions.algorithmOptions is None:
if configOptions.algorithmOptions is not None:
newOptions.algorithmOptions = configOptions.algorithmOptions
else:
newOptions.algorithmOptions = \
" ".join(newOptions.algorithmOptions)
# FIXME gross hack to work around the problem of passing this
# parameter from a resolved tool contract
def unquote(s):
if s[0] in ["'", '"'] and s[-1] in ["'", '"']:
return s[1:-1]
return s
if newOptions.algorithmOptions is not None:
newOptions.algorithmOptions = unquote(newOptions.algorithmOptions)
# Return the updated options and an info message.
return newOptions #parser, newOptions, infoMsg
def get_contract_parser(C=Constants, ccs_mode=False):
"""
Create and populate the combined tool contract/argument parser. This
method can optionally be overridden with a different Constants object for
defining additional tasks (e.g. CCS alignment).
"""
p = get_pbparser(
tool_id=C.TOOL_ID,
version=C.VERSION,
name=C.TOOL_ID,
description=C.PARSER_DESC,
driver_exe=C.DRIVER_EXE,
nproc=SymbolTypes.MAX_NPROC,
resource_types=(ResourceTypes.TMP_DIR,),
default_level="WARN")
p.arg_parser.parser = _ArgParser(
description=C.PARSER_DESC,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
p.arg_parser.parser.version = C.VERSION
p.arg_parser.parser.add_argument('--version',
action="version",
help="show program's version number and exit")
add_base_options(p.arg_parser.parser)
# Required options: inputs and outputs.
p.add_input_file_type(C.INPUT_FILE_TYPE, "inputFileName",
"Subread DataSet", "SubreadSet or unaligned .bam")
p.add_input_file_type(FileTypes.DS_REF, "referencePath",
"ReferenceSet", "Reference DataSet or FASTA file")
p.add_output_file_type(C.OUTPUT_FILE_TYPE, "outputFileName",
name="Alignments",
description="Alignment results dataset",
default_name=C.OUTPUT_FILE_NAME)
constructOptionParser(p, ccs_mode=ccs_mode)
p.arg_parser.parser.add_argument(
"--profile", action="store_true",
help="Print runtime profile at exit")
return p
def resolved_tool_contract_to_args(resolved_tool_contract):
rtc = resolved_tool_contract
p = get_contract_parser().arg_parser.parser
args = [
rtc.task.input_files[0],
rtc.task.input_files[1],
rtc.task.output_files[0],
"--nproc", str(resolved_tool_contract.task.nproc),
"--minAccuracy", str(rtc.task.options[Constants.MIN_ACCURACY_ID]),
"--minLength", str(rtc.task.options[Constants.MIN_LENGTH_ID]),
"--hitPolicy", str(rtc.task.options[Constants.HIT_POLICY_ID]),
"--tmpDir", rtc.task.tmpdir_resources[0].path,
"--log-level", rtc.task.log_level,
]
if rtc.task.options[Constants.ALGORITHM_OPTIONS_ID]:
# FIXME this is gross: if I don't quote the options, the parser chokes;
# if I do quote them, the quotes get propagated, so I have to strip
# them off later
args.extend([
"--algorithmOptions=\"%s\"" %
rtc.task.options[Constants.ALGORITHM_OPTIONS_ID],
])
if rtc.task.options.get(Constants.CONCORDANT_ID, False):
args.append("--concordant")
if rtc.task.options.get(Constants.NO_SPLIT_ID, False):
args.append("--noSplitSubreads")
log.info("Converted command line: 'pbalign {a}'".format(a=" ".join(args)))
return p.parse_args(args)
|