-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
286 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
core-domain/src/main/java/org/uniprot/core/uniparc/SequenceFeatureLocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...omain/src/test/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationBuilderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.