RankUtils { public static Rank inferRank(String rankMarker) { if (rankMarker != null) { return RANK_MARKER_MAP.get(NORMALIZE_RANK_MARKER.matcher(rankMarker.toLowerCase()).replaceAll("")); } return null; }  static Rank inferRank(String rankMarker); static Rank inferRank(LinneanName pn); static final List<Rank> INFRASUBSPECIFIC_MICROBIAL_RANKS; static final Map<String, Rank> RANK_MARKER_MAP_FAMILY_GROUP; static final Map<String, Rank> RANK_MARKER_MAP_SUPRAGENERIC; static final Map<String, Rank> RANK_MARKER_MAP_INFRAGENERIC; static final Map<String, Rank> RANK_MARKER_MAP_SPECIFIC; static final Map<String, Rank> RANK_MARKER_MAP_INFRASPECIFIC; static final Map<String, Rank> RANK_MARKER_MAP; static final Map<NomCode, Map<String, Rank>> SUFFICES_RANK_MAP; }
@Test public void testInferRank() { assertInferred("Asteraceae", NomCode.BOTANICAL, Rank.FAMILY); assertInferred("Asteraceae", null, Rank.FAMILY); assertInferred("Asteraceae", NomCode.ZOOLOGICAL, Rank.UNRANKED); assertInferred("Magnoliophyta", NomCode.BOTANICAL, Rank.PHYLUM); assertInferred("Fabales", NomCode.BOTANICAL, Rank.ORDER); assertInferred("Hominidae", NomCode.ZOOLOGICAL, Rank.FAMILY); assertInferred("Drosophilinae", NomCode.ZOOLOGICAL, Rank.SUBFAMILY); assertInferred("Agaricomycetes", NomCode.BOTANICAL, Rank.CLASS); assertInferred("Agaricomycetes", null, Rank.CLASS); assertInferred("Woodsioideae", null, Rank.SUBFAMILY); assertInferred("Antrophyoideae", null, Rank.SUBFAMILY); assertInferred("Protowoodsioideae", null, Rank.SUBFAMILY); assertInferred("Negarnaviricota", NomCode.VIRUS, Rank.PHYLUM); assertInferred("Negarnaviricota", null, Rank.PHYLUM); assertInferred("Picornavirales", null, Rank.ORDER); assertInferred("Riboviria", null, Rank.REALM); assertEquals(Rank.SPECIES, RankUtils.inferRank(build("Abies","Abies", "alba"))); assertEquals(Rank.SPECIES, RankUtils.inferRank(build("Abies", null, "alba"))); assertEquals(Rank.INFRAGENERIC_NAME, RankUtils.inferRank(build(null, "Abies", null))); assertEquals(Rank.INFRAGENERIC_NAME, RankUtils.inferRank(build("", "Abies", null))); assertEquals(Rank.SUBFAMILY, RankUtils.inferRank(build("Neurolaenodinae", null, null, NomCode.ZOOLOGICAL))); assertEquals(Rank.UNRANKED, RankUtils.inferRank(build("Compositae", null, null, NomCode.BOTANICAL))); }
@Test public void testInferRank2() { for (Rank r : Rank.values()) { if (r.getMarker() != null) { assertEquals(r.getMarker(), r, RankUtils.inferRank(r.getMarker())); } } }
@Test public void testRankMarkers() { for (Rank r : Rank.values()) { if (r.notOtherOrUnranked() && r != Rank.CULTIVAR_GROUP) { assertEquals(r, RankUtils.inferRank(r.getMarker())); assertEquals(r, RankUtils.inferRank("notho"+r.getMarker())); } } }