当前位置: 首页>>代码示例>>Python>>正文


Python py2neo.node函数代码示例

本文整理汇总了Python中py2neo.node函数的典型用法代码示例。如果您正苦于以下问题:Python node函数的具体用法?Python node怎么用?Python node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了node函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_nodo

    def create_nodo(self, **kwargs):
        d={"created":self.created}
        for item in kwargs.items():
            d.update({item[0]:item[1]})

        print "$$$$$$$$$$Diccionario para creacion de nodo$$$$$$$"
        print d
        if d["element_type"] == "person":
            person = graph_db.create(node(d))
            person[0].add_labels("User", "Person")
            m = "Node Created!"
            print m
        elif d["element_type"] == "individual":
            #individual = graph_db.create(node(**d))
            individual = graph_db.create(node(element_type=d["element_type"],
                                              id=d["id"],
                                              chromosome=str(d["chromosome"]),
                                              views=d["views"]))
            individual[0].add_labels("Individuals", "Individual")
            m = "Node Created!"
            print m
        elif d["element_type"] == "Collection":
            collection = graph_db.create(node(d))
            collection[0].add_labels("Collections", "Collection")
            m = "Node Created!"
            print m
        return m
开发者ID:jcromerohdz,项目名称:evoDrawing_gaming,代码行数:27,代码来源:userGraph.py

示例2: create_db

def create_db(usercol, refcol, start, end):
    '''
    try to generate relationships using a different example from the fundamentals page

    '''

    graph_db = neo4j.GraphDatabaseService("http://localhost:7474/db/data/")

    rowlist = []

    #nodes first
    for i in range(11, 100):
        rowlist.append (node(user=usercol[i]))
        rowlist.append (node(ref = refcol[i]))

    #relationships second
    for i in range(11, 100):
        rowlist.append(rel(start[i], "RECOMMENDED", end[i]))

    incubate = graph_db.create(*rowlist) #asterisk expands the list & might work better?

    #gives an error Incomplete Read if you try to do the whole thing at once, but
    #looks like you can do this in pieces in order to get the whole thing (?)

    #not sure if this is really necessary, should try +/- the format=pretty part
    neo4j._add_header('X-Stream', 'true;format=pretty')
开发者ID:szeitlin,项目名称:data-incubator,代码行数:26,代码来源:find_relationships.py

示例3: create_project_graph

def create_project_graph():
    """Creates a project Graph and stashes it in Neo4j.

    Returns a tuple of (users, projects, relationships), where each item is
    a list of the created data.

    """
    # Create some Users
    user_nodes = [node(name=t[0], username=t[1]) for t in random_users()]
    users = db.create(*user_nodes)
    for u in users:
        # ...and label them as such.
        u.add_labels("user")

    # Create some Projects.
    project_nodes = [node(name=s) for s in random_projects()]
    projects = db.create(*project_nodes)

    rels = []
    for p in projects:
        # ...and label them as such.
        p.add_labels("project")

        # Set up some relationships.
        # 1. Give the project a single Owner
        rels.append(rel((p, "OWNED_BY", random.choice(users))))

        # 2. Give the project a random number of contributors.
        for u in random.sample(users, random.randrange(3, 50)):
            rels.append(rel((u, "CONTRIBUTES_TO", p)))

    # Save the relationships
    rels = db.create(*rels)
    return (users, projects, rels)
开发者ID:bradmontgomery,项目名称:committed,代码行数:34,代码来源:db.py

示例4: create

 def create(cls, name, *emails): 
     person_node, _ = graph_db.create(node(name=name), 
         rel(cls._root, "PERSON", 0)) 
     for email in emails: 
         graph_db.create(node(email=email), rel(cls._root, "EMAIL", 0),
             rel(person_node, "EMAIL", 0)) 
     return Person(person_node) 
开发者ID:arvindram03,项目名称:amazon-dashboard,代码行数:7,代码来源:del.py

示例5: create_operons

    def create_operons(self):
        f = open(self.directory + 'Operons.txt', 'r')
        data = f.readlines()
        f.close()
        i = 0
        for line in data:
            if line[0] == '#':
                continue
            chunks = line.split('\t')

            ### testing
            if chunks[0] == '' or chunks[1] == '' or chunks[2] == 0:
                continue
            if chunks[3] == '':
                chunks[3] = 'unknown'

            operon, term, term_rel, org_rel = self.connection.\
                create(node({'name': chunks[0], 'start': int(chunks[1]),
                             'end': int(chunks[2]), 'strand': chunks[3],
                             'evidence': chunks[6], 'source': 'RegulonDB'}),
                       node({'text': chunks[0]}),
                       rel(0, 'HAS_NAME', 1),
                       rel(0, 'PART_OF', self.ecoli_node))
            operon.add_labels('Operon', 'BioEntity', 'DNA')
            i += 1
        logging.info('%d operons were created!' % i)
