From e128f8f2c133a5032457ee2c47e41ac6e0be5412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20T=C3=A1rraga=20Gim=C3=A9nez?= Date: Wed, 24 Jun 2020 08:22:43 +0200 Subject: [PATCH] models: add some data models from opencga, #187 --- .../qc/individual/InferredSexReport.java | 88 +++++++++ .../qc/individual/MendelianErrorReport.java | 180 ++++++++++++++++++ .../qc/individual/RelatednessReport.java | 139 ++++++++++++++ .../qc/{ => sample}/MutationalSignature.java | 2 +- .../qc/{ => sample}/QcVariantStats.java | 16 +- .../qc/{ => sample}/SampleQcVariantStats.java | 2 +- .../clinical/qc/{ => sample}/Signature.java | 2 +- .../qc/{ => sample}/SignatureFitting.java | 2 +- 8 files changed, 419 insertions(+), 12 deletions(-) create mode 100644 biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/InferredSexReport.java create mode 100644 biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/MendelianErrorReport.java create mode 100644 biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/RelatednessReport.java rename biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/{ => sample}/MutationalSignature.java (96%) rename biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/{ => sample}/QcVariantStats.java (80%) rename biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/{ => sample}/SampleQcVariantStats.java (98%) rename biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/{ => sample}/Signature.java (98%) rename biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/{ => sample}/SignatureFitting.java (98%) diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/InferredSexReport.java b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/InferredSexReport.java new file mode 100644 index 000000000..25e8cae6c --- /dev/null +++ b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/InferredSexReport.java @@ -0,0 +1,88 @@ +/* + * Copyright 2015-2020 OpenCB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opencb.biodata.models.clinical.qc.individual; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public class InferredSexReport { + + private String method; + private String inferredKaryotypicSex; + private Map values; + private List files; + + public InferredSexReport() { + this("CoverageRatio", "", new LinkedHashMap<>(), new ArrayList<>()); + } + + public InferredSexReport(String method, String inferredKaryotypicSex, Map values, List files) { + this.method = method; + this.inferredKaryotypicSex = inferredKaryotypicSex; + this.values = values; + this.files = files; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("InferredSexReport{"); + sb.append("method='").append(method).append('\''); + sb.append(", inferredKaryotypicSex='").append(inferredKaryotypicSex).append('\''); + sb.append(", values=").append(values); + sb.append(", files=").append(files); + sb.append('}'); + return sb.toString(); + } + + public String getMethod() { + return method; + } + + public InferredSexReport setMethod(String method) { + this.method = method; + return this; + } + + public String getInferredKaryotypicSex() { + return inferredKaryotypicSex; + } + + public InferredSexReport setInferredKaryotypicSex(String inferredKaryotypicSex) { + this.inferredKaryotypicSex = inferredKaryotypicSex; + return this; + } + + public Map getValues() { + return values; + } + + public InferredSexReport setValues(Map values) { + this.values = values; + return this; + } + + public List getFiles() { + return files; + } + + public InferredSexReport setFiles(List files) { + this.files = files; + return this; + } +} diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/MendelianErrorReport.java b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/MendelianErrorReport.java new file mode 100644 index 000000000..c7fdbfb14 --- /dev/null +++ b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/MendelianErrorReport.java @@ -0,0 +1,180 @@ +/* + * Copyright 2015-2020 OpenCB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opencb.biodata.models.clinical.qc.individual; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +//------------------------------------------------------------------------- +// M E N D E L I A N E R R O R S R E P O R T +//------------------------------------------------------------------------- + +public class MendelianErrorReport { + + // Number total of errors for that family + private int numErrors; + + private List sampleAggregation; + + //------------------------------------------------------------------------- + // S A M P L E A G G R E G A T I O N + //------------------------------------------------------------------------- + + public static class SampleAggregation { + + // Sample + private String sample; + + // Number of errors + private int numErrors; + + // Ratio for that sample = total / number_of_variants + private double ratio; + + + // Aggregation per chromosome + private List chromAggregation; + + public SampleAggregation() { + chromAggregation = new ArrayList<>(); + } + + public SampleAggregation(String sample, int numErrors, double ratio, List chromAggregation) { + this.sample = sample; + this.numErrors = numErrors; + this.ratio = ratio; + this.chromAggregation = chromAggregation; + } + + public String getSample() { + return sample; + } + + public SampleAggregation setSample(String sample) { + this.sample = sample; + return this; + } + + public int getNumErrors() { + return numErrors; + } + + public SampleAggregation setNumErrors(int numErrors) { + this.numErrors = numErrors; + return this; + } + + public double getRatio() { + return ratio; + } + + public SampleAggregation setRatio(double ratio) { + this.ratio = ratio; + return this; + } + + public List getChromAggregation() { + return chromAggregation; + } + + public SampleAggregation setChromAggregation(List chromAggregation) { + this.chromAggregation = chromAggregation; + return this; + } + + //------------------------------------------------------------------------- + // C H R O M O S O M E A G G R E G A T I O N + //------------------------------------------------------------------------- + + public static class ChromosomeAggregation { + + // Chromosome + private String chromosome; + + // Number of errors + private int numErrors; + + // Aggregation per error code for that chromosome + private Map errorCodeAggregation; + + public ChromosomeAggregation() { + } + + public ChromosomeAggregation(String chromosome, int numErrors, Map errorCodeAggregation) { + this.chromosome = chromosome; + this.numErrors = numErrors; + this.errorCodeAggregation = errorCodeAggregation; + } + + public String getChromosome() { + return chromosome; + } + + public ChromosomeAggregation setChromosome(String chromosome) { + this.chromosome = chromosome; + return this; + } + + public int getNumErrors() { + return numErrors; + } + + public ChromosomeAggregation setNumErrors(int numErrors) { + this.numErrors = numErrors; + return this; + } + + public Map getErrorCodeAggregation() { + return errorCodeAggregation; + } + + public ChromosomeAggregation setErrorCodeAggregation(Map errorCodeAggregation) { + this.errorCodeAggregation = errorCodeAggregation; + return this; + } + } + } + + public MendelianErrorReport() { + this.numErrors = 0; + this.sampleAggregation = new ArrayList<>(); + } + + public MendelianErrorReport(int numErrors, List sampleAggregation) { + this.numErrors = numErrors; + this.sampleAggregation = sampleAggregation; + } + + public int getNumErrors() { + return numErrors; + } + + public MendelianErrorReport setNumErrors(int numErrors) { + this.numErrors = numErrors; + return this; + } + + public List getSampleAggregation() { + return sampleAggregation; + } + + public MendelianErrorReport setSampleAggregation(List sampleAggregation) { + this.sampleAggregation = sampleAggregation; + return this; + } +} diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/RelatednessReport.java b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/RelatednessReport.java new file mode 100644 index 000000000..669a1d56a --- /dev/null +++ b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/individual/RelatednessReport.java @@ -0,0 +1,139 @@ +/* + * Copyright 2015-2020 OpenCB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opencb.biodata.models.clinical.qc.individual; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public class RelatednessReport { + + // Method., e.g.: Plink/IBD + private String method; + + // Relatedness scores for pair of samples + private List scores; + private List files; + + public RelatednessReport() { + this("Plink/IBD", new ArrayList<>(), new ArrayList<>()); + } + + public RelatednessReport(String method, List scores, List files) { + this.method = method; + this.scores = scores; + this.files = files; + } + + public static class RelatednessScore { + // Pair of samples + private String sampleId1; + private String sampleId2; + + // Reported relation according to pedigree + private String inferredRelationship; + + private Map values; + + public RelatednessScore() { + this("", "", "", new LinkedHashMap<>()); + } + + public RelatednessScore(String sampleId1, String sampleId2, String inferredRelationship, Map values) { + this.sampleId1 = sampleId1; + this.sampleId2 = sampleId2; + this.inferredRelationship = inferredRelationship; + this.values = values; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("RelatednessScore{"); + sb.append("sampleId1='").append(sampleId1).append('\''); + sb.append(", sampleId2='").append(sampleId2).append('\''); + sb.append(", inferredRelationship='").append(inferredRelationship).append('\''); + sb.append(", values=").append(values); + sb.append('}'); + return sb.toString(); + } + + public String getSampleId1() { + return sampleId1; + } + + public RelatednessScore setSampleId1(String sampleId1) { + this.sampleId1 = sampleId1; + return this; + } + + public String getSampleId2() { + return sampleId2; + } + + public RelatednessScore setSampleId2(String sampleId2) { + this.sampleId2 = sampleId2; + return this; + } + + public String getInferredRelationship() { + return inferredRelationship; + } + + public RelatednessScore setInferredRelationship(String inferredRelationship) { + this.inferredRelationship = inferredRelationship; + return this; + } + + public Map getValues() { + return values; + } + + public RelatednessScore setValues(Map values) { + this.values = values; + return this; + } + } + + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("RelatednessReport{"); + sb.append("method='").append(method).append('\''); + sb.append(", scores=").append(scores); + sb.append('}'); + return sb.toString(); + } + + public String getMethod() { + return method; + } + + public RelatednessReport setMethod(String method) { + this.method = method; + return this; + } + + public List getScores() { + return scores; + } + + public RelatednessReport setScores(List scores) { + this.scores = scores; + return this; + } +} diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/MutationalSignature.java b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/MutationalSignature.java similarity index 96% rename from biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/MutationalSignature.java rename to biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/MutationalSignature.java index 5c346b244..24c98c04b 100644 --- a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/MutationalSignature.java +++ b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/MutationalSignature.java @@ -17,7 +17,7 @@ * */ -package org.opencb.biodata.models.clinical.qc; +package org.opencb.biodata.models.clinical.qc.sample; public class MutationalSignature { diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/QcVariantStats.java b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/QcVariantStats.java similarity index 80% rename from biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/QcVariantStats.java rename to biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/QcVariantStats.java index 39b3f8293..60d9d6189 100644 --- a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/QcVariantStats.java +++ b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/QcVariantStats.java @@ -17,7 +17,7 @@ * */ -package org.opencb.biodata.models.clinical.qc; +package org.opencb.biodata.models.clinical.qc.sample; import java.util.Map; @@ -65,7 +65,7 @@ public int getVariantCount() { return variantCount; } - public org.opencb.biodata.models.clinical.qc.QcVariantStats setVariantCount(int variantCount) { + public QcVariantStats setVariantCount(int variantCount) { this.variantCount = variantCount; return this; } @@ -74,7 +74,7 @@ public int getPassCount() { return passCount; } - public org.opencb.biodata.models.clinical.qc.QcVariantStats setPassCount(int passCount) { + public QcVariantStats setPassCount(int passCount) { this.passCount = passCount; return this; } @@ -83,7 +83,7 @@ public Map getChromosomeCount() { return chromosomeCount; } - public org.opencb.biodata.models.clinical.qc.QcVariantStats setChromosomeCount(Map chromosomeCount) { + public QcVariantStats setChromosomeCount(Map chromosomeCount) { this.chromosomeCount = chromosomeCount; return this; } @@ -92,7 +92,7 @@ public Map getTypeCount() { return typeCount; } - public org.opencb.biodata.models.clinical.qc.QcVariantStats setTypeCount(Map typeCount) { + public QcVariantStats setTypeCount(Map typeCount) { this.typeCount = typeCount; return this; } @@ -101,7 +101,7 @@ public Map getBiotypeCount() { return biotypeCount; } - public org.opencb.biodata.models.clinical.qc.QcVariantStats setBiotypeCount(Map biotypeCount) { + public QcVariantStats setBiotypeCount(Map biotypeCount) { this.biotypeCount = biotypeCount; return this; } @@ -110,7 +110,7 @@ public Map getConsequenceTypeCount() { return consequenceTypeCount; } - public org.opencb.biodata.models.clinical.qc.QcVariantStats setConsequenceTypeCount(Map consequenceTypeCount) { + public QcVariantStats setConsequenceTypeCount(Map consequenceTypeCount) { this.consequenceTypeCount = consequenceTypeCount; return this; } @@ -119,7 +119,7 @@ public Map getGenotypeCount() { return genotypeCount; } - public org.opencb.biodata.models.clinical.qc.QcVariantStats setGenotypeCount(Map genotypeCount) { + public QcVariantStats setGenotypeCount(Map genotypeCount) { this.genotypeCount = genotypeCount; return this; } diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/SampleQcVariantStats.java b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/SampleQcVariantStats.java similarity index 98% rename from biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/SampleQcVariantStats.java rename to biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/SampleQcVariantStats.java index 30850f9bd..56646890b 100644 --- a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/SampleQcVariantStats.java +++ b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/SampleQcVariantStats.java @@ -17,7 +17,7 @@ * */ -package org.opencb.biodata.models.clinical.qc; +package org.opencb.biodata.models.clinical.qc.sample; import org.opencb.biodata.models.variant.metadata.SampleVariantStats; diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/Signature.java b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/Signature.java similarity index 98% rename from biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/Signature.java rename to biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/Signature.java index f478a713b..9765aec99 100644 --- a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/Signature.java +++ b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/Signature.java @@ -17,7 +17,7 @@ * */ -package org.opencb.biodata.models.clinical.qc; +package org.opencb.biodata.models.clinical.qc.sample; import java.util.Arrays; import java.util.List; diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/SignatureFitting.java b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/SignatureFitting.java similarity index 98% rename from biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/SignatureFitting.java rename to biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/SignatureFitting.java index 2e9dca3c5..9ed158e0e 100644 --- a/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/SignatureFitting.java +++ b/biodata-models/src/main/java/org/opencb/biodata/models/clinical/qc/sample/SignatureFitting.java @@ -17,7 +17,7 @@ * */ -package org.opencb.biodata.models.clinical.qc; +package org.opencb.biodata.models.clinical.qc.sample; import java.util.Arrays;