23
23
24
24
25
25
26
- API_URL = "http ://api.metagenomics.anl.gov /1"
26
+ API_URL = "https ://api.mg-rast.org /1"
27
27
28
- SKIP = [ "48f15d5aae95892edb9bae03988573fa" ,
29
- '3bfa44d3dad4e2af12bab2601cfa8138' ,
30
- 'a78c50dc4b81f0d02fc0391532cc61f4' ,
31
- 'c0a6a295563e01e7c42628cfe81b7431' ,
32
- '19fe36c957ab88a6b5a567d885db445c' ,
33
- '084905a84b75b6860c877a5804453829' ,
34
- '23bd3abcc793f83d87e16913c99ef5ac' ,
35
- '376206640f1592ac9302e30d7cf8fabb' ,
36
- '7017b76a86eee625ec9d954a6149dd12' ] # these take too long
28
+ # these take too long
29
+ SKIP = [ "48f15d5aae95892edb9bae03988573fa" , '7017b76a86eee625ec9d954a6149dd12' , 'bf0461f5474cd711525dcd104452005b' , # annotation/sequence/mgm4447943.3?evalue=10&type=organism&source=SwissProt
30
+ '3bfa44d3dad4e2af12bab2601cfa8138' , '4978084e1997239e5ea92c873262585e' , # annotation/similarity/mgm4447943.3?identity=80&type=function&source=KO
31
+ 'a78c50dc4b81f0d02fc0391532cc61f4' , 'be43b392342e558d8285fda7ce6304d3' , # download/mgm4447943.3?file=350.1
32
+ 'c0a6a295563e01e7c42628cfe81b7431' , '093f18b3f9fdf63756d185ca3eb4600a' , # compute/alphadiversity/mgm4447943.3?level=order
33
+ '19fe36c957ab88a6b5a567d885db445c' , '376206640f1592ac9302e30d7cf8fabb' , # compute/rarefaction/mgm4447943.3?level=order
34
+ '084905a84b75b6860c877a5804453829' , '4978084e1997239e5ea92c873262585e' , # annotation/similarity/mgm4447943.3?identity=80&type=function&source=KO
35
+ '23bd3abcc793f83d87e16913c99ef5ac' , '093f18b3f9fdf63756d185ca3eb4600a' , # compute/alphadiversity/mgm4447943.3?level=order
36
+ ]
37
37
38
38
39
39
@@ -71,7 +71,23 @@ def getmeajsonobject(url):
71
71
def print_tests (testlist ):
72
72
for test in testlist :
73
73
callhash , call , name , name2 , description = test
74
- print (callhash , call , description )
74
+ print ("\t " .join ([callhash , call , description ]))
75
+
76
+ def print_code (testlist ):
77
+ print ("from subprocess import check_output" )
78
+ for test in testlist :
79
+ callhash , call , name , name2 , description = test
80
+ if call [0 :4 ] == "curl" :
81
+ print ("def test_{}(): # {}" .format (callhash , description ))
82
+ print (" CMD = '''{} 2> {}.err > {}.out'''" .format (call , callhash , callhash ))
83
+ print (' o = check_output(CMD, shell=True)' )
84
+ elif call [0 :4 ] == "http" :
85
+ print ("def test_{}(): # {}" .format (callhash , description ))
86
+ print (" URI = '''{}'''" .format (call ))
87
+ print (" CMD = '''curl '{}' 2> {}.err > {}.out'''" .format (call , callhash , callhash ))
88
+ print (' o = check_output("curl {}".format(URI), shell=True)' )
89
+ else :
90
+ print ("CALL" , call )
75
91
76
92
def check_ok (stem , dir1 , blesseddir ):
77
93
'''Populates a file called WORKING + stem + ".test" with symbols
@@ -214,6 +230,8 @@ def get_example_calls(base_url):
214
230
default = "" , help = "use output format JSON" )
215
231
parser .add_argument ("-b" , "--blesseddir" , dest = "blesseddir" , type = str ,
216
232
default = "data" , help = "Location of stored (good) results" )
233
+ parser .add_argument ("-p" , "--python" , dest = "python" , action = "store_true" ,
234
+ help = "output python test code" )
217
235
parser .add_argument ("-w" , "--workdingdir" , dest = "workingdir" , type = str ,
218
236
default = "." , help = "Working dir--will be filled with output files" )
219
237
parser .add_argument ("-t" , "--test" , dest = "tests" , action = "store_true" ,
@@ -237,5 +255,7 @@ def get_example_calls(base_url):
237
255
tests = get_example_calls (API_URL )
238
256
if TESTS :
239
257
print_tests (tests )
258
+ elif opts .python :
259
+ print_code (tests )
240
260
else :
241
261
run_tests (tests )
0 commit comments