scout/adapter/mongo/variant_loader.py
def update_variant_compounds(self, variant, variant_objs = None):
        """Update compounds for a variant.

        This will add all the necessary information of a variant on a compound object.

        Args:
            variant(scout.models.Variant)
            variant_objs(dict): A dictionary with _ids as keys and variant objs as values.

        Returns:
            compound_objs(list(dict)): A dictionary with updated compound objects.

        """
        compound_objs = []
        for compound in variant.get('compounds', []):
            not_loaded = True
            gene_objs = []
            # Check if the compound variant exists
            if variant_objs:
                variant_obj = variant_objs.get(compound['variant'])
            else:
                variant_obj = self.variant_collection.find_one({'_id': compound['variant']})
            if variant_obj:
                # If the variant exosts we try to collect as much info as possible
                not_loaded = False
                compound['rank_score'] = variant_obj['rank_score']
                for gene in variant_obj.get('genes', []):
                    gene_obj = {
                        'hgnc_id': gene['hgnc_id'],
                        'hgnc_symbol': gene.get('hgnc_symbol'),
                        'region_annotation': gene.get('region_annotation'),
                        'functional_annotation': gene.get('functional_annotation'),
                    }
                    gene_objs.append(gene_obj)
                    compound['genes'] = gene_objs

            compound['not_loaded'] = not_loaded
            compound_objs.append(compound)

        return compound_objs
def update_variant_compounds(self, variant, variant_objs = None):
        compound_objs = []
        for compound in variant.get('compounds', []):
            not_loaded = True
            gene_objs = []
            # Check if the compound variant exists
            if variant_objs:
                variant_obj = variant_objs.get(compound['variant'])
            else:
                variant_obj = self.variant_collection.find_one({'_id': compound['variant']})
            if variant_obj:
                # If the variant exosts we try to collect as much info as possible
                not_loaded = False
                compound['rank_score'] = variant_obj['rank_score']
                for gene in variant_obj.get('genes', []):
                    gene_obj = {
                        'hgnc_id': gene['hgnc_id'],
                        'hgnc_symbol': gene.get('hgnc_symbol'),
                        'region_annotation': gene.get('region_annotation'),
                        'functional_annotation': gene.get('functional_annotation'),
                    }
                    gene_objs.append(gene_obj)
                    compound['genes'] = gene_objs

            compound['not_loaded'] = not_loaded
            compound_objs.append(compound)

        return compound_objs
def update_variant_compounds ( self , variant , variant_objs = None ) : compound_objs = [ ] for compound in variant . get ( 'compounds' , [ ] ) : not_loaded = True gene_objs = [ ] # Check if the compound variant exists if variant_objs : variant_obj = variant_objs . get ( compound [ 'variant' ] ) else : variant_obj = self . variant_collection . find_one ( { '_id' : compound [ 'variant' ] } ) if variant_obj : # If the variant exosts we try to collect as much info as possible not_loaded = False compound [ 'rank_score' ] = variant_obj [ 'rank_score' ] for gene in variant_obj . get ( 'genes' , [ ] ) : gene_obj = { 'hgnc_id' : gene [ 'hgnc_id' ] , 'hgnc_symbol' : gene . get ( 'hgnc_symbol' ) , 'region_annotation' : gene . get ( 'region_annotation' ) , 'functional_annotation' : gene . get ( 'functional_annotation' ) , } gene_objs . append ( gene_obj ) compound [ 'genes' ] = gene_objs compound [ 'not_loaded' ] = not_loaded compound_objs . append ( compound ) return compound_objs
Update compounds for a variant.

        This will add all the necessary information of a variant on a compound object.

        Args:
            variant(scout.models.Variant)
            variant_objs(dict): A dictionary with _ids as keys and variant objs as values.

        Returns:
            compound_objs(list(dict)): A dictionary with updated compound objects.
Update compounds for a variant .