Search in sources :

Example 1 with CvTerm

use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.

the class TerminologyService method findCvTermXrefAccessionList.

/**
 * Get the list of xref(s) accession found for the specific database
 *
 * @param cvTermAccession the cvterm accession
 * @param databaseName the database name of the
 * @return a xref accessions list
 */
default List<String> findCvTermXrefAccessionList(String cvTermAccession, String databaseName) {
    Preconditions.checkNotNull(cvTermAccession);
    CvTerm term = findCvTermByAccession(cvTermAccession);
    List<String> accessions = new ArrayList<>();
    if (term != null && term.getXrefs() != null) {
        return term.getXrefs().stream().filter(xref -> xref.getDatabaseName().equals(databaseName)).map(DbXref::getAccession).collect(Collectors.toList());
    }
    return accessions;
}
Also used : CvTerm(org.nextprot.api.core.domain.CvTerm) ArrayList(java.util.ArrayList)

Example 2 with CvTerm

use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.

the class TerminologyServiceTest method shouldReturnAValidCategory.

@Test
public void shouldReturnAValidCategory() {
    CvTerm term = this.terminologyService.findCvTermByAccession("DO-00861");
    String propval = "";
    for (CvTerm.TermProperty property : term.getProperties()) {
        if (property.getPropertyName().equals("Feature category"))
            propval = property.getPropertyValue();
    }
    assertEquals("zinc finger", propval);
}
Also used : CvTerm(org.nextprot.api.core.domain.CvTerm) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 3 with CvTerm

use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.

the class TerminologyServiceTest method shouldReturnAUniprotKeywordId.

@Test
public void shouldReturnAUniprotKeywordId() {
    CvTerm term = this.terminologyService.findCvTermByAccession("KW-0732");
    assertEquals("UniprotKeywordCv", term.getOntology());
}
Also used : CvTerm(org.nextprot.api.core.domain.CvTerm) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 4 with CvTerm

use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.

the class TerminologyServiceTest method shouldReturnAGOTerm.

@Test
public void shouldReturnAGOTerm() {
    CvTerm term = this.terminologyService.findCvTermByAccession("GO:2000145");
    // System.out.println(term.toString());
    assertEquals("GoBiologicalProcessCv", term.getOntology());
    assertEquals(2, term.getSynonyms().size());
}
Also used : CvTerm(org.nextprot.api.core.domain.CvTerm) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 5 with CvTerm

use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.

the class TerminologyServiceTest method searchCvtermWithUndefinedXrefs.

// @Test
public void searchCvtermWithUndefinedXrefs() {
    Map<String, List<String>> map = new HashMap<>();
    // for (CvTerm cvTerm : terminologyService.findAllCVTerms()) {
    for (CvTerm cvTerm : terminologyService.findCvTermsByOntology("UniprotPtmCv")) {
        if (cvTerm.getXrefs() == null || cvTerm.getXrefs().isEmpty()) {
            if (!map.containsKey(cvTerm.getOntology())) {
                map.put(cvTerm.getOntology(), new ArrayList<>());
            }
            map.get(cvTerm.getOntology()).add(cvTerm.getAccession());
        // System.err.println(cvTerm.getAccession()+"\t"+cvTerm.getOntology());
        }
    }
    Collections.sort(map.get("UniprotPtmCv"));
    System.out.println(map.get("UniprotPtmCv"));
}
Also used : CvTerm(org.nextprot.api.core.domain.CvTerm)

Aggregations

CvTerm (org.nextprot.api.core.domain.CvTerm)34 Test (org.junit.Test)9 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)8 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)5 NextProtException (org.nextprot.api.commons.exception.NextProtException)4 CvTermGraph (org.nextprot.api.core.domain.CvTermGraph)4 Annotation (org.nextprot.api.core.domain.annotation.Annotation)4 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)4 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)4 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)4 Publication (org.nextprot.api.core.domain.Publication)3 Supplier (com.google.common.base.Supplier)2 Instant (java.time.Instant)2 java.util (java.util)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Collectors (java.util.stream.Collectors)2 Logger (org.apache.log4j.Logger)2 ApiMethod (org.jsondoc.core.annotation.ApiMethod)2 ConsoleProgressBar (org.nextprot.api.commons.app.ConsoleProgressBar)2