Search in sources :

Example 6 with AnnotationIsoformSpecificity

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

the class DbXrefServiceIntegrationTest method shouldReturn_1_DrugBankXrefAsAnnotation.

@Test
public void shouldReturn_1_DrugBankXrefAsAnnotation() {
    List<Annotation> annotations = this.xrefService.findDbXrefsAsAnnotationsByEntry("NX_Q9Y2D1");
    assertTrue(annotations.size() == 1);
    Annotation annot = annotations.get(0);
    assertTrue(annot.getCategory().equals(AnnotationCategory.SMALL_MOLECULE_INTERACTION.getDbAnnotationTypeName()));
    assertTrue(annot.getAPICategory() == AnnotationCategory.SMALL_MOLECULE_INTERACTION);
    assertTrue(annot.getQualityQualifier().equals("GOLD"));
    Assert.assertEquals("Pseudoephedrine", annot.getDescription());
    for (AnnotationIsoformSpecificity spec : annot.getTargetingIsoformsMap().values()) {
        assertTrue(spec.getSpecificity().equals("UNKNOWN"));
    }
    assertTrue(annot.getEvidences().size() == 1);
    AnnotationEvidence evi = annot.getEvidences().get(0);
    assertTrue(evi.getAssignedBy().equals("DrugBank"));
    assertTrue(evi.getEvidenceCodeAC().equals("ECO:0000305"));
    assertTrue(evi.getResourceAccession().equals("DB00852"));
    assertTrue(evi.getResourceDb().equals("DrugBank"));
    Assert.assertTrue(annotations.get(0).getProperties().isEmpty());
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 7 with AnnotationIsoformSpecificity

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

the class ByAnnotationVariantComparatorTest method mockAnnotationVariant.

private static Annotation mockAnnotationVariant(AnnotationCategory category, String original, String variant, ByIsoformPositionComparatorTest.TargetIsoform... targets) {
    Annotation mock = Mockito.mock(Annotation.class);
    when(mock.getVariant()).thenReturn(new AnnotationVariant(original, variant, ""));
    when(mock.getAPICategory()).thenReturn(category);
    Map<String, AnnotationIsoformSpecificity> map = new HashMap<>();
    for (ByIsoformPositionComparatorTest.TargetIsoform target : targets) {
        AnnotationIsoformSpecificity specificity = Mockito.mock(AnnotationIsoformSpecificity.class);
        when(specificity.getFirstPosition()).thenReturn(target.getStart());
        when(specificity.getLastPosition()).thenReturn(target.getEnd());
        when(specificity.getIsoformAccession()).thenReturn(target.getIsoformAccession());
        when(mock.getStartPositionForIsoform(target.getIsoformAccession())).thenReturn(target.getStart());
        when(mock.getEndPositionForIsoform(target.getIsoformAccession())).thenReturn(target.getEnd());
        map.put(target.getIsoformAccession(), specificity);
    }
    when(mock.getTargetingIsoformsMap()).thenReturn(map);
    return mock;
}
Also used : AnnotationVariant(org.nextprot.api.core.domain.annotation.AnnotationVariant) HashMap(java.util.HashMap) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 8 with AnnotationIsoformSpecificity

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

the class IsoformSequencePositionMapperIntegrationTest method getExpectedPosForEachIsoform.

private Map<String, Integer> getExpectedPosForEachIsoform(Entry entry, Annotation a) {
    Map<String, Integer> isoExpectedPos = new HashMap<String, Integer>();
    for (Isoform isoform : entry.getIsoforms()) {
        String isoname = isoform.getUniqueName();
        AnnotationIsoformSpecificity spec = a.getTargetingIsoformsMap().get(isoname);
        // store variant pos on isoform (default is null)
        isoExpectedPos.put(isoname, null);
        // if variant maps on isoform
        if (spec != null) {
            int p1 = spec.getFirstPosition();
            // store variant position on isoform
            isoExpectedPos.put(isoname, new Integer(p1));
        }
    }
    return isoExpectedPos;
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)

Example 9 with AnnotationIsoformSpecificity

use of org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity 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 10 with AnnotationIsoformSpecificity

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

the class AnnotationUtils method containsAtLeast2NonInclusivePeptides.

// related to  rule to PE1 upgrade
private static boolean containsAtLeast2NonInclusivePeptides(List<Annotation> list, int peptideMinSize, int minCoverage, boolean debug) {
    if (list == null)
        return false;
    for (Annotation a : list) {
        if (a.getAPICategory() != AnnotationCategory.PEPTIDE_MAPPING)
            continue;
        Map<String, AnnotationIsoformSpecificity> timA = a.getTargetingIsoformsMap();
        for (String aIsoAC : timA.keySet()) {
            AnnotationIsoformSpecificity aSpec = timA.get(aIsoAC);
            String aName = getPeptideName(a);
            if (aName == null)
                continue;
            int aP1 = aSpec.getFirstPosition();
            int aP2 = aSpec.getLastPosition();
            int aPepSize = aP2 - aP1 + 1;
            // if < min size => ignore
            if (aPepSize < peptideMinSize)
                continue;
            for (Annotation b : list) {
                if (b.getAPICategory() != AnnotationCategory.PEPTIDE_MAPPING)
                    continue;
                Map<String, AnnotationIsoformSpecificity> timB = b.getTargetingIsoformsMap();
                if (timB.containsKey(aIsoAC)) {
                    AnnotationIsoformSpecificity bSpec = timB.get(aIsoAC);
                    String bName = getPeptideName(b);
                    if (bName == null || aName.equals(bName))
                        continue;
                    int bP1 = bSpec.getFirstPosition();
                    int bP2 = bSpec.getLastPosition();
                    int bPepSize = bP2 - bP1 + 1;
                    // if < min size => ignore
                    if (bPepSize < peptideMinSize)
                        continue;
                    // if b is on the left side of a with or without overlap
                    if (aP1 > bP1 && aP2 > bP2) {
                        int overlap = bP2 - aP1 + 1;
                        if (overlap < 0)
                            overlap = 0;
                        if (aPepSize + bPepSize - overlap >= minCoverage) {
                            if (debug == true) {
                                System.out.println("Found 2 non inclusive peptides on " + aIsoAC + ":" + aName + " at " + aP1 + "-" + aP2 + " and " + bName + " at " + bP1 + "-" + bP2 + " with overlap " + overlap + " and coverage " + (aPepSize + bPepSize - overlap));
                            }
                            return true;
                        }
                    }
                // we get here in the following cases:
                // 1) a includes b or a is included in b => ignore
                // or
                // 2) b is on the right side of a with or without overlap
                // this case is met later on going iterating until a and b are swapped
                // (symmetric situation for a and b)
                }
            }
        }
    }
    return false;
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Aggregations

AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)24 Annotation (org.nextprot.api.core.domain.annotation.Annotation)19 Test (org.junit.Test)12 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)12 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)5 Isoform (org.nextprot.api.core.domain.Isoform)3 ArrayList (java.util.ArrayList)2 AnnotationProperty (org.nextprot.api.core.domain.annotation.AnnotationProperty)2 AnnotationVariant (org.nextprot.api.core.domain.annotation.AnnotationVariant)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 Family (org.nextprot.api.core.domain.Family)1 PepXIsoformMatch (org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch)1 TargetIsoformStatementPosition (org.nextprot.commons.statements.TargetIsoformStatementPosition)1