Skip to content

Commit

Permalink
Update the version of Mill and fixup all compiler warnings (#36)
Browse files Browse the repository at this point in the history
* Update the version of Mill and fixup all compiler warnings

* Generate docs files

---------

Co-authored-by: Nobody <[email protected]>
  • Loading branch information
clintval and Nobody authored Apr 10, 2024
1 parent 3994076 commit e4f968b
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
.idea_modules
.java-version
out
jars
project
Expand All @@ -8,3 +9,4 @@ target
.metals
.vscode
.bsp
*.iml
70 changes: 58 additions & 12 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,58 @@ trait CommonModule extends SbtModule {
os.copy(assembly.path, os.pwd / Symbol("jars") / jarName, replaceExisting = true)
}

override def repositories: Seq[coursier.Repository] = super.repositories ++ Seq(
MavenRepository("https://oss.sonatype.org/content/repositories/public"),
MavenRepository("https://oss.sonatype.org/content/repositories/snapshots"),
MavenRepository("https://jcenter.bintray.com/"),
MavenRepository("https://broadinstitute.jfrog.io/artifactory/libs-snapshot/")
)
override def repositoriesTask: Task[Seq[coursier.Repository]] = T.task {
super.repositoriesTask() ++ Seq(
MavenRepository("https://oss.sonatype.org/content/repositories/public"),
MavenRepository("https://oss.sonatype.org/content/repositories/snapshots"),
MavenRepository("https://jcenter.bintray.com/"),
MavenRepository("https://broadinstitute.jfrog.io/artifactory/libs-snapshot/")
)
}

/** All Scala compiler options for this package. */
override def scalacOptions: T[Seq[String]] = T {
Seq(
"-opt:inline:com.fulcrumgenomics.**", // Turn on the inliner.
"-opt-inline-from:com.fulcrumgenomics.**", // Tells the inliner that it is allowed to inline things from these classes.
"-Yopt-log-inline", "_", // Optional, logs the inliner activity so you know it is doing something.
"-Yopt-inline-heuristics:at-inline-annotated", // Tells the inliner to use your `@inliner` tags.
"-opt-warnings:at-inline-failed", // Tells you if methods marked with `@inline` cannot be inlined, so you can remove the tag.
// The following are sourced from https://nathankleyn.com/2019/05/13/recommended-scalac-flags-for-2-13/
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
"-Xfatal-warnings", // Fail the compilation if there are any warnings.
"-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver.
"-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error.
"-Xlint:delayedinit-select", // Selecting member of DelayedInit.
"-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element.
"-Xlint:inaccessible", // Warn about inaccessible types in method signatures.
"-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`.
"-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id.
"-Xlint:nullary-unit", // Warn when nullary methods return Unit.
"-Xlint:option-implicit", // Option.apply used implicit view.
"-Xlint:package-object-classes", // Class or object defined in package object.
"-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds.
"-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field.
"-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component.
"-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope.
"-Ywarn-dead-code", // Warn when dead code is identified.
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
"-Ywarn-numeric-widen", // Warn when numerics are widened.
"-Ywarn-unused:implicits", // Warn if an implicit parameter is unused.
"-Ywarn-unused:imports", // Warn if an import selector is not referenced.
"-Ywarn-unused:locals", // Warn if a local definition is unused.
"-Ywarn-unused:params", // Warn if a value parameter is unused.
"-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused.
"-Ywarn-unused:privates", // Warn if a private member is unused.
"-Ybackend-parallelism", Math.min(Runtime.getRuntime.availableProcessors(), 8).toString, // Enable parallelization — scalac max is 16.
"-Ycache-plugin-class-loader:last-modified", // Enables caching of classloaders for compiler plugins
"-Ycache-macro-class-loader:last-modified", // and macro definitions. This can lead to performance improvements.
)
}
}

