Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Phylum
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Castillo
Phylum
Commits
faa34582
Commit
faa34582
authored
Nov 08, 2016
by
Castillo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ngrams api
parent
d3eb479b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
173 additions
and
1 deletion
+173
-1
SQL.py
bigindex/SQL.py
+2
-1
ngrams-api.py
bigindex/ngrams-api.py
+76
-0
postg_mesh.py
bigindex/postg_mesh.py
+94
-0
phylomain.js
static/phylomain.js
+1
-0
No files found.
bigindex/SQL.py
View file @
faa34582
...
...
@@ -32,7 +32,8 @@ class SQL:
# for item in chunk:
# print(item)
args_str
=
','
.
join
(
cursor
.
mogrify
(
"
%
s"
,
(
x
,
))
for
x
in
chunk
)
sql
=
"INSERT INTO publication (id, year,itemset) VALUES "
+
args_str
+
""
# sql = "INSERT INTO "+tablename+" (id, year,itemset) VALUES "+args_str+""
sql
=
"INSERT INTO "
+
tablename
+
" (id, label) VALUES "
+
args_str
+
""
# print(sql)
try
:
...
...
bigindex/ngrams-api.py
0 → 100644
View file @
faa34582
# pip install simplejson git+https://github.com/miguelgrinberg/Flask-Runner.git
# pip install biopython
# more: https://flask-runner.readthedocs.io/en/latest/
# sudo su pksm3
# export SPARK_HOME="/opt/spark2"
# export PATH=$SPARK_HOME/bin:$PATH
# source env/bin/activate
# python phylum_srv.py -t 0.0.0.0 -p 8080
from
flask
import
Flask
,
render_template
,
request
,
flash
,
jsonify
,
url_for
from
flask.ext.runner
import
Runner
#*#
import
simplejson
as
json
from
flask_wtf
import
Form
from
wtforms
import
StringField
,
TextField
,
IntegerField
,
DecimalField
,
validators
from
wtforms.validators
import
DataRequired
from
flask_wtf.csrf
import
CsrfProtect
csrf
=
CsrfProtect
()
import
datetime
import
pprint
app
=
Flask
(
__name__
,
static_url_path
=
'/static'
)
app
.
secret_key
=
's3cr3t'
csrf
.
init_app
(
app
)
runner
=
Runner
(
app
)
#*#
from
bigindex
import
LoadShit
import
urllib
I
=
{}
@
app
.
route
(
"/close"
,
methods
=
(
"GET"
,))
def
close_contexts
():
for
i
in
I
:
I
[
i
]
.
sc
.
stop
()
return
json
.
dumps
(
[
"connections"
,
"closed"
]
)
for
i
in
I
:
del
I
[
i
]
# p_["scontext"] (value="blabla")
# p_["elemfrequency"] (value="1")
# p_["from_"] (value="1983")
# p_["to_"] (value="1984")
# p_["minfpgsupp"] (value="0.0001")
# p_["minfsetsize"] (value="4")
# p_["minsetdistance"] (value="0.2")
# p_["mram"] (value="0.2")
# p_["ncores"] (value="0.2")
@
csrf
.
exempt
@
app
.
route
(
"/ngrams"
,
methods
=
(
"GET"
,
"POST"
,))
def
test_post
():
pprint
.
pprint
(
request
)
if
request
.
method
==
"POST"
:
p_
=
{}
print
(
"did a POST"
)
for
i
in
request
.
form
:
print
(
i
,
":"
,
request
.
form
[
i
]
)
p_
[
i
]
=
request
.
form
[
i
]
rr
=
{
"hola"
:
"mundo"
}
return
json
.
dumps
(
rr
)
# return json.dumps( ["post","worked","mofos"] )
return
json
.
dumps
(
[
"regular"
,
"get"
]
)
# return jsonify( data=["normal","return"] )
runner
.
run
()
bigindex/postg_mesh.py
0 → 100644
View file @
faa34582
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
sys
import
glob
import
json
import
pprint
from
datetime
import
datetime
import
time
import
re
import
json
INPUT
=
"mesh.json"
# OUTPUT = "folder"
if
len
(
sys
.
argv
)
>
1
and
sys
.
argv
[
1
]
!=
None
:
INPUT
=
sys
.
argv
[
1
]
# if len(sys.argv)>2 and sys.argv[2]!=None: OUTPUT = sys.argv[2]
import
psycopg2
conn
=
psycopg2
.
connect
(
"dbname=meshfiltrd user=pksm3"
)
c
=
conn
.
cursor
()
sql_commands
=
[
"DROP TABLE IF EXISTS june2016;"
,
"CREATE TABLE june2016( id INTEGER PRIMARY KEY , label VARCHAR(255) )"
,
]
for
command
in
sql_commands
:
c
.
execute
(
command
)
conn
.
commit
()
f
=
open
(
INPUT
,
"r"
)
K
=
json
.
load
(
f
)
f
.
close
()
DATA
=
[]
DD
=
{}
C
=
1
for
ID
in
K
:
# if C==100:
# break
if
ID
not
in
DD
:
DD
[
ID
]
=
True
DATA
.
append
(
(
ID
,
K
[
ID
],)
)
C
+=
1
print
(
""
)
print
(
"inserting..."
,
len
(
DATA
))
from
SQL
import
SQL
execc
=
SQL
()
execc
.
InsertInto_modular
(
connection
=
conn
,
cursor
=
c
,
tablename
=
"june2016"
,
data
=
DATA
)
print
(
"creating indexes..."
)
sql_indexes
=
[
"CREATE INDEX label_idx ON june2016 (label);"
]
for
command
in
sql_indexes
:
c
.
execute
(
command
)
conn
.
commit
()
conn
.
close
()
# # # # CREATE INDEX # #
# # import psycopg2
# # conn = psycopg2.connect("dbname=pubmed user=pksm3")
# # c = conn.cursor()
# # print("creating indexes...")
# # sql_indexes = [
# # "CREATE INDEX year_idx ON publication (year);"
# # ]
# # for command in sql_indexes:
# # c.execute( command )
# # conn.commit()
# # conn.close()
\ No newline at end of file
static/phylomain.js
View file @
faa34582
...
...
@@ -262,6 +262,7 @@ function pubmed_scan( query ) {
retmax
:
0
},
success
:
function
(
data
)
{
console
.
log
(
data
.
esearchresult
)
var
count
=
parseInt
(
data
.
esearchresult
.
count
)
console
.
log
(
"AAAAH "
+
count
)
$
(
"#pubmed_scan-results"
).
html
(
count
+
" hits."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment