def __init__(self): db_url = 'http://{}:{}{}'.format( settings.NEO4J_DATABASES['default']['HOST'], settings.NEO4J_DATABASES['default']['PORT'], settings.NEO4J_DATABASES['default']['ENDPOINT']) config = Config(db_url, settings.NEO4J_DATABASES['default']['USER'], settings.NEO4J_DATABASES['default']['PASSWORD']) self.g = Graph(config)
''' Created on 20 August 2013 @author: Andrei ''' from bulbs.neo4jserver import Graph as Neo4jGraph from bulbs.neo4jserver import Config, NEO4J_URI, FulltextIndex import NodeRelTypes as DDT class Graph(Neo4jGraph): def __init__(self, config=None): super(Graph, self).__init__(config) #Annotations self.Person = self.build_proxy(DDT.Person) self.AnnotNode = self.build_proxy(DDT.AnnotNode) self.Organisation = self.build_proxy(DDT.Organisation) self.Handle = self.build_proxy(DDT.Handle) self.belongs_to = self.build_proxy(DDT.belongs_to) self.describes = self.build_proxy(DDT.describes) self.MailingList = self.build_proxy(DDT.MailingList) Graph.default_index = FulltextIndex config = Config(NEO4J_URI) config.vertex_index = "fulltext_vertex" config.edge_index = "fulltext_edge" DatabaseGraph = Graph(config)
id = Integer() name = String(nullable=False) region = String(nullable=False) security = Float() class IsConnectedTo(Relationship): label = "is_connected_to" conn = sqlite3.connect(os.path.expanduser("~/eve.db")) conn.row_factory = sqlite3.Row # populate graph from bulbs.neo4jserver import Graph, Config, NEO4J_URI g = Graph(Config(NEO4J_URI, "neo4j", "key")) g.add_proxy("system", System) g.add_proxy("is_connected_to", IsConnectedTo) systems = {} for item in g.V[1::]: systems[item.get("id")] = item def id_to_name(i): c = conn.cursor() c.execute("select solarSystemName from mapSolarSystems where solarSystemID=?", (i, )) return c.fetchone()[0] def distance_between(f, t): print f, t
from app import graph from bulbs.neo4jserver import Graph, Config, NEO4J_URI config = Config(NEO4J_URI, "james", "secret") graph.config = config DEBUG = False SECRET_KEY = 'top-secret!'
''' Created on 20 August 2013 @author: Andrei ''' from bulbs.neo4jserver import Graph as Neo4jGraph from bulbs.neo4jserver import Config, NEO4J_URI, FulltextIndex import NodeRelTypes as DDT class Graph(Neo4jGraph): def __init__(self, config=None): super(Graph, self).__init__(config) #Annotations self.Person=self.build_proxy(DDT.Person) self.AnnotNode=self.build_proxy(DDT.AnnotNode) self.Organisation=self.build_proxy(DDT.Organisation) self.Handle=self.build_proxy(DDT.Handle) self.belongs_to=self.build_proxy(DDT.belongs_to) self.describes=self.build_proxy(DDT.describes) self.MailingList=self.build_proxy(DDT.MailingList) Graph.default_index = FulltextIndex config = Config(NEO4J_URI) config.vertex_index = "fulltext_vertex" config.edge_index = "fulltext_edge" DatabaseGraph=Graph(config)
from settlers import Tile, Adjacency, TileEdge, TileVertex from constants import * from bulbs.neo4jserver import Graph, Config import os, random, itertools from collections import defaultdict, Iterable config = Config('http://192.168.1.14:7474/db/data/') g = Graph(config) g.add_proxy('tiles', Tile) g.add_proxy('touches', Adjacency) g.add_proxy('sides', TileEdge) g.add_proxy('corners', TileVertex) def configure_model(): vertex_dict = defaultdict(lambda: defaultdict(dict)) edge_dict = defaultdict(dict) def mk_ti(**kwargs): return g.tiles.create(**kwargs) def mk_to(src, dst): return g.touches.create(src, 'touches', dst) def mk_s(src, dst, **data): h, t = sorted([src, dst], key=lambda x: x._id if hasattr(x, '_id') else 0) if not t in edge_dict[h]: edge_dict[h][t] = g.sides.create(src, dst, **data) return edge_dict[h][t]
""" An interface declaration required by bulbs module """ from bulbs.neo4jserver import Graph as Neo4jGraph, Config import neo4j_object_class_declaration as ddl from bioflow.main_configs import neo4j_server from bioflow.utils.log_behavior import get_logger import os log = get_logger(__name__) if neo4j_server != 'http://localhost:7474': neo4j_server_local = Config(neo4j_server + '/db/data/') else: neo4j_server_local = None class Graph(Neo4jGraph): """ The interface with the neo4j graph database """ def __init__(self, config=neo4j_server_local): super(Graph, self).__init__(config) # Annotations self.Location = self.build_proxy(ddl.Location) self.AnnotNode = self.build_proxy(ddl.AnnotNode) self.Originating_Organism = self.build_proxy(ddl.Originating_Organism) self.Pathway = self.build_proxy(ddl.Pathway) self.PathwayStep = self.build_proxy(ddl.Pathway_Step) self.GOTerm = self.build_proxy(ddl.GOTerm)