Skip to content

Commit

Permalink
Merge pull request #1755 from milaboratory/json-preset-export
Browse files Browse the repository at this point in the history
export preset as json
  • Loading branch information
gnefedev authored Aug 23, 2024
2 parents 23374f7 + 39d201c commit b0a1df4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
9 changes: 9 additions & 0 deletions itests/case-export_preset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ mixcr exportPreset --mixcr-file result.clns original_from_file.yaml
if ! cmp original_from_param.yaml original_from_file.yaml; then
diff original_from_param.yaml original_from_file.yaml
fi

# json is working
mixcr exportPreset --preset-name test-tcr-shotgun \
--assemble-clonotypes-by CDR3 \
--species hs \
--rna \
--floating-left-alignment-boundary \
--floating-right-alignment-boundary J\
original_from_param.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.milaboratory.mixcr.presets.MiXCRParams
import com.milaboratory.mixcr.presets.MiXCRParamsBundle
import com.milaboratory.mixcr.presets.MiXCRParamsSpec
import com.milaboratory.util.K_YAML_OM
import com.mixcr.util.K_JSON_OM
import io.repseq.core.VDJCLibraryRegistry
import picocli.CommandLine.ArgGroup
import picocli.CommandLine.Command
Expand Down Expand Up @@ -97,7 +98,7 @@ class CommandExportPreset : MiXCRCommandWithOutputs(), MiXCRPresetAwareCommand<U
)
private var outputFile: Path? = null
set(value) {
ValidationException.requireFileType(value, InputFileType.YAML)
ValidationException.requireFileType(value, InputFileType.YAML, InputFileType.JSON)
field = value
}

Expand Down Expand Up @@ -224,11 +225,12 @@ class CommandExportPreset : MiXCRCommandWithOutputs(), MiXCRPresetAwareCommand<U
validate = !noValidation
).first

val of = outputFile
if (of != null)
K_YAML_OM.writeValue(of.toFile(), bundle)
else
K_YAML_OM.writeValue(System.out, bundle)
val outputFile = outputFile
when {
outputFile == null -> K_YAML_OM.writeValue(System.out, bundle)
InputFileType.JSON.matches(outputFile) -> K_JSON_OM.writeValue(outputFile.toFile(), bundle)
else -> K_YAML_OM.writeValue(outputFile.toFile(), bundle)
}
}

override val paramsResolver: ParamsResolver<MiXCRParamsBundle, Unit>
Expand Down

0 comments on commit b0a1df4

Please sign in to comment.