Search in sources :

Example 1 with Family

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

the class FamilyDaoIntegrationTest method shouldReturn_2_Families.

@Test
public void shouldReturn_2_Families() {
    List<Family> families = familyDao.findFamilies("NX_Q3SY69");
    assertTrue(families.size() == 2);
    for (Family fam : families) {
        assertTrue(fam.getAccession() != null);
        assertTrue(fam.getDescription() != null);
        assertTrue(fam.getName() != null);
        // may be null for some other entries
        assertTrue(fam.getRegion() != null);
        assertTrue(fam.getFamilyId() > 0);
        // the parent (if any) is set later in the family service
        assertTrue(fam.getParent() == null);
    }
}
Also used : Family(org.nextprot.api.core.domain.Family) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 2 with Family

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

the class FamilyServiceIntegrationTest method shouldReturn_2_Families_1_Family_Having_1_Parent.

@Test
public void shouldReturn_2_Families_1_Family_Having_1_Parent() {
    List<Family> families = familyService.findFamilies("NX_Q3SY69");
    assertTrue(families.size() == 2);
    for (Family fam : families) {
        System.out.println(fam);
        assertTrue(fam.getAccession() != null);
        assertTrue(fam.getDescription() != null);
        assertTrue(fam.getName() != null);
        // may be null for some other entries
        assertTrue(fam.getRegion() != null);
        assertTrue(fam.getFamilyId() > 0);
        if (fam.getName().startsWith("GART")) {
            // this family has no parent
            assertTrue(fam.getParent() == null);
        } else if (fam.getName().startsWith("ALDH1L")) {
            // this family has 1 parent
            assertTrue(fam.getParent() != null);
        } else {
            // this should NOT occur
            assertTrue(false);
        }
    }
}
Also used : Family(org.nextprot.api.core.domain.Family) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 3 with Family

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

the class AnnotationFieldBuilder method init.

