Skip to content

Commit

Permalink
1.1.2
Browse files Browse the repository at this point in the history
handle paraphyly more gracefully
  • Loading branch information
d-shapiro committed Jun 22, 2019
1 parent 2cd0be5 commit 710a315
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "wikiClade"

version := "1.1.1"
version := "1.1.2"

scalaVersion := "2.12.8"

Expand Down
14 changes: 12 additions & 2 deletions src/main/scala/cladograms/WikiClade.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,33 @@ abstract class WikiClade extends Clade {

def priorityOverride: Double

case class WikiCladeMetadata(trueName: String, ancestors: List[Clade], path: Option[String], cladeType: String, docPriority: Double)
case class WikiCladeMetadata(trueName: String, ancestors: List[Clade], path: Option[String], cladeType: String,
docPriority: Double, paraphyletic: Boolean = false)

override def DOTDefinition: Option[String] = {
val cladeTypeStr = if (meta.cladeType.isEmpty) "" else s"""<FONT POINT-SIZE=\"10\">${meta.cladeType}</FONT><br/>"""
val hrefStr = meta.path match {
case None => ""
case Some(p) => s"""href="${WikiClade.baseUrl}${p.replaceAll("&", "&amp;")}","""
}
val asterisk = if (meta.paraphyletic) "*" else ""
val dispname =
if (meta.trueName == name) name
else s"${meta.trueName}<br/>($name)"
else s"${meta.trueName}<br/>($name)$asterisk"
Some(s""""$name" [$hrefStr label=<$cladeTypeStr<B>$dispname</B>>]""")
}

def priority: Double = Math.min(
Math.min(priorityOverride, meta.docPriority),
if (WikiClade.importantCladeTypes contains meta.cladeType) 20 else 100)

def canEqual(obj: Any): Boolean = obj.isInstanceOf[WikiClade]
override def equals(obj: Any): Boolean = obj match {
case obj: WikiClade => obj.canEqual(this) && this.meta.trueName == obj.meta.trueName
case _ => false
}

override def hashCode(): Int = meta.trueName.hashCode
}

object WikiClade {
Expand Down
11 changes: 2 additions & 9 deletions src/main/scala/cladograms/WikiPageClade.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class WikiPageClade(val name: String, path: Option[String], val priorityOverride
else WikiClade.newClade(details.name, Some(details.path))
}
val docPriority = priorityBasedOnDoc(docOpt)
WikiCladeMetadata(mydetails.name ,ancestors, path, WikiClade.sanitizeCladeType(mydetails.cladeType), docPriority)
WikiCladeMetadata(mydetails.name ,ancestors, path, WikiClade.sanitizeCladeType(mydetails.cladeType), docPriority,
mydetails.path.nonEmpty && !mydetails.cladeType.contains("pecies"))
}

private def extractTaxonomy(elems: Elements): List[TaxonDetails] = {
Expand Down Expand Up @@ -95,14 +96,6 @@ class WikiPageClade(val name: String, path: Option[String], val priorityOverride
case None => 99
}

def canEqual(obj: Any): Boolean = obj.isInstanceOf[WikiPageClade]
override def equals(obj: Any): Boolean = obj match {
case obj: WikiPageClade => obj.canEqual(this) && this.meta.trueName == obj.meta.trueName
case _ => false
}

override def hashCode(): Int = meta.trueName.hashCode

private def taxonDetails(name: String, cladeType: String, path: String): TaxonDetails = {
TaxonDetails(name, cladeType, false, path, "")
}
Expand Down
8 changes: 0 additions & 8 deletions src/main/scala/cladograms/WikiTaxoboxClade.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,4 @@ class WikiTaxoboxClade(val name: String, taxonomyPath: Option[String], details:
}
iter(elems.size() - 1, List())
}

def canEqual(obj: Any): Boolean = obj.isInstanceOf[WikiTaxoboxClade]
override def equals(obj: Any): Boolean = obj match {
case obj: WikiTaxoboxClade => obj.canEqual(this) && this.meta.trueName == obj.meta.trueName
case _ => false
}

override def hashCode(): Int = meta.trueName.hashCode
}

0 comments on commit 710a315

Please sign in to comment.