Mercurial > repos > iuc > ncbi_eutils_egquery
comparison efetch.py @ 0:22fed2340d2b draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
| author | iuc |
|---|---|
| date | Sat, 31 Oct 2015 12:45:31 -0400 |
| parents | |
| children | 20a86bfb54eb |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:22fed2340d2b |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 import argparse | |
| 3 import eutils | |
| 4 | |
| 5 | |
| 6 if __name__ == '__main__': | |
| 7 parser = argparse.ArgumentParser(description='EFetch', epilog='') | |
| 8 parser.add_argument('db', help='Database to use') | |
| 9 parser.add_argument('--user_email', help="User email") | |
| 10 parser.add_argument('--admin_email', help="Admin email") | |
| 11 | |
| 12 # ID source | |
| 13 parser.add_argument('--id_list', help='list of ids') | |
| 14 parser.add_argument('--id', help='Comma separated individual IDs') | |
| 15 parser.add_argument('--history_file', help='Fetch results from previous query') | |
| 16 | |
| 17 # Output | |
| 18 parser.add_argument('--retmode', help='Retmode') | |
| 19 parser.add_argument('--rettype', help='Rettype') | |
| 20 parser.add_argument('--whole', action='store_true', | |
| 21 help='Download all records associated with query') | |
| 22 args = parser.parse_args() | |
| 23 | |
| 24 c = eutils.Client(history_file=args.history_file, user_email=args.user_email, admin_email=args.admin_email) | |
| 25 merged_ids = c.parse_ids(args.id_list, args.id, args.history_file) | |
| 26 | |
| 27 payload = {} | |
| 28 if args.history_file is not None: | |
| 29 payload.update(c.get_history()) | |
| 30 else: | |
| 31 payload['id'] = ','.join(merged_ids) | |
| 32 | |
| 33 for attr in ('retmode', 'rettype'): | |
| 34 if getattr(args, attr, None) is not None: | |
| 35 payload[attr] = getattr(args, attr) | |
| 36 | |
| 37 c.fetch(args.db, whole=args.whole, **payload) |
