Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadshadab committed Sep 30, 2024
1 parent 5b08cde commit 5f308e7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class UniParcCrossReferencePair implements Pair<String, List<UniParcCross
private String key;
private List<UniParcCrossReference> value;


UniParcCrossReferencePair(){}
public UniParcCrossReferencePair(String key, List<UniParcCrossReference> value) {
this.key = key;
this.value = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public class UniParcEntryLightValueMapper implements EntityValueMapper<UniParcEn

private static final List<String> UNIPARC_FIELDS =
List.of("upi",
"oldestCrossRefCreated",
"mostRecentCrossRefUpdated",
"organism",
"organism_id",
"gene",
Expand Down Expand Up @@ -54,57 +52,43 @@ private Map<String, String> getSimpleAttributeValues(UniParcEntryLight entry, Li
case "upi":
map.put(UNIPARC_FIELDS.get(0), entry.getUniParcId());
break;
case "oldestCrossRefCreated":
map.put(
UNIPARC_FIELDS.get(1),
Optional.of(entry.getOldestCrossRefCreated())
.map(LocalDate::toString)
.orElse(""));
break;
case "mostRecentCrossRefUpdated":
map.put(
UNIPARC_FIELDS.get(2),
Optional.of(entry.getMostRecentCrossRefUpdated())
.map(LocalDate::toString)
.orElse(""));
break;
case "organism":
map.put(
UNIPARC_FIELDS.get(3),
UNIPARC_FIELDS.get(1),
entry.getOrganisms().stream()
.map(Organism::getScientificName)
.collect(Collectors.joining(DELIMITER2)));
break;
case "organism_id":
map.put(
UNIPARC_FIELDS.get(4),
UNIPARC_FIELDS.get(2),
entry.getOrganisms().stream()
.map(Organism::getTaxonId)
.map(String::valueOf)
.collect(Collectors.joining(DELIMITER2)));
break;
case "gene":
map.put(UNIPARC_FIELDS.get(5),String.join(DELIMITER2, entry.getGeneNames()));
map.put(UNIPARC_FIELDS.get(3),String.join(DELIMITER2, entry.getGeneNames()));
break;
case "protein":
map.put(UNIPARC_FIELDS.get(6),String.join(DELIMITER2, entry.getProteinNames()));
map.put(UNIPARC_FIELDS.get(4),String.join(DELIMITER2, entry.getProteinNames()));
break;
case "proteome":
map.put(UNIPARC_FIELDS.get(7),entry.getProteomes().stream().map(e -> e.getId()+":"+e.getComponent()).collect(Collectors.joining(DELIMITER2)));
map.put(UNIPARC_FIELDS.get(5),entry.getProteomes().stream().map(e -> e.getId()+":"+e.getComponent()).collect(Collectors.joining(DELIMITER2)));
break;
case "accession":
map.put(UNIPARC_FIELDS.get(8),String.join(DELIMITER2, entry.getUniProtKBAccessions()));
map.put(UNIPARC_FIELDS.get(6),String.join(DELIMITER2, entry.getUniProtKBAccessions()));
break;
case "first_seen":
map.put(
UNIPARC_FIELDS.get(9),
UNIPARC_FIELDS.get(7),
Optional.of(entry.getOldestCrossRefCreated())
.map(LocalDate::toString)
.orElse(""));
break;
case "last_seen":
map.put(
UNIPARC_FIELDS.get(10),
UNIPARC_FIELDS.get(8),
Optional.of(entry.getMostRecentCrossRefUpdated())
.map(LocalDate::toString)
.orElse(""));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package org.uniprot.core.parser.tsv.uniparc;

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

import java.time.LocalDate;
import java.util.*;

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

import java.time.LocalDate;
import java.util.*;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author jluo
* @date: 24 Jun 2019
Expand All @@ -31,9 +32,7 @@ void testSimpleAttributeValues() {
UniParcCrossReferenceMap xrefMap =
new UniParcCrossReferenceMap(Collections.singletonList(xref));
Map<String, String> result = xrefMap.attributeValues();
assertEquals(13, result.size());
assertEquals("2017-05-17", result.get("first_seen"));
assertEquals("2018-02-07", result.get("last_seen"));
assertEquals(11, result.size());
assertEquals("IDVALUE", result.get("EnsemblBacteria"));
assertEquals("", result.get("gene"));
assertEquals("", result.get("protein"));
Expand All @@ -52,13 +51,11 @@ void testAttributeValues() {
List<UniParcCrossReference> xrefs = create();
UniParcCrossReferenceMap xrefMap = new UniParcCrossReferenceMap(xrefs);
Map<String, String> result = xrefMap.attributeValues();
assertEquals(14, result.size());
assertEquals(12, result.size());
assertEquals("geneValue", result.get("gene"));
assertEquals("some pname;some pname2", result.get("protein"));
assertEquals("P12345; P12347.2 (obsolete)", result.get("accession"));
assertEquals("UP00000564:chromosome 1", result.get("proteome"));
assertEquals("2015-01-11", result.get("first_seen"));
assertEquals("2018-02-07", result.get("last_seen"));
assertEquals("P12345", result.get("UniProtKB/Swiss-Prot"));
assertEquals("P12347", result.get("UniProtKB/TrEMBL"));
}
Expand All @@ -72,8 +69,6 @@ void testFields() {
"protein",
"proteome",
"accession",
"first_seen",
"last_seen",
"database",
"active",
"ncbiGi",
Expand All @@ -95,9 +90,7 @@ void testAttributeValuesWithoutDates() {
List<UniParcCrossReference> xrefs = createWithoutDates();
UniParcCrossReferenceMap xrefMap = new UniParcCrossReferenceMap(xrefs);
Map<String, String> result = xrefMap.attributeValues();
assertEquals(14, result.size());
assertTrue(result.get("first_seen").isEmpty());
assertTrue(result.get("last_seen").isEmpty());
assertEquals(12, result.size());
assertTrue(result.get("timeline").isEmpty());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.uniprot.core.parser.tsv.uniparc;

import org.junit.jupiter.api.Test;
import org.uniprot.core.Location;
import org.uniprot.core.Sequence;
import org.uniprot.core.impl.SequenceBuilder;
import org.uniprot.core.uniparc.*;
Expand All @@ -10,9 +9,12 @@
import org.uniprot.core.uniprotkb.taxonomy.impl.OrganismBuilder;

import java.time.LocalDate;
import java.util.*;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;

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

class UniParcEntryLightValueMapperTest {

Expand Down Expand Up @@ -78,16 +80,6 @@ void testGetSequenceFeature() {
verify("sigId2", "PROSITE", result);
}

@Test
void testGetDates() {
UniParcEntryLight entry = create();
List<String> fields = Arrays.asList("oldestCrossRefCreated", "mostRecentCrossRefUpdated");
Map<String, String> result = new UniParcEntryLightValueMapper().mapEntity(entry, fields);
assertEquals(2, result.size());
verify("2017-02-12", "oldestCrossRefCreated", result);
verify("2020-10-25", "mostRecentCrossRefUpdated", result);
}

private void verify(String expected, String field, Map<String, String> result) {
assertEquals(expected, result.get(field));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void testGetDataProteinGene() {
UniParcEntry entry = create();
List<String> fields = Arrays.asList("upi", "protein", "gene", "accession");
Map<String, String> result = new UniParcEntryValueMapper().mapEntity(entry, fields);
assertEquals(15, result.size());
assertEquals(13, result.size());
verify("UPI0000083A08", "upi", result);
verify("some pname;some pname", "protein", result);
verify("some gname", "gene", result);
Expand All @@ -54,7 +54,7 @@ void testGetDate() {
UniParcEntry entry = create();
List<String> fields = Arrays.asList("upi", "first_seen", "last_seen");
Map<String, String> result = new UniParcEntryValueMapper().mapEntity(entry, fields);
assertEquals(15, result.size());
assertEquals(3, result.size());
verify("UPI0000083A08", "upi", result);
verify("2017-02-12", "first_seen", result);
verify("2017-04-23", "last_seen", result);
Expand Down Expand Up @@ -88,11 +88,11 @@ void testGetSequenceFeature() {
@Test
void testGetDates() {
UniParcEntry entry = create();
List<String> fields = Arrays.asList("oldestCrossRefCreated", "mostRecentCrossRefUpdated");
List<String> fields = Arrays.asList("first_seen", "last_seen");
Map<String, String> result = new UniParcEntryValueMapper().mapEntity(entry, fields);
assertEquals(2, result.size());
verify("2017-02-12", "oldestCrossRefCreated", result);
verify("2017-04-23", "mostRecentCrossRefUpdated", result);
verify("2017-02-12", "first_seen", result);
verify("2017-04-23", "last_seen", result);
}

private void verify(String expected, String field, Map<String, String> result) {
Expand Down

0 comments on commit 5f308e7

Please sign in to comment.