开发者ID:promodel,项目名称:BiomeDB_load_RegulonDB,代码行数:26,代码来源:regulondb.py

示例6: add_ind_to_col

def add_ind_to_col(request, username):
    global message
    if request.method == 'POST':

        if request.user.is_authenticated():

            u1 = User.objects.get(username=username)
            u = User.objects.get(id=u1.id)

            json_data = json.loads(request.body)

            col = json_data['userCollection']
            ind = json_data['id']

            c = Collection.objects.get(id=col)
            collection_name = c.name
            #print collection_name

            itc = Collection_Individual(collection=c,
                                        individual_id=ind,
                                        added_from=c,
                                        from_user=u,
                                        date_added=datetime.datetime.now())

            itc.save()

            #Agregar activity stream
            activity_stream = Activity_stream()
            usr = request.user.username
            activity_stream.activity("person", "save", "individual to collection", usr)

            #Agregar relacion entre individuo y coleccion en la red de grafos
            collection = GraphCollection()
            collection_result = collection.get_collection(collection_name)
            individual = Graph_Individual()
            individual_result = individual.get_node(ind)
            nodo1 = node(collection_result[0][0])
            nodo2 = node(individual_result[0][0])
            relation = Relations()
            relation.has(nodo1, nodo2)





            message = "Individual is now added to this collection!"
        else:
            message = "No username in evoart!"

        print "YYYYYYYYYYYYYYY"
        print col
        print ind
        print message

        data = ({'collection': col, 'individual': ind, 'message': message})
        datar = json.dumps(data)

    return HttpResponse(datar, content_type='application/json')
开发者ID:mariosky,项目名称:evo-drawings,代码行数:58,代码来源:views.py

示例7: create_update_promoters

    def create_update_promoters(self):
        f = open(self.directory + 'All Promoters.txt', 'r')
        data = f.readlines()
        f.close()
        created, updated = [0]*2

        for line in data:
            if line[0] == '#':
                continue
            regid, name, strand, tss, sigma, seq, evidence = line.split('\t')
            tss = int(tss)

            # skipping incomplete data
            if '' in [regid, name, strand, tss]:
                continue

            query = 'MATCH (ch:Chromosome {name: "%s"})<-[:PART_OF]-' \
                    '(p:Promoter {tss: %d})-[:PART_OF]->' \
                    '(o:Organism {name: "%s"}) ' \
                    'RETURN p' % (self.chro_name, tss,  self.ecoli_name)
            res = neo4j.CypherQuery(self.connection, query)
            res_nodes = res.execute()

            # creating promoter
            if not res_nodes:
                promoter, term, rel_org, rel_chr, rel_term = self.connection.create(
                    node({'name': name, 'start': tss,
                          'end': tss, 'strand': strand,
                          'tss': tss, 'seq': seq,
                          'evidence': evidence, 'Reg_id': regid,
                          'source': 'RegulonDB'}),
                    node({'text': name}),
                    rel(0, 'PART_OF', self.ecoli_node),
                    rel(0, 'PART_OF', self.chro_node),
                    rel(0, 'HAS_NAME', 1))
                promoter.add_labels('Promoter', 'Feature', 'BioEntity', 'DNA')
                term.add_labels('Term')
                created += 1
            else:
                # one promoter with the tss
                for record in res_nodes.data:
                    promoter = record.values[0]
                    promoter.update_properties({'seq': seq,
                                                'evidence': evidence,
                                                'Reg_id': regid})
                    update_source_property(promoter)
                    self.check_create_terms(promoter, name)
                    updated += 1

                # duplicates!
                if len(res_nodes.data) > 1:
                    logging.warning("There are %d nodes for a promoter with "
                                     "tss in the %d position! It was skipped!"
                                     % (len(res_nodes.data), tss))

        logging.info("%d promoters were updated!" % updated)
        logging.info("%d promoters were created!" % created)
开发者ID:promodel,项目名称:BiomeDB_load_RegulonDB,代码行数:57,代码来源:regulondb.py

示例8: test_can_use_return_values_as_references

def test_can_use_return_values_as_references(graph):
    batch = WriteBatch(graph)
    a = batch.create(node(name="Alice"))
    b = batch.create(node(name="Bob"))
    batch.create(rel(a, "KNOWS", b))
    results = batch.submit()
    ab = results[2]
    assert isinstance(ab, Relationship)
    assert ab.start_node["name"] == "Alice"
    assert ab.end_node["name"] == "Bob"
开发者ID:EricEllett,项目名称:py2neo,代码行数:10,代码来源:batch_test.py

