diff --git a/src/core/parser/PedWriter.ts b/src/core/parser/PedWriter.ts index 17cb9f2..a9e668b 100644 --- a/src/core/parser/PedWriter.ts +++ b/src/core/parser/PedWriter.ts @@ -18,6 +18,12 @@ export class PedWriter { write(pedigree: Pedigree): string { const lines: string[] = []; + // Build ID to label mapping (use label if available, otherwise use ID) + const idToLabel = new Map(); + for (const [id, person] of pedigree.persons) { + idToLabel.set(id, person.metadata.label || id); + } + // Add header comment lines.push(`# Pedigree: ${pedigree.familyId}`); lines.push(`# Generated: ${new Date().toISOString()}`); @@ -28,7 +34,7 @@ export class PedWriter { const sortedPersons = this.sortPersonsByGeneration(pedigree); for (const person of sortedPersons) { - const line = this.formatPersonLine(person); + const line = this.formatPersonLine(person, idToLabel); lines.push(line); } @@ -38,12 +44,16 @@ export class PedWriter { /** * Format a single person as a PED line */ - private formatPersonLine(person: Person): string { + private formatPersonLine(person: Person, idToLabel: Map): string { + const individualId = idToLabel.get(person.id) || person.id; + const paternalId = person.fatherId ? (idToLabel.get(person.fatherId) || person.fatherId) : '0'; + const maternalId = person.motherId ? (idToLabel.get(person.motherId) || person.motherId) : '0'; + const fields = [ person.familyId, - person.id, - person.fatherId ?? '0', - person.motherId ?? '0', + individualId, + paternalId, + maternalId, this.formatSex(person.sex), this.formatPhenotype(person.phenotypes[0] ?? Phenotype.Unknown), ]; diff --git a/src/core/renderer/ConnectionRenderer.ts b/src/core/renderer/ConnectionRenderer.ts index 9fc66d4..0c6c439 100644 --- a/src/core/renderer/ConnectionRenderer.ts +++ b/src/core/renderer/ConnectionRenderer.ts @@ -137,11 +137,11 @@ export class ConnectionRenderer { } const childY = children[0].y; - const midY = parentY + halfSymbol + dropHeight; + const midY = parentY + dropHeight; - // Vertical line from parent connection point + // Vertical line from parent connection point (starts at spouse line level) paths.push({ - d: `M ${parentX} ${parentY + halfSymbol} L ${parentX} ${midY}`, + d: `M ${parentX} ${parentY} L ${parentX} ${midY}`, className: 'connection-parent-child', });