Skip to content

Commit

Permalink
changelog and better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
gnefedev committed Apr 26, 2024
1 parent 2e80112 commit b518de7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
3 changes: 3 additions & 0 deletions changelogs/v4.6.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
different expression levels on the consensus assembly algorithm. This change is specifically important for single-cell
presets with cell-level assembly (most of the MiXCR presets for single-cell data).
- Export of trees and tree nodes now support imputed features
- Options `--dont-correct-tag-with-name <tag_name>` or `--dont-correct-tag-type (Molecule|Cell|Sample)` could be
specified to skip tag correction. It will degrade the overall quality of analysis, but will decrease memory
consumption

## 🛠️ Minor improvements & fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,13 @@ object CommandRefineTagsAndSort {

// Running correction, results are temporarily persisted in temp file, so the object can be used
// multiple time to perform the correction and stream corrected and filtered results
corrector.calculate()
try {
corrector.calculate()
} catch (e: Throwable) {
throw TagCorrectionError(
correctionEnabled.mapIndexedNotNull { i, b -> tagNames[i].takeIf { b } }, e
)
}

// Available after calculation finishes
mitoolReport = corrector.report
Expand Down Expand Up @@ -464,3 +470,6 @@ object CommandRefineTagsAndSort {
}
}
}

class TagCorrectionError(val tags: List<String>, cause: Throwable) :
RuntimeException("Error on tag correction of $tags", cause)
42 changes: 26 additions & 16 deletions src/main/kotlin/com/milaboratory/mixcr/cli/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.milaboratory.mixcr.cli.qc.CommandExportQcCoverage
import com.milaboratory.mixcr.cli.qc.CommandExportQcTags
import com.milaboratory.mixcr.clonegrouping.CellType
import com.milaboratory.mixcr.presets.Presets
import com.milaboratory.mixcr.presets.RefineTagsAndSortMixins
import com.milaboratory.mixcr.util.MiXCRVersionInfo
import com.milaboratory.util.NoSpaceOnDiskException
import com.milaboratory.util.TempFileManager
Expand Down Expand Up @@ -100,24 +101,33 @@ object Main {
exitProcess(execute(*args))
}

fun execute(vararg args: String): Int {
val commandLine = mkCmd(args)
try {
return commandLine.execute(*args)
} catch (e: OutOfMemoryError) {
if (logger.verbose) {
e.printStackTrace()
fun execute(vararg args: String): Int = try {
mkCmd(args).execute(*args)
} catch (e: OutOfMemoryError) {
if (logger.verbose) {
e.printStackTrace()
}
val memoryInOSMessage = memoryInOS()?.let { "${it / FileUtils.ONE_MB} Mb" }
val mb = Runtime.getRuntime().maxMemory() / FileUtils.ONE_MB
System.err.println("Not enough memory for run command. This run used approximately ${mb}m of memory, this machine has ${memoryInOSMessage ?: "unknown"} in total")
System.err.println()
System.err.println("Try to increase -Xmx. For example:")
System.err.println("mixcr -Xmx40g ${args.joinToString(" ")}")
val tagCorrectionError = e.suppressed.filterIsInstance<TagCorrectionError>().firstOrNull()
if (tagCorrectionError != null && tagCorrectionError.tags.isNotEmpty()) {
System.err.println()
System.err.println("Or try to disable correction for some tags. It will degrade the overall quality of analysis, but also will lover memory consumption. For example:")
(1..tagCorrectionError.tags.size).forEach { size ->
val tagOptions = tagCorrectionError.tags.take(size)
.flatMap { tag -> listOf(RefineTagsAndSortMixins.DontCorrectTagName.CMD_OPTION, tag) }
val optionsLeft = args.drop(1)
System.err.println("mixcr ${args.first()} ${(tagOptions + optionsLeft).joinToString(" ")}")
}
val memoryInOSMessage = memoryInOS()?.let { "${it / FileUtils.ONE_MB} Mb" }
System.err.println("Not enough memory for run command, try to increase -Xmx. Available memory: ${memoryInOSMessage ?: "unknown"}")
System.err.println("Example: `mixcr -Xmx40g ${args.joinToString(" ")}`")
val mb = Runtime.getRuntime().maxMemory() / FileUtils.ONE_MB
System.err.println("This run used approximately ${mb}m of memory")
return 2
} catch (e: Error) {
System.err.println("App version: " + MiXCRVersionInfo.get().shortestVersionString)
throw e
}
2
} catch (e: Error) {
System.err.println("App version: " + MiXCRVersionInfo.get().shortestVersionString)
throw e
}

private fun assertionsDisabled(): Boolean = System.getProperty("noAssertions") != null
Expand Down

0 comments on commit b518de7

Please sign in to comment.