LHNCBC / skr_web_python_api

SKR Web API: Python implementation
Other
35 stars 7 forks source link

How to request file batch MTI requests? #5

Open C-molloy opened 1 year ago

C-molloy commented 1 year ago

For the generic_batch_file.py, I wanted to ask what are the arguments to pass the file through the MTI batch request i.e. https://ii.nlm.nih.gov/Batch/UTS_Required/MTI.html

If there is documentation on this where can I find this?

MasonRoberts commented 1 year ago

Hi - I think the mti_interactive.py shows how to make a request to the MTI module. You can edit it to meet your needs. I put an example below. You will need to edit the "inputtext" variable to be what you want to send. I imagine you can make this a loop. This might not be perfect as I am experimenting with this myself.

""" MTI interactive """ import argparse import os from skr_web_api import Submission, SEMREP_INTERACTIVE_URL

if name == 'main':

parser = argparse.ArgumentParser(description="test cas auth") parser.add_argument('-s', '--serviceurl', default=SEMREP_INTERACTIVE_URL, help='url of service')

parser.add_argument('-e', '--email', help='Email address')

parser.add_argument('-a', '--apikey', help='UTS api key')

args = parser.parse_args() if args.email is None and 'EMAIL' in os.environ: args.email = os.environ['EMAIL'] if args.apikey is None and 'UTS_API_KEY' in os.environ: args.apikey = os.environ['UTS_API_KEY']

inputtext = "A spinal tap was performed and oligoclonal bands \ were detected in the cerebrospinal fluid.\n"

inst = Submission(, ,) if args.serviceurl: inst.set_serviceurl(args.serviceurl) inst.init_mti_interactive(inputtext, args='-opt1L_DCMS') response = inst.submit() print('response status: {}'.format(response.status_code)) print('content: {}'.format(response.content.decode()))

MasonRoberts commented 1 year ago

Woops - those commented out sections are being read as headers in markup. I commented them out so it would be easy to see how I was editing the .py example the author provided.