Coverage for /home/deng/Projects/metatree_drawer/metatreedrawer/treeprofiler/treeprofiler.py: 0%
40 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-07 10:33 +0200
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-07 10:33 +0200
1#!/usr/bin/env python
3import sys
4import argparse as ap
6from treeprofiler import tree_annotate
7from treeprofiler import tree_plot
10__author__ = 'DENG Ziqi'
11__license__ = "GPL v3"
12__email__ = 'dengziqi1234@gmail.com'
13__version__ = '1.1.0'
14__date__ = '14-07-2023'
15__description__ = ('A program for profiling metadata on target '
16 'tree and conduct summary analysis')
18def populate_main_args(main_args_p):
19 """
20 Parse the input parameters
21 """
23 # input parameters group
24 group = main_args_p.add_argument_group(title='SOURCE TREE INPUT',
25 description="Source tree input parameters")
26 group.add_argument('-t', '--tree',
27 type=str,
28 required=True,
29 help="Input tree, .nw file, customized tree input")
30 group.add_argument('--annotated-tree',
31 default=False,
32 action='store_true',
33 help="(deprecated) input tree already annotated by treeprofiler if you want to skip the annotate part.")
34 group.add_argument('--internal',
35 default="support",
36 choices=["name", "support"],
37 type=str,
38 required=False,
39 help="How to interpret the newick values of internal nodes. [default: name]")
40 group.add_argument('--input-type',
41 type=str,
42 default="auto",
43 choices=["auto", "newick", "ete"],
44 help="Specify input tree format. [newick, ete]. [default: ete]")
45 group.add_argument('--prop2type',
46 type=str,
47 help="config tsv file where determine the datatype of target properties, if your input tree type is .ete, it's note necessary")
48 group.add_argument('--resolve-polytomy',
49 default=False,
50 action='store_true',
51 required=False,
52 help="Preprocess tree by changing polytomies into series of dicotomies.")
53 group = main_args_p.add_argument_group(title='Pruning parameters',
54 description="Auto pruning parameters")
55 group.add_argument('--rank-limit',
56 type=str,
57 help="TAXONOMIC_LEVEL prune annotate tree by rank limit")
58 group.add_argument('--pruned-by',
59 type=str,
60 action='append',
61 help='target tree pruned by customized conditions, such as --pruned_by "name contains FALPE"')
63def main():
64 desc = (f'treeprofiler.py (ver. {__version__} of {__date__}).'
65 f'{__description__} Authors: {__author__} ({__email__})')
66 main_args_p = ap.ArgumentParser(description=desc,
67 formatter_class=ap.RawTextHelpFormatter,
68 add_help=False)
70 populate_main_args(main_args_p)
72 parser = ap.ArgumentParser(description="this is tree profiler ",
73 formatter_class=ap.RawDescriptionHelpFormatter)
74 subparser = parser.add_subparsers(title="AVAILABLE PROGRAMS")
76 ## - ANNOTATE -
77 annotate_args_p = subparser.add_parser('annotate', parents=[main_args_p],
78 description='annotate tree')
79 tree_annotate.populate_annotate_args(annotate_args_p)
80 annotate_args_p.set_defaults(func=tree_annotate.run)
82 ## - PLOT -
83 plot_args_p = subparser.add_parser('plot', parents=[main_args_p],
84 description='annotate plot')
85 tree_plot.poplulate_plot_args(plot_args_p)
86 plot_args_p.set_defaults(func=tree_plot.run)
88 ## - RUN -
89 if len(sys.argv[1:]) < 1:
90 print(parser.print_usage())
91 return
93 args = parser.parse_args(sys.argv[1:])
94 args.func(args)
96if __name__ == '__main__':
97 main()