示例9: test_can_create_multiple_nodes

 def test_can_create_multiple_nodes(self):
     self.batch.create({"name": "Alice"})
     self.batch.create(node({"name": "Bob"}))
     self.batch.create(node(name="Carol"))
     alice, bob, carol = self.batch.submit()
     assert isinstance(alice, Node)
     assert isinstance(bob, Node)
     assert isinstance(carol, Node)
     assert alice["name"] == "Alice"
     assert bob["name"] == "Bob"
     assert carol["name"] == "Carol"
开发者ID:EricEllett,项目名称:py2neo,代码行数:11,代码来源:batch_test.py

示例10: test_unique_constraint

def test_unique_constraint():
    graph_db = get_clean_database()
    label_1 = uuid4().hex
    borough, = graph_db.create(node(name="Taufkirchen"))
    borough.add_labels(label_1)
    graph_db.schema.add_unique_constraint(label_1, "name")
    constraints = graph_db.schema.get_unique_constraints(label_1)
    assert "name" in constraints
    borough_2, = graph_db.create(node(name="Taufkirchen"))
    with pytest.raises(ValueError):
        borough_2.add_labels(label_1)
    graph_db.delete(borough, borough_2)
开发者ID:EricEllett,项目名称:py2neo,代码行数:12,代码来源:schema_test.py

示例11: test_unique_constraint

def test_unique_constraint():
    graph_db = get_clean_database()
    if graph_db is None:
        return
    borough, = graph_db.create(node(name="Taufkirchen"))
    borough.add_labels("borough")
    graph_db.schema.add_unique_constraint("borough", "name")
    constraints = graph_db.schema.get_unique_constraints("borough")
    assert "name" in constraints
    borough_2, = graph_db.create(node(name="Taufkirchen"))
    with pytest.raises(ValueError):
        borough_2.add_labels("borough")
开发者ID:bambata,项目名称:py2neo,代码行数:12,代码来源:neo4j_schema.py

示例12: get_or_create_node

def get_or_create_node(graph_db, KEY, VALUE, FULL_NODE={}):
	query = neo4j.CypherQuery(graph_db, "MATCH (a) WHERE a.%s = '%s' RETURN a" % (KEY,VALUE) ) 
	results = query.execute()
	if len(results.data)==1:
		d, = results.data[0].values
		return d
	elif len(results.data)==0:
		if len(FULL_NODE)==0: a, = graph_db.create(node({KEY: VALUE}) )
		if len(FULL_NODE) > 0: a, = graph_db.create(node(FULL_NODE) )
		return a
	elif len(results.data) > 1:
		return False
	else:
		raise Exception
开发者ID:heyalexej,项目名称:charlotte,代码行数:14,代码来源:neo4j+recorder.py

示例13: test_create_function

 def test_create_function(self):
     self.batch.create(node(name="Alice"))
     self.batch.create(node(name="Bob"))
     self.batch.create(rel(0, "KNOWS", 1))
     alice, bob, ab = self.batch.submit()
     assert isinstance(alice, Node)
     assert alice["name"] == "Alice"
     assert isinstance(bob, Node)
     assert bob["name"] == "Bob"
     assert isinstance(ab, Relationship)
     assert ab.start_node == alice
     assert ab.type == "KNOWS"
     assert ab.end_node == bob
     self.recycling = [ab, alice, bob]
开发者ID:EricEllett,项目名称:py2neo,代码行数:14,代码来源:batch_test.py

示例14: titan_insert

def titan_insert():
    start = datetime.now()
    die_hard = graph_db.create(
    node(name="Bruce Willis"),
    node(name="John McClane"),
    node(name="Alan Rickman"),
    node(name="Hans Gruber"),
    node(name="Nakatomi Plaza"),
    rel(0, "PLAYS", 1),
    rel(2, "PLAYS", 3),
    rel(1, "VISITS", 4),
    rel(3, "STEALS_FROM", 4),
    rel(1, "KILLS", 3),
    )
    stop = datetime.now()
    return stop - start
开发者ID:dominika101303,项目名称:AnDIP,代码行数:16,代码来源:neoStressTests.py

示例15: createNodeImageFlickr

 def createNodeImageFlickr(self, idf, title, url, datetaken, tags):
     #query_string = "Create (f:Image {name: 'flickr"+idf+"', idf:"+idf+", title:'"+title+"', url:'"+url+"', datetaken:'"+datetaken+"', tags:'"+tags+"'})"
     #query = neo4j.CypherQuery(self.graph_db,query_string)
     #query.execute()
     ndo, = self.graph_db.create(node({"idf":idf,"title":title,"url":url,"datetaken":datetaken,"tags":tags}))
     ndo.add_labels("Image")
     return ndo
开发者ID:silkend,项目名称:tfmRecomSystem,代码行数:7,代码来源:conexion.py


注:本文中的py2neo.node函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。