Skip to content

Commit

Permalink
updated README section on gimme_taxa; fixed gimme_taxa header bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Youngblut authored and kblin committed Jun 26, 2018
1 parent dce851f commit ec01008
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
21 changes: 13 additions & 8 deletions README.md
Expand Up @@ -196,22 +196,27 @@ file to pass in to it. It utilises the `ete3` toolkit, so refer to their site to
if it's not already satisfied.

You can query the database using a particular TaxID, or a scientific name. The primary function of the
script is to return all the child taxa of the specified parent taxa. If specified with `-v` verbose
flags however, the script will also print out some information about the lineages etc.
script is to return all the child taxa of the specified parent taxa. The script has various options
for what information is written in the output.

A basic invocation may look like:

```
# Fetch all descendent taxa for Escherichia:
python gimme_taxa.py -v -o ~/mytaxafile.txt -t 561
# Fetch all descendent taxa for Escherichia (taxid 561):
python gimme_taxa.py -o ~/mytaxafile.txt 561
alternatively
# Alternatively, just provide the taxon name
python gimme_taxa.py -o all_descendent_taxids.txt Escherichia
python gimme_taxa.py -v -o ~/mytaxafile.txt -n Escherichia
# You can provide multiple taxids and/or names
python gimme_taxa.py -o all_descendent_taxids.txt 561,Methanobrevibacter
```

On first use, a small sqlite database will be created in your home directory. In future this can be
updated by providing the `--update` flag.
On first use, a small sqlite database will be created in your home directory
by default (change the location with the `--database` flag). You can update this database
by using the `--update` flag. Note that if the database is not in your home directory,
you must specify it with `--database` or a new database will be created in your home
directory.

To see all help:
```
Expand Down
17 changes: 10 additions & 7 deletions contrib/gimme_taxa.py
Expand Up @@ -157,25 +157,28 @@ def main():
# If names were provided in taxid list, convert to taxids
args.taxid = args.taxid.replace('"', '').replace("'", '').split(',')
args.taxid = name2taxid(args.taxid, ncbi)

# Output
if args.outfile is None:
outFH = sys.stdout
else:
outFH = open(args.outfile, 'w')

## header
if args.taxon_info:
outFH.write('\t'.join(['name', 'taxid', 'rank', 'lineage']) + '\n')
elif not args.just_taxids:
outFH.write('\t'.join(['parent_taxid',
'descendent_taxid',
'descendent_name']) + '\n')
## body
for taxid in args.taxid:
if args.taxon_info:
outFH.write('\t'.join(['name', 'taxid', 'rank', 'lineage']) + '\n')
taxon_info(taxid, ncbi, outFH)
else:
if not args.just_taxids:
outFH.write('\t'.join(['parent_taxid',
'descendent_taxid',
'descendent_name']) + '\n')
desc_taxa(taxid, ncbi, outFH, args.just_taxids)

outFH.close()


if __name__ == "__main__":
main()

0 comments on commit ec01008

Please sign in to comment.