Skip to content

Commit

Permalink
feat: --sample-table (SetSampleTable) mixin renamed to --sample-sheet…
Browse files Browse the repository at this point in the history
… (SetSampleSheet)

feat: case insensistive tag type deduction. Now "Cell" is valid tag name, not only "CELL".
feat: tagsValidation in align
fix: fixed grammar in PresetValidation
  • Loading branch information
dbolotin committed Jul 1, 2023
1 parent cc3c3b5 commit 4b5e5d1
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 40 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ val toObfuscate: Configuration by configurations.creating {

val obfuscationLibs: Configuration by configurations.creating

val mixcrAlgoVersion = "4.3.0-215-tiny-things"
val mixcrAlgoVersion = "4.3.0-219-final-440-fixes"
val milibVersion = "3.0.0-1-master"
val mitoolVersion = ""
val repseqioVersion = ""
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/com/milaboratory/mixcr/cli/CommandAlign.kt
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,10 @@ object CommandAlign {
// Tags
val tagsExtractor = getTagsExtractor(cmdParams, inputFileGroups)

// Validating output tags if required
for (tagsValidation in cmdParams.tagsValidations)
tagsValidation.validate(tagsExtractor.tagsInfo)

// true if final NSQTuple will have two reads, false otherwise
val pairedPayload = tagsExtractor.pairedPatternPayload
?: inputFileGroups.inputType.pairedRecords
Expand Down
18 changes: 0 additions & 18 deletions src/main/kotlin/com/milaboratory/mixcr/cli/CommandAlignPipeline.kt
Original file line number Diff line number Diff line change
Expand Up @@ -183,24 +183,6 @@ object CommandAlignPipeline {
)
}

// fun inferSampleTable(fileGroups: CommandAlign.InputFileGroups): CommandAlignParams.SampleTable {
// val sampleTagNames = fileGroups.tags.filter { TagType.detectByTagName(it) == TagType.Sample }
// return CommandAlignParams.SampleTable(
// sampleTagNames,
// fileGroups.fileGroups
// .map { fg -> sampleTagNames.map { fg.getTag(it) } }
// .toSortedSet(listComparator())
// .map { sample ->
// CommandAlignParams.SampleTable.Row(
// matchTags = sampleTagNames
// .mapIndexed { i, tn -> tn to sample[i] }
// .toMap(TreeMap()),
// sample = sample
// )
// }
// )
// }

sealed interface TagExtractor {
fun extract(
originalReadId: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ private val flagOptions = mapOf(
"${AlignMixins.AlignmentBoundaryConstants.RIGHT_RIGID_CMD_OPTION} [(${Labels.GENE_TYPE}|${Labels.ANCHOR_POINT})])",
Flags.TagPattern to "${AlignMixins.SetTagPattern.CMD_OPTION} <pattern>",
Flags.SampleTable to
"${AlignMixins.SetSampleTable.CMD_OPTION_FUZZY} sample_table.tsv\n" +
"${AlignMixins.SetSampleTable.CMD_OPTION_STRICT} sample_table.tsv",
"${AlignMixins.SetSampleSheet.CMD_OPTION_FUZZY} sample_table.tsv\n" +
"${AlignMixins.SetSampleSheet.CMD_OPTION_STRICT} sample_table.tsv",
)
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ val presetFlagsMessages = mapOf(
Flags.TagPattern to
"This preset requires to specify tag pattern, \n" +
"please use ${AlignMixins.SetTagPattern.CMD_OPTION} mix-in to set it, alternatively " +
"tag pattern can be provided with sample table using ${AlignMixins.SetSampleTable.CMD_OPTION_FUZZY} or " +
"${AlignMixins.SetSampleTable.CMD_OPTION_STRICT} mixin.",
"tag pattern can be provided with sample table using ${AlignMixins.SetSampleSheet.CMD_OPTION_FUZZY} or " +
"${AlignMixins.SetSampleSheet.CMD_OPTION_STRICT} mixin.",

Flags.SampleTable to
"This preset requires to specify sample table, \n" +
"please use ${AlignMixins.SetSampleTable.CMD_OPTION_FUZZY} or " +
"${AlignMixins.SetSampleTable.CMD_OPTION_STRICT} mix-in.",
"please use ${AlignMixins.SetSampleSheet.CMD_OPTION_FUZZY} or " +
"${AlignMixins.SetSampleSheet.CMD_OPTION_STRICT} mix-in.",
)


Expand Down
44 changes: 36 additions & 8 deletions src/main/kotlin/com/milaboratory/mixcr/cli/Mixins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,51 @@ class AlignMiXCRMixins : MiXCRMixinCollector() {

@Option(
description = ["Loads sample table from a tab separated file (one substitution will be allowed during matching)"],
names = [AlignMixins.SetSampleTable.CMD_OPTION_FUZZY],
names = [AlignMixins.SetSampleSheet.OLD_CMD_OPTION_FUZZY],
arity = "1",
paramLabel = "sample_table.tsv",
order = OptionsOrder.mixins.align + 330
hidden = true
)
fun sampleTableFuzzy(arg: String) =
mixIn(AlignMixins.SetSampleTable(arg, null, true))
fun sampleTableFuzzy(arg: String) {
println(
"Option ${AlignMixins.SetSampleSheet.OLD_CMD_OPTION_FUZZY}is deprecated. Use ${AlignMixins.SetSampleSheet.CMD_OPTION_FUZZY} instead."
)
mixIn(AlignMixins.SetSampleSheet(arg, null, true))
}

@Option(
description = ["Loads sample table from a tab separated file (one substitution will be allowed during matching)"],
names = [AlignMixins.SetSampleSheet.CMD_OPTION_FUZZY],
arity = "1",
paramLabel = "sample_sheet.tsv",
order = OptionsOrder.mixins.align + 330,
)
fun sampleSheetFuzzy(arg: String) =
mixIn(AlignMixins.SetSampleSheet(arg, null, true))

@Option(
description = ["Loads sample table from a tab separated file (strict matching will be used)."],
names = [AlignMixins.SetSampleTable.CMD_OPTION_STRICT],
names = [AlignMixins.SetSampleSheet.OLD_CMD_OPTION_STRICT],
arity = "1",
paramLabel = "sample_table.tsv",
order = OptionsOrder.mixins.align + 331
hidden = true
)
fun sampleTableStrict(arg: String) {
println(
"Option ${AlignMixins.SetSampleSheet.OLD_CMD_OPTION_STRICT}is deprecated. Use ${AlignMixins.SetSampleSheet.CMD_OPTION_STRICT} instead."
)
mixIn(AlignMixins.SetSampleSheet(arg, null, false))
}

@Option(
description = ["Loads sample table from a tab separated file (strict matching will be used)."],
names = [AlignMixins.SetSampleSheet.CMD_OPTION_STRICT],
arity = "1",
paramLabel = "sample_sheet.tsv",
order = OptionsOrder.mixins.align + 335
)
fun sampleTableStrict(arg: String) =
mixIn(AlignMixins.SetSampleTable(arg, null, false))
fun sampleSheetStrict(arg: String) =
mixIn(AlignMixins.SetSampleSheet(arg, null, false))

//
// Material type
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/presets/blocks/01-align.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ align-amplicon:
tagUnstranded: false
tagMaxBudget: 10
splitBySample: false
tagsValidations:
# Note: the following validation is applicable to all built-in presets in all cases.
# Validation is performed on the set of output tags. When sample tags are employed and splitBySample is set
# to true, these tags are used within the alignment step and don't appear in the output files. Therefore,
# the validation remains relevant and valid.
- type: MustNotContainTagType
tagType: Sample
parameters:
fixSeed: true
libraryStructure: Unknown
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/presets/protocols/generic-amplicon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ generic-amplicon:
upper: 0.05

generic-amplicon-with-umi:
mixins:
- type: AddTagsValidation
validation:
type: MustContainTagType
tagType: Molecule
inheritFrom: bundle-base
flags:
- species
Expand All @@ -57,9 +62,6 @@ generic-amplicon-with-umi:
- refineTagsAndSort
- assemble
- exportClones
validation:
- type: TagPatternShouldContainsTagName
tagName: UMI
align:
inheritFrom: align-amplicon
refineTagsAndSort:
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/presets/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@
"10x-vdj-tcr-qc-test":
inheritFrom: 10x-vdj-tcr
deprecation: "This preset is only for tests"
validation:
- type: TagPatternShouldContainsTagType
tagType: Cell
mixins:
- type: AddTagsValidation
validation:
type: MustContainTagType
tagType: Cell
qc:
checks:
- type: OffTargetReads
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/com/milaboratory/mixcr/MixinsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MixinsTest {
"S2\t^attagaca \\ ^attacaca(CELL1:NNNN)\tACCC\n" +
"S3\t^attagaca \\ ^gacatata(CELL1:NNNN)\tATTG\n" +
"S4\t^attagaca \\ ^gacatata(CELL1:NNNN)\tACCC\n"
val slMixin = AlignMixins.SetSampleTable(null, sampleList)
val slMixin = AlignMixins.SetSampleSheet(null, sampleList)
Assert.assertTrue(slMixin.packed)
TestUtil.assertJson(K_YAML_OM, slMixin, false)
val parsed = slMixin.parse()
Expand Down

0 comments on commit 4b5e5d1

Please sign in to comment.