python - parsing a drugbank.xml file -
am trying out code github.com on drugbank xml file. keep getting error messsage:
usage: drugbank.py [-h] --input input drugbank.py: error: following arguments required: --input/-i
being new python, mean? here long code:
def run(input): """writes relational database text files drugs, drug_target, drug_target_action, , targets tables. input: path of drugbank xml file. output: text files can used inputs sql tables. method: 1. read , parse xml file. 2. extract data , save records key, value pairs. 3. write output files.""" #output file names drugs_out = input + '.drugs.txt' drug_target_out = input + '.drug_target.txt' drug_target_action_out = input + '.drug_target_action.txt' targets_out = input + '.targets.txt' #counter number of records in each file record_counts = counter() #open input file , parse xml #get drugbank namspace print('reading , parsing xml file.') tree = etree.elementtree(file=input) #a few namespace tricks make code more readable ns = tree.getroot().nsmap ns['db'] = ns[none] del ns[none] drugs = tree.xpath('db:drug', namespaces=ns) code........ def main(): #command line arguments parser = argparse.argumentparser( description='writes relational database text files drugs, drug_target, drug_target_action, , targets', epilog='drugbankxml2db 1.0β1 ©2014 michael yourshaw rights reserved', ) parser.add_argument('--input', '-i', required=true, help='drug bank xml file downloaded http://www.drugbank.ca/system/downloads/current/drugbank.xml.zip',) args = parser.parse_args() run(input=args.input) if __name__ == "__main__": sys.exit(main())
your script requires specify value --input
argument:
parser.add_argument('--input', '-i', required=true, help='drug bank xml file downloaded http://www.drugbank.ca/system/downloads/current/drugbank.xml.zip',)
required=true
means have include -i
or --input
when running script.
you supposed download indicated url yourself, unzip file, point script with:
drugbank.py -i drugbank.xml
Comments
Post a Comment