def load_mnps(): db = get_db() start_time = time.time() db.variants.ensure_index('has_mnp') print 'Done indexing.' while db.variants.find_and_modify({'has_mnp': True}, {'$unset': { 'has_mnp': '', 'mnps': '' }}): pass print 'Deleted MNP data.' with gzip.open(app.config['MNP_FILE']) as mnp_file: for mnp in get_mnp_data(mnp_file): variant = lookups.get_raw_variant(db, mnp['xpos'], mnp['ref'], mnp['alt'], True) db.variants.find_and_modify({'_id': variant['_id']}, { '$set': { 'has_mnp': True }, '$push': { 'mnps': mnp } }, w=0) db.variants.ensure_index('has_mnp') print 'Done loading MNP info. Took %s seconds' % int(time.time() - start_time)
def load_mnps(): db = get_db() start_time = time.time() db.variants.ensure_index('has_mnp') print 'Done indexing.' while db.variants.find_and_modify({'has_mnp' : True}, {'$unset': {'has_mnp': '', 'mnps': ''}}): pass print 'Deleted MNP data.' with gzip.open(app.config['MNP_FILE']) as mnp_file: for mnp in get_mnp_data(mnp_file): variant = lookups.get_raw_variant(db, mnp['xpos'], mnp['ref'], mnp['alt'], True) db.variants.find_and_modify({'_id': variant['_id']}, {'$set': {'has_mnp': True}, '$push': {'mnps': mnp}}, w=0) db.variants.ensure_index('has_mnp') print 'Done loading MNP info. Took %s seconds' % int(time.time() - start_time)
def load_mnps(): db = get_db() start_time = time.time() db.variants.ensure_index("has_mnp") print "Done indexing." while db.variants.find_and_modify({"has_mnp": True}, {"$unset": {"has_mnp": "", "mnps": ""}}): pass print "Deleted MNP data." with gzip.open(app.config["MNP_FILE"]) as mnp_file: for mnp in get_mnp_data(mnp_file): variant = lookups.get_raw_variant(db, mnp["xpos"], mnp["ref"], mnp["alt"], True) db.variants.find_and_modify( {"_id": variant["_id"]}, {"$set": {"has_mnp": True}, "$push": {"mnps": mnp}}, w=0 ) db.variants.ensure_index("has_mnp") print "Done loading MNP info. Took %s seconds" % int(time.time() - start_time)