Permalink
Browse files

switch to py3, requests, utf8 encoding

  • Loading branch information...
kshefchek committed Oct 6, 2017
1 parent 802fd48 commit 36d62342a5202081621574a19cd5a4ec1495c10f
Showing with 18 additions and 22 deletions.
  1. +5 −5 Dockerfile
  2. +2 −2 scripts/configuration-generator.py
  3. +11 −15 scripts/golr-exporter.py
View
@@ -33,16 +33,16 @@ ADD owlsim-services/target/owlsim-services-3.0-SNAPSHOT.jar /data/
ADD scripts/golr-exporter.py /data/golr-exporter.py
ADD scripts/configuration-generator.py /data/configuration-generator.py
RUN apt-get -y update && apt-get install python-pip -y
RUN pip install pyyaml
RUN apt-get -y update && apt-get install python3-pip -y
RUN pip3 install pyyaml requests
RUN if [ $species = "all" ]; \
then \
cd /data && python golr-exporter.py; \
cd /data && python3 golr-exporter.py; \
else \
cd /data && python golr-exporter.py -t $species; \
cd /data && python3 golr-exporter.py -t $species; \
fi
RUN cd /data && python configuration-generator.py
RUN cd /data && python3 configuration-generator.py
CMD java $JAVA_OPTS -jar /data/owlsim-services-3.0-SNAPSHOT.jar server /data/configuration.yaml
@@ -5,7 +5,7 @@
# output an owlsim config file
import yaml
import urllib2
import requests
import fnmatch
import os
@@ -21,7 +21,7 @@ def main():
labelTsvs = [filename for filename in tsvs if filename.endswith('label.tsv')]
# Note: the yaml dump is buggy with the empty string key, so I'm just appending the raw string and add indentation manually
curies = urllib2.urlopen("https://raw.githubusercontent.com/monarch-initiative/dipper/master/dipper/curie_map.yaml").read()
curies = requests.get("https://raw.githubusercontent.com/monarch-initiative/dipper/master/dipper/curie_map.yaml").text
data = dict(
ontologyUris = ['http://purl.obolibrary.org/obo/upheno/monarch.owl'],
View
@@ -2,24 +2,22 @@
import os
import getopt
import urllib
import requests
import json
import csv
import shutil
import argparse
def uniqAndSort(output):
sorted_suffix = '.sorted2'
f = open(output, "r")
fs = open(output + sorted_suffix, "w")
f = open(output, "r", encoding='utf-8')
fs = open(output + sorted_suffix, "w+", encoding='utf-8')
fs.writelines(sorted(set(f.readlines())))
shutil.move(output + sorted_suffix, output)
def transformLabel(input, output):
with open(input) as data_file:
data = json.load(data_file)
def transformLabel(data, output):
with open(output, 'w') as tsvfile:
with open(output, 'w', encoding='utf-8') as tsvfile:
writer = csv.writer(tsvfile, delimiter='\t')
for entry in data:
id = entry["subject"]
@@ -28,11 +26,9 @@ def transformLabel(input, output):
uniqAndSort(output)
def transformAssociation(input, output):
with open(input) as data_file:
data = json.load(data_file)
def transformAssociation(data, output):
with open(output, 'w') as tsvfile:
with open(output, 'w', encoding='utf-8') as tsvfile:
writer = csv.writer(tsvfile, delimiter='\t')
for entry in data:
id = entry["subject"]
@@ -83,10 +79,10 @@ def main():
assocURL = biolink + "/mart/" + subj + "/" + obj + "/NCBITaxon:" + str(taxon_map.get(tax))
print("fetching " + assocURL)
urllib.urlretrieve (assocURL, assocFileJson)
transformAssociation(assocFileJson, assocFileTsv)
transformLabel(assocFileJson, labelFileTsv)
os.remove(assocFileJson)
req = requests.get(assocURL)
data = req.json()
transformAssociation(data, assocFileTsv)
transformLabel(data, labelFileTsv)
if __name__ == "__main__":
main()

0 comments on commit 36d6234

Please sign in to comment.