Created
September 21, 2015 16:27
-
-
Save mtholder/ddae56851edd81180767 to your computer and use it in GitHub Desktop.
pull study info from OTI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env | |
| import sys | |
| ''' | |
| python gen-curl-oti.py template.txt studies.txt | |
| where studies.txt is the list of studies used in synthesis. | |
| and template is a cURL call with XYZ inplace of the study id (and no other XYZ) | |
| cURL | |
| ''' | |
| if False: | |
| template = open(sys.argv[1], 'rU').read().strip() | |
| else: | |
| # when I ran this, template contained: | |
| template = '''curl 'https://api.opentreeoflife.org/oti/v1/singlePropertySearchForStudies' -H 'Origin: https://tree.opentreeoflife.org' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: */*' -H 'Referer: https://tree.opentreeoflife.org/opentree/argus/ottol@158484/Pan-paniscus' -H 'Connection: keep-alive' --data 'property=ot%3AstudyId&value=XYZ&verbose=true' --compressed''' | |
| ts = template.split('XYZ') | |
| assert len(ts) == 2 | |
| study_list = [i.strip() for i in open(sys.argv[2], 'rU').readlines() if i.strip()] | |
| for s in study_list: | |
| ns = s.join(ts) | |
| print ns, '>', s + '.out' |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
redirect stdout to
run.shand thenbash run.shin a clean directory.