diff --git a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapper.java b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapper.java index c149912a9..2a9bd213f 100644 --- a/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapper.java +++ b/core-parser/src/main/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapper.java @@ -21,7 +21,8 @@ public class UniParcEntryLightValueMapper implements EntityValueMapper getSimpleAttributeValues(UniParcEntryLight entry, Li .map(this::getCommonTaxonString) .orElse("")); break; + case "common_taxon_ids": + map.put( + UNIPARC_FIELDS.get(10), + Optional.of(entry.getCommonTaxons()) + .map(this::getCommonTaxonIdString) + .orElse("")); + break; default: // do nothing } @@ -112,4 +120,8 @@ private Map getSimpleAttributeValues(UniParcEntryLight entry, Li private String getCommonTaxonString(List commonTaxons) { return commonTaxons.stream().map(CommonOrganism::getCommonTaxon).collect(Collectors.joining("; ")); } + + private String getCommonTaxonIdString(List commonTaxons) { + return commonTaxons.stream().map(commonOrganism -> String.valueOf(commonOrganism.getCommonTaxonId())).collect(Collectors.joining("; ")); + } } diff --git a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapperTest.java b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapperTest.java index e613c83b0..41bd36fc0 100644 --- a/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapperTest.java +++ b/core-parser/src/test/java/org/uniprot/core/parser/tsv/uniparc/UniParcEntryLightValueMapperTest.java @@ -18,7 +18,7 @@ class UniParcEntryLightValueMapperTest { @Test void testGetDataOrganism() { UniParcEntryLight entry = create(); - List fields = Arrays.asList("upi", "organism", "organism_id", "proteome", "common_taxons"); + List fields = Arrays.asList("upi", "organism", "organism_id", "proteome", "common_taxons", "common_taxon_ids"); Map result = new UniParcEntryLightValueMapper().mapEntity(entry, fields); @@ -28,13 +28,14 @@ void testGetDataOrganism() { verify("9606; 10090", "organism_id", result); verify("UP000005640:C1; UP000002494:C2", "proteome", result); verify("Bacteroides; Enterococcus", "common_taxons", result); + verify("12345; 9876", "common_taxon_ids", result); } @Test void testGetDataOrganism_withEmptyCommonTaxons() { UniParcEntryLight entry = create(); UniParcEntryLight entryWithEmptyCommonTaxons = UniParcEntryLightBuilder.from(entry).commonTaxonsSet(List.of()).build(); - List fields = Arrays.asList("upi", "organism", "organism_id", "proteome", "common_taxons"); + List fields = Arrays.asList("upi", "organism", "organism_id", "proteome", "common_taxons", "common_taxon_ids"); Map result = new UniParcEntryLightValueMapper().mapEntity(entryWithEmptyCommonTaxons, fields); @@ -44,6 +45,8 @@ void testGetDataOrganism_withEmptyCommonTaxons() { verify("9606; 10090", "organism_id", result); verify("UP000005640:C1; UP000002494:C2", "proteome", result); verify("", "common_taxons", result); + verify("", "common_taxons", result); + verify("", "common_taxon_ids", result); } @Test @@ -94,6 +97,8 @@ void testGetSequenceFeature() { verify("sigId2", "PROSITE", result); } + + private void verify(String expected, String field, Map result) { assertEquals(expected, result.get(field)); } @@ -109,7 +114,7 @@ private UniParcEntryLight create() { LinkedHashSet proteinNames = new LinkedHashSet<>(List.of("protein1", "protein2")); LinkedHashSet geneNames = new LinkedHashSet<>(List.of("gene1", "gene2")); - List commonTaxons = List.of(new CommonOrganismBuilder().commonTaxon("Bacteroides").build(),new CommonOrganismBuilder().commonTaxon("Enterococcus").build()); + List commonTaxons = List.of(new CommonOrganismBuilder().commonTaxon("Bacteroides").commonTaxonId(12345L).build(),new CommonOrganismBuilder().commonTaxon("Enterococcus").commonTaxonId(9876L).build()); LinkedHashSet proteomes = new LinkedHashSet<>(List.of(new ProteomeBuilder().id("UP000005640").component("C1").build(), new ProteomeBuilder().id("UP000002494").component("C2").build())); return new UniParcEntryLightBuilder()