comparison ete_init_taxdb.py @ 15:1e85af7a29c4 draft default tip

planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/main/tools/ete commit 6e40bbe92367310e9d3ec69571d08eb49af7c0a6-dirty
author earlhaminst
date Mon, 24 Feb 2025 16:34:12 +0000
parents 03c10736e497
children
comparison
equal deleted inserted replaced
14:d40b9a7debe5 15:1e85af7a29c4
1 import optparse 1 import optparse
2 from urllib.request import urlretrieve
2 3
3 import ete3.ncbi_taxonomy 4 from ete3.ncbi_taxonomy.ncbiquery import update_db
4 from six.moves.urllib.request import urlretrieve
5 5
6 parser = optparse.OptionParser() 6 parser = optparse.OptionParser()
7 parser.add_option('-t', '--taxdump', dest='taxdump', default=None, 7 parser.add_option(
8 help='NCBI taxdump (tar.gz) will be downloaded if not given') 8 "-t",
9 parser.add_option('-d', '--database', dest="database", default=None, 9 "--taxdump",
10 help='ETE sqlite data base to use (default: ~/.etetoolkit/taxa.sqlite)') 10 dest="taxdump",
11 default=None,
12 help="NCBI taxdump (tar.gz), will be downloaded if not given",
13 )
14 parser.add_option(
15 "-d",
16 "--database",
17 dest="database",
18 default=None,
19 help="ETE sqlite data base to create",
20 )
11 options, args = parser.parse_args() 21 options, args = parser.parse_args()
12 if options.database is None: 22 if options.database is None:
13 parser.error("-d option must be specified") 23 parser.error("-d option must be specified")
14 if options.taxdump is not None: 24 if options.taxdump is not None:
15 taxdump = options.taxdump 25 taxdump = options.taxdump
16 else: 26 else:
17 urlretrieve("http://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz", "taxdump.tar.gz") 27 urlretrieve(
28 "https://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz", "taxdump.tar.gz"
29 )
18 taxdump = "taxdump.tar.gz" 30 taxdump = "taxdump.tar.gz"
19 31
20 # will remove a taxdump.tar.gz file at the end 32 update_db(dbfile=options.database, targz_file=taxdump)
21 # which will lead to an errmessage if not present
22 # if the tool is run on a taxdump in the current dir it will be
23 # deleted in the end
24 ete3.ncbi_taxonomy.ncbiquery.update_db(dbfile=options.database, targz_file=taxdump)