Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UniParc light and cross reference #239

Merged
merged 42 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ddf3026
uniparc light model and builder
ahmadshadab Jun 19, 2024
1505ef5
add code for json serializer
ahmadshadab Jun 19, 2024
93a65f2
address the review comments
ahmadshadab Jun 20, 2024
ee80e92
Merge commit '93a65f29d3d37cd531c84b5938c0928b41583662' into uniparc_…
ahmadshadab Jun 20, 2024
67b2297
remove exlusion and make accessions of type linkedhashset
ahmadshadab Jun 27, 2024
1163378
make uniParcId string
ahmadshadab Jul 3, 2024
9459170
update json converter
ahmadshadab Jul 9, 2024
92fd8ab
Merge remote-tracking branch 'origin/main' into uniparc_light_vd
LeonardoGonzales Jul 10, 2024
d8d660a
Merge remote-tracking branch 'origin/main' into uniparc_light_vd
LeonardoGonzales Jul 10, 2024
edddf42
Add Fasta parser from UniParcEntryLight
LeonardoGonzales Jul 10, 2024
8908618
Merge remote-tracking branch 'origin/uniparc_light_vd' into uniparc_l…
LeonardoGonzales Jul 10, 2024
ae019b6
Add TSV parser for UniParcEntryLight
LeonardoGonzales Jul 19, 2024
19841b9
Update UniParcEntryLight model
LeonardoGonzales Jul 26, 2024
88d3074
Update UniParcEntryLight proteomes attribute.
LeonardoGonzales Jul 26, 2024
f864609
uniparc alternative uniparc solution initial changes
LeonardoGonzales Aug 1, 2024
ebfb92d
fixe NPE issue while creating lightentry builder from lightentry
ahmadshadab Aug 1, 2024
b4512dc
Merge branch 'uniparc_light_vd' into uniparc_light_vd_v2
LeonardoGonzales Aug 2, 2024
62786ae
uniparc alternative uniparc solution fix json serialization
LeonardoGonzales Aug 5, 2024
8cb14dd
temporary commit while testing json parser
LeonardoGonzales Aug 5, 2024
b14172b
add equals and hashcode method
ahmadshadab Aug 5, 2024
241904c
move model to core domain
ahmadshadab Aug 5, 2024
d08f8fc
rename field to crossRefereneCount
ahmadshadab Aug 8, 2024
6a80ebb
add extraAttributes attribute in light model
ahmadshadab Aug 30, 2024
a180bf5
merge with main
ahmadshadab Sep 2, 2024
5799243
Merge branch 'main' into uniparc_light_vd_v2
ahmadshadab Sep 10, 2024
a8964d8
make dbRef optional, add light xml converter and a new xsd for xref
ahmadshadab Sep 10, 2024
06937df
update xsd and add a new converter
ahmadshadab Sep 11, 2024
eed267f
rename xsd file
ahmadshadab Sep 12, 2024
5e991c9
catch up with main branch
ahmadshadab Sep 12, 2024
f9426f3
address review comment
ahmadshadab Sep 24, 2024
5b08cde
address few more review comments
ahmadshadab Sep 27, 2024
5f308e7
address review comments
ahmadshadab Sep 30, 2024
da162c6
add test class
ahmadshadab Sep 30, 2024
e21338c
Merge branch 'main' into uniparc_light_vd_v2
ahmadshadab Oct 4, 2024
a50d98c
move duplicate code to a util class
ahmadshadab Oct 11, 2024
bfdb374
fix a typo
ahmadshadab Oct 11, 2024
5798f2d
Merge branch 'uniparc_light_xml' into uniparc_light_vd_v2
ahmadshadab Oct 11, 2024
d8eb9ed
merge with xml branch
ahmadshadab Oct 11, 2024
e37a1be
tsv changes
supun-ebi Oct 24, 2024
d030c11
address review comments
supun-ebi Oct 25, 2024
23757b1
Merge pull request #243 from ebi-uniprot/TRM-31990-add-common-taxon-u…
supun-ebi Oct 28, 2024
6ee1659
Merge branch 'main' into uniparc_light_vd_v2
ahmadshadab Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package org.uniprot.cv.xdb;

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.uniprot.core.cv.xdb.UniProtDatabaseDetail;
import org.uniprot.cv.common.CVSystemProperties;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.uniprot.core.cv.xdb.UniProtDatabaseDetail;
import static org.junit.jupiter.api.Assertions.*;

