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