-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUniquePatternGenerator.py
43 lines (32 loc) · 1.11 KB
/
UniquePatternGenerator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
__author__ = 'cyberbeast'
from itertools import product, chain
from multiprocessing import Pool
from py2neo import neo4j, Node, Relationship, watch, authenticate, Graph
def logic_patterncounting(inp1):
count = 0
tx = graph.cypher.begin()
statement = "MERGE (:Pattern {ID:{WORD}})"
for word in product(*['ATCG'] * inp1):
tx.append(statement, {"WORD": ''.join(word)})
count += 1
tx.commit()
print(count)
if __name__ == '__main__':
watch("httpstream")
# watch("py2neo.cypher")
authenticate("192.168.6.74:7474", "neo4j", "trvlr")
graph = neo4j.Graph("http://192.168.6.64:7474/db/data/")
for record in graph.cypher.execute("MATCH (n:Info) RETURN n.LastDepth as LastDepth"):
depth = int(record.LastDepth)
depth += 1
print(depth)
UniquePatterns = []
GDS = {}
pool = Pool()
pool.map(logic_patterncounting, range(depth, depth + 2))
pool.close()
pool.join()
statement_state = "MATCH (n:Info) SET n.LastDepth={d_val}"
tx_new = graph.cypher.begin()
tx_new.append(statement_state, {"d_val": int(depth + 2)})
tx_new.commit()