From fb0693aab71ed7d27a0b8d0ee04d5111c94d6c84 Mon Sep 17 00:00:00 2001 From: uniprotci Date: Tue, 12 Sep 2023 22:32:55 +0000 Subject: [PATCH 01/31] "Bumping up the POM version to 1.0.27-SNAPSHOT" --- controlled-vocabulary/pom.xml | 2 +- core-common/pom.xml | 2 +- core-domain-utils/pom.xml | 2 +- core-domain/pom.xml | 2 +- core-parser/pom.xml | 2 +- ff-parser/pom.xml | 2 +- jacoco-aggregate-report/pom.xml | 2 +- json-parser/pom.xml | 2 +- pom.xml | 2 +- tools-entry-scorer/pom.xml | 2 +- xml-parser/pom.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/controlled-vocabulary/pom.xml b/controlled-vocabulary/pom.xml index a6e2462e2..95345a55e 100644 --- a/controlled-vocabulary/pom.xml +++ b/controlled-vocabulary/pom.xml @@ -6,7 +6,7 @@ org.uniprot core-parent - 1.0.26 + 1.0.27-SNAPSHOT ../ diff --git a/core-common/pom.xml b/core-common/pom.xml index f8c359e19..75139f5d0 100644 --- a/core-common/pom.xml +++ b/core-common/pom.xml @@ -5,7 +5,7 @@ org.uniprot core-parent - 1.0.26 + 1.0.27-SNAPSHOT ../ diff --git a/core-domain-utils/pom.xml b/core-domain-utils/pom.xml index 839587558..81904e295 100644 --- a/core-domain-utils/pom.xml +++ b/core-domain-utils/pom.xml @@ -5,7 +5,7 @@ core-parent org.uniprot - 1.0.26 + 1.0.27-SNAPSHOT 4.0.0 diff --git a/core-domain/pom.xml b/core-domain/pom.xml index 65ac09977..dfc98a974 100644 --- a/core-domain/pom.xml +++ b/core-domain/pom.xml @@ -5,7 +5,7 @@ org.uniprot core-parent - 1.0.26 + 1.0.27-SNAPSHOT ../ diff --git a/core-parser/pom.xml b/core-parser/pom.xml index 2c4932404..d8794a22c 100644 --- a/core-parser/pom.xml +++ b/core-parser/pom.xml @@ -5,7 +5,7 @@ org.uniprot core-parent - 1.0.26 + 1.0.27-SNAPSHOT ../ diff --git a/ff-parser/pom.xml b/ff-parser/pom.xml index d340d8c3d..6f324defc 100644 --- a/ff-parser/pom.xml +++ b/ff-parser/pom.xml @@ -6,7 +6,7 @@ org.uniprot core-parent - 1.0.26 + 1.0.27-SNAPSHOT ../ diff --git a/jacoco-aggregate-report/pom.xml b/jacoco-aggregate-report/pom.xml index 68969823e..ad63e8df0 100644 --- a/jacoco-aggregate-report/pom.xml +++ b/jacoco-aggregate-report/pom.xml @@ -5,7 +5,7 @@ core-parent org.uniprot - 1.0.26 + 1.0.27-SNAPSHOT 4.0.0 diff --git a/json-parser/pom.xml b/json-parser/pom.xml index 83d4d0a08..9d5bb4f6b 100644 --- a/json-parser/pom.xml +++ b/json-parser/pom.xml @@ -5,7 +5,7 @@ org.uniprot core-parent - 1.0.26 + 1.0.27-SNAPSHOT ../ 4.0.0 diff --git a/pom.xml b/pom.xml index 974f5d307..4614b716e 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.uniprot core-parent pom - 1.0.26 + 1.0.27-SNAPSHOT UniProt Core Aggregator diff --git a/tools-entry-scorer/pom.xml b/tools-entry-scorer/pom.xml index f199a5eb8..02ab9b52f 100644 --- a/tools-entry-scorer/pom.xml +++ b/tools-entry-scorer/pom.xml @@ -5,7 +5,7 @@ core-parent org.uniprot - 1.0.26 + 1.0.27-SNAPSHOT ../ 4.0.0 diff --git a/xml-parser/pom.xml b/xml-parser/pom.xml index 2d3388d9d..72e748e59 100644 --- a/xml-parser/pom.xml +++ b/xml-parser/pom.xml @@ -6,7 +6,7 @@ org.uniprot core-parent - 1.0.26 + 1.0.27-SNAPSHOT ../ From cf7a9882d93376e386c0c7a34e31a6f11d0d153e Mon Sep 17 00:00:00 2001 From: LeonardoGonzales Date: Thu, 14 Sep 2023 11:12:20 +0100 Subject: [PATCH 02/31] TRM-28411: Add Xref TSV initial logic --- .../tsv/uniprot/EntryCrossReferenceMap.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java index e99d8eb55..657baf585 100644 --- a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java +++ b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java @@ -94,12 +94,39 @@ private String pdbXrefTo3DString(List xrefs) { public static String dbXrefToString(UniProtKBCrossReference xref) { StringBuilder sb = new StringBuilder(); sb.append(xref.getId()); + boolean addQuote = false; + if (xref.hasProperties()) { + String values = dbXrefPropertiesToString(xref); + if(!values.isEmpty()){ + sb.append("; ").append(values).append("."); + addQuote = true; + } + } if (xref.getIsoformId() != null && !xref.getIsoformId().isEmpty()) { sb.append(" [").append(xref.getIsoformId()).append("]"); } + + if (addQuote) { + sb.insert(0, "\""); + sb.append("\""); + } return sb.toString(); } + private static String dbXrefPropertiesToString(UniProtKBCrossReference xref) { + List properties = xref.getProperties(); + if (xref.getProperties().size() == 1) { + properties = xref.getProperties().stream() + .filter(p -> !p.getValue().strip().equals("-")) + .collect(Collectors.toList()); + } + + return properties.stream() + .map(Property::getValue) + .map(String::strip) + .collect(Collectors.joining("; ")); + } + public static String proteomeXrefToString(UniProtKBCrossReference xref) { StringBuilder sb = new StringBuilder(); sb.append(xref.getId()).append(": ").append(xref.getProperties().get(0).getValue()); From fd7243bf53b2deeb51e3aa9143ce89f7181d7a3e Mon Sep 17 00:00:00 2001 From: LeonardoGonzales Date: Thu, 21 Sep 2023 09:20:25 +0100 Subject: [PATCH 03/31] TRM-30227: Update TAIR URL template --- .../src/main/resources/META-INF/drlineconfiguration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controlled-vocabulary/src/main/resources/META-INF/drlineconfiguration.json b/controlled-vocabulary/src/main/resources/META-INF/drlineconfiguration.json index ee781f644..57ac1265a 100644 --- a/controlled-vocabulary/src/main/resources/META-INF/drlineconfiguration.json +++ b/controlled-vocabulary/src/main/resources/META-INF/drlineconfiguration.json @@ -1218,7 +1218,7 @@ "name": "TAIR", "displayName": "TAIR", "category": "ORG", - "uriLink": "https://www.arabidopsis.org/servlets/TairObject?accession=%id", + "uriLink": "https://www.arabidopsis.org/servlets/TairObject?type=locus&name=%id", "attributes": [ { "name": "GeneName", From 5fc512c253923605b8281bb530fc8469241ed9bf Mon Sep 17 00:00:00 2001 From: LeonardoGonzales Date: Fri, 22 Sep 2023 16:31:56 +0100 Subject: [PATCH 04/31] Update to use selected multiple id xrefs only --- .../tsv/uniprot/EntryCrossReferenceMap.java | 17 +++++++------ .../uniprot/EntryCrossReferenceMapTest.java | 8 +++---- .../UniProtKBEntryValueMapperTest.java | 24 ++++++++++++++----- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java index 657baf585..8ed53c688 100644 --- a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java +++ b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java @@ -13,6 +13,10 @@ public class EntryCrossReferenceMap implements NamedValueMap { private final List dbReferences; private static final Map D3MethodMAP = new HashMap<>(); + private static final List MULTIPLE_IDS_XREF = List.of("EMBL", "Ensembl", "EnsemblBacteria", "EnsemblFungi", "EnsemblMetazoa", "EnsemblPlants", "EnsemblProtists", "MANE-Select", "RefSeq", "WormBase", "WBParaSite"); + + private static final List NOT_ID_ATTRIBUTES = List.of("GeneName", "Status", "MoleculeType"); + static { D3MethodMAP.put("X-ray", "X-ray crystallography"); D3MethodMAP.put("NMR", "NMR spectroscopy"); @@ -95,7 +99,7 @@ public static String dbXrefToString(UniProtKBCrossReference xref) { StringBuilder sb = new StringBuilder(); sb.append(xref.getId()); boolean addQuote = false; - if (xref.hasProperties()) { + if (MULTIPLE_IDS_XREF.contains(xref.getDatabase().getName())) { String values = dbXrefPropertiesToString(xref); if(!values.isEmpty()){ sb.append("; ").append(values).append("."); @@ -114,16 +118,11 @@ public static String dbXrefToString(UniProtKBCrossReference xref) { } private static String dbXrefPropertiesToString(UniProtKBCrossReference xref) { - List properties = xref.getProperties(); - if (xref.getProperties().size() == 1) { - properties = xref.getProperties().stream() - .filter(p -> !p.getValue().strip().equals("-")) - .collect(Collectors.toList()); - } - - return properties.stream() + return xref.getProperties().stream() + .filter(p -> !NOT_ID_ATTRIBUTES.contains(p.getKey())) .map(Property::getValue) .map(String::strip) + .filter(value -> !value.equals("-")) .collect(Collectors.joining("; ")); } diff --git a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java index 708351152..d4db62607 100644 --- a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java +++ b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java @@ -44,7 +44,7 @@ void hasEmbl() { EntryCrossReferenceMap dl = new EntryCrossReferenceMap(xrefs); Map result = dl.attributeValues(); assertEquals(1, result.size()); - verify("AY189288;AK022746;", "xref_embl", result); + verify("\"AY189288; AAO86732.1.\";\"AK022746; BAB14220.1.\";", "xref_embl", result); } @Test @@ -87,8 +87,8 @@ void hasEmblAndEnsembl() { EntryCrossReferenceMap dl = new EntryCrossReferenceMap(xrefs); Map result = dl.attributeValues(); assertEquals(2, result.size()); - verify("AY189288;AK022746;", "xref_embl", result); - verify("ENST00000330899 [P31689-1];ENST00000439351;", "xref_ensembl", result); + verify("\"AY189288; AAO86732.1.\";\"AK022746; BAB14220.1.\";", "xref_embl", result); + verify("\"ENST00000330899; ENSP00000369127; ENSG00000086061. [P31689-1]\";\"ENST00000439351; ENSP00000414398; ENSG00000090520.\";", "xref_ensembl", result); } @Test @@ -174,7 +174,7 @@ void testBbXrefToString() { "mRNA", null); String result = EntryCrossReferenceMap.dbXrefToString(dbxref); - assertEquals("AY189288", result); + assertEquals("\"AY189288; AAO86732.1.\"", result); } @Test diff --git a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java index 3af7d97d8..c82fbd192 100644 --- a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java +++ b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java @@ -553,11 +553,22 @@ void testXRefs1() { Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); - String embl = - "U53347;AF102826;AF105423;GQ919058;AK292690;AK299137;AK301661;AK316546;AC008622;CH471126;BC000062;AF334818;"; + String embl = "\"U53347; AAC50629.1.\";" + + "\"AF102826; AAD09812.1.\";" + + "\"AF105423; AAD27806.1.\";" + + "\"GQ919058; ACX53626.1.\";" + + "\"AK292690; BAF85379.1.\";" + + "\"AK299137; BAG61189.1.\";" + + "\"AK301661; BAG63136.1.\";" + + "\"AK316546; BAH14917.1.\";" + + "AC008622;" + + "\"CH471126; EAW57446.1.\";" + + "\"BC000062; AAH00062.1.\";" + + "\"AF334818; AAK77026.1.\";"; String ccds = "CCDS12692.1 [Q15758-1];CCDS46125.1 [Q15758-2];CCDS46126.1 [Q15758-3];"; - String refseq = - "NP_001138616.1 [Q15758-3];NP_001138617.1 [Q15758-2];NP_005619.1 [Q15758-1];"; + String refseq = "\"NP_001138616.1; NM_001145144.1. [Q15758-3]\";" + + "\"NP_001138617.1; NM_001145145.1. [Q15758-2]\";" + + "\"NP_005619.1; NM_005628.2. [Q15758-1]\";"; String smr = "Q15758;"; verify(embl, "xref_embl", result); verify(ccds, "xref_ccds", result); @@ -653,8 +664,9 @@ void testXRefs5() { Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); - String ensembl = - "ENST00000412532 [Q15758-3];ENST00000434726 [Q15758-2];ENST00000542575 [Q15758-1];"; + String ensembl = "\"ENST00000412532; ENSP00000397924; ENSG00000105281. [Q15758-3]\";" + + "\"ENST00000434726; ENSP00000406532; ENSG00000105281. [Q15758-2]\";" + + "\"ENST00000542575; ENSP00000444408; ENSG00000105281. [Q15758-1]\";"; String reactome = "R-HSA-352230;"; String interpro = "IPR001991;IPR018107;IPR036458;"; String prosite = "PS00713;PS00714;"; From daa58212b373fb71b1eaedd4a9abbaa4c6d62219 Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Wed, 27 Sep 2023 17:12:12 +0100 Subject: [PATCH 05/31] add internal cross refs for publication --- .../uniprot/cv/xdb/UniProtDatabaseTypes.java | 9 +++- .../META-INF/drlineconfiguration.json | 51 ++++++++++++++++++- .../cv/xdb/CrossReferenceValidatorIT.java | 2 +- .../cv/xdb/UniProtKBDatabaseTypesTest.java | 16 ++++-- .../core/cv/xdb/UniProtDatabaseDetail.java | 24 ++++++++- .../uniprot/core/UniProtKBDatabaseMock.java | 4 +- .../cv/xdb/UniProtKBDatabaseDetailTest.java | 13 +++-- 7 files changed, 104 insertions(+), 15 deletions(-) diff --git a/controlled-vocabulary/src/main/java/org/uniprot/cv/xdb/UniProtDatabaseTypes.java b/controlled-vocabulary/src/main/java/org/uniprot/cv/xdb/UniProtDatabaseTypes.java index d3dba33c2..3e10a366f 100644 --- a/controlled-vocabulary/src/main/java/org/uniprot/cv/xdb/UniProtDatabaseTypes.java +++ b/controlled-vocabulary/src/main/java/org/uniprot/cv/xdb/UniProtDatabaseTypes.java @@ -50,6 +50,11 @@ public List getDBTypesByCategory(UniProtDatabaseCategory .collect(Collectors.toList()); } + public List getInternalDatabaseDetails(){ + return UniProtDatabaseTypes.INSTANCE.getAllDbTypes().stream() + .filter(dbDetail -> "internal".equals(dbDetail.getType())).collect(Collectors.toList()); + } + private void init() { String source = @@ -72,6 +77,7 @@ private void init() { String linkedReason = item.optString("linkedReason", null); String idMappingName = item.optString("idMappingName", null); + String type = item.optString("type", null); List attributes = new ArrayList<>(); List properties = item.getProperties("attributes"); @@ -97,7 +103,8 @@ private void init() { attributes, isImplicit, linkedReason, - idMappingName); + idMappingName, + type); types.add(xdbType); }); typeMap = diff --git a/controlled-vocabulary/src/main/resources/META-INF/drlineconfiguration.json b/controlled-vocabulary/src/main/resources/META-INF/drlineconfiguration.json index 57ac1265a..82a60efec 100644 --- a/controlled-vocabulary/src/main/resources/META-INF/drlineconfiguration.json +++ b/controlled-vocabulary/src/main/resources/META-INF/drlineconfiguration.json @@ -1898,5 +1898,54 @@ "displayName": "AlphaFoldDB", "category": "3DS", "uriLink": "https://alphafold.ebi.ac.uk/entry/%id" - } + }, + { + "name": "eMIND", + "displayName": "eMIND", + "category": "MISC", + "uriLink": "https://research.bioinformatics.udel.edu/itextmine/integrate/doc/emind/medline/%id", + "type": "internal" + }, + { + "name":"PGenN", + "displayName":"PGenN", + "category":"MISC", + "uriLink":"https://research.bioinformatics.udel.edu/itextmine/pgenn/doc/pgenn/medline/%id", + "type":"internal" + }, + { + "name":"Alzforum", + "displayName":"Alzforum", + "category":"GVD", + "uriLink":"https://www.alzforum.org/node/%id", + "type":"internal" + }, + { + "name":"GeneRIF", + "displayName":"GeneRIF", + "category":"SEQ", + "uriLink":"https://www.ncbi.nlm.nih.gov/gene?Db=gene&Cmd=DetailsSearch&Term=%id", + "type":"internal" + }, + { + "name":"IC4R", + "displayName":"IC4R", + "category":"ORG", + "uriLink":"http://ic4r.org/osGene/%id", + "type":"internal" + }, + { + "name":"ORCID", + "displayName":"ORCID", + "category":"MISC", + "uriLink":"https://orcid.org/%id", + "type":"internal" + }, + { + "name":"PubTator", + "displayName":"PubTator", + "category":"MISC", + "uriLink":"https://www.ncbi.nlm.nih.gov/research/pubtator/?query=%id", + "type":"internal" + } ] \ No newline at end of file diff --git a/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/CrossReferenceValidatorIT.java b/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/CrossReferenceValidatorIT.java index 10ac978de..f18a7cf67 100644 --- a/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/CrossReferenceValidatorIT.java +++ b/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/CrossReferenceValidatorIT.java @@ -69,7 +69,7 @@ void testFailedValidation() { opType.getAttributes(), false, null, - null); + null, null); // validate, the category should mismatch List> mismatches = CrossReferenceValidator.validate(actualOpType); diff --git a/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/UniProtKBDatabaseTypesTest.java b/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/UniProtKBDatabaseTypesTest.java index 87c0b2034..58a633d99 100644 --- a/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/UniProtKBDatabaseTypesTest.java +++ b/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/UniProtKBDatabaseTypesTest.java @@ -6,6 +6,7 @@ import static org.uniprot.core.cv.xdb.UniProtDatabaseCategory.*; import java.util.List; +import java.util.stream.Collectors; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -288,7 +289,7 @@ void testProteomesType() { @Test void testDatabaseFieldSize() { - verifyGroupSize(UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(SEQUENCE_DATABASES), 6); + verifyGroupSize(UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(SEQUENCE_DATABASES), 7); verifyGroupSize( UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(D3_STRUCTURE_DATABASES), 12); verifyGroupSize( @@ -301,7 +302,7 @@ void testDatabaseFieldSize() { 13); verifyGroupSize(UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(PTM_DATABASES), 10); verifyGroupSize( - UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(GENERIC_VARIATION_DATABASES), 5); + UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(GENERIC_VARIATION_DATABASES), 6); verifyGroupSize(UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(D2_GEL_DATABASES), 7); verifyGroupSize( UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(PROTEOMIC_DATABASES), 11); @@ -314,13 +315,13 @@ void testDatabaseFieldSize() { 15); verifyGroupSize( UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(ORGANISM_SPECIFIC_DATABASES), - 40); + 41); verifyGroupSize( UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(PHYLOGENOMIC_DATABASES), 9); verifyGroupSize( UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(ENZYME_AND_PATHWAY_DATABASES), 10); - verifyGroupSize(UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(MISCELLANEOUS), 11); + verifyGroupSize(UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(MISCELLANEOUS), 15); verifyGroupSize( UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(GENE_EXPRESSION_DATABASES), 5); verifyGroupSize( @@ -331,6 +332,13 @@ void testDatabaseFieldSize() { verifyGroupSize(UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(PROTEOMES_DATABASES), 1); } + @Test + void testInternalCrossRefs(){ + List internalCrossRefs = UniProtDatabaseTypes.INSTANCE.getInternalDatabaseDetails(); + + assertEquals(7, internalCrossRefs.size()); + } + private void verifyGroupSize(List dbTypesByCategory, int size) { assertEquals(size, dbTypesByCategory.size()); } diff --git a/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java b/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java index dfc77def5..409daedef 100644 --- a/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java +++ b/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java @@ -20,6 +20,7 @@ public class UniProtDatabaseDetail implements Serializable { private boolean implicit = false; private String linkedReason = null; private String idMappingName; + private String type; UniProtDatabaseDetail() { this.attributes = new ArrayList<>(); @@ -35,6 +36,18 @@ public UniProtDatabaseDetail( boolean implicit, String linkedReason, String idMappingName) { + this(name, displayName, category, uriLink, attributes, implicit, linkedReason, idMappingName, null); + } + public UniProtDatabaseDetail( + String name, + String displayName, + UniProtDatabaseCategory category, + String uriLink, + List attributes, + boolean implicit, + String linkedReason, + String idMappingName, + String type) { super(); this.name = name; this.displayName = displayName; @@ -47,6 +60,7 @@ public UniProtDatabaseDetail( if ((attributes != null) && !attributes.isEmpty()) this.attributes.addAll(attributes); else this.attributes.add(DEFAULT_ATTRIBUTE); this.idMappingName = idMappingName; + this.type = type; } public String getName() { @@ -81,6 +95,10 @@ public String getIdMappingName() { return idMappingName; } + public String getType(){ + return this.type; + } + @Override public int hashCode() { return Objects.hash( @@ -91,7 +109,8 @@ public int hashCode() { this.uriLink, this.implicit, this.linkedReason, - this.idMappingName); + this.idMappingName, + this.type); } @Override @@ -109,6 +128,7 @@ public boolean equals(Object obj) { && Objects.equals(this.uriLink, other.uriLink) && Objects.equals(this.implicit, other.implicit) && Objects.equals(this.linkedReason, other.linkedReason) - && Objects.equals(this.idMappingName, other.idMappingName); + && Objects.equals(this.idMappingName, other.idMappingName) + && Objects.equals(this.type, other.type); } } diff --git a/core-domain/src/test/java/org/uniprot/core/UniProtKBDatabaseMock.java b/core-domain/src/test/java/org/uniprot/core/UniProtKBDatabaseMock.java index e14fb20ea..432cadd35 100644 --- a/core-domain/src/test/java/org/uniprot/core/UniProtKBDatabaseMock.java +++ b/core-domain/src/test/java/org/uniprot/core/UniProtKBDatabaseMock.java @@ -20,10 +20,10 @@ public UniProtKBDatabaseMock(String name) { public @Nonnull UniProtDatabaseDetail getUniProtDatabaseDetail() { if (Utils.notNullNotEmpty(this.name)) { return new UniProtDatabaseDetail( - this.name, this.name, null, null, null, false, null, null); + this.name, this.name, null, null, null, false, null, null, null); } else { return new UniProtDatabaseDetail( - "dummy", "dummyName", null, null, null, false, null, null); + "dummy", "dummyName", null, null, null, false, null, null, null); } } diff --git a/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java b/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java index fd6ee19f4..9b2031e76 100644 --- a/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java +++ b/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java @@ -18,6 +18,7 @@ class UniProtKBDatabaseDetailTest { private String uriLink; private List attributes; private String idMappingName; + private String type; @BeforeEach void setUp() { @@ -34,6 +35,7 @@ void setUp() { this.name, this.displayName, this.uriLink)) .collect(Collectors.toList()); this.idMappingName = "idMappingName-" + random; + this.type = "type-" + random; } @Test @@ -49,6 +51,7 @@ void testCreateObject() { assertEquals("description", dbType.getAttributes().get(0).getXmlTag()); Assertions.assertNull(dbType.getAttributes().get(0).getUriLink()); assertEquals(this.idMappingName, dbType.getIdMappingName()); + assertEquals(this.type, dbType.getType()); } @Test @@ -99,6 +102,7 @@ void needDefaultConstructorForJsonDeserialization() { assertEquals(1, obj.getAttributes().size()); assertNull(obj.getLinkedReason()); assertFalse(obj.isImplicit()); + assertNull(obj.getType()); } private UniProtDatabaseDetail createUniProtDatabaseDetail(boolean passAttribute) { @@ -109,7 +113,7 @@ private UniProtDatabaseDetail createUniProtDatabaseDetail(boolean passAttribute) this.category, this.uriLink, this.attributes, - null); + null, null); } else { return createUniProtDatabaseDetail( this.name, @@ -117,7 +121,8 @@ private UniProtDatabaseDetail createUniProtDatabaseDetail(boolean passAttribute) this.category, this.uriLink, null, - this.idMappingName); + this.idMappingName, + this.type); } } @@ -127,8 +132,8 @@ static UniProtDatabaseDetail createUniProtDatabaseDetail( UniProtDatabaseCategory category, String uriLink, List attributes, - String idMappingName) { + String idMappingName, String type) { return new UniProtDatabaseDetail( - name, displayName, category, uriLink, attributes, false, null, idMappingName); + name, displayName, category, uriLink, attributes, false, null, idMappingName, type); } } From c9251baea052df4b3db42954f42df1c16a690550 Mon Sep 17 00:00:00 2001 From: automated changes Date: Wed, 27 Sep 2023 16:14:32 +0000 Subject: [PATCH 06/31] code format with spotless automatic --- .../org/uniprot/cv/xdb/UniProtDatabaseTypes.java | 5 +++-- .../uniprot/cv/xdb/CrossReferenceValidatorIT.java | 3 ++- .../uniprot/cv/xdb/UniProtKBDatabaseTypesTest.java | 6 +++--- .../uniprot/core/cv/xdb/UniProtDatabaseDetail.java | 14 ++++++++++++-- .../core/cv/xdb/UniProtKBDatabaseDetailTest.java | 6 ++++-- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/controlled-vocabulary/src/main/java/org/uniprot/cv/xdb/UniProtDatabaseTypes.java b/controlled-vocabulary/src/main/java/org/uniprot/cv/xdb/UniProtDatabaseTypes.java index 3e10a366f..8423f0de8 100644 --- a/controlled-vocabulary/src/main/java/org/uniprot/cv/xdb/UniProtDatabaseTypes.java +++ b/controlled-vocabulary/src/main/java/org/uniprot/cv/xdb/UniProtDatabaseTypes.java @@ -50,9 +50,10 @@ public List getDBTypesByCategory(UniProtDatabaseCategory .collect(Collectors.toList()); } - public List getInternalDatabaseDetails(){ + public List getInternalDatabaseDetails() { return UniProtDatabaseTypes.INSTANCE.getAllDbTypes().stream() - .filter(dbDetail -> "internal".equals(dbDetail.getType())).collect(Collectors.toList()); + .filter(dbDetail -> "internal".equals(dbDetail.getType())) + .collect(Collectors.toList()); } private void init() { diff --git a/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/CrossReferenceValidatorIT.java b/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/CrossReferenceValidatorIT.java index f18a7cf67..817a2bf24 100644 --- a/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/CrossReferenceValidatorIT.java +++ b/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/CrossReferenceValidatorIT.java @@ -69,7 +69,8 @@ void testFailedValidation() { opType.getAttributes(), false, null, - null, null); + null, + null); // validate, the category should mismatch List> mismatches = CrossReferenceValidator.validate(actualOpType); diff --git a/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/UniProtKBDatabaseTypesTest.java b/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/UniProtKBDatabaseTypesTest.java index 58a633d99..b206933e3 100644 --- a/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/UniProtKBDatabaseTypesTest.java +++ b/controlled-vocabulary/src/test/java/org/uniprot/cv/xdb/UniProtKBDatabaseTypesTest.java @@ -6,7 +6,6 @@ import static org.uniprot.core.cv.xdb.UniProtDatabaseCategory.*; import java.util.List; -import java.util.stream.Collectors; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -333,8 +332,9 @@ void testDatabaseFieldSize() { } @Test - void testInternalCrossRefs(){ - List internalCrossRefs = UniProtDatabaseTypes.INSTANCE.getInternalDatabaseDetails(); + void testInternalCrossRefs() { + List internalCrossRefs = + UniProtDatabaseTypes.INSTANCE.getInternalDatabaseDetails(); assertEquals(7, internalCrossRefs.size()); } diff --git a/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java b/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java index 409daedef..3902a83e5 100644 --- a/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java +++ b/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java @@ -36,8 +36,18 @@ public UniProtDatabaseDetail( boolean implicit, String linkedReason, String idMappingName) { - this(name, displayName, category, uriLink, attributes, implicit, linkedReason, idMappingName, null); + this( + name, + displayName, + category, + uriLink, + attributes, + implicit, + linkedReason, + idMappingName, + null); } + public UniProtDatabaseDetail( String name, String displayName, @@ -95,7 +105,7 @@ public String getIdMappingName() { return idMappingName; } - public String getType(){ + public String getType() { return this.type; } diff --git a/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java b/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java index 9b2031e76..2cc3652c4 100644 --- a/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java +++ b/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java @@ -113,7 +113,8 @@ private UniProtDatabaseDetail createUniProtDatabaseDetail(boolean passAttribute) this.category, this.uriLink, this.attributes, - null, null); + null, + null); } else { return createUniProtDatabaseDetail( this.name, @@ -132,7 +133,8 @@ static UniProtDatabaseDetail createUniProtDatabaseDetail( UniProtDatabaseCategory category, String uriLink, List attributes, - String idMappingName, String type) { + String idMappingName, + String type) { return new UniProtDatabaseDetail( name, displayName, category, uriLink, attributes, false, null, idMappingName, type); } From 4fa0e237f92714b563d62d5b766065ee828e59fc Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Fri, 29 Sep 2023 11:05:38 +0100 Subject: [PATCH 07/31] add a test to make sonar happy --- .../cv/xdb/UniProtKBDatabaseDetailTest.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java b/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java index 2cc3652c4..017046123 100644 --- a/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java +++ b/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java @@ -51,7 +51,6 @@ void testCreateObject() { assertEquals("description", dbType.getAttributes().get(0).getXmlTag()); Assertions.assertNull(dbType.getAttributes().get(0).getUriLink()); assertEquals(this.idMappingName, dbType.getIdMappingName()); - assertEquals(this.type, dbType.getType()); } @Test @@ -105,6 +104,15 @@ void needDefaultConstructorForJsonDeserialization() { assertNull(obj.getType()); } + @Test + void testCreateObjectWithType(){ + UniProtDatabaseDetail dbDetails = new UniProtDatabaseDetail(this.name, this.displayName, + this.category, this.uriLink, this.attributes, false, + null, this.idMappingName, this.type); + assertNotNull(dbDetails); + assertEquals(this.type, dbDetails.getType()); + } + private UniProtDatabaseDetail createUniProtDatabaseDetail(boolean passAttribute) { if (passAttribute) { return createUniProtDatabaseDetail( @@ -113,7 +121,6 @@ private UniProtDatabaseDetail createUniProtDatabaseDetail(boolean passAttribute) this.category, this.uriLink, this.attributes, - null, null); } else { return createUniProtDatabaseDetail( @@ -122,8 +129,7 @@ private UniProtDatabaseDetail createUniProtDatabaseDetail(boolean passAttribute) this.category, this.uriLink, null, - this.idMappingName, - this.type); + this.idMappingName); } } @@ -133,9 +139,8 @@ static UniProtDatabaseDetail createUniProtDatabaseDetail( UniProtDatabaseCategory category, String uriLink, List attributes, - String idMappingName, - String type) { + String idMappingName) { return new UniProtDatabaseDetail( - name, displayName, category, uriLink, attributes, false, null, idMappingName, type); + name, displayName, category, uriLink, attributes, false, null, idMappingName); } } From cad7eeb0f80f55375b8ad6cacb9049853a90452b Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Tue, 3 Oct 2023 15:48:32 +0100 Subject: [PATCH 08/31] use main branch in pipeline --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 04159396d..a7829554a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ variables: SONAR_PROPS: "-Dsonar.organization=ebi-uniprot -Dsonar.qualitygate.timeout=1800 -Dsonar.qualitygate.wait=true" SONAR_HOST_URL: "https://sonarcloud.io" MAVEN_SETTINGS: "maven-settings.xml" - URL_MAVEN_SETTINGS: "https://gitlab.ebi.ac.uk/api/v4/projects/${CONFIG_PROJECT_ID}/repository/files/${MAVEN_SETTINGS}/raw?ref=master&private_token=${GITLAB_USER_API_TOKEN}" + URL_MAVEN_SETTINGS: "https://gitlab.ebi.ac.uk/api/v4/projects/${CONFIG_PROJECT_ID}/repository/files/${MAVEN_SETTINGS}/raw?ref=main&private_token=${GITLAB_USER_API_TOKEN}" UNIPROT_RESOURCES: "-Dcv.db.types.location=ftp://ftp.ebi.ac.uk/pub/databases/uniprot/current_release/knowledgebase/complete/docs/dbxref.txt" GIT_DEPTH: 0 # Tells git to fetch all the branches of the project, required by the analysis task SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" @@ -38,7 +38,7 @@ core:settings: paths: - ./${MAVEN_SETTINGS} rules: - - if: '$CI_COMMIT_REF_NAME == "master"' + - if: '$CI_COMMIT_REF_NAME == "main"' - when: manual allow_failure: true @@ -59,7 +59,7 @@ core:test: junit: - ./*/target/surefire-reports/TEST-*.xml rules: - - if: '$CI_COMMIT_REF_NAME == "master"' + - if: '$CI_COMMIT_REF_NAME == "main"' - when: manual allow_failure: true @@ -76,7 +76,7 @@ core:sonar: - ./target - ./*/target rules: - - if: '$CI_COMMIT_REF_NAME == "master"' + - if: '$CI_COMMIT_REF_NAME == "main"' - when: manual allow_failure: true @@ -87,7 +87,7 @@ core:deploy: - core:settings - core:sonar only: - - master + - main #after_script: # - 'pwd' @@ -101,4 +101,4 @@ store:downstream: trigger: uniprot/deployment/mirror-uniprot-store when: on_success only: - - master \ No newline at end of file + - main \ No newline at end of file From a78c4422a8d104d17dc9da4195e4104d09e12648 Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Tue, 3 Oct 2023 16:11:16 +0100 Subject: [PATCH 09/31] use master ref of config project --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a7829554a..f69dac8aa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ variables: SONAR_PROPS: "-Dsonar.organization=ebi-uniprot -Dsonar.qualitygate.timeout=1800 -Dsonar.qualitygate.wait=true" SONAR_HOST_URL: "https://sonarcloud.io" MAVEN_SETTINGS: "maven-settings.xml" - URL_MAVEN_SETTINGS: "https://gitlab.ebi.ac.uk/api/v4/projects/${CONFIG_PROJECT_ID}/repository/files/${MAVEN_SETTINGS}/raw?ref=main&private_token=${GITLAB_USER_API_TOKEN}" + URL_MAVEN_SETTINGS: "https://gitlab.ebi.ac.uk/api/v4/projects/${CONFIG_PROJECT_ID}/repository/files/${MAVEN_SETTINGS}/raw?ref=master&private_token=${GITLAB_USER_API_TOKEN}" UNIPROT_RESOURCES: "-Dcv.db.types.location=ftp://ftp.ebi.ac.uk/pub/databases/uniprot/current_release/knowledgebase/complete/docs/dbxref.txt" GIT_DEPTH: 0 # Tells git to fetch all the branches of the project, required by the analysis task SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" From 1842bced08c9230e6149af7b83d7b321be78d08b Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Wed, 4 Oct 2023 14:27:47 +0100 Subject: [PATCH 10/31] change the RefSeq case to use camelcase --- .../java/org/uniprot/core/proteome/GenomeAssemblySource.java | 2 +- .../org/uniprot/core/proteome/GenomeAssemblySourceTest.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/GenomeAssemblySource.java b/core-domain/src/main/java/org/uniprot/core/proteome/GenomeAssemblySource.java index ab688b7fa..38051e931 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/GenomeAssemblySource.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/GenomeAssemblySource.java @@ -16,7 +16,7 @@ public enum GenomeAssemblySource implements EnumDisplay { ENSEMBLPROTISTS("EnsemblProtists"), ENSEMBLMETAZOA("EnsemblMetazoa"), ENSEMBL("Ensembl"), - REFSEQ("Refseq"), + REFSEQ("RefSeq"), WORMBASE("WormBase"); private final String name; diff --git a/core-domain/src/test/java/org/uniprot/core/proteome/GenomeAssemblySourceTest.java b/core-domain/src/test/java/org/uniprot/core/proteome/GenomeAssemblySourceTest.java index bb675cc76..05b8b0cbd 100644 --- a/core-domain/src/test/java/org/uniprot/core/proteome/GenomeAssemblySourceTest.java +++ b/core-domain/src/test/java/org/uniprot/core/proteome/GenomeAssemblySourceTest.java @@ -23,6 +23,7 @@ void getName_toDisplayName_areSame() { @Test void testToDisplayName() { assertSame("EnsemblFungi", GenomeAssemblySource.ENSEMBLFUNGI.getDisplayName()); + assertSame("RefSeq", GenomeAssemblySource.REFSEQ.getDisplayName()); } @Nested From 74328c5a164604ec357f8c757078438fac6aa949 Mon Sep 17 00:00:00 2001 From: automated changes Date: Wed, 4 Oct 2023 13:29:51 +0000 Subject: [PATCH 11/31] code format with spotless automatic --- .../core/cv/xdb/UniProtKBDatabaseDetailTest.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java b/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java index 017046123..0fdbda077 100644 --- a/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java +++ b/core-domain/src/test/java/org/uniprot/core/cv/xdb/UniProtKBDatabaseDetailTest.java @@ -105,10 +105,18 @@ void needDefaultConstructorForJsonDeserialization() { } @Test - void testCreateObjectWithType(){ - UniProtDatabaseDetail dbDetails = new UniProtDatabaseDetail(this.name, this.displayName, - this.category, this.uriLink, this.attributes, false, - null, this.idMappingName, this.type); + void testCreateObjectWithType() { + UniProtDatabaseDetail dbDetails = + new UniProtDatabaseDetail( + this.name, + this.displayName, + this.category, + this.uriLink, + this.attributes, + false, + null, + this.idMappingName, + this.type); assertNotNull(dbDetails); assertEquals(this.type, dbDetails.getType()); } From f7a2671781a9c4964f42d2cc5d5332dcc3345210 Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Thu, 5 Oct 2023 11:50:41 +0100 Subject: [PATCH 12/31] some benign change to test pipeline triggering --- .gitlab-ci.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f69dac8aa..68f25b236 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -89,13 +89,6 @@ core:deploy: only: - main -#after_script: -# - 'pwd' -# - 'ls -al' -# - 'ls -al */' -# - 'ls -al */*/' -# - 'ls -al */*/*/' - store:downstream: stage: bridge trigger: uniprot/deployment/mirror-uniprot-store From 5e4cb5127cf995174b6be1e67602cefcd1209cb2 Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Thu, 5 Oct 2023 12:06:03 +0100 Subject: [PATCH 13/31] unharmful change to test pipeline --- .../test/java/org/uniprot/core/xml/AbstractConverterTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xml-parser/src/test/java/org/uniprot/core/xml/AbstractConverterTest.java b/xml-parser/src/test/java/org/uniprot/core/xml/AbstractConverterTest.java index 7594f5d70..470659acc 100644 --- a/xml-parser/src/test/java/org/uniprot/core/xml/AbstractConverterTest.java +++ b/xml-parser/src/test/java/org/uniprot/core/xml/AbstractConverterTest.java @@ -24,8 +24,8 @@ public abstract class AbstractConverterTest { XMLGregorianCalendar.class, new MethodBasedFactory<>( AbstractConverterTest.class.getMethod("createXMLGregorianCalendar"))); - } catch (NoSuchMethodException e) { - e.printStackTrace(); + } catch (NoSuchMethodException nsme) { + nsme.printStackTrace(); System.exit(0); } objectCreator = new LoremIpsumObjectCreator(classBindings); From ce21161ccf6a740f9346e1c6f101b422cf325046 Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Thu, 5 Oct 2023 13:16:17 +0100 Subject: [PATCH 14/31] one more attempt to test build trigger --- .../test/java/org/uniprot/core/xml/AbstractConverterTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xml-parser/src/test/java/org/uniprot/core/xml/AbstractConverterTest.java b/xml-parser/src/test/java/org/uniprot/core/xml/AbstractConverterTest.java index 470659acc..cc0e01a93 100644 --- a/xml-parser/src/test/java/org/uniprot/core/xml/AbstractConverterTest.java +++ b/xml-parser/src/test/java/org/uniprot/core/xml/AbstractConverterTest.java @@ -24,8 +24,8 @@ public abstract class AbstractConverterTest { XMLGregorianCalendar.class, new MethodBasedFactory<>( AbstractConverterTest.class.getMethod("createXMLGregorianCalendar"))); - } catch (NoSuchMethodException nsme) { - nsme.printStackTrace(); + } catch (NoSuchMethodException nse) { + nse.printStackTrace(); System.exit(0); } objectCreator = new LoremIpsumObjectCreator(classBindings); From db6869add5bb2d76f0fa0eaa58ff0318fbf1187b Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Thu, 5 Oct 2023 15:40:53 +0100 Subject: [PATCH 15/31] update readme --- readme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme b/readme index 0c2b33833..8a7e3c2dd 100644 --- a/readme +++ b/readme @@ -1,2 +1,2 @@ # Parent UniProt -contain core modules for uniprot: common, domain, parsers, flatfile, xml, util +Contains core modules for uniprot: common, domain, parsers, flatfile, xml, util From 4d8285e8ef8e4a2f289510fbeae89834e4f38e37 Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Thu, 5 Oct 2023 17:18:20 +0100 Subject: [PATCH 16/31] change the name of downstream project --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 68f25b236..6f65c3163 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -91,7 +91,7 @@ core:deploy: store:downstream: stage: bridge - trigger: uniprot/deployment/mirror-uniprot-store + trigger: uniprot/deployment/uniprot-store when: on_success only: - main \ No newline at end of file From 325619273fc692ff57c98b2063322bd3106af410 Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Thu, 5 Oct 2023 17:22:13 +0100 Subject: [PATCH 17/31] Revert "change the name of downstream project" This reverts commit 4d8285e8ef8e4a2f289510fbeae89834e4f38e37. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f65c3163..68f25b236 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -91,7 +91,7 @@ core:deploy: store:downstream: stage: bridge - trigger: uniprot/deployment/uniprot-store + trigger: uniprot/deployment/mirror-uniprot-store when: on_success only: - main \ No newline at end of file From 1af99f4128645dea72112496c08a07a2da47acaa Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Thu, 5 Oct 2023 17:31:12 +0100 Subject: [PATCH 18/31] change the name of downstream project --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 68f25b236..6f65c3163 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -91,7 +91,7 @@ core:deploy: store:downstream: stage: bridge - trigger: uniprot/deployment/mirror-uniprot-store + trigger: uniprot/deployment/uniprot-store when: on_success only: - main \ No newline at end of file From e3d4e877b8cf883513ea8da7def2048c4db90529 Mon Sep 17 00:00:00 2001 From: Shadab Ahmad Date: Thu, 5 Oct 2023 17:58:05 +0100 Subject: [PATCH 19/31] dummy change in gitlab ci for final test --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f65c3163..8ab770c4d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ core:settings: - 'wget --no-cache --no-cookies -O ${MAVEN_SETTINGS} "${URL_MAVEN_SETTINGS}"' script: - if [ ! -f ${MAVEN_SETTINGS} ]; - then echo "CI settings missing"; + then echo "CI settings file missing"; fi artifacts: when: always From a75d058ccc03908d14dd5d40c1b9483ca869892d Mon Sep 17 00:00:00 2001 From: LeonardoGonzales Date: Tue, 10 Oct 2023 14:03:53 +0100 Subject: [PATCH 20/31] Implement extra _full fields solution for xref with more than one property and Improve tests --- .../core/cv/xdb/UniProtDatabaseDetail.java | 2 +- .../tsv/uniprot/EntryCrossReferenceMap.java | 69 ++++-- .../uniprot/EntryCrossReferenceMapTest.java | 99 +++++++-- .../UniProtKBEntryValueMapperTest.java | 207 ++++++++++++------ 4 files changed, 278 insertions(+), 99 deletions(-) diff --git a/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java b/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java index dfc77def5..6c2d76679 100644 --- a/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java +++ b/core-domain/src/main/java/org/uniprot/core/cv/xdb/UniProtDatabaseDetail.java @@ -9,7 +9,7 @@ public class UniProtDatabaseDetail implements Serializable { private static final long serialVersionUID = 8751881513996820892L; - private static final UniProtDatabaseAttribute DEFAULT_ATTRIBUTE = + public static final UniProtDatabaseAttribute DEFAULT_ATTRIBUTE = new UniProtDatabaseAttribute("Description", "description", null); private String name; private String displayName; diff --git a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java index 8ed53c688..f392151bd 100644 --- a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java +++ b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java @@ -4,19 +4,18 @@ import java.util.stream.Collectors; import org.uniprot.core.Property; +import org.uniprot.core.cv.xdb.UniProtDatabaseDetail; import org.uniprot.core.parser.tsv.NamedValueMap; import org.uniprot.core.uniprotkb.xdb.UniProtKBCrossReference; -import org.uniprot.core.util.Utils; + +import static org.uniprot.core.util.Utils.*; public class EntryCrossReferenceMap implements NamedValueMap { private static final String CROSS_REF = "xref_"; + private static final String FULL_SUFFIX = "_full"; private final List dbReferences; private static final Map D3MethodMAP = new HashMap<>(); - private static final List MULTIPLE_IDS_XREF = List.of("EMBL", "Ensembl", "EnsemblBacteria", "EnsemblFungi", "EnsemblMetazoa", "EnsemblPlants", "EnsemblProtists", "MANE-Select", "RefSeq", "WormBase", "WBParaSite"); - - private static final List NOT_ID_ATTRIBUTES = List.of("GeneName", "Status", "MoleculeType"); - static { D3MethodMAP.put("X-ray", "X-ray crystallography"); D3MethodMAP.put("NMR", "NMR spectroscopy"); @@ -37,7 +36,7 @@ public static boolean contains(List fields) { } public EntryCrossReferenceMap(List dbReferences) { - this.dbReferences = Utils.unmodifiableList(dbReferences); + this.dbReferences = unmodifiableList(dbReferences); } @Override @@ -72,12 +71,41 @@ private void addToMap( xrefs.stream() .map(EntryCrossReferenceMap::dbXrefToString) .collect(Collectors.joining(";", "", ";"))); + + if (isMultiValueXref(xrefs)) { + map.put( + CROSS_REF + type.toLowerCase() + FULL_SUFFIX, + xrefs.stream() + .map(EntryCrossReferenceMap::dbXrefFullToString) + .collect(Collectors.joining(";", "", ";"))); + } + if (type.equalsIgnoreCase("PDB")) { map.put("structure_3d", pdbXrefTo3DString(xrefs)); } } } + private static boolean isMultiValueXref(List xrefs) { + boolean result = false; + UniProtKBCrossReference xref = xrefs.get(0); + if (notNullNotEmpty(xref.getProperties())) { + if (xref.getProperties().size() > 1) { + result = true; + } else { // else only one property + Property firstProperty = xref.getProperties().get(0); + if (notDefaultProperty(firstProperty)) { + result = true; + } + } + } + return result; + } + + private static boolean notDefaultProperty(Property property) { + return !property.getKey().equalsIgnoreCase(UniProtDatabaseDetail.DEFAULT_ATTRIBUTE.getName()); + } + private String pdbXrefTo3DString(List xrefs) { Map result = xrefs.stream() @@ -98,31 +126,36 @@ private String pdbXrefTo3DString(List xrefs) { public static String dbXrefToString(UniProtKBCrossReference xref) { StringBuilder sb = new StringBuilder(); sb.append(xref.getId()); - boolean addQuote = false; - if (MULTIPLE_IDS_XREF.contains(xref.getDatabase().getName())) { + + if (xref.getIsoformId() != null && !xref.getIsoformId().isEmpty()) { + sb.append(" [").append(xref.getIsoformId()).append("]"); + } + + return sb.toString(); + } + + public static String dbXrefFullToString(UniProtKBCrossReference xref) { + StringBuilder sb = new StringBuilder(); + + sb.append("\"").append(xref.getId()); + if (xref.hasProperties()) { String values = dbXrefPropertiesToString(xref); - if(!values.isEmpty()){ + if (!values.isEmpty()) { sb.append("; ").append(values).append("."); - addQuote = true; } } if (xref.getIsoformId() != null && !xref.getIsoformId().isEmpty()) { sb.append(" [").append(xref.getIsoformId()).append("]"); } - - if (addQuote) { - sb.insert(0, "\""); - sb.append("\""); - } + sb.append("\""); return sb.toString(); } private static String dbXrefPropertiesToString(UniProtKBCrossReference xref) { - return xref.getProperties().stream() - .filter(p -> !NOT_ID_ATTRIBUTES.contains(p.getKey())) + List properties = xref.getProperties(); + return properties.stream() .map(Property::getValue) .map(String::strip) - .filter(value -> !value.equals("-")) .collect(Collectors.joining("; ")); } diff --git a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java index d4db62607..af6f92d2b 100644 --- a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java +++ b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java @@ -23,7 +23,7 @@ void testGetDataEmpty() { } @Test - void hasEmbl() { + void hasMultipleEmblAndFullMaps() { List xrefs = new ArrayList<>(); xrefs.add( createXref( @@ -43,12 +43,16 @@ void hasEmbl() { null)); EntryCrossReferenceMap dl = new EntryCrossReferenceMap(xrefs); Map result = dl.attributeValues(); - assertEquals(1, result.size()); - verify("\"AY189288; AAO86732.1.\";\"AK022746; BAB14220.1.\";", "xref_embl", result); + assertEquals(2, result.size()); + verify("AY189288;AK022746;", "xref_embl", result); + verify( + "\"AY189288; AAO86732.1; -; mRNA.\";\"AK022746; BAB14220.1; -; mRNA.\";", + "xref_embl_full", + result); } @Test - void hasEmblAndEnsembl() { + void hasMultipleEmblAndEnsemblWithFullMap() { List xrefs = new ArrayList<>(); xrefs.add( createXref( @@ -86,13 +90,21 @@ void hasEmblAndEnsembl() { null)); EntryCrossReferenceMap dl = new EntryCrossReferenceMap(xrefs); Map result = dl.attributeValues(); - assertEquals(2, result.size()); - verify("\"AY189288; AAO86732.1.\";\"AK022746; BAB14220.1.\";", "xref_embl", result); - verify("\"ENST00000330899; ENSP00000369127; ENSG00000086061. [P31689-1]\";\"ENST00000439351; ENSP00000414398; ENSG00000090520.\";", "xref_ensembl", result); + assertEquals(4, result.size()); + verify("AY189288;AK022746;", "xref_embl", result); + verify( + "\"AY189288; AAO86732.1; -; mRNA.\";\"AK022746; BAB14220.1; -; mRNA.\";", + "xref_embl_full", + result); + verify("ENST00000330899 [P31689-1];ENST00000439351;", "xref_ensembl", result); + verify( + "\"ENST00000330899; ENSP00000369127; ENSG00000086061. [P31689-1]\";\"ENST00000439351; ENSP00000414398; ENSG00000090520.\";", + "xref_ensembl_full", + result); } @Test - void hasPdbAndSmr() { + void hasPdbAndSmrAlsoHasFullMapped() { List xrefs = new ArrayList<>(); xrefs.add(createXref(new UniProtKBDatabaseImpl("PDB"), "2LO1", "NMR", "-", "A=1-70", null)); xrefs.add(createXref(new UniProtKBDatabaseImpl("PDB"), "2M6Y", "NMR", "-", "A=1-67", null)); @@ -108,15 +120,19 @@ void hasPdbAndSmr() { xrefs.add(createXref(new UniProtKBDatabaseImpl("SMR"), "P31689", "-", null, null, null)); EntryCrossReferenceMap dl = new EntryCrossReferenceMap(xrefs); Map result = dl.attributeValues(); - assertEquals(3, result.size()); + assertEquals(4, result.size()); verify("2LO1;2M6Y;5TKG;", "xref_pdb", result); + verify( + "\"2LO1; NMR; -; A=1-70.\";\"2M6Y; NMR; -; A=1-67.\";\"5TKG; X-ray; 1.20 A; A/B=16-23.\";", + "xref_pdb_full", + result); verify("P31689;", "xref_smr", result); String pdb3d = "NMR spectroscopy (2); X-ray crystallography (1)"; verify(pdb3d, "structure_3d", result); } @Test - void hasIntactAndString() { + void hasIntactAndStringMixedFullAndSingleIds() { List xrefs = new ArrayList<>(); xrefs.add( createXref(new UniProtKBDatabaseImpl("IntAct"), "P31689", "97", null, null, null)); @@ -131,13 +147,14 @@ void hasIntactAndString() { null)); EntryCrossReferenceMap dl = new EntryCrossReferenceMap(xrefs); Map result = dl.attributeValues(); - assertEquals(2, result.size()); + assertEquals(3, result.size()); verify("P31689;", "xref_intact", result); + verify("\"P31689; 97.\";", "xref_intact_full", result); verify("9606.ENSP00000369127;", "xref_string", result); } @Test - void hasChemblAndSwissLipids() { + void hasChemblAndSwissLipidsOnlySingleIds() { List xrefs = new ArrayList<>(); xrefs.add( createXref( @@ -174,7 +191,63 @@ void testBbXrefToString() { "mRNA", null); String result = EntryCrossReferenceMap.dbXrefToString(dbxref); - assertEquals("\"AY189288; AAO86732.1.\"", result); + assertEquals("AY189288", result); + } + + @Test + void testBbXrefToStringWithIsoforms() { + UniProtKBCrossReference dbxref = + createXref( + new UniProtKBDatabaseImpl("EMBL"), + "AY189288", + "AAO86732.1", + "-", + "mRNA", + "P12345-2"); + String result = EntryCrossReferenceMap.dbXrefToString(dbxref); + assertEquals("AY189288 [P12345-2]", result); + } + + @Test + void testDbXrefFullToStringAllIds() { + UniProtKBCrossReference dbxref = + createXref( + new UniProtKBDatabaseImpl("EMBL"), + "AY189288", + "AAO86732.1", + "AAO86732.2", + "mRNA", + null); + String result = EntryCrossReferenceMap.dbXrefFullToString(dbxref); + assertEquals("\"AY189288; AAO86732.1; AAO86732.2; mRNA.\"", result); + } + + @Test + void testDbXrefFullToStringMissingIdsWithDash() { + UniProtKBCrossReference dbxref = + createXref( + new UniProtKBDatabaseImpl("EMBL"), + "AY189288", + "AAO86732.1", + "-", + "mRNA", + null); + String result = EntryCrossReferenceMap.dbXrefFullToString(dbxref); + assertEquals("\"AY189288; AAO86732.1; -; mRNA.\"", result); + } + + @Test + void testDbXrefFullToStringWithIsoforms() { + UniProtKBCrossReference dbxref = + createXref( + new UniProtKBDatabaseImpl("EMBL"), + "AY189288", + "-", + "AAO86732.2", + "mRNA", + "P12345-2"); + String result = EntryCrossReferenceMap.dbXrefFullToString(dbxref); + assertEquals("\"AY189288; -; AAO86732.2; mRNA. [P12345-2]\"", result); } @Test diff --git a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java index c82fbd192..5c611a9eb 100644 --- a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java +++ b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java @@ -1,13 +1,13 @@ package org.uniprot.core.parser.tsv.uniprot; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.nio.charset.Charset; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -76,7 +76,7 @@ private static String inputStreamToString(InputStream is) { @Test void testInactiveEntries() { - List fields = Arrays.asList("accession", "id", "protein_name"); + List fields = List.of("accession", "id", "protein_name"); EntryInactiveReason inactiveReason = new EntryInactiveReasonBuilder().type(InactiveReasonType.DELETED).build(); UniProtKBEntry inactiveEntry = @@ -91,7 +91,7 @@ void testInactiveEntries() { @Test void testIdAccession() { - List fields = Arrays.asList("accession", "id"); + List fields = List.of("accession", "id"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); @@ -100,7 +100,7 @@ void testIdAccession() { @Test void testInfo() { - List fields = Arrays.asList("reviewed", "version", "protein_existence"); + List fields = List.of("reviewed", "version", "protein_existence"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("reviewed", "reviewed", result); @@ -110,7 +110,7 @@ void testInfo() { @Test void testSequence() { - List fields = Arrays.asList("length", "mass", "sequence_version", "sequence"); + List fields = List.of("length", "mass", "sequence_version", "sequence"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("541", "length", result); @@ -133,7 +133,7 @@ void testSequence() { @Test void testDefault() { List fields = - Arrays.asList("accession", "id", "protein_name", "gene_names", "organism_name"); + List.of("accession", "id", "protein_name", "gene_names", "organism_name"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); @@ -147,7 +147,7 @@ void testDefault() { @Test void testECnumber() { - List fields = Arrays.asList("accession", "protein_name", "ec"); + List fields = List.of("accession", "protein_name", "ec"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryP03431, fields); String proteinName = @@ -160,7 +160,7 @@ void testECnumber() { @Test void testGene() { List fields = - Arrays.asList("gene_names", "gene_primary", "gene_synonym", "gene_oln", "gene_orf"); + List.of("gene_names", "gene_primary", "gene_synonym", "gene_oln", "gene_orf"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("SLC1A5 ASCT2 M7V1 RDR RDRC", "gene_names", result); @@ -172,7 +172,7 @@ void testGene() { @Test void testOrganism() { - List fields = Arrays.asList("organism_name", "organism_id"); + List fields = List.of("organism_name", "organism_id"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Homo sapiens (Human)", "organism_name", result); @@ -181,7 +181,7 @@ void testOrganism() { @Test void testVirusHosts() { - List fields = Arrays.asList("accession", "organism_name", "virus_hosts", "lineage"); + List fields = List.of("accession", "organism_name", "virus_hosts", "lineage"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryP03431, fields); verify("P03431", "accession", result); @@ -195,7 +195,7 @@ void testVirusHosts() { @Test void testAlterProduct() { - List fields = Arrays.asList("accession", "cc_alternative_products"); + List fields = List.of("accession", "cc_alternative_products"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); @@ -213,7 +213,7 @@ void testAlterProduct() { @Test void testComments() { List fields = - Arrays.asList( + List.of( "accession", "cc_function", "cc_domain", "cc_subunit", "cc_interaction"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); @@ -253,7 +253,7 @@ void testComments() { @Test void testComments2() { List fields = - Arrays.asList( + List.of( "accession", "cc_interaction", "cc_subcellular_location", @@ -281,7 +281,7 @@ void testComments2() { @Test void testProteinFamily() { - List fields = Arrays.asList("accession", "protein_families", "cc_similarity"); + List fields = List.of("accession", "protein_families", "cc_similarity"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryP03431, fields); verify("P03431", "accession", result); @@ -296,7 +296,7 @@ void testProteinFamily() { @Test void testSequenceCaution() { List fields = - Arrays.asList("accession", "cc_sequence_caution", "error_gmodel_pred"); + List.of("accession", "cc_sequence_caution", "error_gmodel_pred"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ84MC7, fields); verify("Q84MC7", "accession", result); @@ -310,7 +310,7 @@ void testSequenceCaution() { @Test void testBPCP() { List fields = - Arrays.asList( + List.of( "accession", "absorption", "kinetics", @@ -361,7 +361,7 @@ void testBPCP() { @Test void testFeatures() { List fields = - Arrays.asList( + List.of( "accession", "ft_chain", "ft_topo_dom", @@ -455,7 +455,7 @@ void testFeatures() { @Test void testNumberOfFeatures() { - List fields = Arrays.asList("accession", "feature"); + List fields = List.of("accession", "feature"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); @@ -469,7 +469,7 @@ void testNumberOfFeatures() { @Test void testReferences() { - List fields = Arrays.asList("accession", "lit_pubmed_id"); + List fields = List.of("accession", "lit_pubmed_id"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); @@ -482,7 +482,7 @@ void testReferences() { @Test void testGOTerm() { - List fields = Arrays.asList("accession", "go", "go_c", "go_f", "go_p", "go_id"); + List fields = List.of("accession", "go", "go_c", "go_f", "go_p", "go_id"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); @@ -549,26 +549,15 @@ void testGOTerm() { @Test void testXRefs1() { List fields = - Arrays.asList("accession", "xref_embl", "xref_ccds", "xref_refseq", "xref_smr"); + List.of("accession", "xref_embl", "xref_ccds", "xref_refseq", "xref_smr"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); - String embl = "\"U53347; AAC50629.1.\";" + - "\"AF102826; AAD09812.1.\";" + - "\"AF105423; AAD27806.1.\";" + - "\"GQ919058; ACX53626.1.\";" + - "\"AK292690; BAF85379.1.\";" + - "\"AK299137; BAG61189.1.\";" + - "\"AK301661; BAG63136.1.\";" + - "\"AK316546; BAH14917.1.\";" + - "AC008622;" + - "\"CH471126; EAW57446.1.\";" + - "\"BC000062; AAH00062.1.\";" + - "\"AF334818; AAK77026.1.\";"; + String embl = "U53347;AF102826;AF105423;GQ919058;" + + "AK292690;AK299137;AK301661;AK316546;" + + "AC008622;CH471126;BC000062;AF334818;"; String ccds = "CCDS12692.1 [Q15758-1];CCDS46125.1 [Q15758-2];CCDS46126.1 [Q15758-3];"; - String refseq = "\"NP_001138616.1; NM_001145144.1. [Q15758-3]\";" + - "\"NP_001138617.1; NM_001145145.1. [Q15758-2]\";" + - "\"NP_005619.1; NM_005628.2. [Q15758-1]\";"; + String refseq = "NP_001138616.1 [Q15758-3];NP_001138617.1 [Q15758-2];NP_005619.1 [Q15758-1];"; String smr = "Q15758;"; verify(embl, "xref_embl", result); verify(ccds, "xref_ccds", result); @@ -576,10 +565,43 @@ void testXRefs1() { verify(smr, "xref_smr", result); } + @Test + void testXRefs1Full() { + List fields = + List.of("accession", "xref_embl_full", "xref_ccds_full", "xref_refseq_full", "xref_smr_full"); + Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); + + verify("Q15758", "accession", result); + + String emblFull = + "\"U53347; AAC50629.1; -; mRNA.\";" + + "\"AF102826; AAD09812.1; -; mRNA.\";" + + "\"AF105423; AAD27806.1; -; mRNA.\";" + + "\"GQ919058; ACX53626.1; -; mRNA.\";" + + "\"AK292690; BAF85379.1; -; mRNA.\";" + + "\"AK299137; BAG61189.1; -; mRNA.\";" + + "\"AK301661; BAG63136.1; -; mRNA.\";" + + "\"AK316546; BAH14917.1; -; mRNA.\";" + + "\"AC008622; -; NOT_ANNOTATED_CDS; Genomic_DNA.\";" + + "\"CH471126; EAW57446.1; -; Genomic_DNA.\";" + + "\"BC000062; AAH00062.1; -; mRNA.\";" + + "\"AF334818; AAK77026.1; -; mRNA.\";"; + verify(emblFull, "xref_embl_full", result); + assertNull(result.get("xref_ccds_full")); + + String refseqFull = + "\"NP_001138616.1; NM_001145144.1. [Q15758-3]\";" + + "\"NP_001138617.1; NM_001145145.1. [Q15758-2]\";" + + "\"NP_005619.1; NM_005628.2. [Q15758-1]\";"; + verify(refseqFull, "xref_refseq_full", result); + + assertNull(result.get("xref_smr_full")); + } + @Test void testXRefs2() { List fields = - Arrays.asList( + List.of( "accession", "xref_smr", "xref_biogrid", @@ -601,10 +623,33 @@ void testXRefs2() { verify(string, "xref_string", result); } + @Test + void testXRefs2FullXrefs() { + List fields = + List.of( + "accession", + "xref_smr_full", + "xref_biogrid_full", + "xref_intact_full", + "xref_mint_full", + "xref_string_full"); + Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); + + verify("Q15758", "accession", result); + + String biogrid = "\"112401; 92.\";"; + String intact = "\"Q15758; 73.\";"; + assertNull(result.get("xref_smr_full")); + verify(biogrid, "xref_biogrid_full", result); + verify(intact, "xref_intact_full", result); + assertNull(result.get("xref_mint_full")); + assertNull(result.get("xref_string_full")); + } + @Test void testXRefs3() { List fields = - Arrays.asList( + List.of( "accession", "xref_drugbank", "xref_guidetopharmacology", @@ -627,34 +672,33 @@ void testXRefs3() { } @Test - void testXRefs4() { + void testXRefs3Full() { List fields = - Arrays.asList( + List.of( "accession", - "xref_drugbank", - "xref_guidetopharmacology", - "xref_tcdb", - "xref_dmdm", - "xref_maxqb"); + "xref_drugbank_full", + "xref_guidetopharmacology_full", + "xref_tcdb_full", + "xref_dmdm_full", + "xref_maxqb_full"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); - String drugbank = "DB00174;DB13146;DB00130;"; - String guidetopharmacology = "874;"; - String tcdb = "2.A.23.3.3;"; - String dmdm = "21542389;"; + String drugbank = "\"DB00174; Asparagine.\";\"DB13146; Fluciclovine (18F).\";\"DB00130; L-Glutamine.\";"; + String tcdb = "\"2.A.23.3.3; the dicarboxylate/amino acid:cation (na(+) or h(+)) symporter (daacs) family.\";"; + String maxqb = "Q15758;"; - verify(drugbank, "xref_drugbank", result); - verify(guidetopharmacology, "xref_guidetopharmacology", result); - verify(tcdb, "xref_tcdb", result); - verify(dmdm, "xref_dmdm", result); - verify(maxqb, "xref_maxqb", result); + verify(drugbank, "xref_drugbank_full", result); + assertNull(result.get("xref_guidetopharmacology_full")); + verify(tcdb, "xref_tcdb_full", result); + assertNull(result.get("xref_dmdm_full")); + assertNull(result.get("xref_maxqb_full")); } @Test - void testXRefs5() { + void testXRefs4() { List fields = - Arrays.asList( + List.of( "accession", "xref_ensembl", "xref_reactome", @@ -664,9 +708,7 @@ void testXRefs5() { Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); - String ensembl = "\"ENST00000412532; ENSP00000397924; ENSG00000105281. [Q15758-3]\";" + - "\"ENST00000434726; ENSP00000406532; ENSG00000105281. [Q15758-2]\";" + - "\"ENST00000542575; ENSP00000444408; ENSG00000105281. [Q15758-1]\";"; + String ensembl = "ENST00000412532 [Q15758-3];ENST00000434726 [Q15758-2];ENST00000542575 [Q15758-1];"; String reactome = "R-HSA-352230;"; String interpro = "IPR001991;IPR018107;IPR036458;"; String prosite = "PS00713;PS00714;"; @@ -678,9 +720,38 @@ void testXRefs5() { verify(pfam, "xref_pfam", result); } + @Test + void testXRefs4Full() { + List fields = + List.of( + "accession", + "xref_ensembl_full", + "xref_reactome_full", + "xref_interpro_full", + "xref_prosite_full", + "xref_pfam_full"); + Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); + + verify("Q15758", "accession", result); + + String ensemblFull = + "\"ENST00000412532; ENSP00000397924; ENSG00000105281. [Q15758-3]\";" + + "\"ENST00000434726; ENSP00000406532; ENSG00000105281. [Q15758-2]\";" + + "\"ENST00000542575; ENSP00000444408; ENSG00000105281. [Q15758-1]\";"; + String reactomeFull = "\"R-HSA-352230; Amino acid transport across the plasma membrane.\";"; + String interproFull = "\"IPR001991; Na-dicarboxylate_symporter.\";\"IPR018107; Na-dicarboxylate_symporter_CS.\";\"IPR036458; Na:dicarbo_symporter_sf.\";"; + String prositeFull = "\"PS00713; NA_DICARBOXYL_SYMP_1; 1.\";\"PS00714; NA_DICARBOXYL_SYMP_2; 1.\";"; + String pfamFull = "\"PF00375; SDF; 1.\";"; + verify(ensemblFull, "xref_ensembl_full", result); + verify(reactomeFull, "xref_reactome_full", result); + verify(interproFull, "xref_interpro_full", result); + verify(prositeFull, "xref_prosite_full", result); + verify(pfamFull, "xref_pfam_full", result); + } + @Test void testProteome() { - List fields = Arrays.asList("accession", "xref_proteomes"); + List fields = List.of("accession", "xref_proteomes"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryP03431, fields); verify("P03431", "accession", result); @@ -690,19 +761,21 @@ void testProteome() { @Test void testPdb() { - List fields = Arrays.asList("accession", "xref_pdb", "structure_3d"); + List fields = List.of("accession", "xref_pdb", "structure_3d"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryP03431, fields); verify("P03431", "accession", result); String pdb = "2ZNL;2ZTT;3A1G;"; + String pdbFull = "\"2ZNL; X-ray; 2.30 A; B=1-81.\";\"2ZTT; X-ray; 2.10 A; A/C=679-757.\";\"3A1G; X-ray; 1.70 A; A/C=678-757.\";"; String d3d = "X-ray crystallography (3)"; verify(pdb, "xref_pdb", result); + verify(pdbFull, "xref_pdb_full", result); verify(d3d, "structure_3d", result); } @Test - void testkeyword() { - List fields = Arrays.asList("accession", "keyword", "keywordid"); + void testKeyword() { + List fields = List.of("accession", "keyword", "keywordid"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryP03431, fields); verify("P03431", "accession", result); @@ -723,7 +796,7 @@ void testkeyword() { @Test void testExtraAttributeCommentCountForQ15758() { - List fields = Arrays.asList("comment_count"); + List fields = List.of("comment_count"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); String expectedCommentCount = @@ -735,7 +808,7 @@ void testExtraAttributeCommentCountForQ15758() { @Test void testExtraAttributeCommentCountForP03431() { - List fields = Arrays.asList("comment_count"); + List fields = List.of("comment_count"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryP03431, fields); String expectedCommentCount = @@ -747,7 +820,7 @@ void testExtraAttributeCommentCountForP03431() { @Test void testExtraAttributeFeatureCount() { - List fields = Arrays.asList("feature_count"); + List fields = List.of("feature_count"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); String expectedCommentCount = @@ -758,7 +831,7 @@ void testExtraAttributeFeatureCount() { @Test void testExtraAttributeUniParcId() { - List fields = Arrays.asList("uniparc_id"); + List fields = List.of("uniparc_id"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryP03431, fields); verify("UP1234567890", "uniparc_id", result); From 4a940a62e0ebff4ef6399d76852f54022f4b801a Mon Sep 17 00:00:00 2001 From: automated changes Date: Thu, 12 Oct 2023 08:18:07 +0000 Subject: [PATCH 21/31] code format with spotless automatic --- .../tsv/uniprot/EntryCrossReferenceMap.java | 7 ++-- .../UniProtKBEntryValueMapperTest.java | 41 ++++++++++++------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java index f392151bd..05e153a42 100644 --- a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java +++ b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java @@ -1,5 +1,7 @@ package org.uniprot.core.parser.tsv.uniprot; +import static org.uniprot.core.util.Utils.*; + import java.util.*; import java.util.stream.Collectors; @@ -8,8 +10,6 @@ import org.uniprot.core.parser.tsv.NamedValueMap; import org.uniprot.core.uniprotkb.xdb.UniProtKBCrossReference; -import static org.uniprot.core.util.Utils.*; - public class EntryCrossReferenceMap implements NamedValueMap { private static final String CROSS_REF = "xref_"; private static final String FULL_SUFFIX = "_full"; @@ -103,7 +103,8 @@ private static boolean isMultiValueXref(List xrefs) { } private static boolean notDefaultProperty(Property property) { - return !property.getKey().equalsIgnoreCase(UniProtDatabaseDetail.DEFAULT_ATTRIBUTE.getName()); + return !property.getKey() + .equalsIgnoreCase(UniProtDatabaseDetail.DEFAULT_ATTRIBUTE.getName()); } private String pdbXrefTo3DString(List xrefs) { diff --git a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java index 5c611a9eb..e4dc63d5e 100644 --- a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java +++ b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/UniProtKBEntryValueMapperTest.java @@ -213,8 +213,7 @@ void testAlterProduct() { @Test void testComments() { List fields = - List.of( - "accession", "cc_function", "cc_domain", "cc_subunit", "cc_interaction"); + List.of("accession", "cc_function", "cc_domain", "cc_subunit", "cc_interaction"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); @@ -295,8 +294,7 @@ void testProteinFamily() { @Test void testSequenceCaution() { - List fields = - List.of("accession", "cc_sequence_caution", "error_gmodel_pred"); + List fields = List.of("accession", "cc_sequence_caution", "error_gmodel_pred"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ84MC7, fields); verify("Q84MC7", "accession", result); @@ -553,11 +551,13 @@ void testXRefs1() { Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); - String embl = "U53347;AF102826;AF105423;GQ919058;" + - "AK292690;AK299137;AK301661;AK316546;" + - "AC008622;CH471126;BC000062;AF334818;"; + String embl = + "U53347;AF102826;AF105423;GQ919058;" + + "AK292690;AK299137;AK301661;AK316546;" + + "AC008622;CH471126;BC000062;AF334818;"; String ccds = "CCDS12692.1 [Q15758-1];CCDS46125.1 [Q15758-2];CCDS46126.1 [Q15758-3];"; - String refseq = "NP_001138616.1 [Q15758-3];NP_001138617.1 [Q15758-2];NP_005619.1 [Q15758-1];"; + String refseq = + "NP_001138616.1 [Q15758-3];NP_001138617.1 [Q15758-2];NP_005619.1 [Q15758-1];"; String smr = "Q15758;"; verify(embl, "xref_embl", result); verify(ccds, "xref_ccds", result); @@ -568,7 +568,12 @@ void testXRefs1() { @Test void testXRefs1Full() { List fields = - List.of("accession", "xref_embl_full", "xref_ccds_full", "xref_refseq_full", "xref_smr_full"); + List.of( + "accession", + "xref_embl_full", + "xref_ccds_full", + "xref_refseq_full", + "xref_smr_full"); Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); @@ -684,8 +689,10 @@ void testXRefs3Full() { Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); - String drugbank = "\"DB00174; Asparagine.\";\"DB13146; Fluciclovine (18F).\";\"DB00130; L-Glutamine.\";"; - String tcdb = "\"2.A.23.3.3; the dicarboxylate/amino acid:cation (na(+) or h(+)) symporter (daacs) family.\";"; + String drugbank = + "\"DB00174; Asparagine.\";\"DB13146; Fluciclovine (18F).\";\"DB00130; L-Glutamine.\";"; + String tcdb = + "\"2.A.23.3.3; the dicarboxylate/amino acid:cation (na(+) or h(+)) symporter (daacs) family.\";"; String maxqb = "Q15758;"; verify(drugbank, "xref_drugbank_full", result); @@ -708,7 +715,8 @@ void testXRefs4() { Map result = new UniProtKBEntryValueMapper().mapEntity(entryQ15758, fields); verify("Q15758", "accession", result); - String ensembl = "ENST00000412532 [Q15758-3];ENST00000434726 [Q15758-2];ENST00000542575 [Q15758-1];"; + String ensembl = + "ENST00000412532 [Q15758-3];ENST00000434726 [Q15758-2];ENST00000542575 [Q15758-1];"; String reactome = "R-HSA-352230;"; String interpro = "IPR001991;IPR018107;IPR036458;"; String prosite = "PS00713;PS00714;"; @@ -739,8 +747,10 @@ void testXRefs4Full() { + "\"ENST00000434726; ENSP00000406532; ENSG00000105281. [Q15758-2]\";" + "\"ENST00000542575; ENSP00000444408; ENSG00000105281. [Q15758-1]\";"; String reactomeFull = "\"R-HSA-352230; Amino acid transport across the plasma membrane.\";"; - String interproFull = "\"IPR001991; Na-dicarboxylate_symporter.\";\"IPR018107; Na-dicarboxylate_symporter_CS.\";\"IPR036458; Na:dicarbo_symporter_sf.\";"; - String prositeFull = "\"PS00713; NA_DICARBOXYL_SYMP_1; 1.\";\"PS00714; NA_DICARBOXYL_SYMP_2; 1.\";"; + String interproFull = + "\"IPR001991; Na-dicarboxylate_symporter.\";\"IPR018107; Na-dicarboxylate_symporter_CS.\";\"IPR036458; Na:dicarbo_symporter_sf.\";"; + String prositeFull = + "\"PS00713; NA_DICARBOXYL_SYMP_1; 1.\";\"PS00714; NA_DICARBOXYL_SYMP_2; 1.\";"; String pfamFull = "\"PF00375; SDF; 1.\";"; verify(ensemblFull, "xref_ensembl_full", result); verify(reactomeFull, "xref_reactome_full", result); @@ -766,7 +776,8 @@ void testPdb() { verify("P03431", "accession", result); String pdb = "2ZNL;2ZTT;3A1G;"; - String pdbFull = "\"2ZNL; X-ray; 2.30 A; B=1-81.\";\"2ZTT; X-ray; 2.10 A; A/C=679-757.\";\"3A1G; X-ray; 1.70 A; A/C=678-757.\";"; + String pdbFull = + "\"2ZNL; X-ray; 2.30 A; B=1-81.\";\"2ZTT; X-ray; 2.10 A; A/C=679-757.\";\"3A1G; X-ray; 1.70 A; A/C=678-757.\";"; String d3d = "X-ray crystallography (3)"; verify(pdb, "xref_pdb", result); verify(pdbFull, "xref_pdb_full", result); From a9768703679073d7f312bbbc3a6221705289eaa5 Mon Sep 17 00:00:00 2001 From: LeonardoGonzales Date: Tue, 17 Oct 2023 09:55:02 +0100 Subject: [PATCH 22/31] code review --- .../tsv/uniprot/EntryCrossReferenceMap.java | 24 +++++++++---------- .../uniprot/EntryCrossReferenceMapTest.java | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java index 05e153a42..0df6bfff5 100644 --- a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java +++ b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java @@ -14,16 +14,16 @@ public class EntryCrossReferenceMap implements NamedValueMap { private static final String CROSS_REF = "xref_"; private static final String FULL_SUFFIX = "_full"; private final List dbReferences; - private static final Map D3MethodMAP = new HashMap<>(); + private static final Map d3MethodMap = new HashMap<>(); static { - D3MethodMAP.put("X-ray", "X-ray crystallography"); - D3MethodMAP.put("NMR", "NMR spectroscopy"); - D3MethodMAP.put("EM", "Electron microscopy"); - D3MethodMAP.put("Model", "Model"); - D3MethodMAP.put("Neutron", "Neutron diffraction"); - D3MethodMAP.put("Fiber", "Fiber diffraction"); - D3MethodMAP.put("IR", "Infrared spectroscopy"); + d3MethodMap.put("X-ray", "X-ray crystallography"); + d3MethodMap.put("NMR", "NMR spectroscopy"); + d3MethodMap.put("EM", "Electron microscopy"); + d3MethodMap.put("Model", "Model"); + d3MethodMap.put("Neutron", "Neutron diffraction"); + d3MethodMap.put("Fiber", "Fiber diffraction"); + d3MethodMap.put("IR", "Infrared spectroscopy"); } public static boolean contains(List fields) { @@ -58,7 +58,7 @@ private void addToMap( if (type.equalsIgnoreCase("GO")) { EntryGoCrossReferenceMap dlGoXref = new EntryGoCrossReferenceMap(xrefs); Map goMap = dlGoXref.attributeValues(); - goMap.forEach(map::put); + map.putAll(goMap); } else if (type.equalsIgnoreCase("PROTEOMES")) { map.put( CROSS_REF + type.toLowerCase(), @@ -94,9 +94,7 @@ private static boolean isMultiValueXref(List xrefs) { result = true; } else { // else only one property Property firstProperty = xref.getProperties().get(0); - if (notDefaultProperty(firstProperty)) { - result = true; - } + result = notDefaultProperty(firstProperty); } } return result; @@ -113,7 +111,7 @@ private String pdbXrefTo3DString(List xrefs) { .flatMap(val -> val.getProperties().stream()) .filter(val -> val.getKey().equalsIgnoreCase("Method")) .map(Property::getValue) - .map(D3MethodMAP::get) + .map(d3MethodMap::get) .filter(Objects::nonNull) .collect( Collectors.groupingBy( diff --git a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java index af6f92d2b..c8c86c019 100644 --- a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java +++ b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java @@ -195,7 +195,7 @@ void testBbXrefToString() { } @Test - void testBbXrefToStringWithIsoforms() { + void testDbXrefToStringWithIsoforms() { UniProtKBCrossReference dbxref = createXref( new UniProtKBDatabaseImpl("EMBL"), From 919d860e998131a4300ab03027e281ab95992f04 Mon Sep 17 00:00:00 2001 From: LeonardoGonzales Date: Tue, 17 Oct 2023 13:49:29 +0100 Subject: [PATCH 23/31] Update EntryCrossReferenceMap to restrict not necessary public methods --- .../tsv/uniprot/EntryCrossReferenceMap.java | 14 +++---- .../uniprot/EntryCrossReferenceMapTest.java | 40 +++++++++++-------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java index 0df6bfff5..9e637cd76 100644 --- a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java +++ b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMap.java @@ -63,20 +63,20 @@ private void addToMap( map.put( CROSS_REF + type.toLowerCase(), xrefs.stream() - .map(EntryCrossReferenceMap::proteomeXrefToString) + .map(this::proteomeXrefToString) .collect(Collectors.joining("; "))); } else { map.put( CROSS_REF + type.toLowerCase(), xrefs.stream() - .map(EntryCrossReferenceMap::dbXrefToString) + .map(this::dbXrefToString) .collect(Collectors.joining(";", "", ";"))); if (isMultiValueXref(xrefs)) { map.put( CROSS_REF + type.toLowerCase() + FULL_SUFFIX, xrefs.stream() - .map(EntryCrossReferenceMap::dbXrefFullToString) + .map(this::dbXrefFullToString) .collect(Collectors.joining(";", "", ";"))); } @@ -122,7 +122,7 @@ private String pdbXrefTo3DString(List xrefs) { .collect(Collectors.joining("; ")); } - public static String dbXrefToString(UniProtKBCrossReference xref) { + private String dbXrefToString(UniProtKBCrossReference xref) { StringBuilder sb = new StringBuilder(); sb.append(xref.getId()); @@ -133,7 +133,7 @@ public static String dbXrefToString(UniProtKBCrossReference xref) { return sb.toString(); } - public static String dbXrefFullToString(UniProtKBCrossReference xref) { + private String dbXrefFullToString(UniProtKBCrossReference xref) { StringBuilder sb = new StringBuilder(); sb.append("\"").append(xref.getId()); @@ -150,7 +150,7 @@ public static String dbXrefFullToString(UniProtKBCrossReference xref) { return sb.toString(); } - private static String dbXrefPropertiesToString(UniProtKBCrossReference xref) { + private String dbXrefPropertiesToString(UniProtKBCrossReference xref) { List properties = xref.getProperties(); return properties.stream() .map(Property::getValue) @@ -158,7 +158,7 @@ private static String dbXrefPropertiesToString(UniProtKBCrossReference xref) { .collect(Collectors.joining("; ")); } - public static String proteomeXrefToString(UniProtKBCrossReference xref) { + private String proteomeXrefToString(UniProtKBCrossReference xref) { StringBuilder sb = new StringBuilder(); sb.append(xref.getId()).append(": ").append(xref.getProperties().get(0).getValue()); diff --git a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java index c8c86c019..ecb5d7a53 100644 --- a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java +++ b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniprot/EntryCrossReferenceMapTest.java @@ -181,7 +181,7 @@ void hasChemblAndSwissLipidsOnlySingleIds() { } @Test - void testBbXrefToString() { + void testSingleDbXrefToString() { UniProtKBCrossReference dbxref = createXref( new UniProtKBDatabaseImpl("EMBL"), @@ -190,12 +190,13 @@ void testBbXrefToString() { "-", "mRNA", null); - String result = EntryCrossReferenceMap.dbXrefToString(dbxref); - assertEquals("AY189288", result); + EntryCrossReferenceMap dl = new EntryCrossReferenceMap(List.of(dbxref)); + Map result = dl.attributeValues(); + verify("AY189288;", "xref_embl", result); } @Test - void testDbXrefToStringWithIsoforms() { + void testSingleDbXrefToStringWithIsoforms() { UniProtKBCrossReference dbxref = createXref( new UniProtKBDatabaseImpl("EMBL"), @@ -204,12 +205,13 @@ void testDbXrefToStringWithIsoforms() { "-", "mRNA", "P12345-2"); - String result = EntryCrossReferenceMap.dbXrefToString(dbxref); - assertEquals("AY189288 [P12345-2]", result); + EntryCrossReferenceMap dl = new EntryCrossReferenceMap(List.of(dbxref)); + Map result = dl.attributeValues(); + verify("AY189288 [P12345-2];", "xref_embl", result); } @Test - void testDbXrefFullToStringAllIds() { + void testSingleDbXrefFullToStringAllIds() { UniProtKBCrossReference dbxref = createXref( new UniProtKBDatabaseImpl("EMBL"), @@ -218,12 +220,13 @@ void testDbXrefFullToStringAllIds() { "AAO86732.2", "mRNA", null); - String result = EntryCrossReferenceMap.dbXrefFullToString(dbxref); - assertEquals("\"AY189288; AAO86732.1; AAO86732.2; mRNA.\"", result); + EntryCrossReferenceMap dl = new EntryCrossReferenceMap(List.of(dbxref)); + Map result = dl.attributeValues(); + verify("\"AY189288; AAO86732.1; AAO86732.2; mRNA.\";", "xref_embl_full", result); } @Test - void testDbXrefFullToStringMissingIdsWithDash() { + void testSingleDbXrefFullToStringMissingIdsWithDash() { UniProtKBCrossReference dbxref = createXref( new UniProtKBDatabaseImpl("EMBL"), @@ -232,12 +235,13 @@ void testDbXrefFullToStringMissingIdsWithDash() { "-", "mRNA", null); - String result = EntryCrossReferenceMap.dbXrefFullToString(dbxref); - assertEquals("\"AY189288; AAO86732.1; -; mRNA.\"", result); + EntryCrossReferenceMap dl = new EntryCrossReferenceMap(List.of(dbxref)); + Map result = dl.attributeValues(); + verify("\"AY189288; AAO86732.1; -; mRNA.\";", "xref_embl_full", result); } @Test - void testDbXrefFullToStringWithIsoforms() { + void testSingleDbXrefFullToStringWithIsoforms() { UniProtKBCrossReference dbxref = createXref( new UniProtKBDatabaseImpl("EMBL"), @@ -246,8 +250,9 @@ void testDbXrefFullToStringWithIsoforms() { "AAO86732.2", "mRNA", "P12345-2"); - String result = EntryCrossReferenceMap.dbXrefFullToString(dbxref); - assertEquals("\"AY189288; -; AAO86732.2; mRNA. [P12345-2]\"", result); + EntryCrossReferenceMap dl = new EntryCrossReferenceMap(List.of(dbxref)); + Map result = dl.attributeValues(); + verify("\"AY189288; -; AAO86732.2; mRNA. [P12345-2]\";", "xref_embl_full", result); } @Test @@ -261,8 +266,9 @@ void testProteomeXrefToString() { null, null, null); - String result = EntryCrossReferenceMap.proteomeXrefToString(dbxref); - assertEquals("UP000006548: Chromosome 4", result); + EntryCrossReferenceMap dl = new EntryCrossReferenceMap(List.of(dbxref)); + Map result = dl.attributeValues(); + verify("UP000006548: Chromosome 4", "xref_proteomes", result); } private void verify(String expected, String field, Map result) { From 894a7d15bfc54d915140eaa4e3446936d352ffc0 Mon Sep 17 00:00:00 2001 From: supun Date: Wed, 13 Sep 2023 01:27:32 +0100 Subject: [PATCH 24/31] review --- .../uniprot/core/proteome/ProteomeEntry.java | 10 ++++---- .../proteome/impl/ProteomeEntryBuilder.java | 23 ++++++++++++------- .../core/proteome/impl/ProteomeEntryImpl.java | 20 +++++++++++----- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/ProteomeEntry.java b/core-domain/src/main/java/org/uniprot/core/proteome/ProteomeEntry.java index a9ba5ed01..61dce90fe 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/ProteomeEntry.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/ProteomeEntry.java @@ -1,13 +1,13 @@ package org.uniprot.core.proteome; -import java.io.Serializable; -import java.time.LocalDate; -import java.util.List; - import org.uniprot.core.citation.Citation; import org.uniprot.core.taxonomy.TaxonomyLineage; import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; +import java.io.Serializable; +import java.time.LocalDate; +import java.util.List; + public interface ProteomeEntry extends Serializable { ProteomeId getId(); @@ -50,4 +50,6 @@ public interface ProteomeEntry extends Serializable { GenomeAnnotation getGenomeAnnotation(); List getExclusionReasons(); + + ProteomeStatistics getProteomeStatistics(); } diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilder.java b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilder.java index 7d3e4b810..ddf2f2a85 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilder.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilder.java @@ -1,11 +1,5 @@ package org.uniprot.core.proteome.impl; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; - import org.uniprot.core.Builder; import org.uniprot.core.citation.Citation; import org.uniprot.core.proteome.*; @@ -13,6 +7,11 @@ import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; import org.uniprot.core.util.Utils; +import javax.annotation.Nonnull; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + public class ProteomeEntryBuilder implements Builder { private ProteomeId id; private String description; @@ -35,6 +34,7 @@ public class ProteomeEntryBuilder implements Builder { private GenomeAnnotation genomeAnnotation; private List exclusionReasons = new ArrayList<>(); private Integer proteinCount; + private ProteomeStatistics proteomeStatistics; @Override public @Nonnull ProteomeEntry build() { @@ -59,7 +59,8 @@ public class ProteomeEntryBuilder implements Builder { genomeAssembly, genomeAnnotation, exclusionReasons, - proteinCount); + proteinCount, + proteomeStatistics); } public static @Nonnull ProteomeEntryBuilder from(@Nonnull ProteomeEntry instance) { @@ -84,7 +85,8 @@ public class ProteomeEntryBuilder implements Builder { .genomeAssembly(instance.getGenomeAssembly()) .genomeAnnotation(instance.getGenomeAnnotation()) .exclusionReasonsSet(instance.getExclusionReasons()) - .proteinCount(instance.getProteinCount()); + .proteinCount(instance.getProteinCount()) + .proteomeStatistics(instance.getProteomeStatistics()); } public @Nonnull ProteomeEntryBuilder proteomeId(ProteomeId id) { @@ -225,4 +227,9 @@ public class ProteomeEntryBuilder implements Builder { Utils.addOrIgnoreNull(exclusionReason, exclusionReasons); return this; } + + public @Nonnull ProteomeEntryBuilder proteomeStatistics(ProteomeStatistics proteomeStatistics) { + this.proteomeStatistics = proteomeStatistics; + return this; + } } diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java index cace8a707..a227886df 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java @@ -1,15 +1,15 @@ package org.uniprot.core.proteome.impl; -import java.time.LocalDate; -import java.util.List; -import java.util.Objects; - import org.uniprot.core.citation.Citation; import org.uniprot.core.proteome.*; import org.uniprot.core.taxonomy.TaxonomyLineage; import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; import org.uniprot.core.util.Utils; +import java.time.LocalDate; +import java.util.List; +import java.util.Objects; + public class ProteomeEntryImpl implements ProteomeEntry { private static final long serialVersionUID = 1962327704149624243L; @@ -34,12 +34,13 @@ public class ProteomeEntryImpl implements ProteomeEntry { private final GenomeAnnotation genomeAnnotation; private final List taxonLineage; private final List exclusionReasons; + private final ProteomeStatistics proteomeStatistics; // no arg constructor for JSON deserialization ProteomeEntryImpl() { this( null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null); + null, null, null, null, null, null, null, null); } ProteomeEntryImpl( @@ -63,7 +64,8 @@ public class ProteomeEntryImpl implements ProteomeEntry { GenomeAssembly genomeAssembly, GenomeAnnotation genomeAnnotation, List exclusionReasons, - Integer proteinCount) { + Integer proteinCount, + ProteomeStatistics proteomeStatistics) { super(); this.id = id; this.taxonomy = taxonomy; @@ -88,6 +90,7 @@ public class ProteomeEntryImpl implements ProteomeEntry { this.genomeAnnotation = genomeAnnotation; this.exclusionReasons = Utils.unmodifiableList(exclusionReasons); this.proteinCount = proteinCount; + this.proteomeStatistics = proteomeStatistics; } @Override @@ -195,6 +198,11 @@ public List getExclusionReasons() { return exclusionReasons; } + @Override + public ProteomeStatistics getProteomeStatistics() { + return proteomeStatistics; + } + @Override public int hashCode() { return Objects.hash( From 0c0b96c7fadee927efabde56c744d32419687a99 Mon Sep 17 00:00:00 2001 From: supun Date: Wed, 13 Sep 2023 10:41:50 +0100 Subject: [PATCH 25/31] add tests --- .../core/proteome/impl/ProteomeEntryImpl.java | 6 ++-- .../impl/ProteomeEntryBuilderTest.java | 32 ++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java index a227886df..46a6526d4 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java @@ -222,7 +222,8 @@ public int hashCode() { proteomeCompletenessReport, genomeAssembly, proteinCount, - genomeAnnotation); + genomeAnnotation, + proteomeStatistics); } @Override @@ -248,6 +249,7 @@ public boolean equals(Object obj) { && Objects.equals(genomeAssembly, other.genomeAssembly) && Objects.equals(geneCount, other.geneCount) && Objects.equals(proteinCount, other.proteinCount) - && Objects.equals(genomeAnnotation, other.genomeAnnotation); + && Objects.equals(genomeAnnotation, other.genomeAnnotation) + && Objects.equals(proteomeStatistics, other.proteomeStatistics); } } diff --git a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilderTest.java b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilderTest.java index 2aa0f9f43..41df66529 100644 --- a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilderTest.java +++ b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilderTest.java @@ -1,17 +1,10 @@ package org.uniprot.core.proteome.impl; -import static org.hamcrest.CoreMatchers.hasItem; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.*; -import static org.uniprot.core.ObjectsForTests.updateCitationBuilderWithCommonAttributes; - -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.citation.*; +import org.uniprot.core.citation.Citation; +import org.uniprot.core.citation.JournalArticle; +import org.uniprot.core.citation.Submission; +import org.uniprot.core.citation.SubmissionDatabase; import org.uniprot.core.citation.impl.JournalArticleBuilder; import org.uniprot.core.citation.impl.SubmissionBuilder; import org.uniprot.core.proteome.*; @@ -20,6 +13,16 @@ import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; import org.uniprot.core.uniprotkb.taxonomy.impl.TaxonomyBuilder; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.*; +import static org.uniprot.core.ObjectsForTests.updateCitationBuilderWithCommonAttributes; + class ProteomeEntryBuilderTest { @Test @@ -350,4 +353,11 @@ void ExclusionReasons() { assertThat(proteome.getExclusionReasons(), hasItem(ExclusionReason.METAGENOME)); assertThat(proteome.getExclusionReasons(), hasItem(ExclusionReason.MIXED_CULTURE)); } + + @Test + void testProteomeStatistics() { + ProteomeStatistics proteomeStatistics = new ProteomeStatisticsBuilder().build(); + ProteomeEntry proteome = new ProteomeEntryBuilder().proteomeStatistics(proteomeStatistics).build(); + assertSame(proteomeStatistics, proteome.getProteomeStatistics()); + } } From a7e4dc0089061d395e1ba669db0b56eb19d5bc1b Mon Sep 17 00:00:00 2001 From: automated changes Date: Wed, 13 Sep 2023 09:46:32 +0000 Subject: [PATCH 26/31] code format with spotless automatic --- .../uniprot/core/proteome/ProteomeEntry.java | 8 +++---- .../proteome/impl/ProteomeEntryBuilder.java | 11 +++++---- .../core/proteome/impl/ProteomeEntryImpl.java | 8 +++---- .../impl/ProteomeEntryBuilderTest.java | 23 ++++++++++--------- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/ProteomeEntry.java b/core-domain/src/main/java/org/uniprot/core/proteome/ProteomeEntry.java index 61dce90fe..e90eda78b 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/ProteomeEntry.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/ProteomeEntry.java @@ -1,13 +1,13 @@ package org.uniprot.core.proteome; -import org.uniprot.core.citation.Citation; -import org.uniprot.core.taxonomy.TaxonomyLineage; -import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; - import java.io.Serializable; import java.time.LocalDate; import java.util.List; +import org.uniprot.core.citation.Citation; +import org.uniprot.core.taxonomy.TaxonomyLineage; +import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; + public interface ProteomeEntry extends Serializable { ProteomeId getId(); diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilder.java b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilder.java index ddf2f2a85..ade66886b 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilder.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilder.java @@ -1,5 +1,11 @@ package org.uniprot.core.proteome.impl; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Nonnull; + import org.uniprot.core.Builder; import org.uniprot.core.citation.Citation; import org.uniprot.core.proteome.*; @@ -7,11 +13,6 @@ import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; import org.uniprot.core.util.Utils; -import javax.annotation.Nonnull; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; - public class ProteomeEntryBuilder implements Builder { private ProteomeId id; private String description; diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java index 46a6526d4..ef6a37e67 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeEntryImpl.java @@ -1,15 +1,15 @@ package org.uniprot.core.proteome.impl; +import java.time.LocalDate; +import java.util.List; +import java.util.Objects; + import org.uniprot.core.citation.Citation; import org.uniprot.core.proteome.*; import org.uniprot.core.taxonomy.TaxonomyLineage; import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; import org.uniprot.core.util.Utils; -import java.time.LocalDate; -import java.util.List; -import java.util.Objects; - public class ProteomeEntryImpl implements ProteomeEntry { private static final long serialVersionUID = 1962327704149624243L; diff --git a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilderTest.java b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilderTest.java index 41df66529..117f7bfc9 100644 --- a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilderTest.java +++ b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeEntryBuilderTest.java @@ -1,5 +1,15 @@ package org.uniprot.core.proteome.impl; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.*; +import static org.uniprot.core.ObjectsForTests.updateCitationBuilderWithCommonAttributes; + +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.citation.Citation; import org.uniprot.core.citation.JournalArticle; @@ -13,16 +23,6 @@ import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; import org.uniprot.core.uniprotkb.taxonomy.impl.TaxonomyBuilder; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.hamcrest.CoreMatchers.hasItem; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.*; -import static org.uniprot.core.ObjectsForTests.updateCitationBuilderWithCommonAttributes; - class ProteomeEntryBuilderTest { @Test @@ -357,7 +357,8 @@ void ExclusionReasons() { @Test void testProteomeStatistics() { ProteomeStatistics proteomeStatistics = new ProteomeStatisticsBuilder().build(); - ProteomeEntry proteome = new ProteomeEntryBuilder().proteomeStatistics(proteomeStatistics).build(); + ProteomeEntry proteome = + new ProteomeEntryBuilder().proteomeStatistics(proteomeStatistics).build(); assertSame(proteomeStatistics, proteome.getProteomeStatistics()); } } From f99e4f116d0df52ae4b1e64e888763c2f5ac6b95 Mon Sep 17 00:00:00 2001 From: supun Date: Wed, 4 Oct 2023 16:03:10 +0100 Subject: [PATCH 27/31] add defualt constructor to proteome stats --- .../proteome/impl/ProteomeStatisticsImpl.java | 9 ++++- .../impl/ProteomeStatisticsImplTest.java | 12 +++++- .../parser/proteome/ProteomeJsonConfig.java | 39 ++++--------------- 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java index 3f425e4b1..7af954e5d 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java @@ -1,11 +1,12 @@ package org.uniprot.core.proteome.impl; -import java.util.Objects; - import org.uniprot.core.impl.StatisticsImpl; import org.uniprot.core.proteome.ProteomeStatistics; +import java.util.Objects; + public class ProteomeStatisticsImpl extends StatisticsImpl implements ProteomeStatistics { + private static final long serialVersionUID = -8585233468042758658L; private final long isoformProteinCount; ProteomeStatisticsImpl( @@ -14,6 +15,10 @@ public class ProteomeStatisticsImpl extends StatisticsImpl implements ProteomeSt this.isoformProteinCount = isoformProteinCount; } + ProteomeStatisticsImpl() { + this(0, 0,0); + } + @Override public long getIsoformProteinCount() { return isoformProteinCount; diff --git a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java index e4e27baf5..e1e3edcae 100644 --- a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java +++ b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java @@ -1,9 +1,10 @@ package org.uniprot.core.proteome.impl; -import static org.junit.jupiter.api.Assertions.*; - import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + class ProteomeStatisticsImplTest { public static final int REVIEWED_PROTEIN_COUNT = 98; public static final int UNREVIEWED_PROTEIN_COUNT = 33; @@ -20,6 +21,13 @@ void getCountsAreAccurate() { assertEquals(ISOFORM_PROTEIN_COUNT, PROTEOME_STATISTICS.getIsoformProteinCount()); } + @Test + void defaultConstructor() { + ProteomeStatisticsImpl that = + new ProteomeStatisticsImpl(); + assertEquals(new ProteomeStatisticsImpl(0, 0, 0), that); + } + @Test void equals_whenTrue() { ProteomeStatisticsImpl that = diff --git a/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java b/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java index 9040fee57..20b2115e8 100644 --- a/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java +++ b/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java @@ -1,41 +1,19 @@ package org.uniprot.core.json.parser.proteome; -import java.time.LocalDate; - +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.jsontype.NamedType; +import com.fasterxml.jackson.databind.module.SimpleModule; import org.uniprot.core.CrossReference; import org.uniprot.core.Database; import org.uniprot.core.Value; -import org.uniprot.core.citation.Author; -import org.uniprot.core.citation.Book; -import org.uniprot.core.citation.ElectronicArticle; -import org.uniprot.core.citation.Journal; -import org.uniprot.core.citation.JournalArticle; -import org.uniprot.core.citation.Locator; -import org.uniprot.core.citation.Patent; -import org.uniprot.core.citation.PublicationDate; -import org.uniprot.core.citation.Submission; -import org.uniprot.core.citation.Thesis; -import org.uniprot.core.citation.Unpublished; -import org.uniprot.core.citation.impl.AuthorImpl; -import org.uniprot.core.citation.impl.BookImpl; -import org.uniprot.core.citation.impl.ElectronicArticleImpl; -import org.uniprot.core.citation.impl.JournalArticleImpl; -import org.uniprot.core.citation.impl.JournalImpl; -import org.uniprot.core.citation.impl.PatentImpl; -import org.uniprot.core.citation.impl.PublicationDateImpl; -import org.uniprot.core.citation.impl.SubmissionImpl; -import org.uniprot.core.citation.impl.ThesisImpl; -import org.uniprot.core.citation.impl.UnpublishedImpl; +import org.uniprot.core.citation.*; +import org.uniprot.core.citation.impl.*; import org.uniprot.core.impl.CrossReferenceImpl; import org.uniprot.core.impl.DefaultDatabase; import org.uniprot.core.impl.ValueImpl; import org.uniprot.core.json.parser.JsonConfig; import org.uniprot.core.json.parser.deserializer.LocalDateDeserializer; -import org.uniprot.core.json.parser.serializer.AuthorSerializer; -import org.uniprot.core.json.parser.serializer.JournalSerializer; -import org.uniprot.core.json.parser.serializer.LocalDateSerializer; -import org.uniprot.core.json.parser.serializer.LocatorSerializer; -import org.uniprot.core.json.parser.serializer.PublicationDateSerializer; +import org.uniprot.core.json.parser.serializer.*; import org.uniprot.core.json.parser.uniprot.serializer.UniProtKBAccessionSerializer; import org.uniprot.core.proteome.*; import org.uniprot.core.proteome.impl.*; @@ -46,9 +24,7 @@ import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; import org.uniprot.core.uniprotkb.taxonomy.impl.TaxonomyImpl; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.jsontype.NamedType; -import com.fasterxml.jackson.databind.module.SimpleModule; +import java.time.LocalDate; public class ProteomeJsonConfig extends JsonConfig { private static ProteomeJsonConfig instance; @@ -89,6 +65,7 @@ private ObjectMapper initObjectMapper() { mod.addAbstractTypeMapping(ProteomeId.class, ProteomeIdImpl.class); mod.addAbstractTypeMapping(Taxonomy.class, TaxonomyImpl.class); mod.addAbstractTypeMapping(TaxonomyLineage.class, TaxonomyLineageImpl.class); + mod.addAbstractTypeMapping(ProteomeStatistics.class, ProteomeStatisticsImpl.class); mod.addAbstractTypeMapping(Value.class, ValueImpl.class); mod.addAbstractTypeMapping(RedundantProteome.class, RedundantProteomeImpl.class); From 9e966bcb8f16eb49c4417a92e38c70dd406b516a Mon Sep 17 00:00:00 2001 From: automated changes Date: Wed, 18 Oct 2023 10:34:46 +0000 Subject: [PATCH 28/31] code format with spotless automatic --- .../core/proteome/impl/ProteomeStatisticsImpl.java | 6 +++--- .../core/proteome/impl/ProteomeStatisticsImplTest.java | 7 +++---- .../core/json/parser/proteome/ProteomeJsonConfig.java | 9 +++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java index 7af954e5d..132f25bd6 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java @@ -1,10 +1,10 @@ package org.uniprot.core.proteome.impl; +import java.util.Objects; + import org.uniprot.core.impl.StatisticsImpl; import org.uniprot.core.proteome.ProteomeStatistics; -import java.util.Objects; - public class ProteomeStatisticsImpl extends StatisticsImpl implements ProteomeStatistics { private static final long serialVersionUID = -8585233468042758658L; private final long isoformProteinCount; @@ -16,7 +16,7 @@ public class ProteomeStatisticsImpl extends StatisticsImpl implements ProteomeSt } ProteomeStatisticsImpl() { - this(0, 0,0); + this(0, 0, 0); } @Override diff --git a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java index e1e3edcae..e2e3bebc1 100644 --- a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java +++ b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java @@ -1,10 +1,10 @@ package org.uniprot.core.proteome.impl; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; +import org.junit.jupiter.api.Test; + class ProteomeStatisticsImplTest { public static final int REVIEWED_PROTEIN_COUNT = 98; public static final int UNREVIEWED_PROTEIN_COUNT = 33; @@ -23,8 +23,7 @@ void getCountsAreAccurate() { @Test void defaultConstructor() { - ProteomeStatisticsImpl that = - new ProteomeStatisticsImpl(); + ProteomeStatisticsImpl that = new ProteomeStatisticsImpl(); assertEquals(new ProteomeStatisticsImpl(0, 0, 0), that); } diff --git a/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java b/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java index 20b2115e8..cf9bf96d2 100644 --- a/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java +++ b/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java @@ -1,8 +1,7 @@ package org.uniprot.core.json.parser.proteome; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.jsontype.NamedType; -import com.fasterxml.jackson.databind.module.SimpleModule; +import java.time.LocalDate; + import org.uniprot.core.CrossReference; import org.uniprot.core.Database; import org.uniprot.core.Value; @@ -24,7 +23,9 @@ import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; import org.uniprot.core.uniprotkb.taxonomy.impl.TaxonomyImpl; -import java.time.LocalDate; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.jsontype.NamedType; +import com.fasterxml.jackson.databind.module.SimpleModule; public class ProteomeJsonConfig extends JsonConfig { private static ProteomeJsonConfig instance; From e863063704bc94085ede5e2f70c07d7eef197c77 Mon Sep 17 00:00:00 2001 From: supun Date: Wed, 18 Oct 2023 12:02:09 +0100 Subject: [PATCH 29/31] test fix --- ff-parser/dependency-reduced-pom.xml | 157 ++++++++++++++++++ .../json/parser/proteome/ProteomeTest.java | 4 + 2 files changed, 161 insertions(+) create mode 100644 ff-parser/dependency-reduced-pom.xml diff --git a/ff-parser/dependency-reduced-pom.xml b/ff-parser/dependency-reduced-pom.xml new file mode 100644 index 000000000..ee2a6ae96 --- /dev/null +++ b/ff-parser/dependency-reduced-pom.xml @@ -0,0 +1,157 @@ + + + + core-parent + org.uniprot + 1.0.27-SNAPSHOT + + 4.0.0 + ff-parser + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-toolchains-plugin + [1.1,) + + toolchain + + + + + + + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.1.0 + + + generate-sources + + add-source + + + + target/generated-sources/antlr4 + + + + + + + org.antlr + antlr4-maven-plugin + ${antlr4.version} + + + + antlr4 + + + + + true + true + + + + maven-shade-plugin + 2.3 + + + package + + shade + + + + + org.uniprot.core.flatfile.parser.impl.EntryIteratorMain + + + + + + + + + + + org.hamcrest + hamcrest-all + 1.3 + test + + + org.junit.jupiter + junit-jupiter-api + 5.5.2 + test + + + apiguardian-api + org.apiguardian + + + opentest4j + org.opentest4j + + + junit-platform-commons + org.junit.platform + + + + + org.junit.jupiter + junit-jupiter-engine + 5.5.2 + test + + + junit-platform-engine + org.junit.platform + + + apiguardian-api + org.apiguardian + + + + + org.junit.jupiter + junit-jupiter-params + 5.5.2 + test + + + apiguardian-api + org.apiguardian + + + + + + 4.5.3 + 6.1.5.Final + UTF-8 + + + diff --git a/json-parser/src/test/java/org/uniprot/core/json/parser/proteome/ProteomeTest.java b/json-parser/src/test/java/org/uniprot/core/json/parser/proteome/ProteomeTest.java index 586579f6b..a1b0d0456 100644 --- a/json-parser/src/test/java/org/uniprot/core/json/parser/proteome/ProteomeTest.java +++ b/json-parser/src/test/java/org/uniprot/core/json/parser/proteome/ProteomeTest.java @@ -150,6 +150,9 @@ public static ProteomeEntry getCompleteProteomeEntry() { .genomeAnnotation(genomeAnnotation) .build(); + ProteomeStatistics proteomeStatistics = new ProteomeStatisticsBuilder().reviewedProteinCount(1) + .unreviewedProteinCount(10).isoformProteinCount(23).build(); + return new ProteomeEntryBuilder() .proteomeId(proteomeId) .description(description) @@ -177,6 +180,7 @@ public static ProteomeEntry getCompleteProteomeEntry() { .genomeAnnotation(genomeAnnotation) .exclusionReasonsAdd(ExclusionReason.MIXED_CULTURE) .proteinCount(250) + .proteomeStatistics(proteomeStatistics) .build(); } From 454f230c85808611fb51a05e35ed654b8f948e0d Mon Sep 17 00:00:00 2001 From: supun Date: Wed, 18 Oct 2023 12:05:50 +0100 Subject: [PATCH 30/31] remove unwanted --- ff-parser/dependency-reduced-pom.xml | 157 --------------------------- 1 file changed, 157 deletions(-) delete mode 100644 ff-parser/dependency-reduced-pom.xml diff --git a/ff-parser/dependency-reduced-pom.xml b/ff-parser/dependency-reduced-pom.xml deleted file mode 100644 index ee2a6ae96..000000000 --- a/ff-parser/dependency-reduced-pom.xml +++ /dev/null @@ -1,157 +0,0 @@ - - - - core-parent - org.uniprot - 1.0.27-SNAPSHOT - - 4.0.0 - ff-parser - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-toolchains-plugin - [1.1,) - - toolchain - - - - - - - - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.1.0 - - - generate-sources - - add-source - - - - target/generated-sources/antlr4 - - - - - - - org.antlr - antlr4-maven-plugin - ${antlr4.version} - - - - antlr4 - - - - - true - true - - - - maven-shade-plugin - 2.3 - - - package - - shade - - - - - org.uniprot.core.flatfile.parser.impl.EntryIteratorMain - - - - - - - - - - - org.hamcrest - hamcrest-all - 1.3 - test - - - org.junit.jupiter - junit-jupiter-api - 5.5.2 - test - - - apiguardian-api - org.apiguardian - - - opentest4j - org.opentest4j - - - junit-platform-commons - org.junit.platform - - - - - org.junit.jupiter - junit-jupiter-engine - 5.5.2 - test - - - junit-platform-engine - org.junit.platform - - - apiguardian-api - org.apiguardian - - - - - org.junit.jupiter - junit-jupiter-params - 5.5.2 - test - - - apiguardian-api - org.apiguardian - - - - - - 4.5.3 - 6.1.5.Final - UTF-8 - - - From 524be1e5dab9e1b0661a5453f6f5afaa881bf6a7 Mon Sep 17 00:00:00 2001 From: automated changes Date: Wed, 18 Oct 2023 11:07:43 +0000 Subject: [PATCH 31/31] code format with spotless automatic --- .../core/proteome/impl/ProteomeStatisticsImpl.java | 6 +++--- .../core/proteome/impl/ProteomeStatisticsImplTest.java | 7 +++---- .../core/json/parser/proteome/ProteomeJsonConfig.java | 9 +++++---- .../uniprot/core/json/parser/proteome/ProteomeTest.java | 8 ++++++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java index 7af954e5d..132f25bd6 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java @@ -1,10 +1,10 @@ package org.uniprot.core.proteome.impl; +import java.util.Objects; + import org.uniprot.core.impl.StatisticsImpl; import org.uniprot.core.proteome.ProteomeStatistics; -import java.util.Objects; - public class ProteomeStatisticsImpl extends StatisticsImpl implements ProteomeStatistics { private static final long serialVersionUID = -8585233468042758658L; private final long isoformProteinCount; @@ -16,7 +16,7 @@ public class ProteomeStatisticsImpl extends StatisticsImpl implements ProteomeSt } ProteomeStatisticsImpl() { - this(0, 0,0); + this(0, 0, 0); } @Override diff --git a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java index e1e3edcae..e2e3bebc1 100644 --- a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java +++ b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java @@ -1,10 +1,10 @@ package org.uniprot.core.proteome.impl; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; +import org.junit.jupiter.api.Test; + class ProteomeStatisticsImplTest { public static final int REVIEWED_PROTEIN_COUNT = 98; public static final int UNREVIEWED_PROTEIN_COUNT = 33; @@ -23,8 +23,7 @@ void getCountsAreAccurate() { @Test void defaultConstructor() { - ProteomeStatisticsImpl that = - new ProteomeStatisticsImpl(); + ProteomeStatisticsImpl that = new ProteomeStatisticsImpl(); assertEquals(new ProteomeStatisticsImpl(0, 0, 0), that); } diff --git a/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java b/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java index 20b2115e8..cf9bf96d2 100644 --- a/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java +++ b/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java @@ -1,8 +1,7 @@ package org.uniprot.core.json.parser.proteome; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.jsontype.NamedType; -import com.fasterxml.jackson.databind.module.SimpleModule; +import java.time.LocalDate; + import org.uniprot.core.CrossReference; import org.uniprot.core.Database; import org.uniprot.core.Value; @@ -24,7 +23,9 @@ import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; import org.uniprot.core.uniprotkb.taxonomy.impl.TaxonomyImpl; -import java.time.LocalDate; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.jsontype.NamedType; +import com.fasterxml.jackson.databind.module.SimpleModule; public class ProteomeJsonConfig extends JsonConfig { private static ProteomeJsonConfig instance; diff --git a/json-parser/src/test/java/org/uniprot/core/json/parser/proteome/ProteomeTest.java b/json-parser/src/test/java/org/uniprot/core/json/parser/proteome/ProteomeTest.java index a1b0d0456..dd26abe1f 100644 --- a/json-parser/src/test/java/org/uniprot/core/json/parser/proteome/ProteomeTest.java +++ b/json-parser/src/test/java/org/uniprot/core/json/parser/proteome/ProteomeTest.java @@ -150,8 +150,12 @@ public static ProteomeEntry getCompleteProteomeEntry() { .genomeAnnotation(genomeAnnotation) .build(); - ProteomeStatistics proteomeStatistics = new ProteomeStatisticsBuilder().reviewedProteinCount(1) - .unreviewedProteinCount(10).isoformProteinCount(23).build(); + ProteomeStatistics proteomeStatistics = + new ProteomeStatisticsBuilder() + .reviewedProteinCount(1) + .unreviewedProteinCount(10) + .isoformProteinCount(23) + .build(); return new ProteomeEntryBuilder() .proteomeId(proteomeId)