-
Notifications
You must be signed in to change notification settings - Fork 9
demo: flip config to segment-then-reference #5701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
theosanderson
wants to merge
13
commits into
main
Choose a base branch
from
restructure
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,567
−982
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
dccbc09
restructure
theosanderson b0cfb66
update
theosanderson e12b6dd
fixup
theosanderson 44fbcf8
update
theosanderson ab00ab2
fixup
theosanderson cef9fb8
up
theosanderson bd24df4
fixup
theosanderson 9379f1d
fixup
theosanderson c5a74ee
upd
theosanderson 8498009
up
theosanderson 76c0de8
ok
theosanderson d2c2cee
ok
theosanderson 75e0d94
u
theosanderson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
102 changes: 65 additions & 37 deletions
102
kubernetes/loculus/templates/_merged-reference-genomes.tpl
This file contains hidden or 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,60 +1,88 @@ | ||
| {{- define "loculus.mergeReferenceGenomes" -}} | ||
| {{- $referenceGenomes := . -}} | ||
| {{- $segmentFirstConfig := . -}} | ||
| {{- $lapisNucleotideSequences := list -}} | ||
| {{- $lapisGenes := list -}} | ||
|
|
||
| {{- if len $referenceGenomes | eq 1 }} | ||
| {{- include "loculus.generateReferenceGenome" (first (values $referenceGenomes)) -}} | ||
| {{- else }} | ||
| {{- range $suborganismName, $referenceGenomeRaw := $referenceGenomes -}} | ||
| {{- $referenceGenome := include "loculus.generateReferenceGenome" $referenceGenomeRaw | fromYaml -}} | ||
| {{/* Handle empty reference genomes */}} | ||
| {{- if or (not $segmentFirstConfig) (eq (len $segmentFirstConfig) 0) -}} | ||
| {{- $result := dict "nucleotideSequences" (list) "genes" (list) -}} | ||
| {{- $result | toYaml -}} | ||
| {{- else -}} | ||
|
|
||
| {{- $nucleotideSequences := $referenceGenome.nucleotideSequences -}} | ||
| {{- if $nucleotideSequences -}} | ||
| {{- if eq (len $nucleotideSequences) 1 -}} | ||
| {{- $lapisNucleotideSequences = append $lapisNucleotideSequences (dict | ||
| "name" $suborganismName | ||
| "sequence" (first $nucleotideSequences).sequence) | ||
| -}} | ||
| {{- else -}} | ||
| {{- range $sequence := $nucleotideSequences -}} | ||
| {{- $lapisNucleotideSequences = append $lapisNucleotideSequences (dict | ||
| "name" (printf "%s-%s" $suborganismName $sequence.name) | ||
| "sequence" $sequence.sequence | ||
| {{/* Extract all unique reference names from the first segment */}} | ||
| {{- $referenceNames := list -}} | ||
| {{- $firstSegment := first (values $segmentFirstConfig) -}} | ||
| {{- $referenceNames = keys $firstSegment -}} | ||
|
|
||
| {{/* Check if this is single-reference mode (only one reference across all segments) */}} | ||
| {{- if eq (len $referenceNames) 1 -}} | ||
| {{/* Single reference mode - no prefixing */}} | ||
| {{- $singleRef := first $referenceNames -}} | ||
|
|
||
| {{/* Process each segment */}} | ||
| {{- range $segmentName, $refMap := $segmentFirstConfig -}} | ||
| {{- $refData := index $refMap $singleRef -}} | ||
| {{- if $refData -}} | ||
| {{/* Add nucleotide sequence */}} | ||
| {{- $lapisNucleotideSequences = append $lapisNucleotideSequences (dict | ||
| "name" $segmentName | ||
| "sequence" $refData.sequence | ||
| ) -}} | ||
|
|
||
| {{/* Add genes if present */}} | ||
| {{- if $refData.genes -}} | ||
| {{- range $geneName, $geneData := $refData.genes -}} | ||
| {{- $lapisGenes = append $lapisGenes (dict | ||
| "name" $geneName | ||
| "sequence" $geneData.sequence | ||
| ) -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- else -}} | ||
| {{/* Multi-reference mode - prefix with reference name */}} | ||
|
|
||
| {{/* Process each reference */}} | ||
| {{- range $refName := $referenceNames -}} | ||
| {{/* Process each segment */}} | ||
| {{- range $segmentName, $refMap := $segmentFirstConfig -}} | ||
| {{- $refData := index $refMap $refName -}} | ||
| {{- if $refData -}} | ||
| {{/* Add nucleotide sequence with reference prefix */}} | ||
| {{- $lapisNucleotideSequences = append $lapisNucleotideSequences (dict | ||
| "name" (printf "%s-%s" $refName $segmentName) | ||
| "sequence" $refData.sequence | ||
| ) -}} | ||
|
|
||
| {{- if $referenceGenome.genes -}} | ||
| {{- range $gene := $referenceGenome.genes -}} | ||
| {{- $lapisGenes = append $lapisGenes (dict | ||
| "name" (printf "%s-%s" $suborganismName $gene.name) | ||
| "sequence" $gene.sequence) | ||
| -}} | ||
| {{/* Add genes with reference prefix if present */}} | ||
| {{- if $refData.genes -}} | ||
| {{- range $geneName, $geneData := $refData.genes -}} | ||
| {{- $lapisGenes = append $lapisGenes (dict | ||
| "name" (printf "%s-%s" $refName $geneName) | ||
| "sequence" $geneData.sequence | ||
| ) -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- $result := dict "nucleotideSequences" $lapisNucleotideSequences "genes" $lapisGenes -}} | ||
| {{- $result | toYaml -}} | ||
| {{- end -}} | ||
|
|
||
| {{- $result := dict "nucleotideSequences" $lapisNucleotideSequences "genes" $lapisGenes -}} | ||
| {{- $result | toYaml -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
|
|
||
| {{- define "loculus.extractUniqueRawNucleotideSequenceNames" -}} | ||
| {{- $referenceGenomes := . -}} | ||
| {{- $segmentNames := list -}} | ||
| {{- $segmentFirstConfig := . -}} | ||
|
|
||
| {{- range $suborganismName, $referenceGenomeRaw := $referenceGenomes -}} | ||
| {{- $referenceGenome := include "loculus.generateReferenceGenome" $referenceGenomeRaw | fromYaml -}} | ||
|
|
||
| {{- range $sequence := $referenceGenome.nucleotideSequences -}} | ||
| {{- $segmentNames = append $segmentNames $sequence.name -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{/* Extract segment names directly from top-level keys */}} | ||
| {{- $segmentNames := keys $segmentFirstConfig -}} | ||
|
|
||
| segments: | ||
| {{- $segmentNames | uniq | toYaml | nindent 2 -}} | ||
| {{- $segmentNames | sortAlpha | toYaml | nindent 2 -}} | ||
| {{- end -}} | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh? I think this is also an error, we need to do this for every segment not just the first one... also I dont think we should add the reference as a prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goals of the current PR were just to support the current code/set up in a flipped form. There are a bunch of other changes (such as this) that would be needed to fully complete the feature for some organisms.