Skip to content

Commit

Permalink
Merge pull request #1244 from dsenalik/1243-chado_unabbreviate_infras…
Browse files Browse the repository at this point in the history
…pecific_rank

1243 chado unabbreviate infraspecific rank
  • Loading branch information
spficklin committed Feb 22, 2022
2 parents 9d95021 + 862b1ef commit c789988
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tripal_chado/api/modules/tripal_chado.organism.api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ function chado_abbreviate_infraspecific_rank($rank) {
case 'subvariety':
$abb = 'subvar.';
break;
case 'cultivar':
$abb = 'cv.';
break;
case 'forma':
$abb = 'f.';
break;
Expand All @@ -383,3 +386,41 @@ function chado_abbreviate_infraspecific_rank($rank) {
}
return $abb;
}

/**
* A handy function to expand the infraspecific rank from an abbreviation.
*
* @param $rank
* The rank below species or its abbreviation.
* A period at the end of the abbreviation is optional.
*
* @return
* The proper unabbreviated form for the rank.
*
* @ingroup tripal_organism_api
*/
function chado_unabbreviate_infraspecific_rank($rank) {
if (preg_match('/^subsp\.?$/', $rank)) {
$rank = 'subspecies';
}
elseif (preg_match('/^ssp\.?$/', $rank)) {
$rank = 'subspecies';
}
elseif (preg_match('/^var\.?$/', $rank)) {
$rank = 'varietas';
}
elseif (preg_match('/^subvar\.?$/', $rank)) {
$rank = 'subvarietas';
}
elseif (preg_match('/^cv\.?$/', $rank)) {
$rank = 'cultivar';
}
elseif (preg_match('/^f\.?$/', $rank)) {
$rank = 'forma';
}
elseif (preg_match('/^subf\.?$/', $rank)) {
$rank = 'subforma';
}
// if none of the above matched, rank is returned unchanged
return $rank;
}

0 comments on commit c789988

Please sign in to comment.