def main(db, infile, mdbdb, mdbcollection, esindex, user=None, password=None, host=None, port=None, recreateindex=False): if db == "Elasticsearch": dbc = DBconnection(db, esindex, host=host, port=port, recreateindex=recreateindex) read_and_index_faers_records(infile, dbc, es_index_reports) dbc.es.indices.refresh(index=esindex) elif db == "MongoDB": dbc = DBconnection(db, mdbdb, mdbcollection=mdbcollection, host=host, port=port, user=user, password=password, recreateindex=recreateindex) read_and_index_faers_records(infile, dbc.mdbi[mdbcollection], mongodb_index_reports) mongodb_indices(dbc.mdbi[mdbcollection]) if __name__ == '__main__': args = argparse.ArgumentParser( description='Index FDA FAERS dataset json files with Elasticsearch,' ' or MongoDB, downloaded from ' + SOURCEURL) args.add_argument('--infile', required=True, help='drug-event .json or .json.zip files or' 'folder that includes the .json.zip files') dbargs(args) args = args.parse_args() main(args.dbtype, args.infile, args.mdbdb, args.mdbcollection, args.esindex, args.user, args.password, args.host, args.port, args.recreateindex)
recreateindex=True): indxr = Indexer(dbtype, mdbdb, mdbcollection, esindex, host, port, recreateindex=recreateindex) indxr.parse_and_index_xmlfile(infile) pool.close() pool.join() pool.terminate() print("\nCompleted reading and indexing the ClinVar entries") if dbtype == 'Elasticsearch': indxr.es.indices.refresh(index=esindex) else: mongodb_indices(indxr.mcl) if __name__ == '__main__': args = argparse.ArgumentParser( description='Index ClinVar Variation Archive xml files,' ' with Elasticsearch or MongoDB') args.add_argument('infile', help='Input file name of ClinVar Variation Archive,' ' compressed or uncompressed xml file') dbargs(args, mdbcollection='clinvarvariation', esindex='clinvarvariation') args = args.parse_args() main(args.infile, args.dbtype, args.mdbdb, args.mdbcollection, args.esindex, args.host, args.port)