Skip to content

Commit

Permalink
models: update ModeOfInheritance from the opencga/SegregationMode, #189
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Sep 3, 2020
1 parent 7efc592 commit 262e36d
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,62 @@

package org.opencb.biodata.models.clinical;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.security.InvalidParameterException;
import java.util.HashMap;
import java.util.Map;

public class ClinicalProperty {

public enum ModeOfInheritance {
AUTOSOMAL_DOMINANT,
MONOALLELIC_NOT_IMPRINTED,
MONOALLELIC_MATERNALLY_IMPRINTED,
MONOALLELIC_PATERNALLY_IMPRINTED,
AUTOSOMAL_RECESSIVE,
MONOALLELIC_AND_BIALLELIC,
MONOALLELIC_AND_MORE_SEVERE_BIALLELIC,
AUTOSOMAL_DOMINANT("monoallelic"),
AUTOSOMAL_RECESSIVE("biallelic"),
X_LINKED_DOMINANT,
X_LINKED_RECESSIVE,
Y_LINKED,
MITOCHONDRIAL,

// Not modes of inheritance, but...
DE_NOVO,
COMPOUND_HETEROZYGOUS,
MENDELIAN_ERROR,
UNKNOWN
MENDELIAN_ERROR("me"),
COMPOUND_HETEROZYGOUS("ch"),

UNKNOWN;

private static Map<String, ModeOfInheritance> namesMap;

static {
namesMap = new HashMap<>();
for (ModeOfInheritance mode : values()) {
namesMap.put(mode.name().toLowerCase(), mode);
namesMap.put(mode.name().replace("_", "").toLowerCase(), mode);
if (mode.names != null) {
for (String name : mode.names) {
namesMap.put(name.toLowerCase(), mode);
}
}
}
}

private final String[] names;

ModeOfInheritance(String... names) {
this.names = names;
}

@Nullable
public static ModeOfInheritance parseOrNull(String name) {
return namesMap.get(name.toLowerCase());
}

@Nonnull
public static ModeOfInheritance parse(String name) {
ModeOfInheritance moi = namesMap.get(name.toLowerCase());
if (moi == null) {
throw new InvalidParameterException("Unknown ModeOfInheritance value: '" + name + "'");
}
return moi;
}
}

public enum ClinicalSignificance {
Expand All @@ -56,6 +92,13 @@ public enum Penetrance {
UNKNOWN
}

public enum Imprinted {
NOT,
MATERNALLY,
PATERNALLY,
UNKNOWN
}

public enum Confidence {
HIGH,
MEDIUM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import org.opencb.biodata.models.clinical.ClinicalProperty.Confidence;
import org.opencb.biodata.models.clinical.ClinicalProperty.Imprinted;
import org.opencb.biodata.models.clinical.ClinicalProperty.ModeOfInheritance;
import org.opencb.biodata.models.core.OntologyTerm;
import org.opencb.biodata.models.core.Xref;
Expand Down Expand Up @@ -226,10 +227,10 @@ public VariantPanel() {
}

public VariantPanel(String id, List<Xref> xrefs, ModeOfInheritance modeOfInheritance, Penetrance penetrance,
Confidence confidence, List<String> evidences, List<String> publications,
Imprinted imprinted, Confidence confidence, List<String> evidences, List<String> publications,
List<OntologyTerm> phenotypes, List<Coordinate> coordinates, CancerPanel cancerPanel,
String reference, String alternate) {
super(id, xrefs, modeOfInheritance, penetrance, confidence, evidences, publications, phenotypes,
super(id, xrefs, modeOfInheritance, penetrance, imprinted, confidence, evidences, publications, phenotypes,
coordinates, cancerPanel);
this.reference = reference;
this.alternate = alternate;
Expand Down Expand Up @@ -329,6 +330,7 @@ public static class Common {
protected List<Xref> xrefs;
protected ModeOfInheritance modeOfInheritance;
protected Penetrance penetrance;
protected Imprinted imprinted;
protected Confidence confidence;
protected List<String> evidences;
protected List<String> publications;
Expand All @@ -340,18 +342,19 @@ public Common() {
}

public Common(String id, List<Xref> xrefs, ModeOfInheritance modeOfInheritance, Penetrance penetrance,
Confidence confidence, List<String> evidences, List<String> publications,
List<OntologyTerm> phenotypes, List<Coordinate> coordinates, CancerPanel cancerPanel) {
Imprinted imprinted, Confidence confidence, List<String> evidences, List<String> publications,
List<OntologyTerm> phenotypes, List<Coordinate> coordinates, CancerPanel cancer) {
this.id = id;
this.xrefs = xrefs;
this.modeOfInheritance = modeOfInheritance;
this.penetrance = penetrance;
this.imprinted = imprinted;
this.confidence = confidence;
this.evidences = evidences;
this.publications = publications;
this.phenotypes = phenotypes;
this.coordinates = coordinates;
this.cancer = cancerPanel;
this.cancer = cancer;
}

@Override
Expand All @@ -361,6 +364,7 @@ public String toString() {
sb.append(", xrefs=").append(xrefs);
sb.append(", modeOfInheritance=").append(modeOfInheritance);
sb.append(", penetrance=").append(penetrance);
sb.append(", imprinted=").append(imprinted);
sb.append(", confidence=").append(confidence);
sb.append(", evidences=").append(evidences);
sb.append(", publications=").append(publications);
Expand Down Expand Up @@ -398,6 +402,15 @@ public Common setPenetrance(Penetrance penetrance) {
return this;
}

public Imprinted getImprinted() {
return imprinted;
}

public Common setImprinted(Imprinted imprinted) {
this.imprinted = imprinted;
return this;
}

public Confidence getConfidence() {
return confidence;
}
Expand Down Expand Up @@ -474,11 +487,11 @@ public RegionPanel() {
}

public RegionPanel(String name, List<Xref> xrefs, ModeOfInheritance modeOfInheritance, Penetrance penetrance,
Confidence confidence, List<String> evidences, List<String> publications,
Imprinted imprinted, Confidence confidence, List<String> evidences, List<String> publications,
List<OntologyTerm> phenotypes, List<Coordinate> coordinates, CancerPanel cancerPanel,
String description, VariantType typeOfVariants, String haploinsufficiencyScore,
String triplosensitivityScore, int requiredOverlapPercentage) {
super(name, xrefs, modeOfInheritance, penetrance, confidence, evidences, publications, phenotypes,
super(name, xrefs, modeOfInheritance, penetrance, imprinted, confidence, evidences, publications, phenotypes,
coordinates, cancerPanel);
this.description = description;
this.typeOfVariants = typeOfVariants;
Expand Down Expand Up @@ -570,10 +583,10 @@ public STR() {
}

public STR(String id, List<Xref> xrefs, ModeOfInheritance modeOfInheritance, Penetrance penetrance,
Confidence confidence, List<String> evidences, List<String> publications,
Imprinted imprinted, Confidence confidence, List<String> evidences, List<String> publications,
List<OntologyTerm> phenotypes, List<Coordinate> coordinates, CancerPanel cancerPanel, String repeatedSequence,
int normalRepeats, int pathogenicRepeats) {
super(id, xrefs, modeOfInheritance, penetrance, confidence, evidences, publications, phenotypes,
super(id, xrefs, modeOfInheritance, penetrance, imprinted, confidence, evidences, publications, phenotypes,
coordinates, cancerPanel);
this.repeatedSequence = repeatedSequence;
this.normalRepeats = normalRepeats;
Expand Down Expand Up @@ -638,10 +651,10 @@ public GenePanel() {
}

public GenePanel(String id, String name, List<Xref> xrefs, ModeOfInheritance modeOfInheritance,
Penetrance penetrance, Confidence confidence, List<String> evidences,
Penetrance penetrance, Imprinted imprinted, Confidence confidence, List<String> evidences,
List<String> publications, List<OntologyTerm> phenotypes, List<Coordinate> coordinates,
CancerPanel cancerPanel) {
super(id, xrefs, modeOfInheritance, penetrance, confidence, evidences, publications, phenotypes,
super(id, xrefs, modeOfInheritance, penetrance, imprinted, confidence, evidences, publications, phenotypes,
coordinates, cancerPanel);
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static DiseasePanel parseCensus(Path censusTsvFile) throws IOException {
String[] splittedLine = line.split("\t");

DiseasePanel.GenePanel genePanel = new DiseasePanel.GenePanel("", "", new LinkedList<>(),
ClinicalProperty.ModeOfInheritance.UNKNOWN, null, null, new LinkedList<>(), new LinkedList<>(),
ClinicalProperty.ModeOfInheritance.UNKNOWN, null, ClinicalProperty.Imprinted.UNKNOWN, null, new LinkedList<>(), new LinkedList<>(),
new LinkedList<>(), new LinkedList<>(), new CancerPanel(false, false, null, new LinkedList<>(),
new LinkedList<>(), new LinkedList<>(), new LinkedList<>()));
for (int i = 0; i < splittedLine.length; i++) {
Expand Down Expand Up @@ -436,8 +436,10 @@ private static <T extends DiseasePanel.Common> void extractCommonInformationFrom

common.setId(ensemblGeneId);
common.setXrefs(xrefs);
common.setModeOfInheritance(getMoiFromGenePanel(String.valueOf(panelAppCommonMap.get("mode_of_inheritance"))));
String moi = String.valueOf(panelAppCommonMap.get("mode_of_inheritance"));
common.setModeOfInheritance(getMoiFromGenePanel(moi));
common.setPenetrance(penetrance);
common.setImprinted(getImprintedFromGenePanel(moi));
ClinicalProperty.Confidence confidence = ClinicalProperty.Confidence.LOW;
int confidenceLevel = Integer.valueOf(String.valueOf(panelAppCommonMap.get("confidence_level")));
if (confidenceLevel == 2) {
Expand All @@ -463,23 +465,15 @@ private static ClinicalProperty.ModeOfInheritance getMoiFromGenePanel(String inp
return ClinicalProperty.ModeOfInheritance.AUTOSOMAL_RECESSIVE;
}
if (moi.startsWith("MONOALLELIC")) {
if (moi.contains("NOT")) {
return ClinicalProperty.ModeOfInheritance.MONOALLELIC_NOT_IMPRINTED;
} else if (moi.contains("MATERNALLY")) {
return ClinicalProperty.ModeOfInheritance.MONOALLELIC_MATERNALLY_IMPRINTED;
} else if (moi.contains("PATERNALLY")) {
return ClinicalProperty.ModeOfInheritance.MONOALLELIC_PATERNALLY_IMPRINTED;
} else {
return ClinicalProperty.ModeOfInheritance.AUTOSOMAL_DOMINANT;
}
}
if (moi.startsWith("BOTH")) {
if (moi.contains("SEVERE")) {
return ClinicalProperty.ModeOfInheritance.MONOALLELIC_AND_MORE_SEVERE_BIALLELIC;
} else if (moi.contains("")) {
return ClinicalProperty.ModeOfInheritance.MONOALLELIC_AND_BIALLELIC;
}
return ClinicalProperty.ModeOfInheritance.AUTOSOMAL_DOMINANT;
}
// if (moi.startsWith("BOTH")) {
// if (moi.contains("SEVERE")) {
// return ClinicalProperty.ModeOfInheritance.MONOALLELIC_AND_MORE_SEVERE_BIALLELIC;
// } else if (moi.contains("")) {
// return ClinicalProperty.ModeOfInheritance.MONOALLELIC_AND_BIALLELIC;
// }
// }
if (moi.startsWith("MITOCHONDRIAL")) {
return ClinicalProperty.ModeOfInheritance.MITOCHONDRIAL;
}
Expand All @@ -493,4 +487,23 @@ private static ClinicalProperty.ModeOfInheritance getMoiFromGenePanel(String inp
return ClinicalProperty.ModeOfInheritance.UNKNOWN;
}

private static ClinicalProperty.Imprinted getImprintedFromGenePanel(String inputMoi) {
if (org.apache.commons.lang3.StringUtils.isEmpty(inputMoi)) {
return ClinicalProperty.Imprinted.UNKNOWN;
}

String moi = inputMoi.toUpperCase();

if (moi.startsWith("MONOALLELIC")) {
if (moi.contains("NOT")) {
return ClinicalProperty.Imprinted.NOT;
} else if (moi.contains("MATERNALLY")) {
return ClinicalProperty.Imprinted.MATERNALLY;
} else if (moi.contains("PATERNALLY")) {
return ClinicalProperty.Imprinted.PATERNALLY;
}
}

return ClinicalProperty.Imprinted.UNKNOWN;
}
}

0 comments on commit 262e36d

Please sign in to comment.