Skip to content

Commit

Permalink
Merge pull request #199 from ebi-uniprot/TRM-29989-proteome-hdfs-writer
Browse files Browse the repository at this point in the history
Trm 29989 proteome hdfs writer
  • Loading branch information
supun-ebi authored Oct 18, 2023
2 parents e3d4e87 + 9e966bc commit 11bd177
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ public interface ProteomeEntry extends Serializable {
GenomeAnnotation getGenomeAnnotation();

List<ExclusionReason> getExclusionReasons();

ProteomeStatistics getProteomeStatistics();
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ProteomeEntryBuilder implements Builder<ProteomeEntry> {
private GenomeAnnotation genomeAnnotation;
private List<ExclusionReason> exclusionReasons = new ArrayList<>();
private Integer proteinCount;
private ProteomeStatistics proteomeStatistics;

@Override
public @Nonnull ProteomeEntry build() {
Expand All @@ -59,7 +60,8 @@ public class ProteomeEntryBuilder implements Builder<ProteomeEntry> {
genomeAssembly,
genomeAnnotation,
exclusionReasons,
proteinCount);
proteinCount,
proteomeStatistics);
}

public static @Nonnull ProteomeEntryBuilder from(@Nonnull ProteomeEntry instance) {
Expand All @@ -84,7 +86,8 @@ public class ProteomeEntryBuilder implements Builder<ProteomeEntry> {
.genomeAssembly(instance.getGenomeAssembly())
.genomeAnnotation(instance.getGenomeAnnotation())
.exclusionReasonsSet(instance.getExclusionReasons())
.proteinCount(instance.getProteinCount());
.proteinCount(instance.getProteinCount())
.proteomeStatistics(instance.getProteomeStatistics());
}

public @Nonnull ProteomeEntryBuilder proteomeId(ProteomeId id) {
Expand Down Expand Up @@ -225,4 +228,9 @@ public class ProteomeEntryBuilder implements Builder<ProteomeEntry> {
Utils.addOrIgnoreNull(exclusionReason, exclusionReasons);
return this;
}

public @Nonnull ProteomeEntryBuilder proteomeStatistics(ProteomeStatistics proteomeStatistics) {
this.proteomeStatistics = proteomeStatistics;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ public class ProteomeEntryImpl implements ProteomeEntry {
private final GenomeAnnotation genomeAnnotation;
private final List<TaxonomyLineage> taxonLineage;
private final List<ExclusionReason> exclusionReasons;
private final ProteomeStatistics proteomeStatistics;

// no arg constructor for JSON deserialization
ProteomeEntryImpl() {
this(
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null);
null, null, null, null, null, null, null, null);
}

ProteomeEntryImpl(
Expand All @@ -63,7 +64,8 @@ public class ProteomeEntryImpl implements ProteomeEntry {
GenomeAssembly genomeAssembly,
GenomeAnnotation genomeAnnotation,
List<ExclusionReason> exclusionReasons,
Integer proteinCount) {
Integer proteinCount,
ProteomeStatistics proteomeStatistics) {
super();
this.id = id;
this.taxonomy = taxonomy;
Expand All @@ -88,6 +90,7 @@ public class ProteomeEntryImpl implements ProteomeEntry {
this.genomeAnnotation = genomeAnnotation;
this.exclusionReasons = Utils.unmodifiableList(exclusionReasons);
this.proteinCount = proteinCount;
this.proteomeStatistics = proteomeStatistics;
}

@Override
Expand Down Expand Up @@ -195,6 +198,11 @@ public List<ExclusionReason> getExclusionReasons() {
return exclusionReasons;
}

@Override
public ProteomeStatistics getProteomeStatistics() {
return proteomeStatistics;
}

@Override
public int hashCode() {
return Objects.hash(
Expand All @@ -214,7 +222,8 @@ public int hashCode() {
proteomeCompletenessReport,
genomeAssembly,
proteinCount,
genomeAnnotation);
genomeAnnotation,
proteomeStatistics);
}

@Override
Expand All @@ -240,6 +249,7 @@ public boolean equals(Object obj) {
&& Objects.equals(genomeAssembly, other.genomeAssembly)
&& Objects.equals(geneCount, other.geneCount)
&& Objects.equals(proteinCount, other.proteinCount)
&& Objects.equals(genomeAnnotation, other.genomeAnnotation);
&& Objects.equals(genomeAnnotation, other.genomeAnnotation)
&& Objects.equals(proteomeStatistics, other.proteomeStatistics);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.uniprot.core.proteome.ProteomeStatistics;

public class ProteomeStatisticsImpl extends StatisticsImpl implements ProteomeStatistics {
private static final long serialVersionUID = -8585233468042758658L;
private final long isoformProteinCount;

ProteomeStatisticsImpl(
Expand All @@ -14,6 +15,10 @@ public class ProteomeStatisticsImpl extends StatisticsImpl implements ProteomeSt
this.isoformProteinCount = isoformProteinCount;
}

ProteomeStatisticsImpl() {
this(0, 0, 0);
}

@Override
public long getIsoformProteinCount() {
return isoformProteinCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import java.util.List;

import org.junit.jupiter.api.Test;
import org.uniprot.core.citation.*;
import org.uniprot.core.citation.Citation;
import org.uniprot.core.citation.JournalArticle;
import org.uniprot.core.citation.Submission;
import org.uniprot.core.citation.SubmissionDatabase;
import org.uniprot.core.citation.impl.JournalArticleBuilder;
import org.uniprot.core.citation.impl.SubmissionBuilder;
import org.uniprot.core.proteome.*;
Expand Down Expand Up @@ -350,4 +353,12 @@ void ExclusionReasons() {
assertThat(proteome.getExclusionReasons(), hasItem(ExclusionReason.METAGENOME));
assertThat(proteome.getExclusionReasons(), hasItem(ExclusionReason.MIXED_CULTURE));
}

@Test
void testProteomeStatistics() {
ProteomeStatistics proteomeStatistics = new ProteomeStatisticsBuilder().build();
ProteomeEntry proteome =
new ProteomeEntryBuilder().proteomeStatistics(proteomeStatistics).build();
assertSame(proteomeStatistics, proteome.getProteomeStatistics());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.uniprot.core.proteome.impl;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

import org.junit.jupiter.api.Test;

Expand All @@ -20,6 +21,12 @@ void getCountsAreAccurate() {
assertEquals(ISOFORM_PROTEIN_COUNT, PROTEOME_STATISTICS.getIsoformProteinCount());
}

@Test
void defaultConstructor() {
ProteomeStatisticsImpl that = new ProteomeStatisticsImpl();
assertEquals(new ProteomeStatisticsImpl(0, 0, 0), that);
}

@Test
void equals_whenTrue() {
ProteomeStatisticsImpl that =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,14 @@
import org.uniprot.core.CrossReference;
import org.uniprot.core.Database;
import org.uniprot.core.Value;
import org.uniprot.core.citation.Author;
import org.uniprot.core.citation.Book;
import org.uniprot.core.citation.ElectronicArticle;
import org.uniprot.core.citation.Journal;
import org.uniprot.core.citation.JournalArticle;
import org.uniprot.core.citation.Locator;
import org.uniprot.core.citation.Patent;
import org.uniprot.core.citation.PublicationDate;
import org.uniprot.core.citation.Submission;
import org.uniprot.core.citation.Thesis;
import org.uniprot.core.citation.Unpublished;
import org.uniprot.core.citation.impl.AuthorImpl;
import org.uniprot.core.citation.impl.BookImpl;
import org.uniprot.core.citation.impl.ElectronicArticleImpl;
import org.uniprot.core.citation.impl.JournalArticleImpl;
import org.uniprot.core.citation.impl.JournalImpl;
import org.uniprot.core.citation.impl.PatentImpl;
import org.uniprot.core.citation.impl.PublicationDateImpl;
import org.uniprot.core.citation.impl.SubmissionImpl;
import org.uniprot.core.citation.impl.ThesisImpl;
import org.uniprot.core.citation.impl.UnpublishedImpl;
import org.uniprot.core.citation.*;
import org.uniprot.core.citation.impl.*;
import org.uniprot.core.impl.CrossReferenceImpl;
import org.uniprot.core.impl.DefaultDatabase;
import org.uniprot.core.impl.ValueImpl;
import org.uniprot.core.json.parser.JsonConfig;
import org.uniprot.core.json.parser.deserializer.LocalDateDeserializer;
import org.uniprot.core.json.parser.serializer.AuthorSerializer;
import org.uniprot.core.json.parser.serializer.JournalSerializer;
import org.uniprot.core.json.parser.serializer.LocalDateSerializer;
import org.uniprot.core.json.parser.serializer.LocatorSerializer;
import org.uniprot.core.json.parser.serializer.PublicationDateSerializer;
import org.uniprot.core.json.parser.serializer.*;
import org.uniprot.core.json.parser.uniprot.serializer.UniProtKBAccessionSerializer;
import org.uniprot.core.proteome.*;
import org.uniprot.core.proteome.impl.*;
Expand Down Expand Up @@ -89,6 +66,7 @@ private ObjectMapper initObjectMapper() {
mod.addAbstractTypeMapping(ProteomeId.class, ProteomeIdImpl.class);
mod.addAbstractTypeMapping(Taxonomy.class, TaxonomyImpl.class);
mod.addAbstractTypeMapping(TaxonomyLineage.class, TaxonomyLineageImpl.class);
mod.addAbstractTypeMapping(ProteomeStatistics.class, ProteomeStatisticsImpl.class);

mod.addAbstractTypeMapping(Value.class, ValueImpl.class);
mod.addAbstractTypeMapping(RedundantProteome.class, RedundantProteomeImpl.class);
Expand Down

0 comments on commit 11bd177

Please sign in to comment.