Rare Disease

This page explains the Java code that was used to generate A complete example: Rare Disease. The complete code is available in the src/test package of this repository in the class BethlemMyopathyExample.

Builders and Short cuts

The individual elements of a Phenopacket are constructed with functions provided by the protobuf framework. These functions use the Builder pattern. For instance, to create an OntologyClass object, we use the following code.

OntologyClass hematuria = OntologyClass.newBuilder()

Developers may find it easier to define convenience functions that wrap the builders. For instance, for the OntologyClass example, we might define the following function.

public static OntologyClass ontologyClass(String id, String label) {
    return OntologyClass.newBuilder()

We will use the ontologyClass function in our examples, but otherwise show all steps for clarity.

Family members and variants

We define the names of the family members and also an object to represent the variant that was found to occur in a de novo fashion in the son.

private static final String PROBAND_ID = "14 year-old boy";
private static final String MOTHER_ID = "MOTHER";
private static final String FATHER_ID = "FATHER";

// Allele
private static final HgvsAllele c_877G_to_A = HgvsAllele.
// Corresponding variant
private static final Variant heterozygousCOL6A1Variant = Variant.newBuilder()
        .setZygosity(ontologyClass("GENO:0000135", "heterozygous"))


The following function then creates the Proband object. Note how we create OntologyClass objects for onset and severity modifiers, and create an Evidence object that indicates the provenance of the data.

static Phenopacket proband() {

       OntologyClass mild = OntologyClass.
       OntologyClass evidenceCode = OntologyClass.newBuilder().
               setLabel("author statement supported by traceable reference").
       Evidence citation = Evidence.newBuilder().
                       setDescription("COL6A1 mutation leading to Bethlem myopathy with recurrent hematuria: a case report.").

       PhenotypicFeature decreasedFetalMovement = PhenotypicFeature.newBuilder()
               .setType(ontologyClass("HP:0001558", "Decreased fetal movement"))
               .setClassOfOnset(ontologyClass("HP:0011461", "Fetal onset"))
       PhenotypicFeature absentCranialNerveAbnormality = PhenotypicFeature.newBuilder()
               .setType(ontologyClass("HP:0031910", "Abnormal cranial nerve physiology"))
       PhenotypicFeature motorDelay = PhenotypicFeature.newBuilder()
               .setType(ontologyClass("HP:0001270","Motor delay"))
               .setClassOfOnset(ontologyClass("HP:0011463","Childhood onset"))
       PhenotypicFeature hematuria = PhenotypicFeature.newBuilder()
               .setType(ontologyClass("HP:0011463", "Macroscopic hematuria"))

       Individual proband = Individual.newBuilder()
       return Phenopacket.newBuilder()

Unaffected parents

The unaffected father is coded as follows:

static Phenopacket unaffectedFather() {
     Individual father = Individual.newBuilder()
     return Phenopacket.newBuilder()

The mother is coded analogously. Note that in both cases, on two of the elements of the Phenopacket are actually used.


The following code builds the Pedigree object.

private static Pedigree pedigree() {
       Pedigree.Person pedProband = Pedigree.Person.newBuilder()

       Pedigree.Person pedMother = Pedigree.Person.newBuilder()

       Pedigree.Person pedFather = Pedigree.Person.newBuilder()

       return Pedigree.newBuilder()


Finally, the following code pulls everything together to build the Family object.

Note that we use System.currentTimeMillis() to get the current time (when we are creating and submitting this Phenopacket).