@@ -60,23 +60,20 @@ private static Function<Person, Individual> toIndividual() {
6060 return person -> Individual .builder ()
6161 .familyId (person .getFamilyId ())
6262 .id (person .getIndividualId ())
63- .motherId (person .getMaternalId ())
64- .fatherId (person .getPaternalId ())
63+ // PED and the phenopacket schema require a "0" value for missing relations
64+ .motherId (person .getMaternalId ().equals ("0" ) ? "" : person .getMaternalId ())
65+ .fatherId (person .getPaternalId ().equals ("0" ) ? "" : person .getPaternalId ())
6566 .sex (toExomiserSex (person .getSex ()))
6667 .status (toExomiserStatus (person .getAffectedStatus ()))
6768 .build ();
6869 }
6970
7071 private static Individual .Status toExomiserStatus (AffectedStatus affectedStatus ) {
71- switch (affectedStatus ) {
72- case AFFECTED :
73- return Individual .Status .AFFECTED ;
74- case UNAFFECTED :
75- return Individual .Status .UNAFFECTED ;
76- case MISSING :
77- default :
78- return Individual .Status .UNKNOWN ;
79- }
72+ return switch (affectedStatus ) {
73+ case AFFECTED -> Individual .Status .AFFECTED ;
74+ case UNAFFECTED -> Individual .Status .UNAFFECTED ;
75+ default -> Individual .Status .UNKNOWN ;
76+ };
8077 }
8178
8279 public static org .phenopackets .schema .v1 .core .Pedigree toPhenopacketPedigree (Pedigree pedigree ) {
@@ -93,48 +90,36 @@ private static Function<Individual, Person> toPerson() {
9390 return individual -> Person .newBuilder ()
9491 .setFamilyId (individual .familyId ())
9592 .setIndividualId (individual .id ())
96- .setMaternalId (individual .motherId ())
97- .setPaternalId (individual .fatherId ())
93+ // PED and the phenopacket schema require a "0" value for missing relations
94+ .setMaternalId (individual .motherId ().isEmpty () ? "0" : individual .motherId ())
95+ .setPaternalId (individual .fatherId ().isEmpty () ? "0" : individual .fatherId ())
9896 .setSex (toPhenopacketSex (individual .sex ()))
9997 .setAffectedStatus (toPhenopacketStatus (individual .status ()))
10098 .build ();
10199 }
102100
103101 private static AffectedStatus toPhenopacketStatus (Individual .Status status ) {
104- switch (status ) {
105- case UNAFFECTED :
106- return AffectedStatus .UNAFFECTED ;
107- case AFFECTED :
108- return AffectedStatus .AFFECTED ;
109- case UNKNOWN :
110- default :
111- return AffectedStatus .MISSING ;
112- }
102+ return switch (status ) {
103+ case UNAFFECTED -> AffectedStatus .UNAFFECTED ;
104+ case AFFECTED -> AffectedStatus .AFFECTED ;
105+ default -> AffectedStatus .MISSING ;
106+ };
113107 }
114108
115109 public static Sex toPhenopacketSex (Individual .Sex sex ) {
116- switch (sex ) {
117- case FEMALE :
118- return Sex .FEMALE ;
119- case MALE :
120- return Sex .MALE ;
121- case UNKNOWN :
122- default :
123- return Sex .UNKNOWN_SEX ;
124- }
110+ return switch (sex ) {
111+ case FEMALE -> Sex .FEMALE ;
112+ case MALE -> Sex .MALE ;
113+ default -> Sex .UNKNOWN_SEX ;
114+ };
125115 }
126116
127117 public static Individual .Sex toExomiserSex (Sex sex ) {
128- switch (sex ) {
129- case FEMALE :
130- return Individual .Sex .FEMALE ;
131- case MALE :
132- return Individual .Sex .MALE ;
133- case OTHER_SEX :
134- case UNKNOWN_SEX :
135- default :
136- return Individual .Sex .UNKNOWN ;
137- }
118+ return switch (sex ) {
119+ case FEMALE -> Individual .Sex .FEMALE ;
120+ case MALE -> Individual .Sex .MALE ;
121+ default -> Individual .Sex .UNKNOWN ;
122+ };
138123 }
139124
140125}
0 commit comments