Skip to content

Commit

Permalink
add internal cross refs for publication
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadshadab committed Sep 27, 2023
1 parent 797345f commit 762a196
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public List<UniProtDatabaseDetail> getDBTypesByCategory(UniProtDatabaseCategory
.collect(Collectors.toList());
}

public List<UniProtDatabaseDetail> getInternalDatabaseDetails(){
return UniProtDatabaseTypes.INSTANCE.getAllDbTypes().stream()
.filter(dbDetail -> "internal".equals(dbDetail.getType())).collect(Collectors.toList());
}

private void init() {

String source =
Expand All @@ -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<UniProtDatabaseAttribute> attributes = new ArrayList<>();
List<Property> properties = item.getProperties("attributes");
Expand All @@ -97,7 +103,8 @@ private void init() {
attributes,
isImplicit,
linkedReason,
idMappingName);
idMappingName,
type);
types.add(xdbType);
});
typeMap =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void testFailedValidation() {
opType.getAttributes(),
false,
null,
null);
null, null);

// validate, the category should mismatch
List<Pair<String, String>> mismatches = CrossReferenceValidator.validate(actualOpType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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);
Expand All @@ -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(
Expand All @@ -331,6 +332,13 @@ void testDatabaseFieldSize() {
verifyGroupSize(UniProtDatabaseTypes.INSTANCE.getDBTypesByCategory(PROTEOMES_DATABASES), 1);
}

@Test
void testInternalCrossRefs(){
List<UniProtDatabaseDetail> internalCrossRefs = UniProtDatabaseTypes.INSTANCE.getInternalDatabaseDetails();

assertEquals(7, internalCrossRefs.size());
}

private void verifyGroupSize(List<UniProtDatabaseDetail> dbTypesByCategory, int size) {
assertEquals(size, dbTypesByCategory.size());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<>();
Expand All @@ -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<UniProtDatabaseAttribute> attributes,
boolean implicit,
String linkedReason,
String idMappingName,
String type) {
super();
this.name = name;
this.displayName = displayName;
Expand All @@ -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() {
Expand Down Expand Up @@ -81,6 +95,10 @@ public String getIdMappingName() {
return idMappingName;
}

public String getType(){
return this.type;
}

@Override
public int hashCode() {
return Objects.hash(
Expand All @@ -91,7 +109,8 @@ public int hashCode() {
this.uriLink,
this.implicit,
this.linkedReason,
this.idMappingName);
this.idMappingName,
this.type);
}

@Override
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class UniProtKBDatabaseDetailTest {
private String uriLink;
private List<UniProtDatabaseAttribute> attributes;
private String idMappingName;
private String type;

@BeforeEach
void setUp() {
Expand All @@ -34,6 +35,7 @@ void setUp() {
this.name, this.displayName, this.uriLink))
.collect(Collectors.toList());
this.idMappingName = "idMappingName-" + random;
this.type = "type-" + random;
}

@Test
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -109,15 +113,16 @@ private UniProtDatabaseDetail createUniProtDatabaseDetail(boolean passAttribute)
this.category,
this.uriLink,
this.attributes,
null);
null, null);
} else {
return createUniProtDatabaseDetail(
this.name,
this.displayName,
this.category,
this.uriLink,
null,
this.idMappingName);
this.idMappingName,
this.type);
}
}

Expand All @@ -127,8 +132,8 @@ static UniProtDatabaseDetail createUniProtDatabaseDetail(
UniProtDatabaseCategory category,
String uriLink,
List<UniProtDatabaseAttribute> 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);
}
}

0 comments on commit 762a196

Please sign in to comment.