Skip to content

Commit

Permalink
catch up with main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadshadab committed Sep 12, 2024
2 parents 5799243 + fbb9314 commit 5e991c9
Show file tree
Hide file tree
Showing 33 changed files with 286 additions and 91 deletions.
2 changes: 1 addition & 1 deletion controlled-vocabulary/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.uniprot</groupId>
<artifactId>core-parent</artifactId>
<version>1.0.34-SNAPSHOT</version>
<version>1.0.35-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.uniprot</groupId>
<artifactId>core-parent</artifactId>
<version>1.0.34-SNAPSHOT</version>
<version>1.0.35-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core-domain-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>core-parent</artifactId>
<groupId>org.uniprot</groupId>
<version>1.0.34-SNAPSHOT</version>
<version>1.0.35-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion core-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.uniprot</groupId>
<artifactId>core-parent</artifactId>
<version>1.0.34-SNAPSHOT</version>
<version>1.0.35-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import java.io.Serializable;
import java.util.List;

import org.uniprot.core.Location;

/**
* @author jluo
* @date: 22 May 2019
Expand All @@ -16,5 +14,5 @@ public interface SequenceFeature extends Serializable {

String getSignatureDbId();

List<Location> getLocations();
List<SequenceFeatureLocation> getLocations();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.uniprot.core.uniparc;

import java.io.Serializable;

public interface SequenceFeatureLocation extends Serializable {
int getStart();

int getEnd();

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

import javax.annotation.Nonnull;

import org.uniprot.core.util.EnumDisplay;

import javax.annotation.Nonnull;

public enum SignatureDbType implements EnumDisplay {
CDD("CDD"),
GENE3D("Gene3D"),
Expand All @@ -16,7 +16,8 @@ public enum SignatureDbType implements EnumDisplay {
SFLD("SFLD"),
SMART("SMART"),
SUPFAM("SUPFAM"),
NCBIFAM("NCBIfam");
NCBIFAM("NCBIfam"),
FUNFAM("FUNFAM");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import javax.annotation.Nonnull;

import org.uniprot.core.Builder;
import org.uniprot.core.Location;
import org.uniprot.core.uniparc.InterProGroup;
import org.uniprot.core.uniparc.SequenceFeature;
import org.uniprot.core.uniparc.SequenceFeatureLocation;
import org.uniprot.core.uniparc.SignatureDbType;
import org.uniprot.core.util.Utils;

Expand All @@ -20,7 +20,7 @@ public class SequenceFeatureBuilder implements Builder<SequenceFeature> {
private InterProGroup interproGroup;
private SignatureDbType dbType;
private String dbId;
private List<Location> locations = new ArrayList<>();
private List<SequenceFeatureLocation> locations = new ArrayList<>();

@Override
public @Nonnull SequenceFeature build() {
Expand All @@ -42,12 +42,12 @@ public class SequenceFeatureBuilder implements Builder<SequenceFeature> {
return this;
}

public @Nonnull SequenceFeatureBuilder locationsSet(List<Location> locations) {
public @Nonnull SequenceFeatureBuilder locationsSet(List<SequenceFeatureLocation> locations) {
this.locations = Utils.modifiableList(locations);
return this;
}

public @Nonnull SequenceFeatureBuilder locationsAdd(Location location) {
public @Nonnull SequenceFeatureBuilder locationsAdd(SequenceFeatureLocation location) {
Utils.addOrIgnoreNull(location, locations);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import java.util.List;
import java.util.Objects;

import org.uniprot.core.Location;
import org.uniprot.core.uniparc.InterProGroup;
import org.uniprot.core.uniparc.SequenceFeature;
import org.uniprot.core.uniparc.SequenceFeatureLocation;
import org.uniprot.core.uniparc.SignatureDbType;
import org.uniprot.core.util.Utils;

Expand All @@ -17,19 +17,19 @@
public class SequenceFeatureImpl implements SequenceFeature {

/** */
private static final long serialVersionUID = -8511912268843073779L;
private static final long serialVersionUID = 5234475851615797849L;