class UniProtKBCrossReferenceDisplayOrderTest {
@BeforeAll
static void setSystemProperty(){
System.setProperty(CVSystemProperties.DR_ORD_LOCATION,"src/test/resources/xdb/dr_ord");
}

@Test
void testCreateUniProtXDbDisplayOrder() {
Expand Down
4 changes: 4 additions & 0 deletions core-common/src/main/java/org/uniprot/core/util/PairImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ public class PairImpl<K, V> implements Pair<K, V> {
private final K key;
private final V value;

PairImpl(){ // do not use, just to make Jackson serializer happy
this(null, null);
}

public PairImpl(K key, V value) {
this.key = key;
this.value = value;
Expand Down
48 changes: 48 additions & 0 deletions core-common/src/test/java/org/uniprot/core/util/UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,54 @@ void passingList_returnUnmodifiable() {
}
}

@Nested
class unmodifiableSet {
@Test
void passingNullReturnEmptySet() {
Set l = Utils.unmodifiableSet(null);
assertTrue(l.isEmpty());
}

@Test
void passing_emptySet_returnEmptySet() {
Set l = Utils.unmodifiableSet(new HashSet<>());
assertTrue(l.isEmpty());
}

@Test
void passingNullReturnEmptySet_unmodifiable() {
Set<String> l = Utils.unmodifiableSet(null);
assertThrows(UnsupportedOperationException.class, () -> l.add("abc"));
}

@Test
void passing_emptySet_returnEmptySet_unmodifiable() {
Set<String> l = Utils.unmodifiableSet(new HashSet<>());
assertThrows(UnsupportedOperationException.class, () -> l.add("abc"));
}

@Test
void passingSet_returnUnmodifiable() {
Set<String> list = new HashSet<>();
ahmadshadab marked this conversation as resolved.
Show resolved Hide resolved
list.add("a");
list.add("b");
Set<String> l = Utils.unmodifiableSet(list);
assertThrows(UnsupportedOperationException.class, () -> l.add("c"));
}

@Test
void passingLinkedHashSet_returnUnmodifiable() {
Set<String> list = new LinkedHashSet<>();
list.add("a");
list.add("b");
list.add("d");
list.add("c");
Set<String> l = Utils.unmodifiableSet(list);
assertEquals(list,l);
assertThrows(UnsupportedOperationException.class, () -> l.add("c"));
}
}

@Nested
class addOrIgnoreNull {
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.uniprot.core.uniparc;

import java.io.Serializable;

public interface CommonOrganism extends Serializable {
String getTopLevel();
String getCommonTaxon();
}
10 changes: 10 additions & 0 deletions core-domain/src/main/java/org/uniprot/core/uniparc/Proteome.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.uniprot.core.uniparc;

import java.io.Serializable;

public interface Proteome extends Serializable {

String getId();

String getComponent();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.uniprot.core.uniparc;

import org.uniprot.core.Sequence;
import org.uniprot.core.uniprotkb.taxonomy.Organism;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface UniParcEntryLight extends Serializable {
String getUniParcId();

int getCrossReferenceCount();

List<CommonOrganism> getCommonTaxons();

Set<String> getUniProtKBAccessions();

Sequence getSequence();

List<SequenceFeature> getSequenceFeatures();

LocalDate getOldestCrossRefCreated();

LocalDate getMostRecentCrossRefUpdated();

Map<String, Object> getExtraAttributes();

// lazily loaded fields
Set<Organism> getOrganisms();// organism id and name pair

Set<String> getProteinNames();

Set<String> getGeneNames();

Set<Proteome> getProteomes();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.uniprot.core.uniparc.impl;

import org.uniprot.core.Builder;
import org.uniprot.core.uniparc.CommonOrganism;

import javax.annotation.Nonnull;

public class CommonOrganismBuilder implements Builder<CommonOrganism> {

private String topLevel;
private String commonTaxon;

@Nonnull
@Override
public CommonOrganism build() {
return new CommonOrganismImpl(topLevel, commonTaxon);
}

public CommonOrganismBuilder topLevel(String topLevel) {
this.topLevel = topLevel;
return this;
}


public CommonOrganismBuilder commonTaxon(String commonTaxon) {
this.commonTaxon = commonTaxon;
return this;
}

public static @Nonnull CommonOrganismBuilder from(@Nonnull CommonOrganism instance) {
CommonOrganismBuilder builder = new CommonOrganismBuilder()
.topLevel(instance.getTopLevel())
.commonTaxon(instance.getCommonTaxon());
return builder;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.uniprot.core.uniparc.impl;

import org.uniprot.core.uniparc.CommonOrganism;

import java.util.Objects;

public class CommonOrganismImpl implements CommonOrganism {

private static final long serialVersionUID = 4897886166938610296L;

private String topLevel;
private String commonTaxon;

CommonOrganismImpl(){
}

CommonOrganismImpl(String topLevel, String commonTaxon) {
this.topLevel = topLevel;
this.commonTaxon = commonTaxon;
}

@Override
public String getTopLevel() {
return topLevel;
}

@Override
public String getCommonTaxon() {
return commonTaxon;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CommonOrganismImpl that = (CommonOrganismImpl) o;
return Objects.equals(topLevel, that.topLevel) && Objects.equals(commonTaxon, that.commonTaxon);
}

@Override
public int hashCode() {
return Objects.hash(topLevel, commonTaxon);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.uniprot.core.uniparc.impl;

import org.uniprot.core.Builder;
import org.uniprot.core.uniparc.Proteome;

import javax.annotation.Nonnull;

public class ProteomeBuilder implements Builder<Proteome> {

private String id;
private String component;

@Nonnull
@Override
public Proteome build() {
return new ProteomeImpl(id, component);
}

public ProteomeBuilder id(String id) {
this.id = id;
return this;
}


public ProteomeBuilder component(String component) {
this.component = component;
return this;
}

public static @Nonnull ProteomeBuilder from(@Nonnull Proteome instance) {
ProteomeBuilder builder = new ProteomeBuilder()
.id(instance.getId())
.component(instance.getComponent());
return builder;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.uniprot.core.uniparc.impl;

import org.uniprot.core.uniparc.Proteome;

import java.util.Objects;

public class ProteomeImpl implements Proteome {

private static final long serialVersionUID = -7947022870498125809L;

private String id;
private String component;

ProteomeImpl() {
}

ProteomeImpl(String id, String component) {
this.id = id;
this.component = component;
}

@Override
public String getId() {
return id;
}

@Override
public String getComponent() {
return component;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ProteomeImpl proteome = (ProteomeImpl) o;
return Objects.equals(id, proteome.id) && Objects.equals(component, proteome.component);
}

@Override
public int hashCode() {
return Objects.hash(id, component);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class UniParcCrossReferenceImpl extends CrossReferenceImpl<UniParcDatabas
private final String proteomeId;
private final String component;

UniParcCrossReferenceImpl() {
protected UniParcCrossReferenceImpl() {
ahmadshadab marked this conversation as resolved.
Show resolved Hide resolved
this(
null, null, null, 0, null, false, null, null, null, null, null, null, null, null,
null);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.uniprot.core.uniparc.impl;

import org.uniprot.core.uniparc.UniParcCrossReference;
import org.uniprot.core.util.Pair;

import java.io.Serial;
import java.util.List;
import java.util.Objects;

public class UniParcCrossReferencePair implements Pair<String, List<UniParcCrossReference>>{
ahmadshadab marked this conversation as resolved.
Show resolved Hide resolved
@Serial
private static final long serialVersionUID = 7906365717659009263L;
private String key;
private List<UniParcCrossReference> value;
public UniParcCrossReferencePair(){
ahmadshadab marked this conversation as resolved.
Show resolved Hide resolved
this(null, null);
}

public UniParcCrossReferencePair(String key, List<UniParcCrossReference> value) {
this.key = key;
this.value = value;
}


@Override
public String getKey() {
return key;
}

@Override
public List<UniParcCrossReference> getValue() {
return value;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UniParcCrossReferencePair that = (UniParcCrossReferencePair) o;
return Objects.equals(getKey(), that.getKey()) && Objects.equals(getValue(), that.getValue());
}

@Override
public int hashCode() {
return Objects.hash(getKey(), getValue());
}
}
Loading
Loading