/** A base trait for versioning modules. */
Expand Down Expand Up @@ -69,11 +115,11 @@ trait ReleaseModule extends JavaModule {


object tools extends CommonModule with PublishModule with ReleaseModule {
def scalaVersion = "2.13.8"
def scalaVersion = "2.13.11"
override def millSourcePath = super.millSourcePath / os.up
override def mainClass = Some("com.fulcrumgenomics.sv.cmdline.SvMain")
override def artifactName = "fgsv"
def gitHash = Process("git rev-parse --short HEAD").lineStream.head
def gitHash = Process("git rev-parse --short HEAD").lazyLines.head
def publishVersion = s"0.1.0-${gitHash}-SNAPSHOT"
def pomSettings = PomSettings(
description = artifactName(),
Expand All @@ -96,12 +142,12 @@ object tools extends CommonModule with PublishModule with ReleaseModule {

override def ivyDeps = Agg(
ivy"org.scala-lang:scala-compiler:${scalaVersion()}",
ivy"com.fulcrumgenomics:fgbio_2.13:2.1.0".excludeOrg(orgsToExclude:_*)
ivy"com.fulcrumgenomics:fgbio_2.13:2.2.1".excludeOrg(orgsToExclude:_*)
)

object test extends Tests {
override def ivyDeps = Agg(ivy"org.scalatest::scalatest:3.1.0")
override def testFramework = "org.scalatest.tools.Framework"
object test extends SbtModuleTests {
override def ivyDeps = Agg(ivy"org.scalatest::scalatest:3.2.17")
override def testFramework: Target[String] = T { "org.scalatest.tools.Framework" }

// run mill tools.test.singleTest com.fulcrumgenomics.sv.x.y.x.TestClassName
def singleTest(args: String*) = T.command {
Expand Down
1 change: 0 additions & 1 deletion docs/tools/FilterAndMerge.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Filters and merges SVPileup output.
|----|----|----|-----------|---------|---------------|----------------|
|input|i|FilePath|The input pileup file from SvPileup|Required|1||
|output|o|FilePath|The output filtered and merged SvPileup file|Required|1||
|dict|d|PathToSequenceDictionary|The path to the reference sequence dictionary.|Required|1||
|min-pre|m|Int|The minimum # of observations to examine an input site|Optional|1|1|
|min-post|M|Int|The minimum # of observations to output a site|Optional|1|1|
|slop|s|Int|The maximum # bases between a breakend across adjacent sites|Optional|1|0|
Expand Down
2 changes: 1 addition & 1 deletion docs/tools/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: fgsv tools

# fgsv tools

The following tools are available in fgsv version 0.1.1-b1923e1.
The following tools are available in fgsv version 0.1.1-836bce0.
## All tools

All tools.
Expand Down
2 changes: 1 addition & 1 deletion mill
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This is a wrapper script, that automatically download mill from GitHub release pages
# You can give the required mill version with MILL_VERSION env variable
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
DEFAULT_MILL_VERSION=0.10.4
DEFAULT_MILL_VERSION=0.11.7

set -e

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ class FgSvMetricsDoclet extends FgMetricsDoclet {

find(universe.rootPackage)
.filter(d => d.isClass && !d.isAbstract)
.filter(d => d.parentTypes.exists { case (template, typ) => template.toString == classOf[Metric].getName })
.filter(d => d.parentTypes.exists { case (template, _) => template.toString == classOf[Metric].getName })
}

/** Take the body of a scaladoc comment and renders it into MarkDown. */
override protected def renderBody(body: Body): String = {
val buffer = new StringBuilder

// Takes a block element and renders it into MarkDown and writes it into the buffer
def renderBlock(block: Block, indent: String): Unit = {
def renderBlock(block: Block): Unit = {
(block: @unchecked) match {
case para: Paragraph => render(para.text)
case dlist: DefinitionList => () // TODO
case hr: HorizontalRule => () // TODO
case olist: OrderedList => () // TODO
case title: Title => buffer.append("#" * title.level).append(" "); render(title.text); buffer.append("\n\n")
case ulist: UnorderedList => () // TODO
case para: Paragraph => render(para.text)
case _: DefinitionList => () // TODO
case _: HorizontalRule => () // TODO
case _: OrderedList => () // TODO
case title: Title => buffer.append("#" * title.level).append(" "); render(title.text); buffer.append("\n\n")
case _: UnorderedList => () // TODO
}
}

Expand All @@ -120,7 +120,7 @@ class FgSvMetricsDoclet extends FgMetricsDoclet {
case under: Underline => buffer.append("__"); render(under.text); buffer.append("__")
}

body.blocks.foreach(renderBlock(_, ""))
body.blocks.foreach(renderBlock)
buffer.toString()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ case class AggregatedBreakpointPileup(id: String,
)
numOverlap match {
case None => None
case Some(n) => Some(total.toDouble / n, n)
case Some(n) => Some((total.toDouble / n, n))
}
}
val leftResult = frequency_and_count(left_contig, left_pileups, left_min_pos, left_max_pos)
Expand Down Expand Up @@ -457,10 +457,6 @@ case class AggregatedBreakpointPileup(id: String,
right_targets = if (rightOverlapNames.isEmpty) None else Some(rightOverlapNames.mkString(",")),
)
}

private def overlapsTarget(contig: String, start: Int, end: Int, targets: OverlapDetector[BEDFeature]): Boolean = {
targets.overlapsAny(new Interval(contig, start, end))
}
}


Expand Down Expand Up @@ -512,5 +508,5 @@ class PositionList(val positions: Seq[Int]) {

object PositionList {
def apply(positions: Int*): PositionList = new PositionList(positions)
def apply(s: String): PositionList = new PositionList(s.split(",").map(_.toInt))
def apply(s: String): PositionList = new PositionList(s.split(",").map(_.toInt).toIndexedSeq)
}
12 changes: 4 additions & 8 deletions src/main/scala/com/fulcrumgenomics/sv/tools/FilterAndMerge.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package com.fulcrumgenomics.sv.tools

import com.fulcrumgenomics.FgBioDef._
import com.fulcrumgenomics.commons.collection.BetterBufferedIterator
import com.fulcrumgenomics.commons.util.{NumericCounter, SimpleCounter}
import com.fulcrumgenomics.fasta.SequenceDictionary
import com.fulcrumgenomics.commons.util.NumericCounter
import com.fulcrumgenomics.sopt.{arg, clp}
import com.fulcrumgenomics.sv.cmdline.{ClpGroups, SvTool}
import com.fulcrumgenomics.sv.{BreakpointPileup, EvidenceType}
import com.fulcrumgenomics.sv.BreakpointPileup
import com.fulcrumgenomics.util.{Io, Metric}

import scala.collection.immutable.IndexedSeq
Expand All @@ -18,7 +17,6 @@ import scala.collection.immutable.IndexedSeq
class FilterAndMerge
( @arg(flag='i', doc="The input pileup file from SvPileup") input: FilePath,
@arg(flag='o', doc="The output filtered and merged SvPileup file") output: FilePath,
@arg(flag='d', doc="The path to the reference sequence dictionary.") dict: PathToSequenceDictionary,
@arg(flag='m', doc="The minimum # of observations to examine an input site") minPre: Int = 1,
@arg(flag='M', doc="The minimum # of observations to output a site") minPost: Int = 1,
@arg(flag='s', doc="The maximum # bases between a breakend across adjacent sites") slop: Int = 0,
Expand All @@ -28,8 +26,6 @@ class FilterAndMerge
Io.assertCanWriteFile(output)

override def execute(): Unit = {
val dict = SequenceDictionary(this.dict)

// Read in the pileups
val iter = Metric.iterator[BreakpointPileup](input)
.filter(_.total >= minPre)
Expand Down Expand Up @@ -117,12 +113,12 @@ object MergedPileup {
left_contig = pileups.head.left_contig,
left_start = pileups.map(_.left_pos).min,
left_end = pileups.map(_.left_pos).max,
left_mean = Math.round(leftMean),
left_mean = Math.round(leftMean.toFloat),
left_strand = pileups.head.left_strand,
right_contig = pileups.head.right_contig,
right_start = pileups.map(_.right_pos).min,
right_end = pileups.map(_.right_pos).max,
right_mean = Math.round(rightMean),
right_mean = Math.round(rightMean.toFloat),
right_strand = pileups.head.right_strand,
mean_count = meanCount,
stddev_count = counts.stddev(meanCount),
Expand Down
3 changes: 2 additions & 1 deletion src/test/scala/com/fulcrumgenomics/sv/UnitSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package com.fulcrumgenomics.sv
import com.fulcrumgenomics.FgBioDef.PathToBam
import com.fulcrumgenomics.bam.api.{SamRecord, SamSource}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.{Matchers, OptionValues}
import org.scalatest.OptionValues
import org.scalatest.matchers.should._

import java.nio.file.{Files, Path}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class SvPileupTest extends UnitSpec {
// Objects and functions used in testing findBreakpoint()
//////////////////////////////////////////////////////////////////////////////
private val builder = {
val seqs = (Range.inclusive(1, 22) ++ Seq("X", "Y")).map { chr =>
val seqs = (Range.inclusive(1, 22).map(_.toString) ++ Seq("X", "Y")).map { chr =>
SequenceMetadata(name="chr" + chr, length=200e6.toInt)
} ++ Seq(SequenceMetadata(name="chrM", length=16000, topology = Some(Topology.Circular)))
new SamBuilder(readLength=100, sd=Some(SequenceDictionary(seqs:_*)))
Expand Down Expand Up @@ -435,8 +435,8 @@ class SvPileupTest extends UnitSpec {
val prefix = makeTempFile("output", "")
Outputs(
prefix = prefix,
bam = PathUtil.pathTo(prefix + ".bam"),
txt = PathUtil.pathTo(prefix + ".txt")
bam = PathUtil.pathTo(prefix.toString + ".bam"),
txt = PathUtil.pathTo(prefix.toString + ".txt")
)
}
}
Expand Down Expand Up @@ -473,8 +473,6 @@ class SvPileupTest extends UnitSpec {
}

val leftFromTag = s"0;left;from;${SplitRead.snakeName}"
val rightFromTag = s"0;right;from;${SplitRead.snakeName}"
val leftIntoTag = f"0;left;into;${SplitRead.snakeName}"
val rightIntoTag = f"0;right;into;${SplitRead.snakeName}"

// r1Half2 is not annotated, since it is superseded by r1Half1 -> fullR2
Expand Down

0 comments on commit e4f968b

Please sign in to comment.