comparison epost.py @ 3:ae3a5d753d42 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit dae34e5e182b4cceb808d7353080f14aa9a78ca9"
author iuc
date Wed, 23 Sep 2020 09:51:06 +0000
parents 196b8dd07896
children
comparison
equal deleted inserted replaced
2:7d868844e952 3:ae3a5d753d42
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 from __future__ import print_function
3 2
4 import argparse 3 import argparse
5 4
6 import eutils 5 import eutils
7 6
8 7
9 if __name__ == '__main__': 8 if __name__ == '__main__':
10 parser = argparse.ArgumentParser(description='EPost', epilog='') 9 parser = argparse.ArgumentParser(description='EPost', epilog='')
11 parser.add_argument('db', help='Database to use') 10 parser.add_argument('db', help='Database to use')
11 parser.add_argument('--user_email', help="User email")
12 parser.add_argument('--admin_email', help="Admin email")
13
14 parser.add_argument('--version', action='version', version=eutils.Client.getVersion(), help='Version (reports Biopython version)')
15
16 # ID source
12 parser.add_argument('--id_list', help='list of ids') 17 parser.add_argument('--id_list', help='list of ids')
13 parser.add_argument('--id', help='Comma separated individual IDs') 18 parser.add_argument('--id', help='Comma separated individual IDs')
14 parser.add_argument('--history_file', help='Post to new QueryKey in an existing WebEnv') 19 parser.add_argument('--id_json', help='list of ids in a json file as returned by esearch or elink')
15 parser.add_argument('--user_email', help="User email") 20 parser.add_argument('--id_xml', help='list of ids in an xml file as returned by esearch or elink')
16 parser.add_argument('--admin_email', help="Admin email") 21
22 # Target history
23 parser.add_argument('--history_xml', help='Post to new QueryKey in an existing WebEnv (XML)')
24 parser.add_argument('--history_file', help='Post to new QueryKey in an existing WebEnv (JSON)')
25 parser.add_argument('--webenv', help='Post to new WebEnv (History ID)')
17 26
18 args = parser.parse_args() 27 args = parser.parse_args()
19 28
20 c = eutils.Client(history_file=args.history_file, user_email=args.user_email, admin_email=args.admin_email) 29 c = eutils.Client(history_file=args.history_file, user_email=args.user_email, admin_email=args.admin_email)
21 merged_ids = c.parse_ids(args.id_list, args.id, args.history_file)
22 30
23 payload = {} 31 payload = {}
24 if args.history_file is not None: 32 if args.history_file is not None:
25 payload.update(c.get_history()) 33 hist = c.get_history()
26 else: 34 payload['WebEnv'] = hist['WebEnv']
27 payload['id'] = ','.join(merged_ids) 35 elif args.history_xml is not None:
28 payload['WebEnv'] = '' 36 hist = c.extract_history_from_xml_file(args.history_xml)
37 payload['WebEnv'] = hist['WebEnv']
38 elif args.webenv is not None:
39 payload['WebEnv'] = args.webenv
40
41 merged_ids = c.parse_ids(args.id_list, args.id, None, args.id_xml, args.id_json)
42 payload['id'] = ','.join(merged_ids)
29 43
30 print(c.post(args.db, **payload)) 44 print(c.post(args.db, **payload))