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

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 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
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
66 changes: 57 additions & 9 deletions core-common/src/test/java/org/uniprot/core/util/UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,34 +191,82 @@ void nonEmpty_shouldAlwaysReturnFalse() {
class unmodifiableList {
@Test
void passingNullReturnEmptyList() {
List l = Utils.unmodifiableList(null);
assertTrue(l.isEmpty());
List<Object> unmodifiableList = Utils.unmodifiableList(null);
assertTrue(unmodifiableList.isEmpty());
}

@Test
void passing_emptyList_returnEmptyList() {
List l = Utils.unmodifiableList(new ArrayList<>());
assertTrue(l.isEmpty());
List<Object> unmodifiableList = Utils.unmodifiableList(new ArrayList<>());
assertTrue(unmodifiableList.isEmpty());
}

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

@Test
void passing_emptyList_returnEmptyList_unmodifiable() {
List<String> l = Utils.unmodifiableList(new ArrayList<>());
assertThrows(UnsupportedOperationException.class, () -> l.add("abc"));
List<String> unmodifiableList = Utils.unmodifiableList(new ArrayList<>());
assertThrows(UnsupportedOperationException.class, () -> unmodifiableList.add("abc"));
}

@Test
void passingList_returnUnmodifiable() {
List<String> list = new ArrayList<>();
list.add("a");
list.add("b");
List<String> l = Utils.unmodifiableList(list);
List<String> unmodifiableList = Utils.unmodifiableList(list);
assertThrows(UnsupportedOperationException.class, () -> unmodifiableList.add("c"));
}
}

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

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

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

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

@Test
void passingSet_returnUnmodifiable() {
Set<String> set = new HashSet<>();
set.add("a");
set.add("b");
Set<String> unmodifiableSet = Utils.unmodifiableSet(set);
assertThrows(UnsupportedOperationException.class, () -> unmodifiableSet.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"));
}
}
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
@@ -0,0 +1,44 @@
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;

UniParcCrossReferencePair(){}
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