Skip to main content

Taxonomic toolbelt for Python

Project description

pytaxize

docs travis coverage black

This is a port of the R package taxize. There is a lot going on in the R version of this library, so it will take a while to get all the same functionality over here.

Why? A significant advantage of a Python version of taxize will be for those that are pythonistas at heart. Also, you could use pytaxize in a web app, whereas you could with taxize (e.g., in a Shiny app), but it wouldn’t scale, be very fast, etc.

python 2/3

pytaxize is only developed in and tested with Python 3

Installation

Stable from pypi

pip install pytaxize

Development version

sudo pip install git+git://github.com/sckott/pytaxize.git#egg=pytaxize

Taxonomic Ids

I’ve started working on a class interface for taxonomic IDs, which will have a bunch of extension methods to do various things with taxon ids. What’s available right now is just getting COL ids.

from pytaxize import Ids
res = Ids('Poa annua')
res.ncbi()
res.ids
{'Poa annua': [{'id': '93036',
   'name': 'Poa annua',
   'rank': 'species',
   'uri': 'https://www.ncbi.nlm.nih.gov/taxonomy/93036'}]}

Scrape taxonomic names

out = pytaxize.scrapenames(url = 'http://www.mapress.com/zootaxa/2012/f/z03372p265f.pdf')
out['data'][0:3]
[{'verbatim': '(Hemiptera:',
  'scientificName': 'Hemiptera',
  'offsetStart': 222,
  'offsetEnd': 233},
 {'verbatim': 'Sternorrhyncha:',
  'scientificName': 'Sternorrhyncha',
  'offsetStart': 234,
  'offsetEnd': 249},
 {'verbatim': 'Coccoidea:',
  'scientificName': 'Coccoidea',
  'offsetStart': 250,
  'offsetEnd': 260}]

ITIS low level functions

from pytaxize import itis
itis.accepted_names(504239)

{'acceptedName': 'Dasiphora fruticosa',
   'acceptedTsn': '836659',
   'author': '(L.) Rydb.'}
itis.comment_detail(tsn=180543)

[{'commentDetail': 'Status: CITES - Appendix I as U. arctos (Mexico, Bhutan, China, and Mongolia populations) and U. a. isabellinus; otherwise Appendix II. U. S. ESA - Endangered as U. arctos pruinosus, as U. arctos in Mexico, and as U. a. arctos in Italy. Threatened as U. a. ho...',
  'commentId': '18556',
  'commentTimeStamp': '2007-08-20 15:06:38.0',
  'commentator': 'Wilson & Reeder, eds. (2005)',
  'updateDate': '2014-02-03'},
 {'commentDetail': "Comments: Reviewed by Erdbrink (1953), Couturier (1954), Rausch (1963a), Kurtén (1973), Hall (1984) and Pasitschniak-Arts (1993). Ognev (1931) and Allen (1938) recognized U. pruinosus as distinct; not followed by Ellerman and Morrison-Scott (1951), Gao (1987), and Stroganov (1962). Lönnberg (1923b) believed that differences between pruinosus and arctos warranted subgeneric distinction as (Mylarctos) pruinosus; however, this was not supported by Pocock's (1932b) thorough revision. Synonyms allocated a...",
  'commentId': '18557',
  'commentTimeStamp': '2007-08-20 15:06:38.0',
  'commentator': 'Wilson & Reeder, eds. (2005)',
  'updateDate': '2014-02-03'}]
itis.hierarchy_up(tsn = 36485)

{'author': 'Raf.',
 'parentName': 'Asteraceae',
 'parentTsn': '35420',
 'rankName': 'Genus',
 'taxonName': 'Agoseris',
 'tsn': '36485'}

Catalogue of Life

from pytaxize import col
x = col.children(name=["Apis"])
x[0][0:3]
[{'id': '7a4a38c5095963949d6d6ec917d471de',
  'name': 'Apis andreniformis',
  'rank': 'Species'},
 {'id': '39610a4ceff7e5244e334a3fbc5e47e5',
  'name': 'Apis cerana',
  'rank': 'Species'},
 {'id': 'e1d4cbf3872c6c310b7a1c17ddd00ebc',
  'name': 'Apis dorsata',
  'rank': 'Species'}]

Parse names

Parse names using GBIF’s parser API

from pytaxize import gbif
gbif.parse(name=['Arrhenatherum elatius var. elatius',
     'Secale cereale subsp. cereale', 'Secale cereale ssp. cereale',
   'Vanessa atalanta (Linnaeus, 1758)'])
[{'scientificName': 'Arrhenatherum elatius var. elatius',
  'type': 'SCIENTIFIC',
  'genusOrAbove': 'Arrhenatherum',
  'specificEpithet': 'elatius',
  'infraSpecificEpithet': 'elatius',
  'parsed': True,
  'parsedPartially': False,
  'canonicalName': 'Arrhenatherum elatius elatius',
  'canonicalNameWithMarker': 'Arrhenatherum elatius var. elatius',
  'canonicalNameComplete': 'Arrhenatherum elatius var. elatius',
  'rankMarker': 'var.'},
 {'scientificName': 'Secale cereale subsp. cereale',
  'type': 'SCIENTIFIC',
  ...

Contributors

Meta

Changelog

0.7.0 (2020-06-15)

  • first release to pypi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytaxize-0.7.0.tar.gz (71.7 kB view details)

Uploaded Source

Built Distributions

pytaxize-0.7.0-py3.8.egg (155.9 kB view details)

Uploaded Source

pytaxize-0.7.0-py2.py3-none-any.whl (94.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytaxize-0.7.0.tar.gz.

File metadata

  • Download URL: pytaxize-0.7.0.tar.gz
  • Upload date:
  • Size: 71.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for pytaxize-0.7.0.tar.gz
Algorithm Hash digest
SHA256 42742555325f78f3e054f19a2ada9e22924715970db10023d12b2131e282539a
MD5 62341b8070a35928d4c44c42add93f8d
BLAKE2b-256 8e2f7f5459d553ae894000baa98068da122378f614283776cca87d91f7213e12

See more details on using hashes here.

File details

Details for the file pytaxize-0.7.0-py3.8.egg.

File metadata

  • Download URL: pytaxize-0.7.0-py3.8.egg
  • Upload date:
  • Size: 155.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for pytaxize-0.7.0-py3.8.egg
Algorithm Hash digest
SHA256 5fd79eb74e7e53b0be4f8fbb940d08c6398b0d0c7a819f382f06a6e7c8531cd7
MD5 5ba7dbbd7f1f7429d167e276f90c3dbc
BLAKE2b-256 f78366ac0ab333656df95ca81bee32bfda58f9aa83eee1f21db2638f7056a8fa

See more details on using hashes here.

File details

Details for the file pytaxize-0.7.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytaxize-0.7.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 94.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for pytaxize-0.7.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8cb0b84235e9c62ee9f22985f67029c0c9e5d4d5b5b8095d39beaec991e72d29
MD5 b3fd0bdcf6dd9efec0d17bb3455db668
BLAKE2b-256 2abd05b054fc54220133ec4576284d918231a945dcc0e302932cc3a853ad19a2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page