diff --git a/controlled-vocabulary/pom.xml b/controlled-vocabulary/pom.xml index a70ebbffd..b146ff133 100644 --- a/controlled-vocabulary/pom.xml +++ b/controlled-vocabulary/pom.xml @@ -6,7 +6,7 @@ org.uniprot core-parent - 1.0.33-SNAPSHOT + 1.0.35-SNAPSHOT ../ diff --git a/core-common/pom.xml b/core-common/pom.xml index 3c3c6791a..65cb3ef92 100644 --- a/core-common/pom.xml +++ b/core-common/pom.xml @@ -5,7 +5,7 @@ org.uniprot core-parent - 1.0.33-SNAPSHOT + 1.0.35-SNAPSHOT ../ diff --git a/core-domain-utils/pom.xml b/core-domain-utils/pom.xml index 3e6cf5554..cb0c6c440 100644 --- a/core-domain-utils/pom.xml +++ b/core-domain-utils/pom.xml @@ -5,7 +5,7 @@ core-parent org.uniprot - 1.0.33-SNAPSHOT + 1.0.35-SNAPSHOT 4.0.0 diff --git a/core-domain/pom.xml b/core-domain/pom.xml index be157b404..177f56ca5 100644 --- a/core-domain/pom.xml +++ b/core-domain/pom.xml @@ -5,7 +5,7 @@ org.uniprot core-parent - 1.0.33-SNAPSHOT + 1.0.35-SNAPSHOT ../ diff --git a/core-domain/src/main/java/org/uniprot/core/uniparc/SequenceFeature.java b/core-domain/src/main/java/org/uniprot/core/uniparc/SequenceFeature.java index d4b2add93..065388a9a 100644 --- a/core-domain/src/main/java/org/uniprot/core/uniparc/SequenceFeature.java +++ b/core-domain/src/main/java/org/uniprot/core/uniparc/SequenceFeature.java @@ -3,8 +3,6 @@ import java.io.Serializable; import java.util.List; -import org.uniprot.core.Location; - /** * @author jluo * @date: 22 May 2019 @@ -16,5 +14,5 @@ public interface SequenceFeature extends Serializable { String getSignatureDbId(); - List getLocations(); + List getLocations(); } diff --git a/core-domain/src/main/java/org/uniprot/core/uniparc/SequenceFeatureLocation.java b/core-domain/src/main/java/org/uniprot/core/uniparc/SequenceFeatureLocation.java new file mode 100644 index 000000000..dde2de0b0 --- /dev/null +++ b/core-domain/src/main/java/org/uniprot/core/uniparc/SequenceFeatureLocation.java @@ -0,0 +1,11 @@ +package org.uniprot.core.uniparc; + +import java.io.Serializable; + +public interface SequenceFeatureLocation extends Serializable { + int getStart(); + + int getEnd(); + + String getAlignment(); +} diff --git a/core-domain/src/main/java/org/uniprot/core/uniparc/SignatureDbType.java b/core-domain/src/main/java/org/uniprot/core/uniparc/SignatureDbType.java index e02c1dc7b..6635303d0 100644 --- a/core-domain/src/main/java/org/uniprot/core/uniparc/SignatureDbType.java +++ b/core-domain/src/main/java/org/uniprot/core/uniparc/SignatureDbType.java @@ -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"), @@ -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; diff --git a/core-domain/src/main/java/org/uniprot/core/uniparc/UniParcEntryLight.java b/core-domain/src/main/java/org/uniprot/core/uniparc/UniParcEntryLight.java index f2a3af4ad..82131e1ef 100644 --- a/core-domain/src/main/java/org/uniprot/core/uniparc/UniParcEntryLight.java +++ b/core-domain/src/main/java/org/uniprot/core/uniparc/UniParcEntryLight.java @@ -6,6 +6,7 @@ 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 { @@ -25,6 +26,8 @@ public interface UniParcEntryLight extends Serializable { LocalDate getMostRecentCrossRefUpdated(); + Map getExtraAttributes(); + // lazily loaded fields Set getOrganisms();// organism id and name pair diff --git a/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureBuilder.java b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureBuilder.java index 9d84711af..3fbf633ed 100644 --- a/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureBuilder.java +++ b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureBuilder.java @@ -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; @@ -20,7 +20,7 @@ public class SequenceFeatureBuilder implements Builder { private InterProGroup interproGroup; private SignatureDbType dbType; private String dbId; - private List locations = new ArrayList<>(); + private List locations = new ArrayList<>(); @Override public @Nonnull SequenceFeature build() { @@ -42,12 +42,12 @@ public class SequenceFeatureBuilder implements Builder { return this; } - public @Nonnull SequenceFeatureBuilder locationsSet(List locations) { + public @Nonnull SequenceFeatureBuilder locationsSet(List 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; } diff --git a/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureImpl.java b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureImpl.java index 3c1381689..723d2e64d 100644 --- a/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureImpl.java +++ b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureImpl.java @@ -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; @@ -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 locations; + private List locations; SequenceFeatureImpl() { this.locations = Collections.emptyList(); } SequenceFeatureImpl( - InterProGroup domain, SignatureDbType dbType, String dbId, List locations) { + InterProGroup domain, SignatureDbType dbType, String dbId, List locations) { super(); this.interproGroup = domain; this.database = dbType; @@ -53,7 +53,7 @@ public String getSignatureDbId() { } @Override - public List getLocations() { + public List getLocations() { return locations; } diff --git a/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationBuilder.java b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationBuilder.java new file mode 100644 index 000000000..99c64fe6d --- /dev/null +++ b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationBuilder.java @@ -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 { + + 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()); + } +} diff --git a/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationImpl.java b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationImpl.java new file mode 100644 index 000000000..e65cd3e53 --- /dev/null +++ b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationImpl.java @@ -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); + } +} diff --git a/core-domain/src/main/java/org/uniprot/core/uniparc/impl/UniParcEntryLightBuilder.java b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/UniParcEntryLightBuilder.java index 80f82e57b..f9fbec50c 100644 --- a/core-domain/src/main/java/org/uniprot/core/uniparc/impl/UniParcEntryLightBuilder.java +++ b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/UniParcEntryLightBuilder.java @@ -11,11 +11,12 @@ import javax.annotation.Nonnull; import java.time.LocalDate; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; +import java.util.*; + +import static org.uniprot.core.util.Utils.putOrIgnoreNull; + public class UniParcEntryLightBuilder implements Builder { + public static final String HAS_ACTIVE_CROSS_REF = "hasActiveCrossRef"; private String uniParcId; private int crossReferenceCount; private List commonTaxons = new ArrayList<>(); @@ -37,12 +38,15 @@ public class UniParcEntryLightBuilder implements Builder { private Set proteomes = new LinkedHashSet<>(); + private Map extraAttributes = new LinkedHashMap<>(); + @Nonnull @Override public UniParcEntryLight build() { return new UniParcEntryLightImpl(uniParcId, crossReferenceCount, commonTaxons, uniProtKBAccessions, sequence, sequenceFeatures, oldestCrossRefCreated, - mostRecentCrossRefUpdated, (LinkedHashSet) organisms, (LinkedHashSet) proteinNames, (LinkedHashSet) geneNames, (LinkedHashSet) proteomes); + mostRecentCrossRefUpdated, (LinkedHashSet) organisms, (LinkedHashSet) proteinNames, + (LinkedHashSet) geneNames, (LinkedHashSet) proteomes, extraAttributes); } public @Nonnull UniParcEntryLightBuilder uniParcId(String uniParcId) { @@ -140,16 +144,22 @@ public UniParcEntryLight build() { return this; } + public @Nonnull UniParcEntryLightBuilder extraAttributesAdd(String name, Object value) { + putOrIgnoreNull(name, value, this.extraAttributes); + return this; + } + public static @Nonnull UniParcEntryLightBuilder from(UniParcEntryLight uniParcEntryLight){ - LinkedHashSet uniprotKbAccessions = new LinkedHashSet<>(uniParcEntryLight.getUniProtKBAccessions()); + LinkedHashSet uniProtKBAccessions = new LinkedHashSet<>(uniParcEntryLight.getUniProtKBAccessions()); LinkedHashSet organisms = new LinkedHashSet<>(uniParcEntryLight.getOrganisms()); LinkedHashSet proteinNames = new LinkedHashSet<>(uniParcEntryLight.getProteinNames()); LinkedHashSet geneNames = new LinkedHashSet<>(uniParcEntryLight.getGeneNames()); LinkedHashSet proteomes = new LinkedHashSet<>(uniParcEntryLight.getProteomes()); - return new UniParcEntryLightBuilder().uniParcId(uniParcEntryLight.getUniParcId()) + UniParcEntryLightBuilder builder = new UniParcEntryLightBuilder(); + builder.uniParcId(uniParcEntryLight.getUniParcId()) .crossReferenceCount(uniParcEntryLight.getCrossReferenceCount()) .commonTaxonsSet(uniParcEntryLight.getCommonTaxons()) - .uniProtKBAccessionsSet(uniprotKbAccessions) + .uniProtKBAccessionsSet(uniProtKBAccessions) .sequence(uniParcEntryLight.getSequence()) .sequenceFeaturesSet(uniParcEntryLight.getSequenceFeatures()) .oldestCrossRefCreated(uniParcEntryLight.getOldestCrossRefCreated()) @@ -158,5 +168,7 @@ public UniParcEntryLight build() { .proteinNamesSet(proteinNames) .geneNamesSet(geneNames) .proteomesSet(proteomes); + builder.extraAttributes = new LinkedHashMap<>(uniParcEntryLight.getExtraAttributes()); + return builder; } } diff --git a/core-domain/src/main/java/org/uniprot/core/uniparc/impl/UniParcEntryLightImpl.java b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/UniParcEntryLightImpl.java index c02460902..2ac0f5d80 100644 --- a/core-domain/src/main/java/org/uniprot/core/uniparc/impl/UniParcEntryLightImpl.java +++ b/core-domain/src/main/java/org/uniprot/core/uniparc/impl/UniParcEntryLightImpl.java @@ -9,10 +9,7 @@ import org.uniprot.core.util.Utils; import java.time.LocalDate; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Objects; -import java.util.Set; +import java.util.*; public class UniParcEntryLightImpl implements UniParcEntryLight { @@ -31,6 +28,8 @@ public class UniParcEntryLightImpl implements UniParcEntryLight { private final Set geneNames; private final Set proteomes; + private final Map extraAttributes; + UniParcEntryLightImpl() { this(null, 0, null, null, null, null, null, null); } @@ -41,14 +40,14 @@ public class UniParcEntryLightImpl implements UniParcEntryLight { LocalDate oldestCrossRefCreated, LocalDate mostRecentCrossRefUpdated) { this(uniParcId, crossReferenceCount, commonTaxons, uniProtKBAccessions, sequence, sequenceFeatures, oldestCrossRefCreated, mostRecentCrossRefUpdated, - null, null, null, null); + null, null, null, null, null); } UniParcEntryLightImpl(String uniParcId, int crossReferenceCount, List commonTaxons, LinkedHashSet uniProtKBAccessions, Sequence sequence, List sequenceFeatures, LocalDate oldestCrossRefCreated, LocalDate mostRecentCrossRefUpdated, LinkedHashSet organisms, LinkedHashSet proteinNames, LinkedHashSet geneNames, - LinkedHashSet proteomes) { + LinkedHashSet proteomes, Map extraAttributes) { this.uniParcId = uniParcId; this.crossReferenceCount = crossReferenceCount; this.commonTaxons = Utils.unmodifiableList(commonTaxons); @@ -61,6 +60,7 @@ public class UniParcEntryLightImpl implements UniParcEntryLight { this.proteinNames = Utils.unmodifiableSet(proteinNames); this.geneNames = Utils.unmodifiableSet(geneNames); this.proteomes = Utils.unmodifiableSet(proteomes); + this.extraAttributes = Objects.isNull(extraAttributes) ? Map.of() : extraAttributes; } @Override @@ -123,6 +123,11 @@ public Set getProteomes() { return proteomes; } + @Override + public Map getExtraAttributes() { + return this.extraAttributes; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -138,13 +143,15 @@ public boolean equals(Object o) { Objects.equals(getOrganisms(), that.getOrganisms()) && Objects.equals(getProteinNames(), that.getProteinNames()) && Objects.equals(getGeneNames(), that.getGeneNames()) && - Objects.equals(getProteomes(), that.getProteomes()); + Objects.equals(getProteomes(), that.getProteomes()) && + Objects.equals(getExtraAttributes(), that.getExtraAttributes()); } @Override public int hashCode() { return Objects.hash(getUniParcId(), getCrossReferenceCount(), getCommonTaxons(), getUniProtKBAccessions(), getSequence(), getSequenceFeatures(), getOldestCrossRefCreated(), - getMostRecentCrossRefUpdated(), getOrganisms(), getProteinNames(), getGeneNames(), getProteomes()); + getMostRecentCrossRefUpdated(), getOrganisms(), getProteinNames(), getGeneNames(), getProteomes(), + getExtraAttributes()); } } diff --git a/core-domain/src/test/java/org/uniprot/core/ObjectsForTests.java b/core-domain/src/test/java/org/uniprot/core/ObjectsForTests.java index 7db087922..020cb1edb 100644 --- a/core-domain/src/test/java/org/uniprot/core/ObjectsForTests.java +++ b/core-domain/src/test/java/org/uniprot/core/ObjectsForTests.java @@ -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.*; @@ -223,7 +224,7 @@ public static List createEvidenceValuesWithEvidences() { } public static List sequenceFeatures() { - List locations = Arrays.asList(new Location(12, 23), new Location(45, 89)); + List 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() diff --git a/core-domain/src/test/java/org/uniprot/core/uniparc/impl/SequenceFeatureBuilderTest.java b/core-domain/src/test/java/org/uniprot/core/uniparc/impl/SequenceFeatureBuilderTest.java index 7ad39d368..3ba44fc9d 100644 --- a/core-domain/src/test/java/org/uniprot/core/uniparc/impl/SequenceFeatureBuilderTest.java +++ b/core-domain/src/test/java/org/uniprot/core/uniparc/impl/SequenceFeatureBuilderTest.java @@ -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; /** @@ -52,7 +52,7 @@ void testSignatureDbId() { @Test void testLocations() { - List locations = Arrays.asList(new Location(12, 23), new Location(45, 89)); + List 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() @@ -69,7 +69,7 @@ void testLocations() { @Test void testAddLocation() { - List locations = Arrays.asList(new Location(12, 23), new Location(45, 89)); + List 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() @@ -77,7 +77,7 @@ void testAddLocation() { .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()); @@ -87,7 +87,7 @@ void testAddLocation() { @Test void testFrom() { - List locations = Arrays.asList(new Location(12, 23), new Location(45, 89)); + List 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() diff --git a/core-domain/src/test/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationBuilderTest.java b/core-domain/src/test/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationBuilderTest.java new file mode 100644 index 000000000..d954f31d0 --- /dev/null +++ b/core-domain/src/test/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationBuilderTest.java @@ -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); + } +} \ No newline at end of file diff --git a/core-domain/src/test/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationImplTest.java b/core-domain/src/test/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationImplTest.java new file mode 100644 index 000000000..0c2289a25 --- /dev/null +++ b/core-domain/src/test/java/org/uniprot/core/uniparc/impl/SequenceFeatureLocationImplTest.java @@ -0,0 +1,30 @@ +package org.uniprot.core.uniparc.impl; + +import org.junit.jupiter.api.Test; +import org.uniprot.core.uniparc.SequenceFeatureLocation; +import org.uniprot.core.uniparc.UniParcCrossReference; +import org.uniprot.core.uniparc.UniParcDatabase; +import org.uniprot.core.uniprotkb.taxonomy.impl.OrganismBuilder; + +import java.time.LocalDate; +import java.util.Collections; + +import static org.junit.jupiter.api.Assertions.*; + +class SequenceFeatureLocationImplTest { + + @Test + void needDefaultConstructorForJsonDeserialization() { + SequenceFeatureLocation obj = new SequenceFeatureLocationImpl(); + assertNotNull(obj); + } + + @Test + void builderFrom_constructorImp_shouldCreate_equalObject() { + SequenceFeatureLocationImpl impl = + new SequenceFeatureLocationImpl(10,20, "component"); + SequenceFeatureLocation obj = SequenceFeatureLocationBuilder.from(impl).build(); + assertTrue(impl.equals(obj) && obj.equals(impl)); + assertEquals(impl.hashCode(), obj.hashCode()); + } +} \ No newline at end of file diff --git a/core-domain/src/test/java/org/uniprot/core/uniparc/impl/UniParcEntryLightBuilderTest.java b/core-domain/src/test/java/org/uniprot/core/uniparc/impl/UniParcEntryLightBuilderTest.java index 544114ac7..b94d2f384 100644 --- a/core-domain/src/test/java/org/uniprot/core/uniparc/impl/UniParcEntryLightBuilderTest.java +++ b/core-domain/src/test/java/org/uniprot/core/uniparc/impl/UniParcEntryLightBuilderTest.java @@ -340,4 +340,25 @@ void testFromWithEmptyAccessions(){ Assertions.assertDoesNotThrow(() -> UniParcEntryLightBuilder.from(builder.build())); } + @Test + void testExtraAttributes(){ + UniParcEntryLight entry = new UniParcEntryLightBuilder().uniParcId("UPI0000083A08") + .extraAttributesAdd("hasActiveCrossRef", true).build(); + assertEquals("UPI0000083A08", entry.getUniParcId()); + assertEquals(1, entry.getExtraAttributes().size()); + assertEquals(true, entry.getExtraAttributes().get("hasActiveCrossRef")); + } + @Test + void testAddExtraAttributes(){ + UniParcEntryLight entry = new UniParcEntryLightBuilder().uniParcId("UPI0000083A08").build(); + assertEquals("UPI0000083A08", entry.getUniParcId()); + assertTrue(entry.getExtraAttributes().isEmpty()); + // add extra attribute + UniParcEntryLight updatedEntry = UniParcEntryLightBuilder.from(entry) + .extraAttributesAdd("hasActiveCrossRef", false).build(); + assertEquals("UPI0000083A08", updatedEntry.getUniParcId()); + assertEquals(1, updatedEntry.getExtraAttributes().size()); + assertEquals(false, updatedEntry.getExtraAttributes().get("hasActiveCrossRef")); + } + } diff --git a/core-domain/src/test/java/org/uniprot/core/uniparc/impl/UniParcEntryLightImplTest.java b/core-domain/src/test/java/org/uniprot/core/uniparc/impl/UniParcEntryLightImplTest.java index 71bb3d3a0..c07fd3289 100644 --- a/core-domain/src/test/java/org/uniprot/core/uniparc/impl/UniParcEntryLightImplTest.java +++ b/core-domain/src/test/java/org/uniprot/core/uniparc/impl/UniParcEntryLightImplTest.java @@ -14,6 +14,7 @@ import java.time.LocalDate; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import static org.junit.jupiter.api.Assertions.*; import static org.uniprot.core.ObjectsForTests.sequenceFeatures; @@ -47,9 +48,11 @@ void builderFrom_constructorImp_shouldCreate_equalObject() { LinkedHashSet geneNames = new LinkedHashSet<>(List.of("Gene1", "Gene2")); LinkedHashSet proteomes = new LinkedHashSet<>(List.of(new ProteomeBuilder().id("UP000005640").component("C1").build(), new ProteomeBuilder().id("UP000002494").component("C2").build())); LinkedHashSet uniProtKBAccessions = new LinkedHashSet<>(List.of("P21802", "P12345")); + Map extraAttributes = Map.of("hasActiveCrossRef", true); UniParcEntryLight impl = new UniParcEntryLightImpl(uniParcId, crossReferenceCount, commonTaxons, uniProtKBAccessions, - sequence, sequenceFeatures, oldestCrossRefCreated, mostRecentCrossRefUpdated, organisms, proteinNames, geneNames, proteomes); + sequence, sequenceFeatures, oldestCrossRefCreated, mostRecentCrossRefUpdated, organisms, + proteinNames, geneNames, proteomes, extraAttributes); UniParcEntryLight obj = UniParcEntryLightBuilder.from(impl).build(); assertTrue(impl.equals(obj) && obj.equals(impl)); diff --git a/core-parser/pom.xml b/core-parser/pom.xml index 606a09d65..27a734f55 100644 --- a/core-parser/pom.xml +++ b/core-parser/pom.xml @@ -5,7 +5,7 @@ org.uniprot core-parent - 1.0.33-SNAPSHOT + 1.0.35-SNAPSHOT ../ diff --git a/core-parser/src/main/java/org/uniprot/core/parser/fasta/uniparc/UniParcFastaParser.java b/core-parser/src/main/java/org/uniprot/core/parser/fasta/uniparc/UniParcFastaParser.java index 937c959c2..898752dda 100644 --- a/core-parser/src/main/java/org/uniprot/core/parser/fasta/uniparc/UniParcFastaParser.java +++ b/core-parser/src/main/java/org/uniprot/core/parser/fasta/uniparc/UniParcFastaParser.java @@ -5,11 +5,15 @@ import org.uniprot.core.uniparc.UniParcEntry; import org.uniprot.core.uniparc.UniParcEntryLight; +import static org.uniprot.core.uniparc.impl.UniParcEntryLightBuilder.HAS_ACTIVE_CROSS_REF; + /** * @author jluo * @date: 24 Jun 2019 */ public class UniParcFastaParser { + private UniParcFastaParser(){} + public static String toFasta(UniParcEntry entry) { String status = "active"; boolean isActive = entry.getUniParcCrossReferences() @@ -22,14 +26,11 @@ public static String toFasta(UniParcEntry entry) { } public static String toFasta(UniParcEntryLight entry) { - StringBuilder sb = new StringBuilder(); String status = "active"; - //TODO: We currently do not have active attribute in UniParcEntryLight object - //boolean isActive = - // entry.getUniParcCrossReferences().stream().anyMatch(val -> val.isActive()); - //if (!isActive) { - // status = "inactive"; - //} + if(entry.getExtraAttributes().containsKey(HAS_ACTIVE_CROSS_REF) && + entry.getExtraAttributes().get(HAS_ACTIVE_CROSS_REF).equals(false)){ + status = "inactive"; + } return getFastaString(entry.getUniParcId(), status, entry.getSequence()); } diff --git a/core-parser/src/test/java/org/uniprot/core/parser/fasta/UniParcFastaParserTest.java b/core-parser/src/test/java/org/uniprot/core/parser/fasta/UniParcFastaParserTest.java index 051ecec4b..9b14a50f7 100644 --- a/core-parser/src/test/java/org/uniprot/core/parser/fasta/UniParcFastaParserTest.java +++ b/core-parser/src/test/java/org/uniprot/core/parser/fasta/UniParcFastaParserTest.java @@ -1,23 +1,22 @@ package org.uniprot.core.parser.fasta; -import static org.junit.jupiter.api.Assertions.*; - -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import org.junit.jupiter.api.Test; -import org.uniprot.core.Location; import org.uniprot.core.Property; import org.uniprot.core.Sequence; import org.uniprot.core.impl.SequenceBuilder; import org.uniprot.core.uniparc.*; -import org.uniprot.core.uniparc.UniParcCrossReference; import org.uniprot.core.uniparc.impl.*; import org.uniprot.core.uniprotkb.taxonomy.Organism; import org.uniprot.core.uniprotkb.taxonomy.impl.OrganismBuilder; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.uniprot.core.uniparc.impl.UniParcEntryLightBuilder.HAS_ACTIVE_CROSS_REF; + /** * @author jluo * @date: 24 Jun 2019 @@ -28,7 +27,10 @@ class UniParcFastaParserTest { >UPI0000083A08 status=active MSMAMARALATLGRLRYRVSGQLPLLDETAIEVMAGGQFLDGRKAREELGFFSTTALDDT LLRAIDWFRDNGYFNA"""; - + public static final String EXPECTED_FASTA_RESULT_INACTIVE = """ + >UPI0000083A08 status=inactive + MSMAMARALATLGRLRYRVSGQLPLLDETAIEVMAGGQFLDGRKAREELGFFSTTALDDT + LLRAIDWFRDNGYFNA"""; @Test void testUniParcEntryToFasta() { UniParcEntry entry = create(); @@ -43,6 +45,14 @@ void testUniParcEntryLightToFasta() { assertEquals(EXPECTED_FASTA_RESULT, fasta); } + @Test + void testUniParcEntryLightToFastaInactive() { + UniParcEntryLight entry = createEntryLight(); + entry = UniParcEntryLightBuilder.from(entry).extraAttributesAdd(HAS_ACTIVE_CROSS_REF, false).build(); + String fasta = UniParcFastaParser.toFasta(entry); + assertEquals(EXPECTED_FASTA_RESULT_INACTIVE, fasta); + } + private UniParcEntry create() { Sequence sequence = getSequence(); List xrefs = getXrefs(); @@ -72,7 +82,7 @@ private static Sequence getSequence() { } private List getSeqFeatures() { - List locations = Arrays.asList(new Location(12, 23), new Location(45, 89)); + List 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() diff --git a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapperTest.java b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapperTest.java index 52ad9d74d..baa554df0 100644 --- a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapperTest.java +++ b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapperTest.java @@ -120,14 +120,17 @@ private UniParcEntryLight create() { } private List getSeqFeatures() { - List locations = Arrays.asList(new Location(12, 23), new Location(45, 89)); + SequenceFeatureLocationBuilder sflBuilder = new SequenceFeatureLocationBuilder(); + SequenceFeatureLocation sfl1 = sflBuilder.range(12, 13).alignment("M55").build(); + SequenceFeatureLocation sfl2 = sflBuilder.range(45, 89).alignment("Alignment").build(); + List sfls = List.of(sfl1, sfl2); InterProGroup domain = new InterProGroupBuilder().name("name1").id("id1").build(); SequenceFeature sf = new SequenceFeatureBuilder() .interproGroup(domain) .signatureDbType(SignatureDbType.PFAM) .signatureDbId("sigId2") - .locationsSet(locations) + .locationsSet(sfls) .build(); SequenceFeature sf3 = SequenceFeatureBuilder.from(sf).signatureDbType(SignatureDbType.PROSITE).build(); diff --git a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryValueMapperTest.java b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryValueMapperTest.java index 39d4eab0b..1bafde168 100644 --- a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryValueMapperTest.java +++ b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryValueMapperTest.java @@ -9,17 +9,12 @@ import java.util.Map; import org.junit.jupiter.api.Test; -import org.uniprot.core.Location; import org.uniprot.core.Property; import org.uniprot.core.Sequence; import org.uniprot.core.impl.SequenceBuilder; import org.uniprot.core.uniparc.*; import org.uniprot.core.uniparc.UniParcDatabase; -import org.uniprot.core.uniparc.impl.InterProGroupBuilder; -import org.uniprot.core.uniparc.impl.SequenceFeatureBuilder; -import org.uniprot.core.uniparc.impl.UniParcCrossReferenceBuilder; -import org.uniprot.core.uniparc.impl.UniParcEntryBuilder; -import org.uniprot.core.uniparc.impl.UniParcIdBuilder; +import org.uniprot.core.uniparc.impl.*; import org.uniprot.core.uniprotkb.taxonomy.Organism; import org.uniprot.core.uniprotkb.taxonomy.impl.OrganismBuilder; @@ -118,7 +113,7 @@ private UniParcEntry create() { } private List getSeqFeatures() { - List locations = Arrays.asList(new Location(12, 23), new Location(45, 89)); + List 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() diff --git a/ff-parser/pom.xml b/ff-parser/pom.xml index a753b8ea4..7aac0a3a7 100644 --- a/ff-parser/pom.xml +++ b/ff-parser/pom.xml @@ -6,7 +6,7 @@ org.uniprot core-parent - 1.0.33-SNAPSHOT + 1.0.35-SNAPSHOT ../ diff --git a/jacoco-aggregate-report/pom.xml b/jacoco-aggregate-report/pom.xml index 00b38f73b..f89718637 100644 --- a/jacoco-aggregate-report/pom.xml +++ b/jacoco-aggregate-report/pom.xml @@ -5,7 +5,7 @@ core-parent org.uniprot - 1.0.33-SNAPSHOT + 1.0.35-SNAPSHOT 4.0.0 diff --git a/json-parser/pom.xml b/json-parser/pom.xml index fe2c701b5..dc7e50466 100644 --- a/json-parser/pom.xml +++ b/json-parser/pom.xml @@ -5,7 +5,7 @@ org.uniprot core-parent - 1.0.33-SNAPSHOT + 1.0.35-SNAPSHOT ../ 4.0.0 diff --git a/json-parser/src/main/java/org/uniprot/core/json/parser/uniparc/UniParcEntryLightJsonConfig.java b/json-parser/src/main/java/org/uniprot/core/json/parser/uniparc/UniParcEntryLightJsonConfig.java index 922f6f1b4..193348556 100644 --- a/json-parser/src/main/java/org/uniprot/core/json/parser/uniparc/UniParcEntryLightJsonConfig.java +++ b/json-parser/src/main/java/org/uniprot/core/json/parser/uniparc/UniParcEntryLightJsonConfig.java @@ -55,6 +55,7 @@ private ObjectMapper initObjectMapper() { mod.addAbstractTypeMapping(UniParcEntryLight.class, UniParcEntryLightImpl.class); mod.addAbstractTypeMapping(InterProGroup.class, InterProGroupImpl.class); mod.addAbstractTypeMapping(SequenceFeature.class, SequenceFeatureImpl.class); + mod.addAbstractTypeMapping(SequenceFeatureLocation.class, SequenceFeatureLocationImpl.class); mod.addAbstractTypeMapping(CrossReference.class, CrossReferenceImpl.class); mod.addAbstractTypeMapping(Sequence.class, SequenceImpl.class); mod.addAbstractTypeMapping(CommonOrganism.class, CommonOrganismImpl.class); diff --git a/json-parser/src/main/java/org/uniprot/core/json/parser/uniparc/UniParcJsonConfig.java b/json-parser/src/main/java/org/uniprot/core/json/parser/uniparc/UniParcJsonConfig.java index e0437e4b5..cfe169133 100644 --- a/json-parser/src/main/java/org/uniprot/core/json/parser/uniparc/UniParcJsonConfig.java +++ b/json-parser/src/main/java/org/uniprot/core/json/parser/uniparc/UniParcJsonConfig.java @@ -13,11 +13,7 @@ import org.uniprot.core.json.parser.JsonConfig; import org.uniprot.core.json.parser.deserializer.LocalDateDeserializer; import org.uniprot.core.json.parser.serializer.LocalDateSerializer; -import org.uniprot.core.uniparc.InterProGroup; -import org.uniprot.core.uniparc.SequenceFeature; -import org.uniprot.core.uniparc.UniParcCrossReference; -import org.uniprot.core.uniparc.UniParcEntry; -import org.uniprot.core.uniparc.UniParcId; +import org.uniprot.core.uniparc.*; import org.uniprot.core.uniparc.impl.*; import org.uniprot.core.uniparc.impl.UniParcCrossReferenceImpl; import org.uniprot.core.uniprotkb.evidence.Evidence; @@ -69,6 +65,7 @@ private ObjectMapper initObjectMapper() { mod.addAbstractTypeMapping(UniParcEntry.class, UniParcEntryImpl.class); mod.addAbstractTypeMapping(InterProGroup.class, InterProGroupImpl.class); mod.addAbstractTypeMapping(SequenceFeature.class, SequenceFeatureImpl.class); + mod.addAbstractTypeMapping(SequenceFeatureLocation.class, SequenceFeatureLocationImpl.class); mod.addAbstractTypeMapping(Organism.class, OrganismImpl.class); mod.addAbstractTypeMapping(Evidence.class, EvidenceImpl.class); mod.addAbstractTypeMapping(UniParcCrossReference.class, UniParcCrossReferenceImpl.class); diff --git a/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/SequenceFeatureTest.java b/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/SequenceFeatureTest.java index 9b7bf6372..f4aeb566b 100644 --- a/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/SequenceFeatureTest.java +++ b/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/SequenceFeatureTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.fail; import org.junit.jupiter.api.Test; -import org.uniprot.core.Location; import org.uniprot.core.json.parser.ValidateJson; import org.uniprot.core.uniparc.InterProGroup; import org.uniprot.core.uniparc.SequenceFeature; @@ -12,6 +11,7 @@ import org.uniprot.core.uniparc.impl.SequenceFeatureBuilder; import com.fasterxml.jackson.databind.ObjectMapper; +import org.uniprot.core.uniparc.impl.SequenceFeatureLocationBuilder; /** * @author jluo @@ -40,11 +40,11 @@ void testSequenceFeature() { SequenceFeatureBuilder builder = new SequenceFeatureBuilder(); builder.signatureDbType(SignatureDbType.PFAM) .signatureDbId("PF00626") - .locationsAdd(new Location(81, 163)) - .locationsAdd(new Location(202, 267)) - .locationsAdd(new Location(330, 398)) - .locationsAdd(new Location(586, 653)) - .locationsAdd(new Location(692, 766)) + .locationsAdd(new SequenceFeatureLocationBuilder().range(81, 163).alignment("81M").build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(202, 267).alignment("202M").build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(330, 398).alignment("81M").build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(586, 653).alignment("586M").build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(692, 766).alignment("81M").build()) .interproGroup( new InterProGroupBuilder() .id("IPR007123") diff --git a/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/UniParcEntryLightJsonConfigTest.java b/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/UniParcEntryLightJsonConfigTest.java index 130f45a37..a6585222f 100644 --- a/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/UniParcEntryLightJsonConfigTest.java +++ b/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/UniParcEntryLightJsonConfigTest.java @@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.fail; import static org.uniprot.core.json.parser.uniparc.UniParcEntryTest.getSeqFeature; +import static org.uniprot.core.uniparc.impl.UniParcEntryLightBuilder.HAS_ACTIVE_CROSS_REF; class UniParcEntryLightJsonConfigTest { @@ -90,6 +91,7 @@ private UniParcEntryLight getCompleteUniParcEntryLight() { .proteinNamesSet(proteinNames) .geneNamesSet(geneNames) .proteomesSet(proteomes) + .extraAttributesAdd(HAS_ACTIVE_CROSS_REF, true) .build(); } } diff --git a/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/UniParcEntryTest.java b/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/UniParcEntryTest.java index 93487381c..3d588a7ef 100644 --- a/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/UniParcEntryTest.java +++ b/json-parser/src/test/java/org/uniprot/core/json/parser/uniparc/UniParcEntryTest.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; -import org.uniprot.core.Location; import org.uniprot.core.Property; import org.uniprot.core.Sequence; import org.uniprot.core.impl.SequenceBuilder; @@ -10,12 +9,9 @@ import org.uniprot.core.json.parser.uniprot.CreateUtils; import org.uniprot.core.uniparc.SequenceFeature; import org.uniprot.core.uniparc.SignatureDbType; +import org.uniprot.core.uniparc.impl.*; import org.uniprot.core.uniparc.UniParcDatabase; import org.uniprot.core.uniparc.UniParcEntry; -import org.uniprot.core.uniparc.impl.InterProGroupBuilder; -import org.uniprot.core.uniparc.impl.SequenceFeatureBuilder; -import org.uniprot.core.uniparc.impl.UniParcCrossReferenceBuilder; -import org.uniprot.core.uniparc.impl.UniParcEntryBuilder; import org.uniprot.core.uniprotkb.evidence.Evidence; import org.uniprot.core.uniprotkb.taxonomy.Organism; import org.uniprot.core.uniprotkb.taxonomy.impl.OrganismBuilder; @@ -127,7 +123,7 @@ static SequenceFeature getSeqFeature(SignatureDbType signatureType) { return new SequenceFeatureBuilder() .signatureDbType(signatureType) .signatureDbId("id-" + signatureType) - .locationsAdd(new Location(81, 163)) + .locationsAdd(new SequenceFeatureLocationBuilder().range(81, 163).alignment("48M").build()) .interproGroup( new InterProGroupBuilder() .id("IPR007123") diff --git a/pom.xml b/pom.xml index 4c700c24c..dbea7402d 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.uniprot core-parent pom - 1.0.33-SNAPSHOT + 1.0.35-SNAPSHOT UniProt Core Aggregator diff --git a/tools-entry-scorer/pom.xml b/tools-entry-scorer/pom.xml index c9e7ad979..3b6d84492 100644 --- a/tools-entry-scorer/pom.xml +++ b/tools-entry-scorer/pom.xml @@ -5,7 +5,7 @@ core-parent org.uniprot - 1.0.33-SNAPSHOT + 1.0.35-SNAPSHOT ../ 4.0.0 diff --git a/xml-parser/pom.xml b/xml-parser/pom.xml index 0b88892ec..7d8ced32f 100644 --- a/xml-parser/pom.xml +++ b/xml-parser/pom.xml @@ -6,7 +6,7 @@ org.uniprot core-parent - 1.0.33-SNAPSHOT + 1.0.35-SNAPSHOT ../ diff --git a/xml-parser/src/main/java/org/uniprot/core/xml/uniparc/SequenceFeatureConverter.java b/xml-parser/src/main/java/org/uniprot/core/xml/uniparc/SequenceFeatureConverter.java index 3658343df..ca139d41e 100644 --- a/xml-parser/src/main/java/org/uniprot/core/xml/uniparc/SequenceFeatureConverter.java +++ b/xml-parser/src/main/java/org/uniprot/core/xml/uniparc/SequenceFeatureConverter.java @@ -2,12 +2,13 @@ import java.util.stream.Collectors; -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.uniparc.impl.InterProGroupBuilder; import org.uniprot.core.uniparc.impl.SequenceFeatureBuilder; +import org.uniprot.core.uniparc.impl.SequenceFeatureLocationBuilder; import org.uniprot.core.xml.Converter; import org.uniprot.core.xml.jaxb.uniparc.LocationType; import org.uniprot.core.xml.jaxb.uniparc.ObjectFactory; @@ -36,13 +37,15 @@ public SequenceFeatureConverter(ObjectFactory xmlFactory) { @Override public SequenceFeature fromXml(SeqFeatureType xmlObj) { SequenceFeatureBuilder builder = new SequenceFeatureBuilder(); - builder.interproGroup(interproGroupConverter.fromXml(xmlObj.getIpr())) - .signatureDbType(SignatureDbType.typeOf(xmlObj.getDatabase())) + builder.signatureDbType(SignatureDbType.typeOf(xmlObj.getDatabase())) .signatureDbId(xmlObj.getId()) .locationsSet( xmlObj.getLcn().stream() .map(locationConverter::fromXml) .collect(Collectors.toList())); + if(xmlObj.getIpr() != null){ + builder.interproGroup(interproGroupConverter.fromXml(xmlObj.getIpr())); + } return builder.build(); } @@ -52,7 +55,9 @@ public SeqFeatureType toXml(SequenceFeature uniObj) { SeqFeatureType xmlObj = xmlFactory.createSeqFeatureType(); xmlObj.setDatabase(uniObj.getSignatureDbType().getDisplayName()); xmlObj.setId(uniObj.getSignatureDbId()); - xmlObj.setIpr(interproGroupConverter.toXml(uniObj.getInterProDomain())); + if(uniObj.getInterProDomain() != null) { + xmlObj.setIpr(interproGroupConverter.toXml(uniObj.getInterProDomain())); + } uniObj.getLocations().stream() .map(locationConverter::toXml) @@ -81,7 +86,7 @@ public SeqFeatureGroupType toXml(InterProGroup uniObj) { } } - class LocationConverter implements Converter { + class LocationConverter implements Converter { private final ObjectFactory xmlFactory; LocationConverter(ObjectFactory xmlFactory) { @@ -89,15 +94,23 @@ class LocationConverter implements Converter { } @Override - public Location fromXml(LocationType xmlObj) { - return new Location(xmlObj.getStart(), xmlObj.getEnd()); + public SequenceFeatureLocation fromXml(LocationType xmlObj) { + SequenceFeatureLocationBuilder builder = new SequenceFeatureLocationBuilder(); + builder.range(xmlObj.getStart(), xmlObj.getEnd()); + if (xmlObj.getAlignment() != null) { + builder.alignment(xmlObj.getAlignment()); + } + return builder.build(); } @Override - public LocationType toXml(Location uniObj) { + public LocationType toXml(SequenceFeatureLocation uniObj) { LocationType xmlObj = xmlFactory.createLocationType(); xmlObj.setStart(uniObj.getStart()); xmlObj.setEnd(uniObj.getEnd()); + if (uniObj.getAlignment() != null) { + xmlObj.setAlignment(uniObj.getAlignment()); + } return xmlObj; } } diff --git a/xml-parser/src/main/resources/xsd/uniparc.xsd b/xml-parser/src/main/resources/xsd/uniparc.xsd index e7efa3628..eebd1cbcb 100644 --- a/xml-parser/src/main/resources/xsd/uniparc.xsd +++ b/xml-parser/src/main/resources/xsd/uniparc.xsd @@ -82,6 +82,7 @@ + diff --git a/xml-parser/src/test/java/org/uniprot/core/xml/uniparc/SequenceFeatureConverterTest.java b/xml-parser/src/test/java/org/uniprot/core/xml/uniparc/SequenceFeatureConverterTest.java index 0c8c8d2f9..3c69c6a14 100644 --- a/xml-parser/src/test/java/org/uniprot/core/xml/uniparc/SequenceFeatureConverterTest.java +++ b/xml-parser/src/test/java/org/uniprot/core/xml/uniparc/SequenceFeatureConverterTest.java @@ -3,11 +3,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -import org.uniprot.core.Location; import org.uniprot.core.uniparc.SequenceFeature; import org.uniprot.core.uniparc.SignatureDbType; 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.xml.jaxb.uniparc.SeqFeatureType; /** @@ -25,7 +25,22 @@ void testSingleLocation() { SequenceFeatureBuilder builder = new SequenceFeatureBuilder(); builder.signatureDbType(SignatureDbType.PANTHER) .signatureDbId("PTHR11977") - .locationsAdd(new Location(49, 790)) + .locationsAdd(new SequenceFeatureLocationBuilder().range(49, 790).build()) + .interproGroup( + new InterProGroupBuilder().id("IPR007122").name("Villin/Gelsolin").build()); + verify(builder.build()); + } + + @Test + void testSingleLocationWithAlignment() { + // + // + // + // + SequenceFeatureBuilder builder = new SequenceFeatureBuilder(); + builder.signatureDbType(SignatureDbType.PANTHER) + .signatureDbId("PTHR11977") + .locationsAdd(new SequenceFeatureLocationBuilder().range(49, 790).alignment("55M").build()) .interproGroup( new InterProGroupBuilder().id("IPR007122").name("Villin/Gelsolin").build()); verify(builder.build()); @@ -54,11 +69,11 @@ void testMultiLocations() { SequenceFeatureBuilder builder = new SequenceFeatureBuilder(); builder.signatureDbType(SignatureDbType.PFAM) .signatureDbId("PF00626") - .locationsAdd(new Location(81, 163)) - .locationsAdd(new Location(202, 267)) - .locationsAdd(new Location(330, 398)) - .locationsAdd(new Location(586, 653)) - .locationsAdd(new Location(692, 766)) + .locationsAdd(new SequenceFeatureLocationBuilder().range(81, 163).build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(202, 267).alignment("21M").build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(330, 398).build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(586, 653).alignment("55M").build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(692, 766).build()) .interproGroup( new InterProGroupBuilder() .id("IPR007123") diff --git a/xml-parser/src/test/java/org/uniprot/core/xml/uniparc/UniParcEntryConverterTest.java b/xml-parser/src/test/java/org/uniprot/core/xml/uniparc/UniParcEntryConverterTest.java index 3a39a9cc7..437126411 100644 --- a/xml-parser/src/test/java/org/uniprot/core/xml/uniparc/UniParcEntryConverterTest.java +++ b/xml-parser/src/test/java/org/uniprot/core/xml/uniparc/UniParcEntryConverterTest.java @@ -7,15 +7,11 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.uniprot.core.Location; import org.uniprot.core.Sequence; import org.uniprot.core.impl.SequenceBuilder; import org.uniprot.core.uniparc.*; import org.uniprot.core.uniparc.UniParcDatabase; -import org.uniprot.core.uniparc.impl.InterProGroupBuilder; -import org.uniprot.core.uniparc.impl.SequenceFeatureBuilder; -import org.uniprot.core.uniparc.impl.UniParcCrossReferenceBuilder; -import org.uniprot.core.uniparc.impl.UniParcEntryBuilder; +import org.uniprot.core.uniparc.impl.*; import org.uniprot.core.uniprotkb.taxonomy.Organism; import org.uniprot.core.uniprotkb.taxonomy.impl.OrganismBuilder; import org.uniprot.core.xml.jaxb.uniparc.Entry; @@ -52,7 +48,7 @@ private UniParcEntry createEntry() { sfBuilder .signatureDbType(SignatureDbType.PANTHER) .signatureDbId("PTHR11977") - .locationsAdd(new Location(49, 790)) + .locationsAdd(new SequenceFeatureLocationBuilder().range(49, 790).build()) .interproGroup( new InterProGroupBuilder().id("IPR007122").name("Villin/Gelsolin").build()); @@ -60,16 +56,11 @@ private UniParcEntry createEntry() { sfBuilder2 .signatureDbType(SignatureDbType.PFAM) .signatureDbId("PF00626") - .locationsAdd(new Location(81, 163)) - .locationsAdd(new Location(202, 267)) - .locationsAdd(new Location(330, 398)) - .locationsAdd(new Location(586, 653)) - .locationsAdd(new Location(692, 766)) - .interproGroup( - new InterProGroupBuilder() - .id("IPR007123") - .name("Gelsolin-like domain") - .build()); + .locationsAdd(new SequenceFeatureLocationBuilder().range(81, 163).build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(202, 267).alignment("22M").build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(330, 398).build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(586, 653).alignment("57M").build()) + .locationsAdd(new SequenceFeatureLocationBuilder().range(692, 766).build()); sfs.add(sfBuilder.build()); sfs.add(sfBuilder2.build()); builder.uniParcId("UPI0000083A08")