コード例 #1
0
async def get_docs_results(matchengine: MatchEngine, needed_clinical,
                           needed_extended):
    """
    Matching criteria for clinical and extended_attributes values can be set/extended in config.json
    :param matchengine:
    :param needed_clinical:
    :param needed_extended:
    :return:
    """
    clinical_projection = matchengine.match_criteria_transform.projections[
        "clinical"]
    clinical_query = MongoQuery({"_id": {"$in": list(needed_clinical)}})
    db_calls = list()
    db_calls.append(
        perform_db_call(matchengine, "clinical", clinical_query,
                        clinical_projection))
    for extended_collection, extended_ids in needed_extended.items():
        genomic_query = MongoQuery({"_id": {"$in": list(extended_ids)}})
        projection = matchengine.match_criteria_transform.projections[
            extended_collection]
        db_calls.append(
            perform_db_call(matchengine, extended_collection, genomic_query,
                            projection))

    results = await asyncio.gather(*db_calls)
    return results
コード例 #2
0
async def get_matches_to_disable(matchengine: MatchEngine,
                                 new_matches_hashes: list, protocol_no: str,
                                 sample_id: str) -> list:
    """
    Get matches to disable by looking for existing, enabled matches whose
    hashes are not present in newly generated matches during current run.

    Done for every sample_id

    :param matchengine:
    :param new_matches_hashes:
    :param protocol_no:
    :param sample_id:
    :return:
    """
    query = {
        matchengine.match_criteria_transform.match_trial_link_id: protocol_no,
        'sample_id': sample_id,
        'is_disabled': False,
        'hash': {
            '$nin': new_matches_hashes
        }
    }
    matches_to_disable_query = MongoQuery(query)
    projection = {"hash": 1, "is_disabled": 1}
    matches = await asyncio.gather(
        perform_db_call(matchengine, matchengine.trial_match_collection,
                        matches_to_disable_query, projection))
    return matches[0]
コード例 #3
0
ファイル: query.py プロジェクト: zackzwiesler0/matchengine-V2
async def get_docs_results(matchengine: MatchEngine, needed_clinical,
                           needed_genomic):
    """
    Matching criteria for clinical and genomic values can be set/extended in config.json
    :param matchengine:
    :param needed_clinical:
    :param needed_genomic:
    :return:
    """
    genomic_projection = matchengine.match_criteria_transform.genomic_projection
    clinical_projection = matchengine.match_criteria_transform.clinical_projection
    clinical_query = MongoQuery({"_id": {"$in": list(needed_clinical)}})
    genomic_query = MongoQuery({"_id": {"$in": list(needed_genomic)}})
    results = await asyncio.gather(
        perform_db_call(matchengine, "clinical", clinical_query,
                        clinical_projection),
        perform_db_call(matchengine, "genomic", genomic_query,
                        genomic_projection))
    return results
コード例 #4
0
async def get_existing_matches(matchengine: MatchEngine, new_matches_hashes: list) -> list:
    matches_to_not_change_query = MongoQuery({'hash': {'$in': new_matches_hashes}})
    projection = {"hash": 1, "is_disabled": 1}
    matches = await asyncio.gather(
        perform_db_call(matchengine,
                        matchengine.trial_match_collection,
                        matches_to_not_change_query,
                        projection)
    )
    return matches[0]
コード例 #5
0
async def get_matches_to_disable(matchengine: MatchEngine,
                                 new_matches_hashes: list,
                                 protocol_no: str,
                                 sample_id: str) -> list:
    matches_to_disable_query = MongoQuery({'protocol_no': protocol_no,
                                           'sample_id': sample_id,
                                           'is_disabled': False,
                                           'hash': {'$nin': new_matches_hashes}})
    projection = {"hash": 1, "is_disabled": 1}
    matches = await asyncio.gather(
        perform_db_call(matchengine,
                        matchengine.trial_match_collection,
                        matches_to_disable_query,
                        projection)
    )
    return matches[0]
コード例 #6
0
async def get_existing_matches(matchengine: MatchEngine,
                               new_matches_hashes: list) -> list:
    """
    Get matches in db which have the same hashes as newly found matches.
    :param matchengine:
    :param new_matches_hashes:
    :return:
    """
    matches_to_not_change_query = MongoQuery(
        {'hash': {
            '$in': new_matches_hashes
        }})
    projection = {"hash": 1, "is_disabled": 1}
    matches = await asyncio.gather(
        perform_db_call(matchengine, matchengine.trial_match_collection,
                        matches_to_not_change_query, projection))
    return matches[0]