|
19 | 19 | from . import vdj_match |
20 | 20 | from . import convert |
21 | 21 | from . import identity |
| 22 | +from . import msa |
| 23 | +from . import tree |
22 | 24 | from . import show |
23 | 25 | from .util import IgSeqError |
24 | 26 | from .version import __version__ |
@@ -77,10 +79,9 @@ def main(arglist=None): |
77 | 79 | try: |
78 | 80 | if args_extra: |
79 | 81 | # If there were unparsed arguments, see if we're in one of the |
80 | | - # commands (currently just igblast) that can take extra |
81 | | - # pass-through arguments. If so pass them along, but if not, |
82 | | - # error out. |
83 | | - if args.func in [_main_igblast]: |
| 82 | + # commands that can take extra pass-through arguments. If so |
| 83 | + # pass them along, but if not, error out. |
| 84 | + if args.func in [_main_igblast, _main_getreads]: |
84 | 85 | args.func(args, args_extra) |
85 | 86 | else: |
86 | 87 | parser.parse_args(args_extra) |
@@ -111,13 +112,14 @@ def main(arglist=None): |
111 | 112 | except BrokenPipeError: |
112 | 113 | os.dup2(devnull, sys.stderr.fileno()) |
113 | 114 |
|
114 | | -def _main_getreads(args): |
| 115 | +def _main_getreads(args, extra_args=None): |
115 | 116 | if args.no_counts: |
116 | 117 | args.countsfile = None |
117 | 118 | getreads.getreads( |
118 | 119 | path_input=args.input, |
119 | 120 | dir_out=args.outdir, |
120 | 121 | path_counts=args.countsfile, |
| 122 | + extra_args=extra_args, |
121 | 123 | threads_load=args.threads_load, |
122 | 124 | threads_proc=args.threads, |
123 | 125 | dry_run=args.dry_run) |
@@ -240,6 +242,30 @@ def _main_identity(args): |
240 | 242 | colmap=colmap, |
241 | 243 | dry_run=args.dry_run) |
242 | 244 |
|
| 245 | +def _main_msa(args): |
| 246 | + colmap = args_to_colmap(args) |
| 247 | + msa.msa( |
| 248 | + path_in=args.input, |
| 249 | + path_out=args.output, |
| 250 | + fmt_in=args.input_format, |
| 251 | + fmt_out=args.output_format, |
| 252 | + colmap=colmap, |
| 253 | + dry_run=args.dry_run) |
| 254 | + |
| 255 | +def _main_tree(args): |
| 256 | + colmap = args_to_colmap(args) |
| 257 | + tree.tree( |
| 258 | + paths_in=args.input, |
| 259 | + path_out=args.output, |
| 260 | + fmt_in=args.input_format, |
| 261 | + fmt_out=args.output_format, |
| 262 | + aligned=args.aligned, |
| 263 | + pattern=args.set_pattern, |
| 264 | + lists=args.set_list, |
| 265 | + colors=args.set_color, |
| 266 | + colmap=colmap, |
| 267 | + dry_run=args.dry_run) |
| 268 | + |
243 | 269 | def _setup_log(verbose, quiet, prefix): |
244 | 270 | # Handle warnings via logging |
245 | 271 | logging.captureWarnings(True) |
@@ -306,6 +332,14 @@ def __setup_arg_parser(): |
306 | 332 | help="Calculate pairwise identities", |
307 | 333 | description=rewrap(identity.__doc__), |
308 | 334 | formatter_class=argparse.RawDescriptionHelpFormatter) |
| 335 | + p_msa = subps.add_parser("msa", |
| 336 | + help="Create multiple sequence alignments", |
| 337 | + description=rewrap(msa.__doc__), |
| 338 | + formatter_class=argparse.RawDescriptionHelpFormatter) |
| 339 | + p_tree = subps.add_parser("tree", |
| 340 | + help="Create and format phylogenetic trees", |
| 341 | + description=rewrap(tree.__doc__), |
| 342 | + formatter_class=argparse.RawDescriptionHelpFormatter) |
309 | 343 | p_show = subps.add_parser("show", |
310 | 344 | help="show file contents", |
311 | 345 | description=rewrap(show.__doc__), |
@@ -519,6 +553,54 @@ def __setup_arg_parser(): |
519 | 553 | help="Name of column containing sequences (for tabular input/output)") |
520 | 554 | p_identity.set_defaults(func=_main_identity) |
521 | 555 |
|
| 556 | + __add_common_args(p_msa) |
| 557 | + p_msa.add_argument("input", |
| 558 | + help="input file path, or a literal '-' for standard input") |
| 559 | + p_msa.add_argument("output", |
| 560 | + help="output file path, or a literal '-' for standard output") |
| 561 | + p_msa.add_argument("--input-format", |
| 562 | + help="format of input " |
| 563 | + "(default: detect from input filename if possible)") |
| 564 | + p_msa.add_argument("--output-format", |
| 565 | + help="format of output " |
| 566 | + "(default: detect from output filename if possible)") |
| 567 | + p_msa.add_argument("--col-seq-id", |
| 568 | + help="Name of column containing sequence IDs (for tabular input/output)") |
| 569 | + p_msa.add_argument("--col-seq", |
| 570 | + help="Name of column containing sequences (for tabular input/output)") |
| 571 | + p_msa.add_argument("--col-seq-desc", |
| 572 | + help="Name of column containing sequence descriptions (for tabular input/output)") |
| 573 | + p_msa.set_defaults(func=_main_msa) |
| 574 | + |
| 575 | + __add_common_args(p_tree) |
| 576 | + p_tree.add_argument("input", nargs="+", |
| 577 | + help="input file path, or a literal '-' for standard input") |
| 578 | + p_tree.add_argument("output", |
| 579 | + help="output file path, or a literal '-' for standard output") |
| 580 | + p_tree.add_argument("--input-format", |
| 581 | + help="format of input " |
| 582 | + "(default: detect from input filename if possible)") |
| 583 | + p_tree.add_argument("--output-format", |
| 584 | + help="format of output " |
| 585 | + "(default: detect from output filename if possible)") |
| 586 | + p_tree.add_argument("--aligned", action=argparse.BooleanOptionalAction, |
| 587 | + help="Explicitly specify if input is aligned or not, for sequence input " |
| 588 | + "(default: guess from lengths)") |
| 589 | + p_tree.add_argument("--col-seq-id", |
| 590 | + help="Name of column containing sequence IDs (for tabular input)") |
| 591 | + p_tree.add_argument("--col-seq", |
| 592 | + help="Name of column containing sequences (for tabular input)") |
| 593 | + p_tree.add_argument("--set-pattern", "-P", |
| 594 | + help="regular expression to define set membership, with zero or one capture groups. " |
| 595 | + "If a capture group is given, only that text is used to define the set names.") |
| 596 | + p_tree.add_argument("--set-list", "-L", action="append", |
| 597 | + help="filename containing a list of sequence IDs for a set. " |
| 598 | + "This can be given multiple times for multiple set/filename pairs.") |
| 599 | + p_tree.add_argument("--set-color", "-C", action="append", |
| 600 | + help="setname=colorcode, like set1=#ff0000, to override automatic set colors. " |
| 601 | + "This can be given multiple times for multiple set/color pairs.") |
| 602 | + p_tree.set_defaults(func=_main_tree) |
| 603 | + |
522 | 604 | return parser |
523 | 605 |
|
524 | 606 | def __add_common_args(obj): |
|
0 commit comments