本文整理汇总了Python中Authentication.getst方法的典型用法代码示例。如果您正苦于以下问题:Python Authentication.getst方法的具体用法?Python Authentication.getst怎么用?Python Authentication.getst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authentication
的用法示例。
在下文中一共展示了Authentication.getst方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Authentication
# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getst [as 别名]
args = parser.parse_args()
username = args.username
password = args.password
version = args.version
string = args.string
uri = "https://uts-ws.nlm.nih.gov"
content_endpoint = "/rest/search/"+version
##get at ticket granting ticket for the session
AuthClient = Authentication(username,password)
tgt = AuthClient.gettgt()
pageNumber=0
while True:
##generate a new service ticket for each page if needed
ticket = AuthClient.getst(tgt)
pageNumber += 1
query = {'string':string,'ticket':ticket, 'pageNumber':pageNumber}
#query['includeObsolete'] = 'true'
#query['includeSuppressible'] = 'true'
#query['returnIdType'] = "sourceConcept"
#query['sabs'] = "SNOMEDCT_US"
r = requests.get(uri+content_endpoint,params=query)
r.encoding = 'utf-8'
items = json.loads(r.text)
jsonData = items["result"]
#print (json.dumps(items, indent = 4))
print("Results for page " + str(pageNumber)+"\n")
for result in jsonData["results"]:
示例2:
# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getst [as 别名]
tgt = AuthClient.gettgt()
uri = "https://uts-ws.nlm.nih.gov"
try:
source
except NameError:
source = None
if source is None:
content_endpoint = "/rest/content/"+str(version)+"/CUI/"+str(identifier)
else:
content_endpoint = "/rest/content/"+str(version)+"/source/"+str(source)+"/"+str(identifier)
query = {'ticket':AuthClient.getst(tgt)}
r = requests.get(uri+content_endpoint,params=query)
r.encoding = 'utf-8'
items = json.loads(r.text)
jsonData = items["result"]
classType = jsonData["classType"]
name = jsonData["name"]
ui = jsonData["ui"]
AtomCount = jsonData["atomCount"]
Definitions = jsonData["definitions"]
Atoms = jsonData["atoms"]
DefaultPreferredAtom = jsonData["defaultPreferredAtom"]
## print out the shared data elements that are common to both the 'Concept' and 'SourceAtomCluster' class
print ("classType: " + classType)
示例3: open
# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getst [as 别名]
#C2711988 is the CUI for the SNOMED CT CORE Problem List content view
#Full list of content views is here: https://www.nlm.nih.gov/research/umls/knowledge_sources/metathesaurus/release/content_views.html,
#or over web services at https://uts-ws.nlm.nih.gov/rest/content-views/current?ticket=ST...
content_view_endpoint = "/rest/content-views/"+version+"/CUI/C2711988/members"
tgt = AuthClient.gettgt()
pageNumber=1
pageCount=1
f = open(outputfile, 'w')
#column headers - modify accordingly if you are computing a different subset
f.write("SNOMED_CID|NAME|FIRST_IN_SUBSET|IS_RETIRED_FROM_SUBSET|OCCURRENCE|USAGE|REPLACED_BY_SNOMED_CID\n")
##There are ~ 250 pages in this subset, if you're using the default of 25 objects per page.
while pageNumber<=pageCount:
query = {'ticket':AuthClient.getst(tgt),'pageNumber':pageNumber}
r = requests.get(base_uri+content_view_endpoint,params=query)
print(r.url+"\n")
r.encoding = 'utf-8'
items = json.loads(r.text)
pageCount=items["pageCount"]
print("Fetching page " + str(pageNumber)+" of results\n")
for result in items["result"]:
f.write(result["ui"]+"|"+str(result["name"]))
#MOST CONTENT VIEW MEMBERS DO NOT HAVE ATTRIBUTES, BUT FOR MEMBERS OF THE SNOMED CT CORE PROBLEM LIST
#THESE ARE THE CURRENT LIST OF ATTRIBUTE NAMES THAT ARE DEFINED. HOWEVER, IN THE DATA THEY ARE NOT ALWAYS PRESENT
#FOR EXAMPLE, IF IS_RETIRED_FROM_SUBSET = True, THERE IS NO 'OCCURRENCE' OR 'USAGE' ATTRIBUTE AVAILABLE, SO WE MUST CHECK AND THEN
示例4: str
# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getst [as 别名]
uri = "https://uts-ws.nlm.nih.gov"
try:
source
except NameError:
source = None
##if we don't specify a source vocabulary, assume we're retrieving UMLS CUIs
if source is None:
content_endpoint = "/rest/content/" + str(version) + "/CUI/" + str(identifier)
else:
content_endpoint = "/rest/content/" + str(version) + "/source/" + str(source) + "/" + str(identifier)
##ticket is the only parameter needed for this call - paging does not come into play because we're only asking for one Json object
query = {"ticket": AuthClient.getst(tgt)}
r = requests.get(uri + content_endpoint, params=query)
r.encoding = "utf-8"
items = json.loads(r.text)
jsonData = items["result"]
##uncomment the print statment if you want the raw json output, or you can just look at the documentation :=)
# https://documentation.uts.nlm.nih.gov/rest/concept/index.html#sample-output
# https://documentation.uts.nlm.nih.gov/rest/source-asserted-identifiers/index.html#sample-output
# print (json.dumps(items, indent = 4))
############################
### Print out fields ####
classType = jsonData["classType"]
name = jsonData["name"]