comparison uniprotxml_downloader.py @ 3:1a5690a5eedc draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/uniprotxml_downloader commit 6aac77a68426533c8c18c9f6aabd2df56a82de24
author galaxyp
date Tue, 02 Jul 2019 21:46:14 -0400
parents e1abc9a35c64
children 12692567c7f9
comparison
equal deleted inserted replaced
2:e1abc9a35c64 3:1a5690a5eedc
23 parser = optparse.OptionParser() 23 parser = optparse.OptionParser()
24 parser.add_option('-i', '--input', dest='input', default=None, help='Tabular file containing a column of NCBI Taxon IDs') 24 parser.add_option('-i', '--input', dest='input', default=None, help='Tabular file containing a column of NCBI Taxon IDs')
25 parser.add_option('-c', '--column', dest='column', type='int', default=0, help='The column (zero-based) in the tabular file that contains Taxon IDs' ) 25 parser.add_option('-c', '--column', dest='column', type='int', default=0, help='The column (zero-based) in the tabular file that contains Taxon IDs' )
26 parser.add_option('-t', '--taxon', dest='taxon', action='append', default=[], help='NCBI taxon ID to download') 26 parser.add_option('-t', '--taxon', dest='taxon', action='append', default=[], help='NCBI taxon ID to download')
27 parser.add_option('-r', '--reviewed', dest='reviewed', help='Only uniprot reviewed entries') 27 parser.add_option('-r', '--reviewed', dest='reviewed', help='Only uniprot reviewed entries')
28 parser.add_option('-f', '--format', dest='format', choices=['xml', 'fasta'], default='xml',help='output format') 28 parser.add_option('-f', '--format', dest='format', choices=['xml', 'fasta'], default='xml', help='output format')
29 parser.add_option('-o', '--output', dest='output', help='file path for th downloaed uniprot xml') 29 parser.add_option('-o', '--output', dest='output', help='file path for the downloaded uniprot xml')
30 parser.add_option('-v', '--verbose', dest='verbose', action='store_true', default=False, help='Print UniProt Info') 30 parser.add_option('-v', '--verbose', dest='verbose', action='store_true', default=False, help='Print UniProt Info')
31 parser.add_option('-d', '--debug', dest='debug', action='store_true', default=False, help='Turn on wrapper debugging to stderr') 31 parser.add_option('-d', '--debug', dest='debug', action='store_true', default=False, help='Turn on wrapper debugging to stderr')
32 (options, args) = parser.parse_args() 32 (options, args) = parser.parse_args()
33 taxids = set(options.taxon) 33 taxids = set(options.taxon)
34 if options.input: 34 if options.input:
49 dest_path = "uniprot_%s.xml" % '_'.join(taxids) 49 dest_path = "uniprot_%s.xml" % '_'.join(taxids)
50 reviewed = " reviewed:%s" % options.reviewed if options.reviewed else '' 50 reviewed = " reviewed:%s" % options.reviewed if options.reviewed else ''
51 try: 51 try:
52 def reporthook(n1,n2,n3): 52 def reporthook(n1,n2,n3):
53 pass 53 pass
54 url = 'http://www.uniprot.org/uniprot/' 54 url = 'https://www.uniprot.org/uniprot/'
55 query = "%s%s" % (taxon_query, reviewed) 55 query = "%s%s" % (taxon_query, reviewed)
56 params = {'query' : query, 'force' : 'yes' , 'format' : options.format} 56 params = {'query' : query, 'force' : 'yes' , 'format' : options.format}
57 if options.debug: 57 if options.debug:
58 print >> sys.stderr, "%s ? %s" % (url,params) 58 print >> sys.stderr, "%s ? %s" % (url,params)
59 data = urllib.urlencode(params) 59 data = urllib.urlencode(params)