-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
096da5d
commit bff9a73
Showing
17 changed files
with
86 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/org/veupathdb/lib/cli/diamond/commands/DiamondCommandConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
package org.veupathdb.lib.cli.diamond.commands | ||
|
||
import com.fasterxml.jackson.annotation.JsonGetter | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize | ||
import org.veupathdb.lib.cli.diamond.DiamondCommand | ||
import org.veupathdb.lib.cli.diamond.util.DiamondCommandConfigDeserializer | ||
|
||
@JsonDeserialize(using = DiamondCommandConfigDeserializer::class) | ||
sealed interface DiamondCommandConfig { | ||
/** | ||
* Diamond subcommand. | ||
*/ | ||
@get:JsonGetter("tool") | ||
val tool: DiamondCommand | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mond/opts/output_format/BlastTabFormat.kt → ...ts/fields/output_format/BlastTabFormat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.veupathdb.lib.cli.diamond.opts.output_format | ||
package org.veupathdb.lib.cli.diamond.opts.fields.output_format | ||
|
||
class BlastTabFormat(override var formatFields: Iterable<FormatField> = emptyList()) | ||
: BlastTabFormatBase<Iterable<FormatField>>(OutputFormat.BlastTab) |
2 changes: 1 addition & 1 deletion
2
.../opts/output_format/BlastTabFormatBase.kt → ...ields/output_format/BlastTabFormatBase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mond/opts/output_format/FormatField.fn.kt → ...ts/fields/output_format/FormatField.fn.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...diamond/opts/output_format/FormatField.kt → .../opts/fields/output_format/FormatField.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mond/opts/output_format/JsonFlatFormat.kt → ...ts/fields/output_format/JsonFlatFormat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.veupathdb.lib.cli.diamond.opts.output_format | ||
package org.veupathdb.lib.cli.diamond.opts.fields.output_format | ||
|
||
class JsonFlatFormat(override var formatFields: Iterable<FormatField> = emptyList()) | ||
: BlastTabFormatBase<Iterable<FormatField>>(OutputFormat.BlastTab) |
2 changes: 1 addition & 1 deletion
2
.../opts/output_format/OutFormatFormatter.kt → ...ields/output_format/OutFormatFormatter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...iamond/opts/output_format/OutputFormat.kt → ...opts/fields/output_format/OutputFormat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...output_format/OutputFormatDeserializer.kt → ...output_format/OutputFormatDeserializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/output_format/OutputFormatOptions.fn.kt → ...s/output_format/OutputFormatOptions.fn.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...opts/output_format/OutputFormatOptions.kt → ...elds/output_format/OutputFormatOptions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../opts/output_format/SimpleOutputFormat.kt → ...ields/output_format/SimpleOutputFormat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/org/veupathdb/lib/cli/diamond/util/DiamondCommandConfigDeserializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.veupathdb.lib.cli.diamond.util | ||
|
||
import com.fasterxml.jackson.core.JsonParser | ||
import com.fasterxml.jackson.databind.DeserializationContext | ||
import com.fasterxml.jackson.databind.JsonDeserializer | ||
import com.fasterxml.jackson.databind.JsonMappingException | ||
import com.fasterxml.jackson.databind.node.ObjectNode | ||
import com.fasterxml.jackson.module.kotlin.contains | ||
import org.veupathdb.lib.cli.diamond.DiamondCommand | ||
import org.veupathdb.lib.cli.diamond.commands.DiamondCommandConfig | ||
import org.veupathdb.lib.cli.diamond.commands.impl.BlastPImpl | ||
import org.veupathdb.lib.cli.diamond.commands.impl.BlastXImpl | ||
import org.veupathdb.lib.jackson.Json | ||
|
||
internal class DiamondCommandConfigDeserializer : JsonDeserializer<DiamondCommandConfig>() { | ||
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): DiamondCommandConfig { | ||
val obj = p.readValueAs(ObjectNode::class.java) | ||
|
||
if ("tool" !in obj) | ||
throw JsonMappingException( | ||
p, | ||
"cannot deserialize given JSON into a DIAMOND command configuration; the given object has no \"tool\" property" | ||
) | ||
|
||
return when (DiamondCommand.fromJson(obj["tool"])) { | ||
DiamondCommand.BlastP -> Json.parse<BlastPImpl>(obj) | ||
DiamondCommand.BlastX -> Json.parse<BlastXImpl>(obj) | ||
else -> TODO("unsupported type") | ||
} | ||
} | ||
} |