diff --git a/bcotool/import requests.py b/bcotool/import requests.py new file mode 100644 index 0000000..0e42c00 --- /dev/null +++ b/bcotool/import requests.py @@ -0,0 +1,56 @@ +import requests + +def tooltype2(x,y): # function that will return the tool type from ELIXIR databases + + l="https://bio.tools/api/t/?biotoolsID=%22%22&format=json" # The http used to reterive info + + LINK = l[:39]+x+l[39:] # add the input to the http link + LINK2 = l[:39]+y+l[39:] + + + result = requests.get((LINK)) #reterive all the information about The input tool name and store them in the result + result2 = requests.get((LINK2)) + + dic=result.json() # change it from JSON to Python Dictionary + dic2=result2.json() + + if dic['count']>1: # if there is more than one tool with the same name + typet = [] + for i,key in enumerate(dic['list']): + x = (dic['list'][i]['function'][0]['operation']) + for r,key in enumerate(x): + y = (dic['list'][i]['function'][0]['operation'][r]['term']) + typet.append(y) + + h = (set(typet)) + final = typet + for i in h: # go over the two tools and find the similarity + final.remove(i) + else: # if only one tool has the same name + typet = [] + for r,key in enumerate(dic['list'][0]['function'][0]['operation']): + y = (dic['list'][0]['function'][0]['operation'][r]['term']) + typet.append(y) + final = typet + if dic2['count']>1: + typet = [] + for i,key in enumerate(dic2['list']): + x = (dic2['list'][i]['function'][0]['operation']) + for r,key in enumerate(x): + y = (dic2['list'][i]['function'][0]['operation'][r]['term']) + typet.append(y) + + h = (set(typet)) + final2 = typet + for i in h: + final2.remove(i) + else: + typet = [] + for r,key in enumerate(dic2['list'][0]['function'][0]['operation']): + y = (dic2['list'][0]['function'][0]['operation'][r]['term']) + typet.append(y) + final2 = typet + res = [x for x in final + final2 if x in final + and x in final2] # go over the two tools and find the similarity + + return set(res) diff --git a/data_tests/#Tool type call.py b/data_tests/#Tool type call.py new file mode 100644 index 0000000..e6b9b7f --- /dev/null +++ b/data_tests/#Tool type call.py @@ -0,0 +1,29 @@ +# Alhanouf Altuwayjiri +#the needed package to use JSON +import requests +# ask the user for tool name +def ToolType(inp): +#use the templet http and add the tool name to it + x="https://bio.tools/api/t/?format=json&q=&sort=score" + + LINK=x[:39]+inp+x[39:] + +#reterive all the information about The input tool name and store them in the result + result=requests.get((LINK)) +# change it from JSON to Python Dictionary + dic=result.json() +#print the tool type for the used tool name + + typet=[] + for i,key in enumerate(dic['list']): + x=(dic['list'][i]['function'][0]['operation']) + for r,key in enumerate(x): + y=(dic['list'][i]['function'][0]['operation'][r]['term']) + typet.append(y) + + h=(set(typet)) + final=typet + for i in h: + final.remove(i) + + return set(final) \ No newline at end of file