private InterProGroup interproGroup;
private SignatureDbType database;
private String databaseId;
private List<Location> locations;
private List<SequenceFeatureLocation> locations;

SequenceFeatureImpl() {
this.locations = Collections.emptyList();
}

SequenceFeatureImpl(
InterProGroup domain, SignatureDbType dbType, String dbId, List<Location> locations) {
InterProGroup domain, SignatureDbType dbType, String dbId, List<SequenceFeatureLocation> locations) {
super();
this.interproGroup = domain;
this.database = dbType;
Expand All @@ -53,7 +53,7 @@ public String getSignatureDbId() {
}

@Override
public List<Location> getLocations() {
public List<SequenceFeatureLocation> getLocations() {
return locations;
}

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.Builder;
import org.uniprot.core.uniparc.SequenceFeatureLocation;

import javax.annotation.Nonnull;

public class SequenceFeatureLocationBuilder implements Builder<SequenceFeatureLocation> {

private int start;
private int end;
private String alignment;

@Nonnull
@Override
public SequenceFeatureLocation build() {
return new SequenceFeatureLocationImpl(start,end,alignment);
}

public @Nonnull SequenceFeatureLocationBuilder range(int start, int end) {
this.start = start;
this.end = end;
return this;
}

public @Nonnull SequenceFeatureLocationBuilder start(int start) {
this.start = start;
return this;
}

public @Nonnull SequenceFeatureLocationBuilder end(int end) {
this.end = end;
return this;
}

public @Nonnull SequenceFeatureLocationBuilder alignment(String alignment) {
this.alignment = alignment;
return this;
}

public static @Nonnull SequenceFeatureLocationBuilder from(@Nonnull SequenceFeatureLocation instance) {
return new SequenceFeatureLocationBuilder()
.start(instance.getStart())
.end(instance.getEnd())
.alignment(instance.getAlignment());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.uniprot.core.uniparc.impl;

import org.uniprot.core.Location;
import org.uniprot.core.uniparc.SequenceFeatureLocation;

import java.util.Objects;

public class SequenceFeatureLocationImpl extends Location implements SequenceFeatureLocation{

private static final long serialVersionUID = -4804406936471873484L;
private String alignment;

SequenceFeatureLocationImpl(){
super(0, 0);
}

SequenceFeatureLocationImpl(int start, int end, String alignment) {
super(start, end);
this.alignment = alignment;
}

@Override
public String getAlignment() {
return alignment;
}


@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
SequenceFeatureLocationImpl that = (SequenceFeatureLocationImpl) o;
return Objects.equals(alignment, that.alignment);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), alignment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.uniprot.core.uniparc.*;
import org.uniprot.core.uniparc.impl.InterProGroupBuilder;
import org.uniprot.core.uniparc.impl.SequenceFeatureBuilder;
import org.uniprot.core.uniparc.impl.SequenceFeatureLocationBuilder;
import org.uniprot.core.uniparc.impl.UniParcCrossReferenceBuilder;
import org.uniprot.core.uniprotkb.comment.*;
import org.uniprot.core.uniprotkb.comment.impl.*;
Expand Down Expand Up @@ -223,7 +224,7 @@ public static List<EvidencedValue> createEvidenceValuesWithEvidences() {
}

public static List<SequenceFeature> sequenceFeatures() {
List<Location> locations = Arrays.asList(new Location(12, 23), new Location(45, 89));
List<SequenceFeatureLocation> locations = Arrays.asList(new SequenceFeatureLocationBuilder().range(12, 23).alignment("55M").build(), new SequenceFeatureLocationBuilder().range(45, 89).build());
InterProGroup domain = new InterProGroupBuilder().name("name1").id("id1").build();
SequenceFeature sf =
new SequenceFeatureBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import java.util.List;

import org.junit.jupiter.api.Test;
import org.uniprot.core.Location;
import org.uniprot.core.uniparc.InterProGroup;
import org.uniprot.core.uniparc.SequenceFeature;
import org.uniprot.core.uniparc.SequenceFeatureLocation;
import org.uniprot.core.uniparc.SignatureDbType;

/**
Expand Down Expand Up @@ -52,7 +52,7 @@ void testSignatureDbId() {

@Test
void testLocations() {
List<Location> locations = Arrays.asList(new Location(12, 23), new Location(45, 89));
List<SequenceFeatureLocation> locations = Arrays.asList(new SequenceFeatureLocationBuilder().range(12, 23).alignment("55M").build(), new SequenceFeatureLocationBuilder().range(45, 89).build());
InterProGroup domain = new InterProGroupBuilder().name("name1").id("id1").build();
SequenceFeature sf =
new SequenceFeatureBuilder()
Expand All @@ -69,15 +69,15 @@ void testLocations() {

@Test
void testAddLocation() {
List<Location> locations = Arrays.asList(new Location(12, 23), new Location(45, 89));
List<SequenceFeatureLocation> locations = Arrays.asList(new SequenceFeatureLocationBuilder().range(12, 23).alignment("55M").build(), new SequenceFeatureLocationBuilder().range(45, 89).build());
InterProGroup domain = new InterProGroupBuilder().name("name1").id("id1").build();
SequenceFeature sf =
new SequenceFeatureBuilder()
.interproGroup(domain)
.signatureDbType(SignatureDbType.PFAM)
.signatureDbId("sigId2")
.locationsSet(locations)
.locationsAdd(new Location(100, 300))
.locationsAdd(new SequenceFeatureLocationBuilder().range(100, 300).build())
.build();
assertEquals(domain, sf.getInterProDomain());
assertEquals(SignatureDbType.PFAM, sf.getSignatureDbType());
Expand All @@ -87,7 +87,7 @@ void testAddLocation() {

@Test
void testFrom() {
List<Location> locations = Arrays.asList(new Location(12, 23), new Location(45, 89));
List<SequenceFeatureLocation> locations = Arrays.asList(new SequenceFeatureLocationBuilder().range(12, 23).alignment("55M").build(), new SequenceFeatureLocationBuilder().range(45, 89).build());
InterProGroup domain = new InterProGroupBuilder().name("name1").id("id1").build();
SequenceFeature sf =
new SequenceFeatureBuilder()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.uniprot.core.uniparc.impl;

import org.junit.jupiter.api.Test;
import org.uniprot.core.Property;
import org.uniprot.core.uniparc.SequenceFeatureLocation;
import org.uniprot.core.uniparc.UniParcCrossReference;
import org.uniprot.core.uniparc.UniParcDatabase;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

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

class SequenceFeatureLocationBuilderTest {
@Test
void testStart() {
int start = 10;
SequenceFeatureLocation location =
new SequenceFeatureLocationBuilder().start(start).build();
assertEquals(start, location.getStart());
}

@Test
void testEnd() {
int end = 20;
SequenceFeatureLocation location =
new SequenceFeatureLocationBuilder().end(end).build();
assertEquals(end, location.getEnd());
}

@Test
void testRange() {
int start = 10;
int end = 20;
SequenceFeatureLocation location =
new SequenceFeatureLocationBuilder().range(start, end).build();
assertEquals(start, location.getStart());
assertEquals(end, location.getEnd());
}

@Test
void testAlignment() {
String alignment = "M55";
SequenceFeatureLocation location =
new SequenceFeatureLocationBuilder().alignment(alignment).build();
assertEquals(alignment, location.getAlignment());
}
@Test
void testFromSequenceFeatureLocation() {
SequenceFeatureLocation location = new SequenceFeatureLocationImpl(10, 20, "VALUE");
SequenceFeatureLocation fromLocation = SequenceFeatureLocationBuilder.from(location).build();
assertEquals(location, fromLocation);
}
}
Loading

0 comments on commit 5e991c9

Please sign in to comment.