How to use the gtdbtk.biolib_lite.logger.logger_setup function in gtdbtk

To help you get started, we’ve selected a few gtdbtk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Ecogenomics / GTDBTk / tests / test_cli.py View on Github external
self.options.min_perc_aa = 50
        self.options.rnd_seed = 42

        # classify options
        self.options.scratch_dir = None
        self.options.keep_ref_red = None
        self.options.pplacer_cpus = None

        # infer options
        self.options.prot_model = 'WAG'
        self.options.no_support = False
        self.options.no_gamma = True

        self.version = ' unittest'
        self.optionparser = OptionsParser(self.version)
        logger_setup(None, "gtdbtk.log", "GTDB-Tk", self.version, True)
        # self.generic_out_path = 'tests/data/results'
        self.generic_out_path = tempfile.mkdtemp(prefix='gtdbtk_tmp_')
github Ecogenomics / GTDBTk / gtdbtk / __main__.py View on Github external
if len(sys.argv) == 1:
        print_help()
        sys.exit(0)
    elif sys.argv[1] in {'-v', '--v', '-version', '--version'}:
        print("gtdbtk: version %s %s %s" % (__version__,
                                            __copyright__,
                                            __author__))
        sys.exit(0)
    elif sys.argv[1] in {'-h', '--h', '-help', '--help'}:
        print_help()
        sys.exit(0)
    else:
        args = parser.parse_args()

    # setup logger
    logger_setup(args.out_dir if hasattr(args, 'out_dir') else None,
                 "gtdbtk.log", "GTDB-Tk", __version__, False,
                 hasattr(args, 'debug') and args.debug)
    logger = logging.getLogger('timestamp')

    # -------------------------------------------------
    # do what we came here to do
    try:
        gt_parser = OptionsParser(__version__)
        if False:
            import cProfile

            cProfile.run('gt_parser.parseOptions(args)', 'prof')
        else:
            gt_parser.parse_options(args)
    except SystemExit:
        sys.stdout.write('\n')
github Ecogenomics / GTDBTk / scripts / rename_UBAs / prepare_gtdbtk_package.py View on Github external
# get and check options
    args = None
    if len(sys.argv) == 1 or sys.argv[1] == '-h' or sys.argv == '--help':
        print_help()
        sys.exit(0)
    else:
        args = parser.parse_args()

    try:
        logger_setup(args.output_dir,
                     'gtdbtk_toolset.log',
                     'GTDB Tk converter',
                     version(),
                     args.silent)
    except:
        logger_setup(None,
                     'gtdbtk_toolset.log',
                     'GTDB Tk converter',
                     __version__,
                     args.silent)

    # do what we came here to do
    try:
        parser = OptionsParser()
        if False:
            # import pstats
            # p = pstats.Stats('prof')
            # p.sort_stats('cumulative').print_stats(10)
            # p.sort_stats('time').print_stats(10)
            import cProfile

            cProfile.run('parser.parse_options(args)', 'prof')
github Ecogenomics / GTDBTk / scripts / rename_UBAs / prepare_gtdbtk_package.py View on Github external
description='Unroot tree.')
    unroot_tree_parser.add_argument('input_tree', help='')
    unroot_tree_parser.add_argument('output_tree', help='')
    unroot_tree_parser.add_argument(
        '--silent', help="suppress output", action='store_true')

    # get and check options
    args = None
    if len(sys.argv) == 1 or sys.argv[1] == '-h' or sys.argv == '--help':
        print_help()
        sys.exit(0)
    else:
        args = parser.parse_args()

    try:
        logger_setup(args.output_dir,
                     'gtdbtk_toolset.log',
                     'GTDB Tk converter',
                     version(),
                     args.silent)
    except:
        logger_setup(None,
                     'gtdbtk_toolset.log',
                     'GTDB Tk converter',
                     __version__,
                     args.silent)

    # do what we came here to do
    try:
        parser = OptionsParser()
        if False:
            # import pstats
github Ecogenomics / GTDBTk / scripts / gtdb_to_ncbi_majority_vote.py View on Github external
parser.add_argument('--output_file', required=True,
                        help='The output file to write the translated taxonomy.')
    parser.add_argument('--gtdbtk_prefix', required=False, default='gtdbtk',
                        help='The prefix of the GTDB-Tk output files specified in --gtdbtk_output_dir.')

    # Parse the arguments
    if len(sys.argv) == 1:
        print_help()
        sys.exit(0)
    elif sys.argv[1] in {'-h', '--h', '-help', '--help'}:
        print_help()
        sys.exit(0)
    else:
        args = parser.parse_args()

        logger_setup(args.out_dir if hasattr(args, 'out_dir') else None,
                     "gtdbtk.log", 'GTDB to NCBI majority vote', __version__, False,
                     hasattr(args, 'debug') and args.debug)
        logger = logging.getLogger('timestamp')

    try:
        p = Translate()
        p.run(args.gtdbtk_output_dir,
              args.ar122_metadata_file,
              args.bac120_metadata_file,
              args.output_file,
              args.gtdbtk_prefix)
        logger.info('Done.')
    except SystemExit:
        logger.error('Controlled exit resulting from early termination.')
        sys.exit(1)
    except KeyboardInterrupt:
github Ecogenomics / GTDBTk / gtdbtk / trim_msa.py View on Github external
help='maximum number of columns to retain per gene')
    parser.add_argument('--min_perc_aa', type=float, default=0.5,
                        help='filter genomes with an insufficient percentage of AA in the MSA')
    parser.add_argument('--min_consensus', type=float, default=0.25,
                        help='minimum percentage of the same amino acid required to retain column')
    parser.add_argument('--max_consensus', type=float, default=0.95,
                        help='maximum percentage of the same amino acid required to retain column')
    parser.add_argument('--min_perc_taxa', type=float, default=0.50,
                        help='minimum percentage of taxa required to retain column')
    parser.add_argument('--rnd_seed', type=int, default=None,
                        help='random seed to use for selecting columns')
    parser.add_argument('--out_dir', help='output directory')

    args = parser.parse_args()

    logger_setup(args.out_dir, "trim_msa.log", "trim_msa", __version__, False)

    try:
        p = TrimMSA(args.cols_per_gene,
                    args.min_perc_aa,
                    args.min_consensus,
                    args.max_consensus,
                    args.min_perc_taxa,
                    args.rnd_seed,
                    args.out_dir)
        p.run(args.msa, args.marker_list)
    except SystemExit:
        print("\nControlled exit resulting from an unrecoverable error or warning.")
    except:
        print("\nUnexpected error:", sys.exc_info()[0])
        raise