annotate efetch.py @ 6:2d54a753d1f1 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit a4b0969b33a68a0ea9ba12291f6694aec24f13ed
author iuc
date Tue, 30 Oct 2018 19:09:24 -0400
parents 20a86bfb54eb
children f3f5ee550b17
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
1 #!/usr/bin/env python
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
2 import argparse
6
2d54a753d1f1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit a4b0969b33a68a0ea9ba12291f6694aec24f13ed
iuc
parents: 5
diff changeset
3
0
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
4 import eutils
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
5
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
6
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
7 if __name__ == '__main__':
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
8 parser = argparse.ArgumentParser(description='EFetch', epilog='')
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
9 parser.add_argument('db', help='Database to use')
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
10 parser.add_argument('--user_email', help="User email")
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
11 parser.add_argument('--admin_email', help="Admin email")
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
12
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
13 # ID source
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
14 parser.add_argument('--id_list', help='list of ids')
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
15 parser.add_argument('--id', help='Comma separated individual IDs')
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
16 parser.add_argument('--history_file', help='Fetch results from previous query')
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
17
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
18 # Output
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
19 parser.add_argument('--retmode', help='Retmode')
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
20 parser.add_argument('--rettype', help='Rettype')
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
21 args = parser.parse_args()
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
22
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
23 c = eutils.Client(history_file=args.history_file, user_email=args.user_email, admin_email=args.admin_email)
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
24 merged_ids = c.parse_ids(args.id_list, args.id, args.history_file)
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
25
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
26 payload = {}
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
27 if args.history_file is not None:
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
28 payload.update(c.get_history())
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
29 else:
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
30 payload['id'] = ','.join(merged_ids)
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
31
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
32 for attr in ('retmode', 'rettype'):
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
33 if getattr(args, attr, None) is not None:
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
34 payload[attr] = getattr(args, attr)
22fed2340d2b planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 780c9984a9c44d046aadf1e316a668d1e53aa1f0
iuc
parents:
diff changeset
35
5
20a86bfb54eb planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit 15bcc5104c577b4b9c761f2854fc686c07ffa9db
iuc
parents: 0
diff changeset
36 c.fetch(args.db, ftype=args.retmode, **payload)