scout/adapter/mongo/variant.py
def check_causatives(self, case_obj=None, institute_obj=None):
        """Check if there are any variants that are previously marked causative

            Loop through all variants that are marked 'causative' for an
            institute and check if any of the variants are present in the
            current case.

            Args:
                case_obj (dict): A Case object
                institute_obj (dict): check across the whole institute

            Returns:
                causatives(iterable(Variant))
        """
        institute_id = case_obj['owner'] if case_obj else institute_obj['_id']
        institute_causative_variant_ids = self.get_causatives(institute_id)
        if len(institute_causative_variant_ids) == 0:
            return []

        if case_obj:
            # exclude variants that are marked causative in "case_obj"
            case_causative_ids = set(case_obj.get('causatives', []))
            institute_causative_variant_ids = list(
                set(institute_causative_variant_ids).difference(case_causative_ids)
            )

        # convert from unique ids to general "variant_id"
        query = self.variant_collection.find(
            {'_id': {'$in': institute_causative_variant_ids}},
            {'variant_id': 1}
        )
        positional_variant_ids = [item['variant_id'] for item in query]

        filters = {'variant_id': {'$in': positional_variant_ids}}
        if case_obj:
            filters['case_id'] = case_obj['_id']
        else:
            filters['institute'] = institute_obj['_id']
        return self.variant_collection.find(filters)
def check_causatives(self, case_obj=None, institute_obj=None):
        institute_id = case_obj['owner'] if case_obj else institute_obj['_id']
        institute_causative_variant_ids = self.get_causatives(institute_id)
        if len(institute_causative_variant_ids) == 0:
            return []

        if case_obj:
            # exclude variants that are marked causative in "case_obj"
            case_causative_ids = set(case_obj.get('causatives', []))
            institute_causative_variant_ids = list(
                set(institute_causative_variant_ids).difference(case_causative_ids)
            )

        # convert from unique ids to general "variant_id"
        query = self.variant_collection.find(
            {'_id': {'$in': institute_causative_variant_ids}},
            {'variant_id': 1}
        )
        positional_variant_ids = [item['variant_id'] for item in query]

        filters = {'variant_id': {'$in': positional_variant_ids}}
        if case_obj:
            filters['case_id'] = case_obj['_id']
        else:
            filters['institute'] = institute_obj['_id']
        return self.variant_collection.find(filters)
def check_causatives ( self , case_obj = None , institute_obj = None ) : institute_id = case_obj [ 'owner' ] if case_obj else institute_obj [ '_id' ] institute_causative_variant_ids = self . get_causatives ( institute_id ) if len ( institute_causative_variant_ids ) == 0 : return [ ] if case_obj : # exclude variants that are marked causative in "case_obj" case_causative_ids = set ( case_obj . get ( 'causatives' , [ ] ) ) institute_causative_variant_ids = list ( set ( institute_causative_variant_ids ) . difference ( case_causative_ids ) ) # convert from unique ids to general "variant_id" query = self . variant_collection . find ( { '_id' : { '$in' : institute_causative_variant_ids } } , { 'variant_id' : 1 } ) positional_variant_ids = [ item [ 'variant_id' ] for item in query ] filters = { 'variant_id' : { '$in' : positional_variant_ids } } if case_obj : filters [ 'case_id' ] = case_obj [ '_id' ] else : filters [ 'institute' ] = institute_obj [ '_id' ] return self . variant_collection . find ( filters )
Check if there are any variants that are previously marked causative

            Loop through all variants that are marked 'causative' for an
            institute and check if any of the variants are present in the
            current case.

            Args:
                case_obj (dict): A Case object
                institute_obj (dict): check across the whole institute

            Returns:
                causatives(iterable(Variant))
Check if there are any variants that are previously marked causative