GEN-1: export genotypeToFarbschlag for DATA-1 denormalization contract
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
|||||||
wildType,
|
wildType,
|
||||||
} from '../genotype'
|
} from '../genotype'
|
||||||
import { combineLocus } from '../punnett'
|
import { combineLocus } from '../punnett'
|
||||||
import { farbschlagFor, CATALOG_SIZE } from '../catalog'
|
import { farbschlagFor, genotypeToFarbschlag, CATALOG_SIZE } from '../catalog'
|
||||||
import { breed } from '../breed'
|
import { breed } from '../breed'
|
||||||
import { GeneticsWarningCode } from '../warnings'
|
import { GeneticsWarningCode } from '../warnings'
|
||||||
|
|
||||||
@@ -169,6 +169,14 @@ describe('Farbschlag catalog', () => {
|
|||||||
it('has the expected catalogue coverage', () => {
|
it('has the expected catalogue coverage', () => {
|
||||||
expect(CATALOG_SIZE).toBe(18)
|
expect(CATALOG_SIZE).toBe(18)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('genotypeToFarbschlag (DATA-1 denormalization contract) returns the plain name', () => {
|
||||||
|
expect(genotypeToFarbschlag(wildType())).toBe('Agouti')
|
||||||
|
expect(genotypeToFarbschlag(fromDisplayString('aa CC DD EE GG pp spsp rere'))).toBe('Platin')
|
||||||
|
expect(genotypeToFarbschlag(fromDisplayString('aa cchmcchm dd ee gg PP spsp rere'))).toBe(
|
||||||
|
'Unbekannter Farbschlag',
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Partially-unknown parents (wildcards)', () => {
|
describe('Partially-unknown parents (wildcards)', () => {
|
||||||
|
|||||||
@@ -93,5 +93,17 @@ export function farbschlagFor(g: Genotype): FarbschlagMatch {
|
|||||||
return { name, base, unknown: false }
|
return { name, base, unknown: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience: genotype -> German Farbschlag name (with Schecke/Rex modifiers),
|
||||||
|
* or "Unbekannter Farbschlag". This is the DENORMALIZATION contract for DATA-1:
|
||||||
|
* the backend mirrors this mapping into a stored Farbschlag column (recomputed
|
||||||
|
* whenever the genotype changes) so Gridify list filtering/sorting never has to
|
||||||
|
* parse genotype strings in SQL. The catalog (BASE_COLORS) is self-contained in
|
||||||
|
* this file so it can be ported/kept in sync with the backend.
|
||||||
|
*/
|
||||||
|
export function genotypeToFarbschlag(g: Genotype): string {
|
||||||
|
return farbschlagFor(g).name
|
||||||
|
}
|
||||||
|
|
||||||
/** Number of base-colour varieties currently catalogued. */
|
/** Number of base-colour varieties currently catalogued. */
|
||||||
export const CATALOG_SIZE = BASE_COLORS.length
|
export const CATALOG_SIZE = BASE_COLORS.length
|
||||||
|
|||||||
@@ -30,7 +30,13 @@ export type { LocusKey, LocusDef } from './loci'
|
|||||||
export { phenotypeTokens } from './phenotype'
|
export { phenotypeTokens } from './phenotype'
|
||||||
export type { PhenotypeTokens } from './phenotype'
|
export type { PhenotypeTokens } from './phenotype'
|
||||||
|
|
||||||
export { farbschlagFor, BASE_COLORS, CATALOG_SIZE, UNKNOWN_FARBSCHLAG } from './catalog'
|
export {
|
||||||
|
farbschlagFor,
|
||||||
|
genotypeToFarbschlag,
|
||||||
|
BASE_COLORS,
|
||||||
|
CATALOG_SIZE,
|
||||||
|
UNKNOWN_FARBSCHLAG,
|
||||||
|
} from './catalog'
|
||||||
export type { FarbschlagEntry, FarbschlagMatch } from './catalog'
|
export type { FarbschlagEntry, FarbschlagMatch } from './catalog'
|
||||||
|
|
||||||
export { GeneticsWarningCode } from './warnings'
|
export { GeneticsWarningCode } from './warnings'
|
||||||
|
|||||||
Reference in New Issue
Block a user