scout/adapter/mongo/variant_loader.py
def update_variant_rank(self, case_obj, variant_type='clinical', category='snv'):
        """Updates the manual rank for all variants in a case

        Add a variant rank based on the rank score
        Whenever variants are added or removed from a case we need to update the variant rank

        Args:
            case_obj(Case)
            variant_type(str)
        """
        # Get all variants sorted by rank score
        variants = self.variant_collection.find({
            'case_id': case_obj['_id'],
            'category': category,
            'variant_type': variant_type,
        }).sort('rank_score', pymongo.DESCENDING)

        LOG.info("Updating variant_rank for all variants")

        requests = []

        for index, var_obj in enumerate(variants):
            if len(requests) > 5000:
                try:
                    self.variant_collection.bulk_write(requests, ordered=False)
                    requests = []
                except BulkWriteError as err:
                    LOG.warning("Updating variant rank failed")
                    raise err

            operation = pymongo.UpdateOne(
                {'_id': var_obj['_id']},
                {
                    '$set': {
                        'variant_rank': index + 1,
                    }
                })
            requests.append(operation)

        #Update the final bulk
        try:
            self.variant_collection.bulk_write(requests, ordered=False)
        except BulkWriteError as err:
            LOG.warning("Updating variant rank failed")
            raise err

        LOG.info("Updating variant_rank done")
def update_variant_rank(self, case_obj, variant_type='clinical', category='snv'):
        # Get all variants sorted by rank score
        variants = self.variant_collection.find({
            'case_id': case_obj['_id'],
            'category': category,
            'variant_type': variant_type,
        }).sort('rank_score', pymongo.DESCENDING)

        LOG.info("Updating variant_rank for all variants")

        requests = []

        for index, var_obj in enumerate(variants):
            if len(requests) > 5000:
                try:
                    self.variant_collection.bulk_write(requests, ordered=False)
                    requests = []
                except BulkWriteError as err:
                    LOG.warning("Updating variant rank failed")
                    raise err

            operation = pymongo.UpdateOne(
                {'_id': var_obj['_id']},
                {
                    '$set': {
                        'variant_rank': index + 1,
                    }
                })
            requests.append(operation)

        #Update the final bulk
        try:
            self.variant_collection.bulk_write(requests, ordered=False)
        except BulkWriteError as err:
            LOG.warning("Updating variant rank failed")
            raise err

        LOG.info("Updating variant_rank done")
def update_variant_rank ( self , case_obj , variant_type = 'clinical' , category = 'snv' ) : # Get all variants sorted by rank score variants = self . variant_collection . find ( { 'case_id' : case_obj [ '_id' ] , 'category' : category , 'variant_type' : variant_type , } ) . sort ( 'rank_score' , pymongo . DESCENDING ) LOG . info ( "Updating variant_rank for all variants" ) requests = [ ] for index , var_obj in enumerate ( variants ) : if len ( requests ) > 5000 : try : self . variant_collection . bulk_write ( requests , ordered = False ) requests = [ ] except BulkWriteError as err : LOG . warning ( "Updating variant rank failed" ) raise err operation = pymongo . UpdateOne ( { '_id' : var_obj [ '_id' ] } , { '$set' : { 'variant_rank' : index + 1 , } } ) requests . append ( operation ) #Update the final bulk try : self . variant_collection . bulk_write ( requests , ordered = False ) except BulkWriteError as err : LOG . warning ( "Updating variant rank failed" ) raise err LOG . info ( "Updating variant_rank done" )
Updates the manual rank for all variants in a case

        Add a variant rank based on the rank score
        Whenever variants are added or removed from a case we need to update the variant rank

        Args:
            case_obj(Case)
            variant_type(str)
Updates the manual rank for all variants in a case