def add_cypher_relations(cypher,lookup): '''add_cypher_relations will look up relations for connected nodes returned from an object. This is akin to adding one layer of the tree to the graph (and the function could be modified to add more) :param cypher: the cypher object, a dictionary with nodes and links as keys, each a list of them. ''' node_types = list(lookup) for node_type in node_types: for term in lookup[node_type]: if node_type == "condition": new_cypher,lookup = Condition.cypher(term,lookup=lookup,return_lookup=True) elif node_type == "task": new_cypher,lookup = Task.cypher(term,lookup=lookup,return_lookup=True) elif node_type == "contrast": new_cypher,lookup = Contrast.cypher(term,lookup=lookup,return_lookup=True) elif node_type == "concept": new_cypher,lookup = Concept.cypher(term,lookup=lookup,return_lookup=True) cypher = merge_cypher(cypher,new_cypher) return cypher
from cognitive.apps.atlas.query import Task, Concept, Condition, Contrast from cognitive.apps.atlas.utils import merge_cypher from django.http import JsonResponse, HttpResponse from django.template import loader, Context from django.shortcuts import render import csv Task = Task() Concept = Concept() Condition = Condition() Contrast = Contrast() # Return full graph visualizations def task_graph(request, uid): nodes = Task.graph(uid) context = {"graph": nodes} return render(request, "graph/task.html", context) def concept_graph(request, uid): nodes = Concept.graph(uid) context = {"graph": nodes} return render(request, "graph/task.html", context) def explore_graph(request): context = {} return render(request, "graph/explore.html", context)
def all_concepts(request): '''all_concepts returns page with list of all concepts''' concepts = Concept.all(order_by="name") return all_nodes(request, concepts, "concepts")
def update_concept(request, uid): if request.method == "POST": definition = request.POST.get('definition', '') updates = add_update("definition", definition) Concept.update(uid, updates=updates) return view_concept(request, uid)
def concepts_by_letter(request, letter): '''concepts_by_letter returns concept view for a certain letter''' concepts = Concept.filter(filters=[("name", "starts_with", letter)]) concepts_count = len(concepts) return nodes_by_letter(request, letter, concepts, concepts_count, "concepts")
from cognitive.apps.atlas.query import Concept, Task, Disorder, \ Contrast, Battery, Theory, Condition, search from cognitive.apps.atlas.utils import clean_html, update_lookup, add_update from django.http import JsonResponse, HttpResponse from cognitive.settings import DOMAIN from django.shortcuts import render from django.template import loader import pickle import json import numpy Concept = Concept() Task = Task() Disorder = Disorder() Contrast = Contrast() Battery = Battery() Theory = Theory() Condition = Condition() # Needed on all pages counts = { "disorders": Disorder.count(), "tasks": Task.count(), "contrasts": Contrast.count(), "concepts": Concept.count(), "batteries": Battery.count(), "theories": Theory.count() } # VIEWS FOR ALL NODES #############################################################
from cognitive.apps.atlas.query import Concept, Task, Disorder, Theory, Battery Concept = Concept() Task = Task() Disorder = Disorder() Theory = Theory() Battery = Battery() # Needed on all pages counts = {"disorders":Disorder.count(), "tasks":Task.count(), "concepts":Concept.count(), "theories":Theory.count(), "batteries":Battery.count()} def counts_processor(request): return {'counts': counts}
def concept_json(request,uid): nodes = Concept.graph(uid) return JsonResponse(nodes)
def concept_graph(request,uid): nodes = Concept.graph(uid) context = {"graph":nodes} return render(request,"graph/task.html",context)