From 6c11e006bd51aa10ba5e1379d96752cd567ed7bc Mon Sep 17 00:00:00 2001 From: imedina Date: Mon, 11 Mar 2024 03:12:56 +0000 Subject: [PATCH 1/3] Add new SNP classes to store dbSNP --- .../org/opencb/biodata/models/core/Snp.java | 147 ++++++++++++++++++ .../biodata/models/core/SnpAnnotation.java | 90 +++++++++++ 2 files changed, 237 insertions(+) create mode 100644 biodata-models/src/main/java/org/opencb/biodata/models/core/Snp.java create mode 100644 biodata-models/src/main/java/org/opencb/biodata/models/core/SnpAnnotation.java diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/core/Snp.java b/biodata-models/src/main/java/org/opencb/biodata/models/core/Snp.java new file mode 100644 index 00000000..c2d079ba --- /dev/null +++ b/biodata-models/src/main/java/org/opencb/biodata/models/core/Snp.java @@ -0,0 +1,147 @@ +/* + * + * + */ + +package org.opencb.biodata.models.core; + +import java.util.List; + +public class Snp { + private String id; + private String chromosome; + private int position; + private String reference; + private List alleles; + private String type; + private String source; + private String version; + private SnpAnnotation annotation; + + public Snp() { + } + + public Snp(String id, String chromosome, int position, String reference, List alleles, String type, + String source, String version, SnpAnnotation annotation) { + this.id = id; + this.chromosome = chromosome; + this.position = position; + this.reference = reference; + this.alleles = alleles; + this.type = type; + this.source = source; + this.version = version; + this.annotation = annotation; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Snp{"); + sb.append("id='").append(id).append('\''); + sb.append(", chromosome='").append(chromosome).append('\''); + sb.append(", position=").append(position); + sb.append(", reference='").append(reference).append('\''); + sb.append(", alleles=").append(alleles); + sb.append(", type='").append(type).append('\''); + sb.append(", source='").append(source).append('\''); + sb.append(", version='").append(version).append('\''); + sb.append(", annotation=").append(annotation); + sb.append('}'); + return sb.toString(); + } + + public String getId() { + return id; + } + + public Snp setId(String id) { + this.id = id; + return this; + } + + public String getChromosome() { + return chromosome; + } + + public Snp setChromosome(String chromosome) { + this.chromosome = chromosome; + return this; + } + + public int getPosition() { + return position; + } + + public Snp setPosition(int position) { + this.position = position; + return this; + } + + public String getReference() { + return reference; + } + + public Snp setReference(String reference) { + this.reference = reference; + return this; + } + + public List getAlleles() { + return alleles; + } + + public Snp setAlleles(List alleles) { + this.alleles = alleles; + return this; + } + + public String getType() { + return type; + } + + public Snp setType(String type) { + this.type = type; + return this; + } + + public String getSource() { + return source; + } + + public Snp setSource(String source) { + this.source = source; + return this; + } + + public String getVersion() { + return version; + } + + public Snp setVersion(String version) { + this.version = version; + return this; + } + + public SnpAnnotation getAnnotation() { + return annotation; + } + + public Snp setAnnotation(SnpAnnotation annotation) { + this.annotation = annotation; + return this; + } +} diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/core/SnpAnnotation.java b/biodata-models/src/main/java/org/opencb/biodata/models/core/SnpAnnotation.java new file mode 100644 index 00000000..215341ad --- /dev/null +++ b/biodata-models/src/main/java/org/opencb/biodata/models/core/SnpAnnotation.java @@ -0,0 +1,90 @@ +/* + * + * + */ + +package org.opencb.biodata.models.core; + +import org.opencb.biodata.models.variant.avro.EvidenceEntry; +import org.opencb.biodata.models.variant.avro.PopulationFrequency; + +import java.util.List; + +public class SnpAnnotation { + + private List flags; + private String gene; + private List populationFrequencies; + private List traitAssociation; + + public SnpAnnotation() { + } + + public SnpAnnotation(List flags, String gene, List populationFrequencies, List traitAssociation) { + this.flags = flags; + this.gene = gene; + this.populationFrequencies = populationFrequencies; + this.traitAssociation = traitAssociation; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("SnpAnnotation{"); + sb.append("flags=").append(flags); + sb.append(", gene='").append(gene).append('\''); + sb.append(", populationFrequencies=").append(populationFrequencies); + sb.append(", traitAssociation=").append(traitAssociation); + sb.append('}'); + return sb.toString(); + } + + public List getFlags() { + return flags; + } + + public SnpAnnotation setFlags(List flags) { + this.flags = flags; + return this; + } + + public String getGene() { + return gene; + } + + public SnpAnnotation setGene(String gene) { + this.gene = gene; + return this; + } + + public List getPopulationFrequencies() { + return populationFrequencies; + } + + public SnpAnnotation setPopulationFrequencies(List populationFrequencies) { + this.populationFrequencies = populationFrequencies; + return this; + } + + public List getTraitAssociation() { + return traitAssociation; + } + + public SnpAnnotation setTraitAssociation(List traitAssociation) { + this.traitAssociation = traitAssociation; + return this; + } +} From ef752abc04d234ee16e4a68169c32d8d55d28fcb Mon Sep 17 00:00:00 2001 From: imedina Date: Tue, 12 Mar 2024 02:30:43 +0000 Subject: [PATCH 2/3] Update SnpAnnotation data model --- .../biodata/models/core/SnpAnnotation.java | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/core/SnpAnnotation.java b/biodata-models/src/main/java/org/opencb/biodata/models/core/SnpAnnotation.java index 215341ad..16fab718 100644 --- a/biodata-models/src/main/java/org/opencb/biodata/models/core/SnpAnnotation.java +++ b/biodata-models/src/main/java/org/opencb/biodata/models/core/SnpAnnotation.java @@ -19,37 +19,26 @@ package org.opencb.biodata.models.core; -import org.opencb.biodata.models.variant.avro.EvidenceEntry; import org.opencb.biodata.models.variant.avro.PopulationFrequency; import java.util.List; +import java.util.Map; public class SnpAnnotation { private List flags; private String gene; private List populationFrequencies; - private List traitAssociation; + private Map additionalAttributes; public SnpAnnotation() { } - public SnpAnnotation(List flags, String gene, List populationFrequencies, List traitAssociation) { + public SnpAnnotation(List flags, String gene, List populationFrequencies, Map additionalAttributes) { this.flags = flags; this.gene = gene; this.populationFrequencies = populationFrequencies; - this.traitAssociation = traitAssociation; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("SnpAnnotation{"); - sb.append("flags=").append(flags); - sb.append(", gene='").append(gene).append('\''); - sb.append(", populationFrequencies=").append(populationFrequencies); - sb.append(", traitAssociation=").append(traitAssociation); - sb.append('}'); - return sb.toString(); + this.additionalAttributes = additionalAttributes; } public List getFlags() { @@ -79,12 +68,12 @@ public SnpAnnotation setPopulationFrequencies(List populati return this; } - public List getTraitAssociation() { - return traitAssociation; + public Map getAdditionalAttributes() { + return additionalAttributes; } - public SnpAnnotation setTraitAssociation(List traitAssociation) { - this.traitAssociation = traitAssociation; + public SnpAnnotation setAdditionalAttributes(Map additionalAttributes) { + this.additionalAttributes = additionalAttributes; return this; } } From 9ea6c147b64917ff95fed4b8335bd89eae109176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20T=C3=A1rraga=20Gim=C3=A9nez?= Date: Tue, 12 Mar 2024 11:28:15 +0100 Subject: [PATCH 3/3] models: rename alleles to alternates, #TASK-5813, #TASK-5789 --- .../java/org/opencb/biodata/models/core/Snp.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/biodata-models/src/main/java/org/opencb/biodata/models/core/Snp.java b/biodata-models/src/main/java/org/opencb/biodata/models/core/Snp.java index c2d079ba..8f8cc712 100644 --- a/biodata-models/src/main/java/org/opencb/biodata/models/core/Snp.java +++ b/biodata-models/src/main/java/org/opencb/biodata/models/core/Snp.java @@ -26,7 +26,7 @@ public class Snp { private String chromosome; private int position; private String reference; - private List alleles; + private List alternates; private String type; private String source; private String version; @@ -35,13 +35,13 @@ public class Snp { public Snp() { } - public Snp(String id, String chromosome, int position, String reference, List alleles, String type, + public Snp(String id, String chromosome, int position, String reference, List alternates, String type, String source, String version, SnpAnnotation annotation) { this.id = id; this.chromosome = chromosome; this.position = position; this.reference = reference; - this.alleles = alleles; + this.alternates = alternates; this.type = type; this.source = source; this.version = version; @@ -55,7 +55,7 @@ public String toString() { sb.append(", chromosome='").append(chromosome).append('\''); sb.append(", position=").append(position); sb.append(", reference='").append(reference).append('\''); - sb.append(", alleles=").append(alleles); + sb.append(", alternates=").append(alternates); sb.append(", type='").append(type).append('\''); sb.append(", source='").append(source).append('\''); sb.append(", version='").append(version).append('\''); @@ -100,12 +100,12 @@ public Snp setReference(String reference) { return this; } - public List getAlleles() { - return alleles; + public List getAlternates() { + return alternates; } - public Snp setAlleles(List alleles) { - this.alleles = alleles; + public Snp setAlternates(List alternates) { + this.alternates = alternates; return this; }