type=str, required=True) parser.add_argument('--fastrun', dest='fastrun', action='store_true') parser.add_argument('--no-fastrun', dest='fastrun', action='store_false') parser.add_argument('--entrez', help="Run only this one gene") parser.set_defaults(fastrun=True) args = parser.parse_args() log_dir = args.log_dir if args.log_dir else "./logs" run_id = datetime.now().strftime('%Y%m%d_%H:%M') __metadata__['run_id'] = run_id taxon = args.taxon fast_run = args.fastrun mcb = MicrobialChromosomeBot() # get metadata about sources mgd = MyGeneDownloader() metadata = mgd.get_metadata()['src_version'] if args.entrez: main(taxon, metadata, run_id=run_id, log_dir=log_dir, fast_run=fast_run, write=not args.dummy, entrez=args.entrez) sys.exit(0) if "microbe" in taxon: microbe_taxa = mcb.get_all_taxids() taxon = taxon.replace("microbe", ','.join(map(str, microbe_taxa))) for taxon1 in taxon.split(","): try: main(taxon1, metadata, run_id=run_id, log_dir=log_dir, fast_run=fast_run, write=not args.dummy) except Exception as e: # if one taxon fails, still try to run the others
parser = argparse.ArgumentParser(description='run wikidata gene bot') parser.add_argument('--log-dir', help='directory to store logs', type=str) parser.add_argument('--dummy', help='do not actually do write', action='store_true') parser.add_argument('--fastrun', dest='fastrun', action='store_true') parser.add_argument('--no-fastrun', dest='fastrun', action='store_false') parser.set_defaults(fastrun=True) args = parser.parse_args() log_dir = args.log_dir if args.log_dir else "./logs" run_id = datetime.now().strftime('%Y%m%d_%H:%M') __metadata__['run_id'] = run_id fast_run = args.fastrun # get metadata about sources mgd = MyGeneDownloader() metadata = dict() src = mgd.get_metadata()['src'] for source in src.keys(): metadata[source] = src[source]["version"] log_name = '{}-{}.log'.format(__metadata__['name'], run_id) if wdi_core.WDItemEngine.logger is not None: wdi_core.WDItemEngine.logger.handles = [] wdi_core.WDItemEngine.setup_logging(log_dir=log_dir, log_name=log_name, header=json.dumps(__metadata__), logger_name='orthologs') main(metadata, log_dir=log_dir, fast_run=fast_run, write=not args.dummy)