Skip to content

Commit

Permalink
Merge 9e6f90f into 802fd48
Browse files Browse the repository at this point in the history
  • Loading branch information
kshefchek committed Oct 6, 2017
2 parents 802fd48 + 9e6f90f commit 73434fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 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 pip 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
18 changes: 7 additions & 11 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 @@ -15,9 +15,7 @@ def uniqAndSort(output):
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:
writer = csv.writer(tsvfile, delimiter='\t')
Expand All @@ -28,9 +26,7 @@ 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:
writer = csv.writer(tsvfile, delimiter='\t')
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 73434fd

Please sign in to comment.