@Override
protected void init(Entry entry) {
    // Function with canonical first
    List<String> function_canonical = EntryUtils.getFunctionInfoWithCanonicalFirst(entry);
    for (String finfo : function_canonical) {
        addField(Fields.FUNCTION_DESC, finfo);
        addField(Fields.ANNOTATIONS, finfo);
    }
    List<Annotation> annots = entry.getAnnotations();
    for (Annotation currannot : annots) {
        String category = currannot.getCategory();
        AnnotationCategory apiCategory = currannot.getAPICategory();
        String quality = currannot.getQualityQualifier();
        if (apiCategory.equals(AnnotationCategory.FUNCTION_INFO) || apiCategory.equals(AnnotationCategory.EXPRESSION_PROFILE))
            // and tissue specificity values are indexed under other fields
            continue;
        // We also should exclude uninformative category 'sequence conflict'
        // if(!category.equals("tissue specificity")) {//These values are
        // indexed under other fields
        // if(!apiCategory.equals(AnnotationCategory.) {//These values are
        // indexed under other fields
        String desc = currannot.getDescription();
        if (apiCategory.equals(AnnotationCategory.GLYCOSYLATION_SITE)) {
            String xref = currannot.getSynonym();
            if (xref != null)
                // It is actually not a synonym but the carbohydrate id from
                // glycosuitedb !
                addField(Fields.ANNOTATIONS, xref);
        } else if (apiCategory.equals(AnnotationCategory.DNA_BINDING_REGION))
            addField(Fields.ANNOTATIONS, category);
        else if (apiCategory.equals(AnnotationCategory.VARIANT))
            // We need to index them somehow for the GOLD/SILVER tests, or
            // do we ? in creates a lot of useless 'variant null' tokens
            desc = "Variant " + desc;
        if (desc != null) {
            // System.err.println(category + ": " + desc);
            if (apiCategory.equals(AnnotationCategory.SEQUENCE_CAUTION)) {
                int stringpos = 0;
                // The sequence
                desc = desc.split(":")[1].substring(1);
                // AAH70170 differs
                // from that shown.
                // Reason:
                // miscellaneous
                // discrepancy
                String[] desclevels = desc.split("\\.");
                String mainreason = desclevels[0];
                if ((stringpos = mainreason.indexOf(" at position")) != -1) {
                    // truncate the position
                    mainreason = mainreason.substring(0, stringpos);
                }
                addField(Fields.ANNOTATIONS, mainreason);
                if (desclevels.length > 1) {
                    if (// mainreason truncated
                    stringpos > 0)
                        desc = desc.substring(desc.indexOf(".") + 2);
                    else {
                        stringpos = desc.indexOf(mainreason) + mainreason.length();
                        desc = desc.substring(stringpos + 2);
                    }
                    addField(Fields.ANNOTATIONS, desc);
                }
            }
            if (!category.startsWith("go") && desc.length() > 1) {
                // description
                if (!this.isGold() || quality.equals("GOLD")) {
                    if (apiCategory.equals(AnnotationCategory.PHENOTYPIC_VARIATION)) {
                        // Get BED data (also get the notes ? )
                        Map<String, AnnotationIsoformSpecificity> annotSpecs = currannot.getTargetingIsoformsMap();
                        for (Map.Entry<String, AnnotationIsoformSpecificity> mapentry : annotSpecs.entrySet()) {
                            String subjectName = mapentry.getValue().getName();
                            // update description with the subject for each
                            // target isofotm
                            addField(Fields.ANNOTATIONS, subjectName + " " + desc);
                        // System.err.println("adding: " + subjectName +
                        // " " + desc);
                        }
                    } else
                        addField(Fields.ANNOTATIONS, desc);
                }
            }
        // in pathway and disease new annotations may appear due to
        // transformation of specific xrefs (orphanet...) into
        // annotations in the api
        }
        handleAnnotationTerm(currannot, entry);
        if (apiCategory.equals(AnnotationCategory.MATURE_PROTEIN) || apiCategory.equals(AnnotationCategory.MATURATION_PEPTIDE)) {
            String chainid = currannot.getSynonym();
            if (chainid != null) {
                // " synonyms: " + currannot.getAllSynonyms());
                if (chainid.contains("-"))
                    // Uniprot FT id,
                    addField(Fields.ANNOTATIONS, chainid);
                else // like
                // PRO_0000019235,
                // shouldn't be
                // called a
                // synonym
                {
                    List<String> chainsynonyms = currannot.getSynonyms();
                    if (chainsynonyms.size() == 1)
                        addField(Fields.ANNOTATIONS, StringUtils.getSortedValueFromPipeSeparatedField(desc + " | " + chainid));
                    else {
                        chainid = "";
                        for (String syno : chainsynonyms) {
                            chainid += syno + " | ";
                        }
                        addField(Fields.ANNOTATIONS, StringUtils.getSortedValueFromPipeSeparatedField(chainid));
                    }
                }
            }
        // else System.err.println("chainid null for: " + desc);
        // chainid 's null for the main chain, this is wrong
        }
        // variant xrefs and identifiers
        if (apiCategory.equals(AnnotationCategory.VARIANT)) {
            String evidxrefaccs = "";
            List<AnnotationEvidence> evidences = currannot.getEvidences();
            if (evidences != null)
                for (AnnotationEvidence ev : evidences) {
                    if (ev.isResourceAXref()) {
                        String db = ev.getResourceDb();
                        if (db == null)
                            System.err.println("db is null for evidence in variant annot: " + desc);
                        else {
                            if (!evidxrefaccs.isEmpty())
                                evidxrefaccs += " | ";
                            if (db.equals("Cosmic"))
                                evidxrefaccs += db.toLowerCase() + ":" + ev.getResourceAccession();
                            else if (// Just to allow
                            db.equals("dbSNP"))
                                // comparison with
                                // incoherent
                                // current solr
                                // implementation
                                evidxrefaccs += ev.getResourceAccession();
                            else
                                // Uniprot
                                evidxrefaccs += currannot.getSynonym();
                        // FT
                        // id,
                        // like
                        // VAR_056577
                        }
                    }
                }
            if (!this.isGold() || quality.equals("GOLD")) {
                if (!evidxrefaccs.isEmpty())
                    addField(Fields.ANNOTATIONS, StringUtils.getSortedValueFromPipeSeparatedField(evidxrefaccs));
                Collection<AnnotationProperty> props = currannot.getProperties();
                for (AnnotationProperty prop : props) if (prop.getName().equals("mutation AA"))
                    // eg: p.D1685E, it is unclear why this property
                    // exists only in cosmic variants
                    addField(Fields.ANNOTATIONS, prop.getValue());
            }
        }
    }
    // Families (why not part of Annotations ?), always GOLD
    for (Family family : entry.getOverview().getFamilies()) {
        String ac = family.getAccession();
        int stringpos = 0;
        addField(Fields.ANNOTATIONS, ac);
        String famdesc = family.getDescription();
        // There is no get_synonyms() method for families -> can't access
        // PERVR for FA-04785
        addField(Fields.ANNOTATIONS, famdesc);
        stringpos = famdesc.indexOf("elongs to ") + 14;
        // Skip the 'Belongs to' and
        famdesc = famdesc.substring(stringpos);
        // what may come before (eg:
        // NX_P19021)
        // remove
        famdesc = famdesc.substring(0, famdesc.length() - 1);
        // final dot
        addField(Fields.ANNOTATIONS, famdesc);
        // are there subfamilies
        String[] families = famdesc.split("\\. ");
        // ?
        if (families.length > 1) {
            // Always GOLD
            for (int i = 0; i < families.length; i++) {
                addField(Fields.ANNOTATIONS, families[i]);
                if (families[i].contains(") superfamily")) {
                    // index one
                    // more time
                    // without
                    // parenthesis
                    famdesc = families[i].substring(0, families[i].indexOf("(")) + "superfamily";
                    addField(Fields.ANNOTATIONS, famdesc);
                }
            }
        }
        // Sonetimes these synonymes are wrong eg: NX_Q6NUT3 -> Major
        // facilitator (TC 2.A.1) superfamily
        List<String> famsynonyms = this.terminologyservice.findCvTermByAccession(ac).getSynonyms();
        if (famsynonyms != null)
            for (String famsynonym : famsynonyms) addField(Fields.ANNOTATIONS, famsynonym.trim());
    }
}
Also used : AnnotationCategory(org.nextprot.api.commons.constants.AnnotationCategory) Annotation(org.nextprot.api.core.domain.annotation.Annotation) AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) AnnotationProperty(org.nextprot.api.core.domain.annotation.AnnotationProperty) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Family(org.nextprot.api.core.domain.Family) Map(java.util.Map)

