use of org.nextprot.api.core.domain.DbXref in project nextprot-api by calipho-sib.
the class CosmicXrefURLResolverTest method testResolveCosmicBadPrimaryId.
@Test
public void testResolveCosmicBadPrimaryId() throws Exception {
DbXref xref = DbXrefURLResolverDelegateTest.createDbXref("HCFC1", "Cosmic", "whatever");
Assert.assertEquals("http://cancer.sanger.ac.uk/cosmic/gene/overview?ln=HCFC1", resolver.resolve(xref));
}
use of org.nextprot.api.core.domain.DbXref in project nextprot-api by calipho-sib.
the class CosmicXrefURLResolverTest method testResolveCosmicCOSM.
// entry/NX_Q9BXA6/xref.json
@Test
public void testResolveCosmicCOSM() throws Exception {
DbXref xref = DbXrefURLResolverDelegateTest.createDbXref("COSM1172604", "Cosmic", "whatever");
Assert.assertEquals("http://cancer.sanger.ac.uk/cosmic/mutation/overview?id=1172604", resolver.resolve(xref));
}
use of org.nextprot.api.core.domain.DbXref in project nextprot-api by calipho-sib.
the class DbXrefDAOIntegrationTest method mockDbXref.
private static DbXref mockDbXref(long id, String accession, String dbCat, String dbName, String linkUrl, String resolvedUrl, String url) {
DbXref dbxref = Mockito.mock(DbXref.class);
Mockito.when(dbxref.getDbXrefId()).thenReturn(id);
Mockito.when(dbxref.getAccession()).thenReturn(accession);
Mockito.when(dbxref.getDatabaseCategory()).thenReturn(dbCat);
Mockito.when(dbxref.getDatabaseName()).thenReturn(dbName);
Mockito.when(dbxref.getLinkUrl()).thenReturn(linkUrl);
Mockito.when(dbxref.getResolvedUrl()).thenReturn(resolvedUrl);
Mockito.when(dbxref.getUrl()).thenReturn(url);
return dbxref;
}
use of org.nextprot.api.core.domain.DbXref in project nextprot-api by calipho-sib.
the class TerminologyUtils method convertXrefsToString.
public static String convertXrefsToString(List<DbXref> xrefs) {
if (xrefs == null)
return null;
// Build a String of xrefs formatted as "dbcat, db:acc" pairs separated by pipes
StringBuilder sb = new StringBuilder();
int i = xrefs.size();
for (DbXref xref : xrefs) {
sb.append(xref.getDatabaseCategory());
sb.append(", ");
sb.append(xref.getDatabaseName());
sb.append(":");
sb.append(xref.getAccession());
if (--i != 0)
sb.append(" | ");
}
return sb.toString();
}
use of org.nextprot.api.core.domain.DbXref in project nextprot-api by calipho-sib.
the class TerminologyUtils method convertToXrefs.
public static List<DbXref> convertToXrefs(String xrefsstring) {
if (xrefsstring == null)
return null;
// Builds DbXref list from String of xrefs formatted as "dbcat, db, acc, linkurl" quartetss separated by pipes
List<DbXref> xrefs = new ArrayList<>();
List<String> allxrefs = Arrays.asList(xrefsstring.split(" \\| "));
for (String onexref : allxrefs) {
List<String> fields = Arrays.asList(onexref.split("\\^ "));
DbXref dbref = new DbXref();
dbref.setDatabaseCategory(fields.get(0));
dbref.setDatabaseName(fields.get(1));
dbref.setAccession(fields.get(2));
dbref.setDbXrefId(Long.parseLong(fields.get(3)));
String url = null;
String linkurl = null;
if (fields.size() > 4) {
url = fields.get(4);
if (fields.size() > 5)
linkurl = fields.get(5);
}
if (url == null || url.isEmpty() || "none".equalsIgnoreCase(url)) {
dbref.setUrl("None");
dbref.setLinkUrl("None");
} else {
dbref.setUrl(url);
dbref.setLinkUrl(linkurl);
}
xrefs.add(dbref);
}
return xrefs;
}
Aggregations