Example #1
0
    def search_for_summary(self, form):
        """
        Searches references with form object,
        populates has_* exists attributes for reference
        summary
        """
        references = self.reference_dao.search(
            accids=form.accids.data,
            primeAuthor=form.primeAuthor.data,
            authors=form.authors.data,
            journal=form.journal.data,
            title=form.title.data,
            volume=form.volume.data,
            year=form.year.data,
            marker_id=form.marker_id.data,
            allele_id=form.allele_id.data,
            limit=form.reference_limit.data
        )
        

        # load any exists attributes for associated data links
        batchLoadAttributeExists(references, ['all_markers', 
                                          'expression_assays', 
                                          'gxdindex_records',
                                          'explicit_alleles',
                                          'antibodies',
                                          'probes',
                                          'specimens',
                                          'gxd_images',
                                          'mapping_experiments'])


        return references
Example #2
0
def buildDagTrees(adstructures, batchloadOn=True):
    """
    Builds a list of DAG tree views.
    one for every path of every dag node passed in
    (However, there should only ever be one path for an AD term)
    """
    dagtrees = []
    for adstructure in adstructures:
        root = TreeNodeForAD(adstructure)
        dagtree = {"name": 'Anatomical Dictionary',
                   "root":root}
        dagtrees.append(dagtree)
        
        # track all the found dag nodes for batch loading 
        # vocterms later on
        foundNodes = set()
        
        # get immediate children
        # batch load nodes of each fetched edge
        loadFirstChildren(root, foundNodes)
            
        # recurse parents
        stack = [dagtree]
        while stack:
            dtree = stack.pop()
            tree_node = dtree['root']
            
            # if node is first parent
            if len(tree_node.children) == 1 and \
                adstructure._structure_key in [t._term_key for t in tree_node.children]:
                original = tree_node.children[0]
                # load siblings for the original node
                loadSiblings(original, tree_node, foundNodes)
            
            if tree_node.dagnode.parent:
                        
                parent_node = tree_node.dagnode.parent
                
                ptree_node = TreeNodeForAD(parent_node)
                
                # move root down a notch
                tree_node.parent = ptree_node
                ptree_node.children.append(tree_node)
                dtree['root'] = ptree_node
                stack.append(dtree)
        
        # batch load all the term objects for every found node
        if batchloadOn:
            batchLoadAttributeExists(list(foundNodes), ["children"])
            
    # sort all term children
    for tree in dagtrees:
        tree['root'].sort()
    
    return dagtrees
Example #3
0
def buildDagTrees(adstructures, batchloadOn=True):
    """
    Builds a list of DAG tree views.
    one for every path of every dag node passed in
    (However, there should only ever be one path for an AD term)
    """
    dagtrees = []
    for adstructure in adstructures:
        root = TreeNodeForAD(adstructure)
        dagtree = {"name": 'Anatomical Dictionary', "root": root}
        dagtrees.append(dagtree)

        # track all the found dag nodes for batch loading
        # vocterms later on
        foundNodes = set()

        # get immediate children
        # batch load nodes of each fetched edge
        loadFirstChildren(root, foundNodes)

        # recurse parents
        stack = [dagtree]
        while stack:
            dtree = stack.pop()
            tree_node = dtree['root']

            # if node is first parent
            if len(tree_node.children) == 1 and \
                adstructure._structure_key in [t._term_key for t in tree_node.children]:
                original = tree_node.children[0]
                # load siblings for the original node
                loadSiblings(original, tree_node, foundNodes)

            if tree_node.dagnode.parent:

                parent_node = tree_node.dagnode.parent

                ptree_node = TreeNodeForAD(parent_node)

                # move root down a notch
                tree_node.parent = ptree_node
                ptree_node.children.append(tree_node)
                dtree['root'] = ptree_node
                stack.append(dtree)

        # batch load all the term objects for every found node
        if batchloadOn:
            batchLoadAttributeExists(list(foundNodes), ["children"])

    # sort all term children
    for tree in dagtrees:
        tree['root'].sort()

    return dagtrees
Example #4
0
def _prepMarker(marker):
    """
    Load any attributes a detail page might need
    """
    if marker:
        # add the 'has_' existence checks
        batchLoadAttributeExists([marker], [
            'all_references', 'expression_assays', 'gxdindex_records',
            'alleles', 'probes', 'antibodies', 'mapping_experiment_assocs',
            'sequences'
        ])
Example #5
0
def _prepMarker(marker):
    """
    Load any attributes a detail page might need
    """
    if marker:
        # add the 'has_' existence checks
        batchLoadAttributeExists([marker], ['all_references', 
                                        'expression_assays',
                                        'gxdindex_records',
                                        'alleles', 
                                        'probes', 
                                        'antibodies',
                                        'mapping_experiment_assocs',
                                        'sequences'])
Example #6
0
def renderAlleleDetail(allele):
    
    # gather other objects for this allele
    molecularimage = None
    if allele.molecularimageid:
        molecularimage = image_hunter.getImageByMGIID(allele.molecularimageid)
    
    # detect if allele has phenotype data
    hasPheno = allele_hunter.doesAlleleHavePheno(allele._allele_key)
    
    hasAssays = allele_hunter.doesAlleleHaveAssays(allele._allele_key)
    
    # load has_explicit_references, and has_assays existence properties for links
    batchLoadAttributeExists([allele], ['explicit_references'])

    return render_template('detail/allele_detail.html', 
                           allele = allele, 
                           molecularimage = molecularimage,
                           hasPheno = hasPheno,
                           hasAssays = hasAssays)
Example #7
0
def renderAlleleDetail(allele):

    # gather other objects for this allele
    molecularimage = None
    if allele.molecularimageid:
        molecularimage = image_hunter.getImageByMGIID(allele.molecularimageid)

    # detect if allele has phenotype data
    hasPheno = allele_hunter.doesAlleleHavePheno(allele._allele_key)

    hasAssays = allele_hunter.doesAlleleHaveAssays(allele._allele_key)

    # load has_explicit_references, and has_assays existence properties for links
    batchLoadAttributeExists([allele], ['explicit_references'])

    return render_template('detail/allele_detail.html',
                           allele=allele,
                           molecularimage=molecularimage,
                           hasPheno=hasPheno,
                           hasAssays=hasAssays)
Example #8
0
def buildChildNodes(vocTerm, 
                    ignoreObsoletes=True):
    """
    returns list of child nodes for given parent vocTerm
    """
    children = []
    # expand startNode one level down
    if vocTerm.dagnode:
        
        if vocTerm.dagnode.child_edges:
                        
            # pre-load needed relationships
            batchLoadAttribute(vocTerm.dagnode.child_edges, "child_node")
            batchLoadAttribute(vocTerm.dagnode.child_edges, "child_node.vocterm")
            childNodes = [edge.child_node for edge in vocTerm.dagnode.child_edges]
            batchLoadAttributeExists(childNodes, ["child_edges"])
                        
            childNodes.sort(key=lambda x: x.vocterm.term)
            
            for childNode in childNodes:
                childTerm = childNode.vocterm
                
                # skip if obsolete
                if ignoreObsoletes and childTerm.isobsolete:
                    continue
                
                children.append({
                    'id': childTerm.primaryid,
                    'label': childTerm.term
                })
                
                # check for future children expansion
                if (childNode.has_child_edges):
                    # set child node as expandable
                    children[-1]['ex'] = True
    

    return children