Skip to content

Commit

Permalink
fathomnet/fathomnet-py#25 - prepping release
Browse files Browse the repository at this point in the history
  • Loading branch information
hohonuuli committed Feb 29, 2024
1 parent 0d061cf commit cf2b776
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/main/scala/org/fathomnet/worms/StateController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ object StateController:
else
candidate.map(c => {
val alternateNames = (outdated.flatMap(n => n.names) ++ c.alternateNames)
.filter(s => s != c.acceptedName)
.toSet
.toSeq
.sorted
Expand Down Expand Up @@ -138,15 +139,18 @@ object StateController:
)

def synonyms(name: String): Either[ErrorMsg, List[String]] =
def search(data: Data): List[String] =
data.findNodeByName(name) match
case None => Nil
case Some(node) => node.names.toList
for
node <- taxaInfo(name)
names <- findNamesByAphiaId(node.acceptedAphiaId)
yield
val alternativeNames = if (names.acceptedName == name)
names.alternateNames.toList
else
names.name :: names.alternateNames.toList

names.acceptedName +: alternativeNames.filter(s => s != names.acceptedName).distinct.sorted


runSearch(search).fold(
e => Left(e),
v => if (v.isEmpty) Left(NotFound(s"Unable to find `$name`")) else Right(v)
)

def descendantTaxa(name: String): Either[ErrorMsg, WormsNode] =
def search(data: Data): Option[WormsNode] =
Expand Down

0 comments on commit cf2b776

Please sign in to comment.