ropensci / taxa

taxonomic classes for R
https://docs.ropensci.org/taxa
Other
48 stars 12 forks source link

Add database taxon ID checking via regex/taxize #145

Open zachary-foster opened 6 years ago

zachary-foster commented 6 years ago

@sckott, what do you think about this:

  1. A method called check_db_id of the taxon_database class that takes a taxon_id. It could optionally use taxize to actually check via an API call.
  2. Methods in taxon, hierarchy, and taxonomy that call that method on all their taxa

When do you think this checking should occur?

  1. on constructors
  2. setters of taxon_id, and taxon, and taxa described in #139

Can you think of any other instance where these should be checked automatically?

related to #144

sckott commented 6 years ago

Does check_db_id check if it's a valid/known ID to the specific data source? Or some other kind of check?

zachary-foster commented 6 years ago

It would check if the ID conforms the the regex we set for whatever data source is specified by the taxon_database object. A taxon object would check the taxon_database object in its taxon_id object for which database it is from and use the regex there to determine what a valid ID is.

The taxon_database is one place where it might make sense to allow for vectors that match a name in database_list rather than require taxon_database objects, since each taxon will have separate database info for its name, id, and rank. Actually, we might want to force the taxon database to be a vector that matches a name in database_list and have a function that can add to that list for custom databases.

sckott commented 6 years ago

regex checking seems safe enough where it wouldn't add to much time, but API calls would have to be designed to fail safely i guess