@sjcrh/proteinpaint-server 2.63.6 → 2.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/routes/genesetEnrichment.js +107 -0
- package/routes/hicdata.js +17 -16
- package/routes/{hicdata.genome.js → hicgenome.js} +22 -15
- package/routes/termdb.config.js +1 -1
- package/routes/termdb.singlecellSamples.js +23 -7
- package/src/app.js +899 -600
- package/src/serverconfig.js +1 -0
- package/utils/gsea.py +75 -0
package/src/serverconfig.js
CHANGED
|
@@ -55,6 +55,7 @@ if (!serverconfig.clustalo) serverconfig.clustalo = 'clustalo'
|
|
|
55
55
|
if (!serverconfig.Rscript) serverconfig.Rscript = 'Rscript'
|
|
56
56
|
if (!serverconfig.gfServer) serverconfig.gfServer = 'gfServer'
|
|
57
57
|
if (!serverconfig.gfClient) serverconfig.gfClient = 'gfClient'
|
|
58
|
+
if (!serverconfig.python) serverconfig.python = 'python3'
|
|
58
59
|
// NOTE: will set other cmd paths that require binpath after it's filled-in below
|
|
59
60
|
|
|
60
61
|
/******************
|
package/utils/gsea.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# 'cat ~/sjpp/test.txt | python gsea.py
|
|
2
|
+
|
|
3
|
+
import blitzgsea as blitz
|
|
4
|
+
import json
|
|
5
|
+
import time
|
|
6
|
+
import sys
|
|
7
|
+
import sqlite3
|
|
8
|
+
import pandas as pd
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def extract_symbols(x):
|
|
12
|
+
return x['symbol']
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
# Try to read a single character from stdin without blocking
|
|
16
|
+
if sys.stdin.read(1):
|
|
17
|
+
# Read from stdin
|
|
18
|
+
for line in sys.stdin:
|
|
19
|
+
# Process each line
|
|
20
|
+
json_object = json.loads(line)
|
|
21
|
+
db=json_object['db']
|
|
22
|
+
table_name=json_object['gene_set_group']
|
|
23
|
+
genes=json_object['genes']
|
|
24
|
+
fold_change=json_object['fold_change']
|
|
25
|
+
df = {'Genes': genes, 'fold_change': fold_change}
|
|
26
|
+
|
|
27
|
+
# Connect to the SQLite database
|
|
28
|
+
conn = sqlite3.connect(db)
|
|
29
|
+
|
|
30
|
+
# Create a cursor object using the cursor() method
|
|
31
|
+
cursor = conn.cursor()
|
|
32
|
+
|
|
33
|
+
# SQL query to select all data from the table
|
|
34
|
+
query = f"select id from terms where parent_id='" + table_name + "'"
|
|
35
|
+
|
|
36
|
+
# Execute the SQL query
|
|
37
|
+
cursor.execute(query)
|
|
38
|
+
|
|
39
|
+
# Fetch all rows from the executed SQL query
|
|
40
|
+
rows = cursor.fetchall()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
start_loop_time = time.time()
|
|
44
|
+
msigdb_library={}
|
|
45
|
+
# Iterate over the rows and print them
|
|
46
|
+
for row in rows:
|
|
47
|
+
#print(row[0])
|
|
48
|
+
query2=f"select genes from term2genes where id='" + row[0] + "'"
|
|
49
|
+
cursor.execute(query2)
|
|
50
|
+
rows2 = cursor.fetchall()
|
|
51
|
+
row3=json.loads(rows2[0][0])
|
|
52
|
+
msigdb_library[row[0]] = list(map(extract_symbols,row3))
|
|
53
|
+
|
|
54
|
+
#print ("msigdb_library:",msigdb_library)
|
|
55
|
+
# Close the cursor and connection to the database
|
|
56
|
+
cursor.close()
|
|
57
|
+
conn.close()
|
|
58
|
+
stop_loop_time = time.time()
|
|
59
|
+
execution_time = stop_loop_time - start_loop_time
|
|
60
|
+
print(f"Execution time: {execution_time} seconds")
|
|
61
|
+
signature=pd.DataFrame(df)
|
|
62
|
+
|
|
63
|
+
# run enrichment analysis
|
|
64
|
+
start_gsea_time = time.time()
|
|
65
|
+
if __name__ == "__main__":
|
|
66
|
+
result = blitz.gsea(signature, msigdb_library).T
|
|
67
|
+
print ("result:",result.to_json())
|
|
68
|
+
stop_gsea_time = time.time()
|
|
69
|
+
gsea_time = stop_gsea_time - start_gsea_time
|
|
70
|
+
print (f"GSEA time: {gsea_time} seconds")
|
|
71
|
+
|
|
72
|
+
else:
|
|
73
|
+
pass
|
|
74
|
+
except (EOFError, IOError):
|
|
75
|
+
pass
|