Skip to content

Commit

Permalink
refactor: remove remains of pango_lineage from source code
Browse files Browse the repository at this point in the history
  • Loading branch information
Taepper committed Jan 15, 2025
1 parent 34aba5c commit a05ff33
Show file tree
Hide file tree
Showing 15 changed files with 9 additions and 63 deletions.
3 changes: 0 additions & 3 deletions backend/src/main/kotlin/org/loculus/backend/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ enum class MetadataType {
@JsonProperty("date")
DATE,

@JsonProperty("pango_lineage")
PANGO_LINEAGE,

@JsonProperty("boolean")
BOOLEAN,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import java.time.format.DateTimeFormatter
import java.time.format.DateTimeParseException

private const val DATE_FORMAT = "yyyy-MM-dd"
private const val PANGO_LINEAGE_REGEX_PATTERN = "[a-zA-Z]{1,3}(\\.\\d{1,3}){0,3}"
private val pangoLineageRegex = Regex(PANGO_LINEAGE_REGEX_PATTERN)

interface Symbol {
val symbol: Char
Expand Down Expand Up @@ -100,9 +98,6 @@ private fun <T> validateNoUnknownInMetaData(data: Map<String, T>, known: List<St
}
}

private fun isValidPangoLineage(pangoLineageCandidate: String): Boolean =
pangoLineageCandidate.matches(pangoLineageRegex)

private fun validateKnownMetadataField(metadata: BaseMetadata, processedMetadataMap: MetadataMap): MetadataMap {
val fieldName = metadata.name
val fieldValue = processedMetadataMap[fieldName]
Expand Down Expand Up @@ -141,17 +136,6 @@ private fun validateType(fieldValue: JsonNode, metadata: BaseMetadata) {
return
}

MetadataType.PANGO_LINEAGE -> {
if (!isValidPangoLineage(fieldValue.asText())) {
throw ProcessingValidationException(
"Expected type 'pango_lineage' for field '${metadata.name}', " +
"found value '$fieldValue'. " +
"A pango lineage must be of the form $PANGO_LINEAGE_REGEX_PATTERN, e.g. 'XBB' or 'BA.1.5'.",
)
}
return
}

else -> {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,6 @@ object PreparedProcessedData {
),
)

fun withWrongPangoLineageFormat(accession: Accession) = defaultSuccessfulSubmittedData.copy(
accession = accession,
data = defaultProcessedData.copy(
metadata = defaultProcessedData.metadata + mapOf(
"pangoLineage" to TextNode("A.5.invalid"),
),
),
)

fun withWrongBooleanFormat(accession: Accession) = defaultSuccessfulSubmittedData.copy(
accession = accession,
data = defaultProcessedData.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,6 @@ class SubmitProcessedDataEndpointTest(
expectedErrorMessage =
"Expected type 'boolean' for field 'booleanColumn', found value '\"not a boolean\"'.",
),
InvalidDataScenario(
name = "data with wrong pango lineage format",
processedDataThatNeedsAValidAccession = PreparedProcessedData.withWrongPangoLineageFormat(
accession = "DoesNotMatter",
),
expectedErrorMessage =
"Expected type 'pango_lineage' for field 'pangoLineage', found value '\"A.5.invalid\"'. " +
"A pango lineage must be of the form [a-zA-Z]{1,3}(\\.\\d{1,3}){0,3}, e.g. 'XBB' or 'BA.1.5'.",
),
InvalidDataScenario(
name = "data with explicit null for required field",
processedDataThatNeedsAValidAccession = PreparedProcessedData.withNullForFields(
Expand Down
4 changes: 2 additions & 2 deletions backend/src/test/resources/backend_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},
{
"name": "pangoLineage",
"type": "pango_lineage",
"type": "string",
"autocomplete": true
},
{
Expand Down Expand Up @@ -172,7 +172,7 @@
},
{
"name": "pangoLineage",
"type": "pango_lineage",
"type": "string",
"autocomplete": true
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},
{
"name": "pangoLineage",
"type": "pango_lineage",
"type": "string",
"autocomplete": true
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ organisms:
type: string
autocomplete: true
- name: pangoLineage
type: pango_lineage
type: string
autocomplete: true
required: true
- name: insdcAccessionFull
Expand Down
4 changes: 0 additions & 4 deletions kubernetes/loculus/templates/lapis-silo-database-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ data:

preprocessing_config.yaml: |
ndjsonInputFilename: data.ndjson.zst
pangoLineageDefinitionFilename: pangolineage_alias.json
referenceGenomeFilename: reference_genomes.json
reference_genomes.json: |
Expand All @@ -32,7 +31,4 @@ data:
silo_import_wrapper.sh: |
{{ range $importScriptWrapperLines }}
{{ . }}{{ end }}
pangolineage_alias.json: |
{{ $instance.pangolineage_alias | default dict | toJson }}
{{- end }}
3 changes: 0 additions & 3 deletions kubernetes/loculus/templates/lapis-silo-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ spec:
- name: lapis-silo-database-config-processed
mountPath: /preprocessing/input/reference_genomes.json
subPath: reference_genomes.json
- name: lapis-silo-database-config-processed
mountPath: /preprocessing/input/pangolineage_alias.json
subPath: pangolineage_alias.json
- name: lapis-silo-database-config-processed
mountPath: /preprocessing/input/database_config.yaml
subPath: database_config.yaml
Expand Down
1 change: 0 additions & 1 deletion preprocessing/specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ The `metadata` field should contain a flat object consisting of the fields speci
- `int` (integer)
- `float`
- `date` (supplied as a string with complete ISO-8601 date, e.g., "2023-08-30")
- `pango_lineage` (supplied as a string with a properly formatted SARS-CoV-2 Pango lineage, e.g., "B.1.1.7")
- `authors` (comma separated list of authors, treated as a string in the current prepro pipeline)

#### Sequences
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/SearchPage/SearchForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const defaultSearchFormFilters: MetadataFilter[] = [
},
{
name: 'field3',
type: 'pango_lineage',
type: 'string',
label: 'Field 3',
autocomplete: true,
initiallyVisible: true,
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/SearchPage/SearchFullUI.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const defaultSearchFormFilters: MetadataFilter[] = [
},
{
name: 'field3',
type: 'pango_lineage',
type: 'string',
label: 'Field 3',
autocomplete: true,
initiallyVisible: true,
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/SearchPage/fields/FieldProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export type FieldProps = {
onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
fieldValue: string;
type?: 'string' | 'boolean' | 'float' | 'int' | 'pango_lineage' | 'authors';
type?: 'string' | 'boolean' | 'float' | 'int' | 'authors';
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type NormalFieldProps = {
onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
fieldValue: string | number;
type?: 'string' | 'boolean' | 'float' | 'int' | 'pango_lineage' | 'authors';
type?: 'string' | 'boolean' | 'float' | 'int' | 'authors';
};

export const NormalTextField = forwardRef<HTMLInputElement, NormalFieldProps>((props, ref) => {
Expand Down
11 changes: 1 addition & 10 deletions website/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@ import { mutationProportionCount, orderByType } from './lapis.ts';
import { referenceGenomes } from './referencesGenomes.ts';

// These metadata types need to be kept in sync with the backend config class `MetadataType` in Config.kt
const metadataPossibleTypes = z.enum([
'string',
'date',
'int',
'float',
'pango_lineage',
'timestamp',
'boolean',
'authors',
] as const);
const metadataPossibleTypes = z.enum(['string', 'date', 'int', 'float', 'timestamp', 'boolean', 'authors'] as const);

export const segmentedMutations = z.object({
segment: z.string(),
Expand Down

0 comments on commit a05ff33

Please sign in to comment.