diff --git a/README.md b/README.md index 7799ba825..10353e92a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The European Variation Archive pipeline processes Variant Call Format (VCF) file * Variant annotation: consequence type, SIFT and Polyphen scores, etc * Statistics: allele and genotype counts and frequencies -You can find a more detailed description of these operations in the [project wiki](https://github.com/EBIvariation/eva-pipeline/wiki/Jobs). Please visit the [EVA website](http://www.ebi.ac.uk/eva/?Variant Browser) to see a public service depending on this pipeline, and the [EVA web services repository](https://github.com/EBIvariation/eva-ws) for more information on the API. +You can find a more detailed description of these operations in the [project wiki](https://github.com/EBIvariation/eva-pipeline/wiki/Jobs). Please visit the [EVA website](http://www.ebi.ac.uk/eva/?Variant%20Browser) to see a public service depending on this pipeline, and the [EVA web services repository](https://github.com/EBIvariation/eva-ws) for more information on the API. The pipeline automatically tracks the job status, and avoids waste of computation by resuming a job in the exact point where it failed; successful steps already executed are automatically skipped. diff --git a/pom.xml b/pom.xml index 29b0c9546..6e857d38c 100644 --- a/pom.xml +++ b/pom.xml @@ -113,6 +113,16 @@ + + uk.ac.ebi.eva + variation-commons-mongodb + 0.7-SNAPSHOT + + + uk.ac.ebi.eva + variation-commons-core + 0.7-SNAPSHOT + diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/data/Variant.java b/src/main/java/uk/ac/ebi/eva/commons/models/data/Variant.java index ac11da547..3665b44ac 100644 --- a/src/main/java/uk/ac/ebi/eva/commons/models/data/Variant.java +++ b/src/main/java/uk/ac/ebi/eva/commons/models/data/Variant.java @@ -17,7 +17,7 @@ package uk.ac.ebi.eva.commons.models.data; import org.opencb.commons.utils.CryptoUtils; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import java.util.HashMap; import java.util.HashSet; @@ -120,7 +120,7 @@ public enum VariantType { /** * Annotations of the genomic variation. */ - private Set annotations; + private Set annotations; public Variant() { diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/metadata/AnnotationMetadata.java b/src/main/java/uk/ac/ebi/eva/commons/models/metadata/AnnotationMetadata.java deleted file mode 100644 index d15c2c311..000000000 --- a/src/main/java/uk/ac/ebi/eva/commons/models/metadata/AnnotationMetadata.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2015-2017 EMBL - European Bioinformatics Institute - * - * 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 uk.ac.ebi.eva.commons.models.metadata; - -import org.springframework.data.mongodb.core.mapping.Document; -import org.springframework.data.mongodb.core.mapping.Field; -import org.springframework.util.Assert; - -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; - -@Document -public class AnnotationMetadata { - - private String id; - - @Field(Annotation.VEP_VERSION_FIELD) - private String vepVersion; - - @Field(Annotation.VEP_CACHE_VERSION_FIELD) - private String cacheVersion; - - AnnotationMetadata() { - // Empty document constructor for spring-data - } - - public AnnotationMetadata(String vepVersion, String cacheVersion) { - Assert.hasText(vepVersion, "A non empty vepVerion is required"); - Assert.hasText(vepVersion, "A non empty cacheVersion is required"); - - this.id = vepVersion + "_" + cacheVersion; - this.vepVersion = vepVersion; - this.cacheVersion = cacheVersion; - } - - public String getVepVersion() { - return vepVersion; - } - - public String getCacheVersion() { - return cacheVersion; - } - -} diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/Annotation.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/Annotation.java deleted file mode 100644 index 1cd191d97..000000000 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/Annotation.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2017 EMBL - European Bioinformatics Institute - * - * 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 uk.ac.ebi.eva.commons.models.mongo.entity; - -import com.google.common.base.Strings; -import org.springframework.data.annotation.Id; -import org.springframework.data.mongodb.core.mapping.Document; -import org.springframework.data.mongodb.core.mapping.Field; -import uk.ac.ebi.eva.commons.models.data.Variant; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.ConsequenceType; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.Xref; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -/** - * Mongo database representation of a variant annotation. - */ -@Document -public class Annotation { - - public static final String CHROMOSOME_FIELD = "chr"; - - public static final String START_FIELD = "start"; - - public static final String END_FIELD = "end"; - - public static final String VEP_VERSION_FIELD = "vepv"; - - public static final String VEP_CACHE_VERSION_FIELD = "cachev"; - - public static final String CONSEQUENCE_TYPE_FIELD = "ct"; - - public static final String XREFS_FIELD = "xrefs"; - - @Id - private String id; - - @Field(value = CHROMOSOME_FIELD) - private String chromosome; - - @Field(value = START_FIELD) - private int start; - - @Field(value = END_FIELD) - private int end; - - @Field(value = VEP_VERSION_FIELD) - private String vepVersion; - - @Field(value = VEP_CACHE_VERSION_FIELD) - private String vepCacheVersion; - - @Field(value = CONSEQUENCE_TYPE_FIELD) - private Set consequenceTypes; - - @Field(value = XREFS_FIELD) - private Set xrefs; - - Annotation() { - // Empty document constructor for spring-data - } - - public Annotation(String chromosome, int start, int end, String referenceAllele, String alternativeAllele, - String vepVersion, String vepCacheVersion) { - this.chromosome = chromosome; - this.start = start; - this.end = end; - this.vepVersion = vepVersion; - this.vepCacheVersion = vepCacheVersion; - - this.id = buildAnnotationId(chromosome, start, referenceAllele, alternativeAllele, vepVersion, vepCacheVersion); - this.xrefs = new HashSet<>(); - this.consequenceTypes = new HashSet<>(); - } - - /** - * Private copy constructor - * - * @param annotation - */ - private Annotation(Annotation annotation) { - chromosome = annotation.chromosome; - start = annotation.start; - end = annotation.end; - vepVersion = annotation.vepVersion; - vepCacheVersion = annotation.vepCacheVersion; - - id = annotation.id; - xrefs = new HashSet<>(); - consequenceTypes = new HashSet<>(); - - xrefs.addAll(annotation.xrefs); - consequenceTypes.addAll(annotation.consequenceTypes); - } - - public String getChromosome() { - return chromosome; - } - - public int getStart() { - return start; - } - - public int getEnd() { - return end; - } - - public String getId() { - return id; - } - - public Set getXrefs() { - return xrefs; - } - - public Set getConsequenceTypes() { - return Collections.unmodifiableSet(consequenceTypes); - } - - public void addConsequenceType(ConsequenceType consequenceType) { - consequenceTypes.add(consequenceType); - generateXrefsFromConsequenceType(consequenceType); - } - - public void addConsequenceTypes(Set consequenceTypes) { - for (ConsequenceType consequenceType : consequenceTypes) { - addConsequenceType(consequenceType); - } - } - - public String getVepVersion() { - return vepVersion; - } - - public String getVepCacheVersion() { - return vepCacheVersion; - } - - private void generateXrefsFromConsequenceType(ConsequenceType consequenceType) { - if (!Strings.isNullOrEmpty(consequenceType.getGeneName())) { - xrefs.add(new Xref(consequenceType.getGeneName(), "HGNC")); - } - if (!Strings.isNullOrEmpty(consequenceType.getEnsemblGeneId())) { - xrefs.add(new Xref(consequenceType.getEnsemblGeneId(), "ensemblGene")); - } - if (!Strings.isNullOrEmpty(consequenceType.getEnsemblTranscriptId())) { - xrefs.add(new Xref(consequenceType.getEnsemblTranscriptId(), "ensemblTranscript")); - } - } - - public static String buildAnnotationId(String chromosome, int start, String reference, String alternate, - String vepVersion, String vepCacheVersion) { - StringBuilder builder = new StringBuilder(VariantDocument.buildVariantId( - chromosome, start, - reference, - alternate)); - builder.append("_"); - builder.append(vepVersion); - builder.append("_"); - builder.append(vepCacheVersion); - return builder.toString(); - } - - /** - * Builds the variant id from the current annotation id. In essence we remove the two extra fields added at the end - * of the id and the underscores. - * - * @return - */ - public String buildVariantId() { - return getId().substring(0, getId().length() - vepVersion.length() - vepCacheVersion.length() - 2); - } - - /** - * Concatenate two annotations in a new one. This method returns a new instance with the concatenated array of - * consequence types and computed xrefs. - * - * @param annotation - * @return - */ - public Annotation concatenate(Annotation annotation) { - Annotation temp = new Annotation(this); - if (annotation.getConsequenceTypes() != null) { - temp.addConsequenceTypes(annotation.getConsequenceTypes()); - } - return temp; - } -} diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/VariantDocument.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/VariantDocument.java index cce17112f..13b951ae4 100644 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/VariantDocument.java +++ b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/VariantDocument.java @@ -21,10 +21,10 @@ import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Field; import uk.ac.ebi.eva.commons.models.data.Variant; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.HgvsMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.HgvsMongo; import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantAnnotation; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantAt; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantSourceEntryMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.VariantAtMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.VariantSourceEntryMongo; import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantStatsMongo; import java.util.HashSet; @@ -92,7 +92,7 @@ public class VariantDocument { private String alternate; @Field(AT_FIELD) - private VariantAt at; + private VariantAtMongo at; @Field(HGVS_FIELD) private Set hgvs; @@ -184,13 +184,13 @@ public static String buildVariantId(String chromosome, int start, String referen return builder.toString(); } - public static VariantAt generateAtField(String chromosome, int start) { + public static VariantAtMongo generateAtField(String chromosome, int start) { int smallChunkId = start / VariantMongoDBWriter.CHUNK_SIZE_SMALL; int bigChunkId = start / VariantMongoDBWriter.CHUNK_SIZE_BIG; String chunkSmall = chromosome + "_" + smallChunkId + "_" + ONE_THOUSAND_STRING; String chunkBig = chromosome + "_" + bigChunkId + "_" + TEN_THOUSAND_STRING; - return new VariantAt(chunkSmall, chunkBig); + return new VariantAtMongo(chunkSmall, chunkBig); } public static Set createHgvsMongo(Map> hgvs) { @@ -236,7 +236,7 @@ public String getAlternate() { return alternate; } - public VariantAt getAt() { + public VariantAtMongo getAt() { return at; } diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/projections/SimplifiedAnnotation.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/projections/SimplifiedAnnotation.java deleted file mode 100644 index 63b3a1ef0..000000000 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/projections/SimplifiedAnnotation.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2017 EMBL - European Bioinformatics Institute - * - * 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 uk.ac.ebi.eva.commons.models.mongo.entity.projections; - -import org.springframework.data.annotation.Id; -import org.springframework.data.mongodb.core.mapping.Field; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; - -import static uk.ac.ebi.eva.commons.models.mongo.entity.Annotation.CHROMOSOME_FIELD; -import static uk.ac.ebi.eva.commons.models.mongo.entity.Annotation.END_FIELD; -import static uk.ac.ebi.eva.commons.models.mongo.entity.Annotation.START_FIELD; -import static uk.ac.ebi.eva.commons.models.mongo.entity.Annotation.VEP_CACHE_VERSION_FIELD; -import static uk.ac.ebi.eva.commons.models.mongo.entity.Annotation.VEP_VERSION_FIELD; - -/** - * Simplified form of {@link Annotation} used to improve the update of annotations in mongo. - */ -public class SimplifiedAnnotation { - - @Id - private String id; - - @Field(value = CHROMOSOME_FIELD) - private String chromosome; - - @Field(value = START_FIELD) - private int start; - - @Field(value = END_FIELD) - private int end; - - @Field(value = VEP_VERSION_FIELD) - private String vepVersion; - - @Field(value = VEP_CACHE_VERSION_FIELD) - private String vepCacheVersion; - - SimplifiedAnnotation(){ - //Empty constructor for spring - } - - public SimplifiedAnnotation(Annotation annotation) { - this.id = annotation.getId(); - this.chromosome = annotation.getChromosome(); - this.start = annotation.getStart(); - this.end = annotation.getEnd(); - this.vepVersion = annotation.getVepVersion(); - this.vepCacheVersion = annotation.getVepCacheVersion(); - } -} diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/projections/SimplifiedVariant.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/projections/SimplifiedVariant.java index 9b8583ed4..1f4f48b18 100644 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/projections/SimplifiedVariant.java +++ b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/projections/SimplifiedVariant.java @@ -18,8 +18,8 @@ import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Field; import uk.ac.ebi.eva.commons.models.data.Variant; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.HgvsMongo; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantAt; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.HgvsMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.VariantAtMongo; import java.util.List; import java.util.Map; @@ -68,7 +68,7 @@ public class SimplifiedVariant { private String alternate; @Field(AT_FIELD) - private VariantAt at; + private VariantAtMongo at; @Field(HGVS_FIELD) private Set hgvs; @@ -123,7 +123,7 @@ public String getAlternate() { return alternate; } - public VariantAt getAt() { + public VariantAtMongo getAt() { return at; } diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/ConsequenceType.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/ConsequenceType.java deleted file mode 100644 index dcfdc4bdd..000000000 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/ConsequenceType.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2015-2017 EMBL - European Bioinformatics Institute - * - * 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 uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments; - -import org.springframework.data.mongodb.core.mapping.Field; - -import java.util.Set; - -/** - * Mongo database representation of a consequence type in a genomic variant annotation. - */ -public class ConsequenceType { - - private static final String GENE_NAME_FIELD = "gn"; - - private static final String ENSEMBL_GENE_ID_FIELD = "ensg"; - - private static final String ENSEMBL_TRANSCRIPT_ID_FIELD = "enst"; - - private static final String STRAND_FIELD = "strand"; - - private static final String BIOTYPE_FIELD = "bt"; - - private static final String C_DNA_POSITION_FIELD = "cDnaPos"; - - private static final String CDS_POSITION_FIELD = "cdsPos"; - - private static final String AA_POSITION_FIELD = "aaPos"; - - private static final String AA_CHANGE_FIELD = "aaChange"; - - private static final String CODON_FIELD = "codon"; - - public static final String SIFT_FIELD = "sift"; - - public static final String POLYPHEN_FIELD = "polyphen"; - - public static final String SO_ACCESSION_FIELD = "so"; - - private static final String RELATIVE_POS_FIELD = "relPos"; - - @Field(value = GENE_NAME_FIELD) - private String geneName; - - @Field(value = ENSEMBL_GENE_ID_FIELD) - private String ensemblGeneId; - - @Field(value = ENSEMBL_TRANSCRIPT_ID_FIELD) - private String ensemblTranscriptId; - - @Field(value = STRAND_FIELD) - private String strand; - - @Field(value = BIOTYPE_FIELD) - private String biotype; - - @Field(value = C_DNA_POSITION_FIELD) - private Integer cDnaPosition; - - @Field(value = CDS_POSITION_FIELD) - private Integer cdsPosition; - - @Field(value = AA_POSITION_FIELD) - private Integer aaPosition; - - @Field(value = AA_CHANGE_FIELD) - private String aaChange; - - @Field(value = CODON_FIELD) - private String codon; - - @Field(value = SIFT_FIELD) - private Score sift; - - @Field(value = POLYPHEN_FIELD) - private Score polyphen; - - @Field(value = SO_ACCESSION_FIELD) - private Set soAccessions; - - @Field(value = RELATIVE_POS_FIELD) - private Integer relativePosition; - - public ConsequenceType() { - } - - public void setEnsemblTranscriptId(String ensemblTranscriptId) { - this.ensemblTranscriptId = ensemblTranscriptId; - } - - public void setGeneName(String geneName) { - this.geneName = geneName; - } - - public void setEnsemblGeneId(String ensemblGeneId) { - this.ensemblGeneId = ensemblGeneId; - } - - public void setRelativePosition(Integer relativePosition) { - this.relativePosition = relativePosition; - } - - public void setCodon(String codon) { - this.codon = codon; - } - - public void setStrand(String strand) { - this.strand = strand; - } - - public void setBiotype(String biotype) { - this.biotype = biotype; - } - - public void setcDnaPosition(Integer cDnaPosition) { - this.cDnaPosition = cDnaPosition; - } - - public void setCdsPosition(Integer cdsPosition) { - this.cdsPosition = cdsPosition; - } - - public void setAaPosition(Integer aaPosition) { - this.aaPosition = aaPosition; - } - - public void setAaChange(String aaChange) { - this.aaChange = aaChange; - } - - public String getGeneName() { - return geneName; - } - - public String getEnsemblGeneId() { - return ensemblGeneId; - } - - public String getEnsemblTranscriptId() { - return ensemblTranscriptId; - } - - public Integer getRelativePosition() { - return relativePosition; - } - - public String getCodon() { - return codon; - } - - public String getStrand() { - return strand; - } - - public String getBiotype() { - return biotype; - } - - public Integer getcDnaPosition() { - return cDnaPosition; - } - - public Integer getCdsPosition() { - return cdsPosition; - } - - public Integer getAaPosition() { - return aaPosition; - } - - public String getAaChange() { - return aaChange; - } - - public Set getSoAccessions() { - return soAccessions; - } - - public void setSoAccessions(Set soAccessions) { - this.soAccessions = soAccessions; - } - - public Score getSift() { - return sift; - } - - public void setSift(Score sift) { - this.sift = sift; - } - - public Score getPolyphen() { - return polyphen; - } - - public void setPolyphen(Score polyphen) { - this.polyphen = polyphen; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ConsequenceType that = (ConsequenceType) o; - - if (geneName != null ? !geneName.equals(that.geneName) : that.geneName != null) return false; - if (ensemblGeneId != null ? !ensemblGeneId.equals(that.ensemblGeneId) : that.ensemblGeneId != null) - return false; - if (ensemblTranscriptId != null ? !ensemblTranscriptId - .equals(that.ensemblTranscriptId) : that.ensemblTranscriptId != null) return false; - if (strand != null ? !strand.equals(that.strand) : that.strand != null) return false; - if (biotype != null ? !biotype.equals(that.biotype) : that.biotype != null) return false; - if (cDnaPosition != null ? !cDnaPosition.equals(that.cDnaPosition) : that.cDnaPosition != null) return false; - if (cdsPosition != null ? !cdsPosition.equals(that.cdsPosition) : that.cdsPosition != null) return false; - if (aaPosition != null ? !aaPosition.equals(that.aaPosition) : that.aaPosition != null) return false; - if (aaChange != null ? !aaChange.equals(that.aaChange) : that.aaChange != null) return false; - if (codon != null ? !codon.equals(that.codon) : that.codon != null) return false; - if (sift != null ? !sift.equals(that.sift) : that.sift != null) return false; - if (polyphen != null ? !polyphen.equals(that.polyphen) : that.polyphen != null) return false; - if (soAccessions != null ? !soAccessions.equals(that.soAccessions) : that.soAccessions != null) return false; - return relativePosition != null ? relativePosition - .equals(that.relativePosition) : that.relativePosition == null; - } - - @Override - public int hashCode() { - int result = geneName != null ? geneName.hashCode() : 0; - result = 31 * result + (ensemblGeneId != null ? ensemblGeneId.hashCode() : 0); - result = 31 * result + (ensemblTranscriptId != null ? ensemblTranscriptId.hashCode() : 0); - result = 31 * result + (strand != null ? strand.hashCode() : 0); - result = 31 * result + (biotype != null ? biotype.hashCode() : 0); - result = 31 * result + (cDnaPosition != null ? cDnaPosition.hashCode() : 0); - result = 31 * result + (cdsPosition != null ? cdsPosition.hashCode() : 0); - result = 31 * result + (aaPosition != null ? aaPosition.hashCode() : 0); - result = 31 * result + (aaChange != null ? aaChange.hashCode() : 0); - result = 31 * result + (codon != null ? codon.hashCode() : 0); - result = 31 * result + (sift != null ? sift.hashCode() : 0); - result = 31 * result + (polyphen != null ? polyphen.hashCode() : 0); - result = 31 * result + (soAccessions != null ? soAccessions.hashCode() : 0); - result = 31 * result + (relativePosition != null ? relativePosition.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/HgvsMongo.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/HgvsMongo.java deleted file mode 100644 index 2841fed5c..000000000 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/HgvsMongo.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2017 EMBL - European Bioinformatics Institute - * - * 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 uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments; - -import org.springframework.data.mongodb.core.mapping.Field; - -/** - * Mongo database representation of HGVS field. - */ -public class HgvsMongo { - - private static final String TYPE_FIELD = "type"; - - private static final String NAME_FIELD = "name"; - - @Field(TYPE_FIELD) - private String type; - - @Field(NAME_FIELD) - private String name; - - HgvsMongo(){ - //Empty constructor for spring - } - - public HgvsMongo(String type, String name) { - this.type = type; - this.name = name; - } -} diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/Score.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/Score.java deleted file mode 100644 index c8b021743..000000000 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/Score.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2015-2017 EMBL - European Bioinformatics Institute - * - * 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 uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments; - -import org.springframework.data.mongodb.core.mapping.Field; - -/** - * Mongo database representation of a score / description pair of values. - */ -public class Score { - - public final static String SCORE_SCORE_FIELD = "sc"; - - public final static String SCORE_DESCRIPTION_FIELD = "desc"; - - @Field(value = SCORE_SCORE_FIELD) - private Double score; - - @Field(value = SCORE_DESCRIPTION_FIELD) - private String description; - - Score(){ - //Empty constructor for spring - } - - public Score(Double score, String description) { - this.score = score; - this.description = description; - } - - public Double getScore() { - return score; - } - - public String getDescription() { - return description; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Score score1 = (Score) o; - - if (score != null ? !score.equals(score1.score) : score1.score != null) return false; - return description != null ? description.equals(score1.description) : score1.description == null; - } - - @Override - public int hashCode() { - int result = score != null ? score.hashCode() : 0; - result = 31 * result + (description != null ? description.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantAnnotation.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantAnnotation.java index 8d2b81f0e..38cb7a2f3 100644 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantAnnotation.java +++ b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantAnnotation.java @@ -17,7 +17,10 @@ import org.springframework.data.mongodb.core.mapping.Field; import org.springframework.util.Assert; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.ConsequenceTypeMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.ScoreMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.XrefMongo; import java.util.ArrayList; import java.util.Collection; @@ -89,7 +92,7 @@ private VariantAnnotation(VariantAnnotation variantAnnotation) { doConcatenate(variantAnnotation); } - public VariantAnnotation(Annotation annotation) { + public VariantAnnotation(AnnotationMongo annotation) { this(annotation.getVepVersion(), annotation.getVepCacheVersion()); doConcatenate(annotation); } @@ -113,16 +116,16 @@ private void doConcatenate(VariantAnnotation variantAnnotation) { } } - private void doConcatenate(Annotation annotation) { - for (Xref xref : annotation.getXrefs()) { + private void doConcatenate(AnnotationMongo annotation) { + for (XrefMongo xref : annotation.getXrefs()) { addXrefId(xref.getId()); } - for (ConsequenceType consequenceType : annotation.getConsequenceTypes()) { - final Score sift = consequenceType.getSift(); + for (ConsequenceTypeMongo consequenceType : annotation.getConsequenceTypes()) { + final ScoreMongo sift = consequenceType.getSift(); if (sift != null) { concatenateSiftRange(sift.getScore()); } - final Score polyphen = consequenceType.getPolyphen(); + final ScoreMongo polyphen = consequenceType.getPolyphen(); if (polyphen != null) { concatenatePolyphenRange(polyphen.getScore()); } @@ -224,7 +227,7 @@ public String getVepCacheVersion() { return vepCacheVersion; } - public VariantAnnotation concatenate(Annotation annotation) { + public VariantAnnotation concatenate(AnnotationMongo annotation) { VariantAnnotation temp = new VariantAnnotation(this); temp.doConcatenate(annotation); return temp; diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantAt.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantAt.java deleted file mode 100644 index d07cdad51..000000000 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantAt.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2017 EMBL - European Bioinformatics Institute - * - * 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 uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments; - -import org.springframework.data.mongodb.core.mapping.Field; - -import java.util.HashSet; -import java.util.Set; - -/** - * Mongo database representation of a Variant AT field. - */ -public class VariantAt { - - private static final String CHUNK_IDS_FIELD = "chunkIds"; - - @Field(CHUNK_IDS_FIELD) - private Set chunkIds; - - VariantAt(){ - //Empty constructor for spring - } - - public VariantAt(String chunkSmall, String chunkBig) { - chunkIds = new HashSet<>(); - chunkIds.add(chunkSmall); - chunkIds.add(chunkBig); - } -} diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantSourceEntryMongo.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantSourceEntryMongo.java deleted file mode 100644 index b7e3c9f78..000000000 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantSourceEntryMongo.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright 2017 EMBL - European Bioinformatics Institute - * - * 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 uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments; - -import com.mongodb.BasicDBObject; -import org.opencb.biodata.models.feature.Genotype; -import org.springframework.data.mongodb.core.mapping.Field; -import uk.ac.ebi.eva.utils.CompressionHelper; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Mongo database representation of Variant Source entry. - */ -public class VariantSourceEntryMongo { - - public final static char CHARACTER_TO_REPLACE_DOTS = (char) 163; // <-- £ - - public final static String FILEID_FIELD = "fid"; - - public final static String STUDYID_FIELD = "sid"; - - public final static String ALTERNATES_FIELD = "alts"; - - public final static String ATTRIBUTES_FIELD = "attrs"; - - public final static String FORMAT_FIELD = "fm"; - - public final static String SAMPLES_FIELD = "samp"; - - @Field(FILEID_FIELD) - private String fileId; - - @Field(STUDYID_FIELD) - private String studyId; - - @Field(ALTERNATES_FIELD) - private String[] alternates; - - @Field(ATTRIBUTES_FIELD) - private BasicDBObject attrs; - - @Field(FORMAT_FIELD) - private String format; - - @Field(SAMPLES_FIELD) - private BasicDBObject samp; - - VariantSourceEntryMongo() { - // Spring empty constructor - } - - public VariantSourceEntryMongo(String fileId, String studyId, String[] alternates, Map attributes) { - this.fileId = fileId; - this.studyId = studyId; - if (alternates != null && alternates.length > 0) { - this.alternates = new String[alternates.length]; - System.arraycopy(alternates, 0, this.alternates, 0, alternates.length); - } - attrs = buildAttributes(attributes); - - this.format = null; - this.samp = null; - } - - public VariantSourceEntryMongo(String fileId, String studyId, String[] alternates, Map - attributes, String format, List> samplesData) { - this(fileId, studyId, alternates, attributes); - this.format = format; - this.samp = buildSampleData(samplesData); - } - - private BasicDBObject buildSampleData(List> samplesData) { - Map> genotypeCodes = classifySamplesByGenotype(samplesData); - - // Get the most common genotype - Map.Entry> longestList = getLongestGenotypeList(genotypeCodes); - - // In Mongo, samples are stored in a map, classified by their genotype. - // The most common genotype will be marked as "default" and the specific - // positions where it is shown will not be stored. Example from 1000G: - // "def" : 0|0, - // "0|1" : [ 41, 311, 342, 358, 881, 898, 903 ], - // "1|0" : [ 262, 290, 300, 331, 343, 369, 374, 391, 879, 918, 930 ] - BasicDBObject mongoSamples = new BasicDBObject(); - for (Map.Entry> entry : genotypeCodes.entrySet()) { - String genotypeStr = entry.getKey().toString().replace(".", "-1"); - if (longestList != null && entry.getKey().equals(longestList.getKey())) { - mongoSamples.append("def", genotypeStr); - } else { - mongoSamples.append(genotypeStr, entry.getValue()); - } - } - - return mongoSamples; - } - - private Map.Entry> getLongestGenotypeList(Map> genotypeCodes) { - Map.Entry> longestList = null; - for (Map.Entry> entry : genotypeCodes.entrySet()) { - List genotypeList = entry.getValue(); - if (longestList == null || genotypeList.size() > longestList.getValue().size()) { - longestList = entry; - } - } - return longestList; - } - - private Map> classifySamplesByGenotype(List> samplesData) { - Map> genotypeCodes = new HashMap<>(); - - for (int i = 0; i < samplesData.size(); i++) { - String genotype = samplesData.get(i).get("GT"); - if (genotype != null) { - Genotype g = new Genotype(genotype); - List samplesWithGenotype = genotypeCodes.get(g); - if (samplesWithGenotype == null) { - samplesWithGenotype = new ArrayList<>(); - genotypeCodes.put(g, samplesWithGenotype); - } - samplesWithGenotype.add(i); - } - } - return genotypeCodes; - } - - private BasicDBObject buildAttributes(Map attributes) { - BasicDBObject attrs = null; - for (Map.Entry entry : attributes.entrySet()) { - Object value = entry.getValue(); - if (entry.getKey().equals("src")) { - String[] fields = entry.getValue().split("\t"); - StringBuilder sb = new StringBuilder(); - sb.append(fields[0]); - for (int i = 1; i < fields.length && i < 8; i++) { - sb.append("\t").append(fields[i]); - } - try { - value = CompressionHelper.gzip(sb.toString()); - } catch (IOException ex) { - Logger.getLogger(VariantSourceEntryMongo.class.getName()).log(Level.SEVERE, null, ex); - } - } - - if (attrs == null) { - attrs = new BasicDBObject(entry.getKey().replace('.', CHARACTER_TO_REPLACE_DOTS), value); - } else { - attrs.append(entry.getKey().replace('.', CHARACTER_TO_REPLACE_DOTS), value); - } - } - return attrs; - } - -} diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/Xref.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/Xref.java deleted file mode 100644 index 00b245dd0..000000000 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/Xref.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2017 EMBL - European Bioinformatics Institute - * - * 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 uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments; - -import org.springframework.data.mongodb.core.mapping.Field; - -/** - * Mongo database representation of Xref field in a genomic variant annotation - */ -public class Xref { - - public final static String XREF_ID_FIELD = "id"; - - private final static String XREF_SOURCE_FIELD = "src"; - - @Field(value = XREF_ID_FIELD) - private String id; - - @Field(value = XREF_SOURCE_FIELD) - private String src; - - Xref(){ - //Empty constructor for spring - } - - public Xref(String id, String src) { - this.id = id; - this.src = src; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Xref xref = (Xref) o; - - if (id != null ? !id.equals(xref.id) : xref.id != null) return false; - return src != null ? src.equals(xref.src) : xref.src == null; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (src != null ? src.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/readers/AnnotationReaderConfiguration.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/readers/AnnotationReaderConfiguration.java index 4806bccf5..de033bb5d 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/readers/AnnotationReaderConfiguration.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/readers/AnnotationReaderConfiguration.java @@ -20,7 +20,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.pipeline.io.readers.AnnotationFlatFileReader; import uk.ac.ebi.eva.pipeline.parameters.AnnotationParameters; @@ -34,7 +34,7 @@ public class AnnotationReaderConfiguration { @Bean(VARIANT_ANNOTATION_READER) @StepScope - public ItemStreamReader annotationReader(AnnotationParameters annotationParameters) { + public ItemStreamReader annotationReader(AnnotationParameters annotationParameters) { return new AnnotationFlatFileReader(annotationParameters.getVepOutput(), annotationParameters.getVepVersion(), annotationParameters.getVepCacheVersion()); } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationCompositeWriterConfiguration.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationCompositeWriterConfiguration.java index 8d7ba019f..4c678f0b6 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationCompositeWriterConfiguration.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationCompositeWriterConfiguration.java @@ -25,7 +25,7 @@ import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Profile; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.pipeline.Application; import java.util.Arrays; @@ -41,17 +41,17 @@ public class AnnotationCompositeWriterConfiguration { @Autowired @Qualifier(ANNOTATION_WRITER) - private ItemWriter> annotationItemWriter; + private ItemWriter> annotationItemWriter; @Autowired @Qualifier(ANNOTATION_IN_VARIANT_WRITER) - private ItemWriter> variantAnnotationItemWriter; + private ItemWriter> variantAnnotationItemWriter; @Bean(COMPOSITE_ANNOTATION_VARIANT_WRITER) @StepScope @Profile(Application.VARIANT_ANNOTATION_MONGO_PROFILE) - public CompositeItemWriter> compositeAnnotationItemWriter(){ - CompositeItemWriter> writer = new CompositeItemWriter<>(); + public CompositeItemWriter> compositeAnnotationItemWriter(){ + CompositeItemWriter> writer = new CompositeItemWriter<>(); writer.setDelegates(Arrays.asList(annotationItemWriter, variantAnnotationItemWriter)); return writer; } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationInVariantWriterConfiguration.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationInVariantWriterConfiguration.java index 00cc0b586..43724aa4b 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationInVariantWriterConfiguration.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationInVariantWriterConfiguration.java @@ -22,7 +22,7 @@ import org.springframework.context.annotation.Profile; import org.springframework.data.mongodb.core.MongoOperations; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.pipeline.Application; import uk.ac.ebi.eva.pipeline.io.writers.AnnotationInVariantMongoWriter; import uk.ac.ebi.eva.pipeline.parameters.AnnotationParameters; @@ -38,7 +38,7 @@ public class AnnotationInVariantWriterConfiguration { @Bean(ANNOTATION_IN_VARIANT_WRITER) @StepScope @Profile(Application.VARIANT_ANNOTATION_MONGO_PROFILE) - public ItemWriter> variantAnnotationItemWriter(MongoOperations mongoOperations, + public ItemWriter> variantAnnotationItemWriter(MongoOperations mongoOperations, DatabaseParameters databaseParameters, AnnotationParameters annotationParameters) { return new AnnotationInVariantMongoWriter(mongoOperations, databaseParameters.getCollectionVariantsName(), diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationWriterConfiguration.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationWriterConfiguration.java index 0025dfd4f..83a77c10d 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationWriterConfiguration.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/io/writers/AnnotationWriterConfiguration.java @@ -21,7 +21,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.data.mongodb.core.MongoOperations; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.pipeline.Application; import uk.ac.ebi.eva.pipeline.io.writers.AnnotationMongoWriter; import uk.ac.ebi.eva.pipeline.parameters.DatabaseParameters; @@ -36,7 +36,7 @@ public class AnnotationWriterConfiguration { @Bean(ANNOTATION_WRITER) @StepScope @Profile(Application.VARIANT_ANNOTATION_MONGO_PROFILE) - public ItemWriter> annotationItemWriter(MongoOperations mongoOperations, + public ItemWriter> annotationItemWriter(MongoOperations mongoOperations, DatabaseParameters databaseParameters) { return new AnnotationMongoWriter(mongoOperations, databaseParameters.getCollectionAnnotationsName()); } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/GenerateVepAnnotationStepConfiguration.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/GenerateVepAnnotationStepConfiguration.java index 8daf98f00..9e31fc6d0 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/GenerateVepAnnotationStepConfiguration.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/GenerateVepAnnotationStepConfiguration.java @@ -30,7 +30,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.pipeline.configuration.ChunkSizeCompletionPolicyConfiguration; import uk.ac.ebi.eva.pipeline.configuration.io.readers.VariantsMongoReaderConfiguration; import uk.ac.ebi.eva.pipeline.configuration.io.writers.AnnotationCompositeWriterConfiguration; @@ -71,18 +71,18 @@ public class GenerateVepAnnotationStepConfiguration { @Autowired @Qualifier(ANNOTATION_COMPOSITE_PROCESSOR) - private ItemProcessor, List> annotationCompositeProcessor; + private ItemProcessor, List> annotationCompositeProcessor; @Autowired @Qualifier(COMPOSITE_ANNOTATION_VARIANT_WRITER) - private ItemWriter> annotationWriter; + private ItemWriter> annotationWriter; @Bean(GENERATE_VEP_ANNOTATION_STEP) public Step generateVepAnnotationStep(StepBuilderFactory stepBuilderFactory, JobOptions jobOptions) { logger.debug("Building '" + GENERATE_VEP_ANNOTATION_STEP + "'"); return stepBuilderFactory.get(GENERATE_VEP_ANNOTATION_STEP) - ., List>chunk(1) + ., List>chunk(1) .reader(nonAnnotatedVariantsReader) .processor(annotationCompositeProcessor) .writer(annotationWriter) diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/AnnotationCompositeProcessorConfiguration.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/AnnotationCompositeProcessorConfiguration.java index 687cf9c87..ee3e2d2a4 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/AnnotationCompositeProcessorConfiguration.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/AnnotationCompositeProcessorConfiguration.java @@ -25,7 +25,7 @@ import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Profile; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.pipeline.Application; import uk.ac.ebi.eva.pipeline.model.EnsemblVariant; @@ -46,13 +46,13 @@ public class AnnotationCompositeProcessorConfiguration { @Autowired @Qualifier(ANNOTATION_PARSER_PROCESSOR) - private ItemProcessor, List> annotationParserProcessor; + private ItemProcessor, List> annotationParserProcessor; @Bean(ANNOTATION_COMPOSITE_PROCESSOR) @StepScope @Profile(Application.VARIANT_ANNOTATION_MONGO_PROFILE) - public CompositeItemProcessor, List> compositeAnnotationItemWriter(){ - CompositeItemProcessor, List> processor = new CompositeItemProcessor<>(); + public CompositeItemProcessor, List> compositeAnnotationItemWriter(){ + CompositeItemProcessor, List> processor = new CompositeItemProcessor<>(); processor.setDelegates(Arrays.asList(vepAnnotationProcessor, annotationParserProcessor)); return processor; } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/AnnotationParserProcessorConfiguration.java b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/AnnotationParserProcessorConfiguration.java index b4228cd85..37e38dba3 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/AnnotationParserProcessorConfiguration.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/processors/AnnotationParserProcessorConfiguration.java @@ -20,7 +20,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.pipeline.jobs.steps.processors.AnnotationParserProcessor; import uk.ac.ebi.eva.pipeline.parameters.AnnotationParameters; @@ -39,7 +39,7 @@ public class AnnotationParserProcessorConfiguration { @Bean(ANNOTATION_PARSER_PROCESSOR) @StepScope - public ItemProcessor, List> annotationParserProcessor( + public ItemProcessor, List> annotationParserProcessor( AnnotationParameters annotationParameters) { return new AnnotationParserProcessor(annotationParameters); } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapper.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapper.java index 528375fae..4d00cd539 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapper.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapper.java @@ -22,18 +22,19 @@ import org.slf4j.LoggerFactory; import org.springframework.batch.item.file.LineMapper; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.ConsequenceType; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.Score; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.ConsequenceTypeMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.ScoreMongo; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; /** - * Map a line in VEP output file to {@link Annotation} + * Map a line in VEP output file to {@link AnnotationMongo} * * Example of VEP output line * 20_60343_G/A 20:60343 A - - - intergenic_variant - - - - - - @@ -45,12 +46,12 @@ * public methods in VepFormatReader can't be reused because there is a reference to the previous line (currentVariantString) * that prevent each line to be independent * - * Here each line is mapped to {@link Annotation}; in case of two annotations for the same variant, a new - * {@link Annotation} object is created containing only the fields that will be appended: + * Here each line is mapped to {@link AnnotationMongo}; in case of two annotations for the same variant, a new + * {@link AnnotationMongo} object is created containing only the fields that will be appended: * - ConsequenceTypes * - Hgvs */ -public class AnnotationLineMapper implements LineMapper { +public class AnnotationLineMapper implements LineMapper { private static final Logger logger = LoggerFactory.getLogger(AnnotationLineMapper.class); private final String vepVersion; @@ -62,10 +63,10 @@ public AnnotationLineMapper(String vepVersion, String vepCacheVersion) { } /** - * Map a line in VEP output file to {@link Annotation} + * Map a line in VEP output file to {@link AnnotationMongo} * @param line in VEP output * @param lineNumber - * @return a {@link Annotation} + * @return a {@link AnnotationMongo} * * Most of the code is from org.opencb.biodata.formats.annotation.io.VepFormatReader#read() with few differences: * - An empty array is initialized for Hgvs (like ConsequenceTypes); @@ -73,18 +74,13 @@ public AnnotationLineMapper(String vepVersion, String vepCacheVersion) { * - The logic to move around the file (read line) and reference to previous line (currentVariantString) are removed; */ @Override - public Annotation mapLine(String line, int lineNumber) { - ConsequenceType consequenceType = new ConsequenceType(); + public AnnotationMongo mapLine(String line, int lineNumber) { + ConsequenceTypeMongo consequenceType = new ConsequenceTypeMongo(null, null, + null, null, null, null, null, null, + null, null, null, null, null, null); String[] lineFields = line.split("\t"); Map variantMap = parseVariant(lineFields[0], lineFields[1]); // coordinates and alternative are only parsed once - Annotation currentAnnotation = new Annotation( - variantMap.get("chromosome"), - Integer.valueOf(variantMap.get("start")), - Integer.valueOf(variantMap.get("end")), variantMap.get("reference"), - variantMap.get("alternative"), - vepVersion, - vepCacheVersion); /** * parses extra column and populates fields as required. @@ -101,16 +97,38 @@ public Annotation mapLine(String line, int lineNumber) { } else { consequenceType.setSoAccessions(mapSoTermsToSoAccessions(lineFields[6].split(","))); } - currentAnnotation.addConsequenceType(consequenceType); - - return currentAnnotation; + AnnotationMongo currentAnnotation = new AnnotationMongo( + AnnotationMongo.buildAnnotationId( + variantMap.get("chromosome"), + Integer.valueOf(variantMap.get("start")), + variantMap.get("reference"), + variantMap.get("alternative"), + vepVersion, + vepCacheVersion), + variantMap.get("chromosome"), + Integer.valueOf(variantMap.get("start")), + Integer.valueOf(variantMap.get("end")), + vepVersion, + vepCacheVersion, + null, + Collections.singleton(consequenceType)); + + AnnotationMongo AnnotationWithXref = new AnnotationMongo( + variantMap.get("chromosome"), + Long.valueOf(variantMap.get("start")), + Long.valueOf(variantMap.get("end")), + variantMap.get("reference"), + variantMap.get("alternative"), + vepVersion, + vepCacheVersion); + return AnnotationWithXref.concatenate(currentAnnotation); } /** * From org.opencb.biodata.formats.annotation.io.VepFormatReader * #parseRemainingFields(org.opencb.biodata.models.variant.annotation.ConsequenceType, java.lang.String[]) */ - private void parseTranscriptFields(ConsequenceType consequenceType, String[] lineFields) { + private void parseTranscriptFields(ConsequenceTypeMongo consequenceType, String[] lineFields) { consequenceType.setEnsemblGeneId(lineFields[3]); consequenceType.setEnsemblTranscriptId(lineFields[4]); if(!lineFields[6].equals("") && !lineFields[6].equals("-")) { // VEP may leave this field empty @@ -198,7 +216,7 @@ private Map parseVariant(String variantString, String coordinates * * The parseFrequencies option has been removed */ - private void parseExtraField(ConsequenceType consequenceType, String extraField) { + private void parseExtraField(ConsequenceTypeMongo consequenceType, String extraField) { for (String field : extraField.split(";")) { String[] keyValue = field.split("="); @@ -229,8 +247,8 @@ private void parseExtraField(ConsequenceType consequenceType, String extraField) * From org.opencb.biodata.formats.annotation.io.VepFormatReader * #parseProteinSubstitutionScore(java.lang.String, java.lang.String) */ - private Score parseProteinSubstitutionScore(String scoreString) { + private ScoreMongo parseProteinSubstitutionScore(String scoreString) { String[] scoreFields = scoreString.split("[\\(\\)]"); - return new Score(Double.valueOf(scoreFields[1]), scoreFields[0]); + return new ScoreMongo(Double.valueOf(scoreFields[1]), scoreFields[0]); } } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/AnnotationFlatFileReader.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/AnnotationFlatFileReader.java index 35f70f34c..aff483f13 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/AnnotationFlatFileReader.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/AnnotationFlatFileReader.java @@ -18,7 +18,7 @@ import org.springframework.batch.item.file.FlatFileItemReader; import org.springframework.core.io.Resource; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.pipeline.io.GzipLazyResource; import uk.ac.ebi.eva.pipeline.io.mappers.AnnotationLineMapper; @@ -34,7 +34,7 @@ * 20_60479_C/T 20:60479 T - - - intergenic_variant - - - - - rs149529999 GMAF=T:0.0018;AFR_MAF=T:0.01;AMR_MAF=T:0.0028 * ... */ -public class AnnotationFlatFileReader extends FlatFileItemReader { +public class AnnotationFlatFileReader extends FlatFileItemReader { public AnnotationFlatFileReader(File file, String vepVersion, String vepCacheVersion) { Resource resource = new GzipLazyResource(file); diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/VariantsMongoReader.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/VariantsMongoReader.java index 87c449a5d..366248cb4 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/VariantsMongoReader.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/readers/VariantsMongoReader.java @@ -28,11 +28,11 @@ import org.springframework.data.mongodb.core.convert.MongoConverter; import org.springframework.util.ClassUtils; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.commons.models.mongo.entity.VariantDocument; import uk.ac.ebi.eva.commons.models.mongo.entity.projections.SimplifiedVariant; import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantAnnotation; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantSourceEntryMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.VariantSourceEntryMongo; import uk.ac.ebi.eva.pipeline.model.EnsemblVariant; import javax.annotation.PostConstruct; @@ -111,8 +111,8 @@ public VariantsMongoReader(MongoOperations mongoOperations, String collectionVar if (excludeAnnotated) { BasicDBObject exists = new BasicDBObject("$exists", 1); BasicDBObject annotationSubdocument = new BasicDBObject(VariantAnnotation.SO_ACCESSION_FIELD, exists) - .append(Annotation.VEP_VERSION_FIELD, vepVersion) - .append(Annotation.VEP_CACHE_VERSION_FIELD, vepCacheVersion); + .append(AnnotationMongo.VEP_VERSION_FIELD, vepVersion) + .append(AnnotationMongo.VEP_CACHE_VERSION_FIELD, vepCacheVersion); BasicDBObject noElementMatchesOurVersion = new BasicDBObject("$not", new BasicDBObject("$elemMatch", annotationSubdocument)); queryBuilder.add(VariantDocument.ANNOTATION_FIELD, noElementMatchesOurVersion); diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationInVariantMongoWriter.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationInVariantMongoWriter.java index 19d86abb5..0c2fea406 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationInVariantMongoWriter.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationInVariantMongoWriter.java @@ -25,7 +25,7 @@ import org.springframework.data.mongodb.core.query.BasicUpdate; import org.springframework.util.Assert; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantAnnotation; import java.util.Arrays; @@ -47,7 +47,7 @@ * - soAccessions * - Xref Ids */ -public class AnnotationInVariantMongoWriter implements ItemWriter> { +public class AnnotationInVariantMongoWriter implements ItemWriter> { public static final String ID = "_id"; public static final String SET = "$set"; @@ -80,8 +80,8 @@ public AnnotationInVariantMongoWriter(MongoOperations mongoOperations, } @Override - public void write(List> annotations) throws Exception { - for (List annotationList : annotations) { + public void write(List> annotations) throws Exception { + for (List annotationList : annotations) { Map variantAnnotations = generateVariantAnnotations(annotationList); BulkOperations bulkOperations = mongoOperations.bulkOps(BulkOperations.BulkMode.UNORDERED, collection); @@ -90,10 +90,10 @@ public void write(List> annotations) throws Exception } } - private Map generateVariantAnnotations(List annotations) { + private Map generateVariantAnnotations(List annotations) { HashMap variantAnnotations = new HashMap<>(); - for (Annotation annotation : annotations) { + for (AnnotationMongo annotation : annotations) { String id = annotation.getId(); variantAnnotations.putIfAbsent(id, new VariantAnnotation(annotation)); variantAnnotations.computeIfPresent(id, (key, oldVar) -> oldVar.concatenate(annotation)); diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationMongoWriter.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationMongoWriter.java index 71f9a60ef..e88bd090e 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationMongoWriter.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationMongoWriter.java @@ -27,10 +27,10 @@ import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Update; import org.springframework.util.Assert; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; -import uk.ac.ebi.eva.commons.models.mongo.entity.projections.SimplifiedAnnotation; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.ConsequenceType; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.Xref; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.projections.SimplifiedAnnotation; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.ConsequenceTypeMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.XrefMongo; import uk.ac.ebi.eva.utils.MongoDBHelper; import java.util.Collection; @@ -38,11 +38,11 @@ import java.util.List; import java.util.Map; -import static uk.ac.ebi.eva.commons.models.mongo.entity.Annotation.CONSEQUENCE_TYPE_FIELD; -import static uk.ac.ebi.eva.commons.models.mongo.entity.Annotation.XREFS_FIELD; +import static uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo.CONSEQUENCE_TYPE_FIELD; +import static uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo.XREFS_FIELD; /** - * Write a list of {@link Annotation} into MongoDB + * Write a list of {@link AnnotationMongo} into MongoDB *

* A new annotation is added in the existing document. * In case of two annotations (or more) in the same variant the other annotations are appended: @@ -63,12 +63,12 @@ * { "id" : "ENST00000608838", "src" : "ensemblTranscript" }, * { "id" : "ENSG00000178591", "src" : "ensemblGene" */ -public class AnnotationMongoWriter implements ItemWriter> { +public class AnnotationMongoWriter implements ItemWriter> { - private static final String ANNOTATION_XREF_ID_FIELD = Annotation.XREFS_FIELD + "." + Xref.XREF_ID_FIELD; + private static final String ANNOTATION_XREF_ID_FIELD = XREFS_FIELD + "." + XrefMongo.XREF_ID_FIELD; - private static final String ANNOTATION_CT_SO_FIELD = Annotation.CONSEQUENCE_TYPE_FIELD + "." - + ConsequenceType.SO_ACCESSION_FIELD; + private static final String ANNOTATION_CT_SO_FIELD = CONSEQUENCE_TYPE_FIELD + "." + + ConsequenceTypeMongo.SO_ACCESSION_FIELD; public static final String EACH = "$each"; public static final String ADD_TO_SET = "$addToSet"; @@ -86,24 +86,24 @@ public AnnotationMongoWriter(MongoOperations mongoOperations, String collection) } @Override - public void write(List> annotations) throws Exception { - for (List annotationList : annotations) { + public void write(List> annotations) throws Exception { + for (List annotationList : annotations) { BulkOperations bulk = mongoOperations.bulkOps(BulkOperations.BulkMode.UNORDERED, collection); prepareBulk(annotationList, bulk); bulk.execute(); } } - private void prepareBulk(List annotations, BulkOperations bulk) { - Map annotationsByStorageId = groupAnnotationById(annotations); - for (Annotation annotation : annotationsByStorageId.values()) { + private void prepareBulk(List annotations, BulkOperations bulk) { + Map annotationsByStorageId = groupAnnotationById(annotations); + for (AnnotationMongo annotation : annotationsByStorageId.values()) { writeAnnotationInMongoDb(bulk, annotation); } } - private Map groupAnnotationById(List annotations) { - Map groupedAnnotations = new HashMap<>(); - for (Annotation annotation : annotations) { + private Map groupAnnotationById(List annotations) { + Map groupedAnnotations = new HashMap<>(); + for (AnnotationMongo annotation : annotations) { String id = annotation.getId(); groupedAnnotations.computeIfPresent(id, (key, oldVar) -> oldVar.concatenate(annotation)); groupedAnnotations.putIfAbsent(id, annotation); @@ -111,24 +111,24 @@ private Map groupAnnotationById(List a return groupedAnnotations; } - private void writeAnnotationInMongoDb(BulkOperations bulk, Annotation annotation) { + private void writeAnnotationInMongoDb(BulkOperations bulk, AnnotationMongo annotation) { Query upsertQuery = new BasicQuery(convertToMongo(new SimplifiedAnnotation(annotation))); Update update = buildUpdateQuery(annotation); bulk.upsert(upsertQuery, update); } - private BasicUpdate buildUpdateQuery(Annotation annotation) { + private BasicUpdate buildUpdateQuery(AnnotationMongo annotation) { final BasicDBObject addToSetValue = new BasicDBObject(); addToSetValue.append(CONSEQUENCE_TYPE_FIELD, buildInsertConsequenceTypeQuery(annotation)); addToSetValue.append(XREFS_FIELD, buildInsertXrefsQuery(annotation)); return new BasicUpdate(new BasicDBObject(ADD_TO_SET, addToSetValue)); } - private BasicDBObject buildInsertXrefsQuery(Annotation annotation) { + private BasicDBObject buildInsertXrefsQuery(AnnotationMongo annotation) { return new BasicDBObject(EACH, convertToMongo(annotation.getXrefs())); } - private BasicDBObject buildInsertConsequenceTypeQuery(Annotation annotation) { + private BasicDBObject buildInsertConsequenceTypeQuery(AnnotationMongo annotation) { return new BasicDBObject(EACH, convertToMongo(annotation.getConsequenceTypes())); } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/VariantMongoWriter.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/VariantMongoWriter.java index 77dc67b60..0362ce2e6 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/VariantMongoWriter.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/writers/VariantMongoWriter.java @@ -29,7 +29,7 @@ import uk.ac.ebi.eva.commons.models.data.VariantStats; import uk.ac.ebi.eva.commons.models.mongo.entity.VariantDocument; import uk.ac.ebi.eva.commons.models.mongo.entity.projections.SimplifiedVariant; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantSourceEntryMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.VariantSourceEntryMongo; import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantStatsMongo; import uk.ac.ebi.eva.utils.MongoDBHelper; diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/jobs/steps/processors/AnnotationParserProcessor.java b/src/main/java/uk/ac/ebi/eva/pipeline/jobs/steps/processors/AnnotationParserProcessor.java index 3b7e26376..d3be3bf35 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/jobs/steps/processors/AnnotationParserProcessor.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/jobs/steps/processors/AnnotationParserProcessor.java @@ -17,7 +17,7 @@ import org.springframework.batch.item.ItemProcessor; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.pipeline.io.VepProcess; import uk.ac.ebi.eva.pipeline.io.mappers.AnnotationLineMapper; import uk.ac.ebi.eva.pipeline.parameters.AnnotationParameters; @@ -29,7 +29,7 @@ * ItemStreamWriter that takes VariantWrappers and serialize them into a {@link VepProcess}, which will be responsible * for annotating the variants and writing them to a file. */ -public class AnnotationParserProcessor implements ItemProcessor, List> { +public class AnnotationParserProcessor implements ItemProcessor, List> { private static final int UNUSED_LINE_NUMBER = 0; @@ -41,7 +41,7 @@ public AnnotationParserProcessor(AnnotationParameters annotationParameters) { } @Override - public List process(List ensemblVariants) throws Exception { + public List process(List ensemblVariants) throws Exception { return ensemblVariants.stream() .map(ensemblVariant -> annotationLineMapper.mapLine(ensemblVariant, UNUSED_LINE_NUMBER)) .collect(Collectors.toList()); diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/jobs/steps/tasklets/AnnotationMetadataTasklet.java b/src/main/java/uk/ac/ebi/eva/pipeline/jobs/steps/tasklets/AnnotationMetadataTasklet.java index 9ecfff5dd..277e2d0a5 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/jobs/steps/tasklets/AnnotationMetadataTasklet.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/jobs/steps/tasklets/AnnotationMetadataTasklet.java @@ -24,7 +24,7 @@ import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; -import uk.ac.ebi.eva.commons.models.metadata.AnnotationMetadata; +import uk.ac.ebi.eva.commons.core.models.AnnotationMetadata; import uk.ac.ebi.eva.pipeline.parameters.AnnotationParameters; import uk.ac.ebi.eva.pipeline.parameters.DatabaseParameters; diff --git a/src/test/java/uk/ac/ebi/eva/commons/models/converters/data/VariantSourceEntryToDBObjectConverterTest.java b/src/test/java/uk/ac/ebi/eva/commons/models/converters/data/VariantSourceEntryToDBObjectConverterTest.java index 78b5b2e74..3e6359f7a 100644 --- a/src/test/java/uk/ac/ebi/eva/commons/models/converters/data/VariantSourceEntryToDBObjectConverterTest.java +++ b/src/test/java/uk/ac/ebi/eva/commons/models/converters/data/VariantSourceEntryToDBObjectConverterTest.java @@ -26,7 +26,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import uk.ac.ebi.eva.commons.models.data.VariantSourceEntry; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantSourceEntryMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.VariantSourceEntryMongo; import uk.ac.ebi.eva.test.configuration.MongoOperationConfiguration; import java.util.Arrays; @@ -34,10 +34,10 @@ import java.util.Map; import static org.junit.Assert.assertEquals; -import static uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantSourceEntryMongo.ATTRIBUTES_FIELD; -import static uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantSourceEntryMongo.CHARACTER_TO_REPLACE_DOTS; -import static uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantSourceEntryMongo.FILEID_FIELD; -import static uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantSourceEntryMongo.STUDYID_FIELD; +import static uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.VariantSourceEntryMongo.ATTRIBUTES_FIELD; +import static uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.VariantSourceEntryMongo.CHARACTER_TO_REPLACE_DOTS; +import static uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.VariantSourceEntryMongo.FILEID_FIELD; +import static uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.VariantSourceEntryMongo.STUDYID_FIELD; /** * Tests automatic conversion from {@link VariantSourceEntryMongo} to {@link DBObject} @@ -63,6 +63,7 @@ public void setUp() { file.addAttribute("QUAL", "0.01"); file.addAttribute("AN", "2"); file.addAttribute("MAX.PROC", "2"); + file.setFormat("gzip"); Map na001 = new HashMap<>(); na001.put("GT", "0/0"); @@ -88,6 +89,7 @@ public void setUp() { ((DBObject) mongoFileWithIds.get("samp")).put("def", "0/0"); ((DBObject) mongoFileWithIds.get("samp")).put("0/1", Arrays.asList(indexNa002)); ((DBObject) mongoFileWithIds.get("samp")).put("1/1", Arrays.asList(indexNa003)); + mongoFileWithIds.put("fm", "gzip"); } @Test diff --git a/src/test/java/uk/ac/ebi/eva/commons/models/converters/data/VariantToDBObjectConverterTest.java b/src/test/java/uk/ac/ebi/eva/commons/models/converters/data/VariantToDBObjectConverterTest.java index c57269419..b87290e3d 100644 --- a/src/test/java/uk/ac/ebi/eva/commons/models/converters/data/VariantToDBObjectConverterTest.java +++ b/src/test/java/uk/ac/ebi/eva/commons/models/converters/data/VariantToDBObjectConverterTest.java @@ -28,8 +28,8 @@ import uk.ac.ebi.eva.commons.models.data.Variant; import uk.ac.ebi.eva.commons.models.data.VariantSourceEntry; import uk.ac.ebi.eva.commons.models.mongo.entity.VariantDocument; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.HgvsMongo; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantSourceEntryMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.HgvsMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.VariantSourceEntryMongo; import uk.ac.ebi.eva.test.configuration.MongoOperationConfiguration; import java.util.ArrayList; diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/AnnotationJobTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/AnnotationJobTest.java index 89b978819..e34403ae6 100644 --- a/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/AnnotationJobTest.java +++ b/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/AnnotationJobTest.java @@ -46,7 +46,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static uk.ac.ebi.eva.commons.models.mongo.entity.Annotation.CONSEQUENCE_TYPE_FIELD; +import static uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo.CONSEQUENCE_TYPE_FIELD; import static uk.ac.ebi.eva.test.utils.JobTestUtils.assertCompleted; import static uk.ac.ebi.eva.test.utils.TestFileUtils.getResourceUrl; import static uk.ac.ebi.eva.utils.FileUtils.getResource; diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/AnnotationMetadataStepTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/AnnotationMetadataStepTest.java index f78e92f78..06c981d4e 100644 --- a/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/AnnotationMetadataStepTest.java +++ b/src/test/java/uk/ac/ebi/eva/pipeline/configuration/jobs/steps/AnnotationMetadataStepTest.java @@ -32,7 +32,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; -import uk.ac.ebi.eva.commons.models.metadata.AnnotationMetadata; +import uk.ac.ebi.eva.commons.core.models.AnnotationMetadata; import uk.ac.ebi.eva.pipeline.Application; import uk.ac.ebi.eva.pipeline.configuration.BeanNames; import uk.ac.ebi.eva.pipeline.configuration.MongoConfiguration; diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapperTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapperTest.java index e95bf1b30..c85de3516 100644 --- a/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapperTest.java +++ b/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapperTest.java @@ -17,9 +17,9 @@ import org.junit.Test; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.ConsequenceType; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.Score; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.ConsequenceTypeMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.ScoreMongo; import uk.ac.ebi.eva.test.data.VepOutputContent; import java.util.Set; @@ -43,7 +43,7 @@ public class AnnotationLineMapperTest { public void shouldParseAllDefaultFieldsInVepOutput() throws Exception { AnnotationLineMapper lineMapper = new AnnotationLineMapper(VEP_VERSION, VEP_CACHE_VERSION); for (String annotLine : VepOutputContent.vepOutputContent.split("\n")) { - Annotation annotation = lineMapper.mapLine(annotLine, 0); + AnnotationMongo annotation = lineMapper.mapLine(annotLine, 0); assertNotNull(annotation.getConsequenceTypes()); } } @@ -51,13 +51,13 @@ public void shouldParseAllDefaultFieldsInVepOutput() throws Exception { @Test public void shouldParseAllTranscriptFieldsInVepOutput() { AnnotationLineMapper lineMapper = new AnnotationLineMapper(VEP_VERSION, VEP_CACHE_VERSION); - Annotation annotation = lineMapper.mapLine(VepOutputContent.vepOutputContentTranscriptFields, 0); - Set consequenceTypes = annotation.getConsequenceTypes(); + AnnotationMongo annotation = lineMapper.mapLine(VepOutputContent.vepOutputContentTranscriptFields, 0); + Set consequenceTypes = annotation.getConsequenceTypes(); assertNotNull(consequenceTypes); assertEquals(1, consequenceTypes.size()); - ConsequenceType consequenceType = consequenceTypes.iterator().next(); + ConsequenceTypeMongo consequenceType = consequenceTypes.iterator().next(); assertEquals(Integer.valueOf(1), consequenceType.getcDnaPosition()); assertEquals(Integer.valueOf(4), consequenceType.getCdsPosition()); @@ -69,13 +69,13 @@ public void shouldParseAllTranscriptFieldsInVepOutput() { @Test public void shouldParseVepOutputWithoutTranscript() { AnnotationLineMapper lineMapper = new AnnotationLineMapper(VEP_VERSION, VEP_CACHE_VERSION); - Annotation annotation = lineMapper.mapLine(VepOutputContent.vepOutputContentWithOutTranscript, 0); - Set consequenceTypes = annotation.getConsequenceTypes(); + AnnotationMongo annotation = lineMapper.mapLine(VepOutputContent.vepOutputContentWithOutTranscript, 0); + Set consequenceTypes = annotation.getConsequenceTypes(); assertNotNull(consequenceTypes); assertEquals(1, consequenceTypes.size()); - ConsequenceType consequenceType = consequenceTypes.iterator().next(); + ConsequenceTypeMongo consequenceType = consequenceTypes.iterator().next(); assertNotNull(consequenceType.getSoAccessions()); assertNull(consequenceType.getcDnaPosition()); @@ -94,7 +94,7 @@ public void shouldNotParseVepOutputWithMalformedCoordinates() { @Test public void shouldParseVepOutputWithChromosomeIdWithUnderscore() { AnnotationLineMapper lineMapper = new AnnotationLineMapper(VEP_VERSION, VEP_CACHE_VERSION); - Annotation annotation = lineMapper + AnnotationMongo annotation = lineMapper .mapLine(VepOutputContent.vepOutputContentChromosomeIdWithUnderscore, 0); assertEquals("20_1", annotation.getChromosome()); @@ -109,23 +109,23 @@ public void shouldNotParseVepOutputWithMalformedVariantFields() { @Test public void shouldParseVepOutputWithExtraFields() { AnnotationLineMapper lineMapper = new AnnotationLineMapper(VEP_VERSION, VEP_CACHE_VERSION); - Annotation annotation = lineMapper.mapLine(VepOutputContent.vepOutputContentWithExtraFieldsSingleAnnotation, 0); + AnnotationMongo annotation = lineMapper.mapLine(VepOutputContent.vepOutputContentWithExtraFieldsSingleAnnotation, 0); - Set consequenceTypes = annotation.getConsequenceTypes(); + Set consequenceTypes = annotation.getConsequenceTypes(); assertNotNull(consequenceTypes); assertEquals(1, consequenceTypes.size()); - ConsequenceType consequenceType = consequenceTypes.iterator().next(); + ConsequenceTypeMongo consequenceType = consequenceTypes.iterator().next(); - Score polyphen = consequenceType.getPolyphen(); - Score sifts = consequenceType.getSift(); + ScoreMongo polyphen = consequenceType.getPolyphen(); + ScoreMongo sifts = consequenceType.getSift(); assertNotNull(polyphen); assertNotNull(sifts); - Score expectedSift = new Score(0.07, "tolerated"); - Score expectedPolyphen = new Score(0.859, "possibly_damaging"); + ScoreMongo expectedSift = new ScoreMongo(0.07, "tolerated"); + ScoreMongo expectedPolyphen = new ScoreMongo(0.859, "possibly_damaging"); assertEquals(expectedSift, sifts); assertEquals(expectedPolyphen, polyphen); diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/io/readers/AnnotationFlatFileReaderTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/io/readers/AnnotationFlatFileReaderTest.java index 27d6d5f0b..0066cd48f 100644 --- a/src/test/java/uk/ac/ebi/eva/pipeline/io/readers/AnnotationFlatFileReaderTest.java +++ b/src/test/java/uk/ac/ebi/eva/pipeline/io/readers/AnnotationFlatFileReaderTest.java @@ -21,7 +21,7 @@ import org.springframework.batch.item.file.FlatFileParseException; import org.springframework.batch.test.MetaDataInstanceFactory; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.test.data.VepOutputContent; import uk.ac.ebi.eva.test.rules.PipelineTemporaryFolderRule; import uk.ac.ebi.eva.test.utils.JobTestUtils; @@ -60,7 +60,7 @@ public void shouldReadAllLinesInVepOutput() throws Exception { annotationFlatFileReader.setSaveState(false); annotationFlatFileReader.open(executionContext); - Annotation annotation; + AnnotationMongo annotation; int consequenceTypeCount = 0; int count = 0; while ((annotation = annotationFlatFileReader.read()) != null) { diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationInVariantMongoWriterTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationInVariantMongoWriterTest.java index dd64f72c5..afddd1b1f 100644 --- a/src/test/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationInVariantMongoWriterTest.java +++ b/src/test/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationInVariantMongoWriterTest.java @@ -31,7 +31,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.commons.models.mongo.entity.VariantDocument; import uk.ac.ebi.eva.pipeline.Application; import uk.ac.ebi.eva.pipeline.configuration.MongoConfiguration; @@ -96,9 +96,9 @@ public void shouldWriteAllFieldsIntoMongoDb() throws Exception { String databaseName = mongoRule.restoreDumpInTemporaryDatabase(getResourceUrl(MONGO_DUMP)); //prepare annotation sets - List annotationSet1 = new ArrayList<>(); - List annotationSet2 = new ArrayList<>(); - List annotationSet3 = new ArrayList<>(); + List annotationSet1 = new ArrayList<>(); + List annotationSet2 = new ArrayList<>(); + List annotationSet3 = new ArrayList<>(); String[] vepOutputLines = vepOutputContentWithExtraFields.split("\n"); @@ -180,7 +180,7 @@ public void shouldUpdateFieldsOfExistingAnnotationVersion() throws Exception { String[] vepOutputLines = vepOutputContentWithExtraFields.split("\n"); - List annotations = new ArrayList<>(); + List annotations = new ArrayList<>(); annotations.add(annotationLineMapper.mapLine(vepOutputLines[1], 0)); annotations.add(annotationLineMapper.mapLine(vepOutputLines[2], 0)); @@ -209,10 +209,10 @@ public void shouldUpdateFieldsOfExistingAnnotationVersion() throws Exception { "ENST00000608838"))); } - private BasicDBList writeAndGetAnnotation(String databaseName, Annotation annotation) throws Exception { + private BasicDBList writeAndGetAnnotation(String databaseName, AnnotationMongo annotation) throws Exception { annotationInVariantMongoWriter.write(Collections.singletonList(Collections.singletonList(annotation))); - BasicDBObject query = new BasicDBObject(Annotation.START_FIELD, annotation.getStart()); + BasicDBObject query = new BasicDBObject(AnnotationMongo.START_FIELD, annotation.getStart()); DBCursor cursor = mongoRule.getCollection(databaseName, COLLECTION_VARIANTS_NAME).find(query); assertTrue(cursor.hasNext()); @@ -233,8 +233,8 @@ public void shouldAddAnnotationIfVersionIsNotPresent() throws Exception { String[] vepOutputLines = vepOutputContentWithExtraFields.split("\n"); - Annotation firstAnnotation = annotationLineMapper.mapLine(vepOutputLines[1], 0); - Annotation differentVersionAnnotation = differentVersionAnnotationLineMapper.mapLine(vepOutputLines[2], 0); + AnnotationMongo firstAnnotation = annotationLineMapper.mapLine(vepOutputLines[1], 0); + AnnotationMongo differentVersionAnnotation = differentVersionAnnotationLineMapper.mapLine(vepOutputLines[2], 0); // load the first annotation MongoOperations operations = MongoConfiguration.getMongoOperations(databaseName, mongoConnection, diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationMongoWriterTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationMongoWriterTest.java index d3b0f6bf7..e02810672 100644 --- a/src/test/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationMongoWriterTest.java +++ b/src/test/java/uk/ac/ebi/eva/pipeline/io/writers/AnnotationMongoWriterTest.java @@ -31,9 +31,9 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.ConsequenceType; -import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.Score; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.ConsequenceTypeMongo; +import uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.ScoreMongo; import uk.ac.ebi.eva.pipeline.Application; import uk.ac.ebi.eva.pipeline.configuration.MongoConfiguration; import uk.ac.ebi.eva.pipeline.io.mappers.AnnotationLineMapper; @@ -57,10 +57,10 @@ import static uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantAnnotation.POLYPHEN_FIELD; import static uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantAnnotation.SIFT_FIELD; -import static uk.ac.ebi.eva.commons.models.mongo.entity.Annotation.CONSEQUENCE_TYPE_FIELD; -import static uk.ac.ebi.eva.commons.models.mongo.entity.Annotation.XREFS_FIELD; -import static uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.Score.SCORE_DESCRIPTION_FIELD; -import static uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.Score.SCORE_SCORE_FIELD; +import static uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo.CONSEQUENCE_TYPE_FIELD; +import static uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo.XREFS_FIELD; +import static uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.ScoreMongo.SCORE_DESCRIPTION_FIELD; +import static uk.ac.ebi.eva.commons.mongodb.entities.subdocuments.ScoreMongo.SCORE_SCORE_FIELD; import static uk.ac.ebi.eva.test.data.VepOutputContent.vepOutputContent; import static uk.ac.ebi.eva.test.utils.JobTestUtils.count; @@ -104,7 +104,7 @@ public void setUp() throws Exception { public void shouldWriteAllFieldsIntoMongoDb() throws Exception { String databaseName = mongoRule.getRandomTemporaryDatabaseName(); - List annotations = new ArrayList<>(); + List annotations = new ArrayList<>(); for (String annotLine : vepOutputContent.split("\n")) { annotations.add(annotationLineMapper.mapLine(annotLine, 0)); } @@ -143,9 +143,9 @@ public void shouldWriteAllFieldsIntoMongoDbMultipleSetsAnnotations() throws Exce String databaseName = mongoRule.getRandomTemporaryDatabaseName(); //prepare annotation sets - List annotationSet1 = new ArrayList<>(); - List annotationSet2 = new ArrayList<>(); - List annotationSet3 = new ArrayList<>(); + List annotationSet1 = new ArrayList<>(); + List annotationSet2 = new ArrayList<>(); + List annotationSet3 = new ArrayList<>(); String[] vepOutputLines = vepOutputContent.split("\n"); @@ -188,17 +188,27 @@ public void shouldWriteAllFieldsIntoMongoDbMultipleSetsAnnotations() throws Exce public void shouldWriteSubstitutionScoresIntoMongoDb() throws Exception { String databaseName = mongoRule.getRandomTemporaryDatabaseName(); - Annotation annotation = new Annotation("X", 1, 10, "A", "T", - VEP_VERSION, VEP_CACHE_VERSION); + ScoreMongo siftScore = new ScoreMongo(0.02, "deleterious"); + ScoreMongo polyphenScore = new ScoreMongo(0.846, "possibly_damaging"); - Score siftScore = new Score(0.02, "deleterious"); - Score polyphenScore = new Score(0.846, "possibly_damaging"); - - ConsequenceType consequenceType = new ConsequenceType(); + ConsequenceTypeMongo consequenceType = new ConsequenceTypeMongo(null, null, + null, null, null, null, null, null, + null, null, null, null, null, null); consequenceType.setSift(siftScore); consequenceType.setPolyphen(polyphenScore); - annotation.addConsequenceType(consequenceType); + AnnotationMongo annotation = new AnnotationMongo( + AnnotationMongo.buildAnnotationId("X", 1, "A", "T", + VEP_VERSION, VEP_CACHE_VERSION), + "X", + 1, + 10, + VEP_VERSION, + VEP_CACHE_VERSION, + null, + Collections.singleton(consequenceType)); + + annotation = annotation.concatenate(annotation); MongoOperations operations = MongoConfiguration.getMongoOperations(databaseName, mongoConnection, mongoMappingContext); @@ -250,7 +260,7 @@ public void indexesShouldBeCreatedInBackground() throws UnknownHostException { public void shouldUpdateFieldsOfExistingAnnotationVersion() throws Exception { String databaseName = mongoRule.getRandomTemporaryDatabaseName(); - List annotations = new ArrayList<>(); + List annotations = new ArrayList<>(); for (String annotLine : vepOutputContent.split("\n")) { annotations.add(annotationLineMapper.mapLine(annotLine, 0)); } @@ -283,9 +293,9 @@ public void shouldAddAnnotationIfAnnotationVersionIsNotPresent() throws Exceptio String databaseName = mongoRule.getRandomTemporaryDatabaseName(); String annotLine = vepOutputContent.split("\n")[1]; - List> firstVersionAnnotation = Collections.singletonList(Collections.singletonList( + List> firstVersionAnnotation = Collections.singletonList(Collections.singletonList( annotationLineMapper.mapLine(annotLine, 0))); - List> secondVersionAnnotation = Collections.singletonList((Collections.singletonList( + List> secondVersionAnnotation = Collections.singletonList((Collections.singletonList( differentVersionAnnotationLineMapper.mapLine(annotLine, 0)))); // load the annotation diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/jobs/steps/processors/AnnotationParserProcessorTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/jobs/steps/processors/AnnotationParserProcessorTest.java index 9bbc972db..f9dd233ce 100644 --- a/src/test/java/uk/ac/ebi/eva/pipeline/jobs/steps/processors/AnnotationParserProcessorTest.java +++ b/src/test/java/uk/ac/ebi/eva/pipeline/jobs/steps/processors/AnnotationParserProcessorTest.java @@ -18,7 +18,7 @@ import org.junit.Test; -import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; +import uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo; import uk.ac.ebi.eva.pipeline.parameters.AnnotationParameters; import uk.ac.ebi.eva.test.data.VepOutputContent; @@ -41,7 +41,7 @@ public void shouldParseAllDefaultFieldsInVepOutput() throws Exception { AnnotationParserProcessor parser = new AnnotationParserProcessor(annotationParameters); List textAnnotations = Arrays.asList(VepOutputContent.vepOutputContent.split("\n")); - List annotations = parser.process(textAnnotations); + List annotations = parser.process(textAnnotations); assertEquals(textAnnotations.size(), annotations.size()); } diff --git a/src/test/java/uk/ac/ebi/eva/test/utils/GenotypedVcfJobTestUtils.java b/src/test/java/uk/ac/ebi/eva/test/utils/GenotypedVcfJobTestUtils.java index 12ae3ba57..708eba4ae 100644 --- a/src/test/java/uk/ac/ebi/eva/test/utils/GenotypedVcfJobTestUtils.java +++ b/src/test/java/uk/ac/ebi/eva/test/utils/GenotypedVcfJobTestUtils.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static uk.ac.ebi.eva.commons.models.mongo.entity.Annotation.CONSEQUENCE_TYPE_FIELD; +import static uk.ac.ebi.eva.commons.mongodb.entities.AnnotationMongo.CONSEQUENCE_TYPE_FIELD; import static uk.ac.ebi.eva.test.utils.JobTestUtils.count; import static uk.ac.ebi.eva.test.utils.JobTestUtils.getLines; import static uk.ac.ebi.eva.utils.FileUtils.getResource;