001/* 002 * Copyright 2020 Global Biodiversity Information Facility (GBIF) 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.gbif.api.vocabulary; 017 018import org.apache.commons.lang3.StringUtils; 019 020/** 021 * A short classification of scientific name strings used in Checklist Bank. 022 */ 023public enum NameType { 024 025 /** 026 * A scientific latin name that might contain authorship but is not any of the other name types below (virus, hybrid, cultivar, etc). 027 */ 028 SCIENTIFIC, 029 030 /** 031 * A virus name. 032 */ 033 VIRUS, 034 035 /** 036 * A hybrid <b>formula</b> (not a hybrid name). 037 */ 038 HYBRID, 039 040 /** 041 * A scientific name with some informal addition like "cf." or indetermined like Abies spec. 042 */ 043 INFORMAL, 044 045 /** 046 * A cultivated plant name. 047 */ 048 CULTIVAR, 049 050 /** 051 * Candidatus is a component of the taxonomic name for a bacterium that cannot be maintained in a 052 * Bacteriology Culture Collection. It is an interim taxonomic status for noncultivable organisms. 053 * An example would be "Candidatus Phytoplasma allocasuarinae". 054 * This can be abbreviated to "Ca. Phytoplasma allocasuarinae". 055 * 056 * @see <a href="http://en.wikipedia.org/wiki/Candidatus">wikipedia</a> 057 * @see <a href="http://www.bacterio.cict.fr/candidatus.html">J.P. Euzéby</a> 058 * 059 */ 060 CANDIDATUS, 061 062 /** 063 * Operational Taxonomic Unit. 064 * An OTU is a pragmatic definition to group individuals by similarity, equivalent to but not necessarily in line 065 * with classical Linnaean taxonomy or modern Evolutionary taxonomy. 066 * 067 * A OTU usually refers to clusters of organisms, grouped by DNA sequence similarity of a specific taxonomic marker gene. 068 * In other words, OTUs are pragmatic proxies for "species" at different taxonomic levels. 069 * 070 * Sequences can be clustered according to their similarity to one another, 071 * and operational taxonomic units are defined based on the similarity threshold (usually 97% similarity) set by the researcher. 072 * Typically, OTU's are based on similar 16S rRNA sequences. 073 */ 074 OTU, 075 076 /** 077 * Doubtful whether this is a scientific name at all. 078 */ 079 DOUBTFUL, 080 081 /** 082 * A placeholder name like "incertae sedis" or "unknown genus". 083 */ 084 PLACEHOLDER, 085 086 /** 087 * Surely not a scientific name of any kind. 088 */ 089 NO_NAME, 090 091 /** 092 * A name that has been flagged by the name parser due to the use of blacklisted epithets/words. 093 */ 094 BLACKLISTED; 095 096 /** 097 * Case insensitive lookup of a name type by its name that does not throw an exception but returns null 098 * for not found name types. 099 * 100 * @param nameType case insensitive name of name type 101 * 102 * @return the matching NameType or null 103 */ 104 public static NameType fromString(String nameType) { 105 if (StringUtils.isNotEmpty(nameType)) { 106 try { 107 return valueOf(nameType.toUpperCase().trim()); 108 } catch (IllegalArgumentException e) { 109 // swallow 110 } 111 } 112 return null; 113 } 114 115 /** 116 * @return true if the type of name is included in the GBIF backbone 117 */ 118 public boolean isBackboneType() { 119 return this == SCIENTIFIC || this == VIRUS || this == DOUBTFUL; 120 } 121 122 /** 123 * @return true if the GBIF name parser can parse such a name into a ParsedName instance 124 */ 125 public boolean isParsable() { 126 return this == SCIENTIFIC || this == INFORMAL || this == CULTIVAR || this == CANDIDATUS || this == DOUBTFUL || this == BLACKLISTED; 127 } 128 129}