Example 4 with Family

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

the class NamesFieldBuilder method init.

@Override
protected void init(Entry entry) {
    Overview ovv = entry.getOverview();
    // TODO Daniel repeated code in CvFieldBuilder
    List<EntityName> altnames = null;
    altnames = ovv.getProteinNames();
    if (altnames != null)
        for (EntityName altname : altnames) {
            List<EntityName> paltnames = altname.getSynonyms();
            if (paltnames != null)
                for (EntityName paltfullname : paltnames) {
                    if (// Enzymes are delt with elsewhere
                    !paltfullname.getType().equals("enzyme name"))
                        addField(Fields.ALTERNATIVE_NAMES, paltfullname.getName());
                    List<EntityName> paltshortnames = paltfullname.getSynonyms();
                    if (paltshortnames != null)
                        for (EntityName paltshortname : paltshortnames) {
                            if (!paltshortname.getType().equals("enzyme name"))
                                addField(Fields.ALTERNATIVE_NAMES, paltshortname.getName());
                        }
                }
        }
    // special names (INN, allergens)
    altnames = ovv.getAdditionalNames();
    if (altnames != null)
        for (EntityName altname : altnames) {
            // System.err.println(altname.getName());
            addField(Fields.ALTERNATIVE_NAMES, altname.getName());
            String nametype = altname.getType();
            if (nametype.equals("CD antigen"))
                addField(Fields.CD_ANTIGEN, altname.getName());
            else if (nametype.equals("International Nonproprietary Names"))
                addField(Fields.INTERNATIONAL_NAME, altname.getName());
        }
    // The enzymatic activities of a multifunctional enzyme (maybe redundent with getEnzymes)
    altnames = ovv.getFunctionalRegionNames();
    if (altnames != null)
        for (EntityName altname : altnames) {
            // region_name should be renamed activity_name
            addField(Fields.REGION_NAME, altname.getName());
            List<EntityName> paltnames = altname.getSynonyms();
            if (paltnames != null)
                for (EntityName ecname : paltnames) {
                    addField(Fields.REGION_NAME, ecname.getName());
                    List<EntityName> shortnames = ecname.getSynonyms();
                    if (shortnames != null) {
                        for (EntityName xname : shortnames) addField(Fields.REGION_NAME, xname.getName());
                    }
                }
        }
    // Gene names, synonyms and orf names
    List<EntityName> genenames = ovv.getGeneNames();
    if (genenames != null) {
        String allgenenames = null;
        for (EntityName currname : genenames) {
            // Concatenate official gene names
            if (allgenenames == null)
                allgenenames = currname.getName();
            else
                allgenenames += "; " + currname.getName();
            List<EntityName> genesynonames = currname.getSynonyms();
            if (genesynonames != null)
                for (EntityName genesynoname : genesynonames) {
                    if (!genesynoname.getType().equals("open reading frame"))
                        addField(Fields.ALTERNATIVE_GENE_NAMES, genesynoname.getName());
                }
        }
        addField(Fields.RECOMMENDED_GENE_NAMES, allgenenames);
        addField(Fields.RECOMMENDED_GENE_NAMES_S, allgenenames);
        List<String> orfnames = getORFNames(ovv);
        if (orfnames != null)
            for (String orfname : orfnames) addField(Fields.ORF_NAMES, orfname);
    }
    // else System.err.println("no gene names for: " + entry.getUniqueName());
    List<Family> families = ovv.getFamilies();
    String allfamilies = null;
    for (Family family : families) {
        // We choose to index the descriptions (like "Belongs to the DNase II family") instead of the names
        if (// allfamilies = family.getName();
        allfamilies == null)
            // allfamilies = family.getName();
            allfamilies = family.getDescription();
        else
            allfamilies += " , " + family.getDescription();
    }
    if (allfamilies != null) {
        addField(Fields.FAMILY_NAMES, allfamilies);
        addField(Fields.FAMILY_NAMES_S, allfamilies);
    }
}
Also used : EntityName(org.nextprot.api.core.domain.EntityName) Family(org.nextprot.api.core.domain.Family) Overview(org.nextprot.api.core.domain.Overview) List(java.util.List) ArrayList(java.util.ArrayList)

Example 5 with Family

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

the class FamilyDaoImpl method findParentOfFamilyId.

@Override
public Family findParentOfFamilyId(Long familyId) {
    String sql = sqlDictionary.getSQLQuery("parent-family-by-term-id");
    SqlParameterSource namedParameters = new MapSqlParameterSource("familyId", familyId);
    List<Family> parents = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sql, namedParameters, new FamilyRowMapper());
    if (parents == null || parents.size() == 0)
        return null;
    return parents.get(0);
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) Family(org.nextprot.api.core.domain.Family)

Aggregations

Family (org.nextprot.api.core.domain.Family)12 Test (org.junit.Test)6 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)6 ArrayList (java.util.ArrayList)2 Annotation (org.nextprot.api.core.domain.annotation.Annotation)2 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)2 List (java.util.List)1 Map (java.util.Map)1 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)1 CvTerm (org.nextprot.api.core.domain.CvTerm)1 EntityName (org.nextprot.api.core.domain.EntityName)1 Overview (org.nextprot.api.core.domain.Overview)1 AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)1 AnnotationProperty (org.nextprot.api.core.domain.annotation.AnnotationProperty)1 Cacheable (org.springframework.cache.annotation.Cacheable)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)1 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)1