Skip to content

Commit

Permalink
Merge 8c36230 into 802fd48
Browse files Browse the repository at this point in the history
  • Loading branch information
kshefchek committed Oct 6, 2017
2 parents 802fd48 + 8c36230 commit a54d8c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ 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

Expand Down
24 changes: 10 additions & 14 deletions scripts/golr-exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import os
import getopt
import urllib
import requests
import json
import csv
import shutil
Expand All @@ -11,15 +11,13 @@
def uniqAndSort(output):
sorted_suffix = '.sorted2'
f = open(output, "r")
fs = open(output + sorted_suffix, "w")
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"]
Expand All @@ -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"]
Expand Down Expand Up @@ -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 a54d8c7

Please sign in to comment.