private static Collection<InteractorXref> extractCrossReferencesFrom(Protein protein, String databaseMiRef, String qualifierMiRef) { Collection<InteractorXref> parents = new ArrayList<InteractorXref>(); for (InteractorXref ref : protein.getXrefs()) { if (ref.getCvDatabase().getIdentifier().equals(databaseMiRef)) { if (ref.getCvXrefQualifier().getIdentifier().equals(qualifierMiRef)) { parents.add(ref); } } } return parents; }
private static Collection<InteractorXref> extractCrossReferencesFrom(Protein protein, String databaseMiRef, String qualifierMiRef) { Collection<InteractorXref> parents = new ArrayList<InteractorXref>(); for (InteractorXref ref : protein.getXrefs()) { if (ref.getCvDatabase().getIdentifier().equals(databaseMiRef)) { if (ref.getCvXrefQualifier().getIdentifier().equals(qualifierMiRef)) { parents.add(ref); } } } return parents; }
/** * Retreives Imex identifier stored in the Xrefs. * * @param interaction the interaction to search on. * @return an imex id or null if not found. */ public static String getImexIdentifier(Interaction interaction) { if (interaction == null) { throw new IllegalArgumentException("You must give a non null interaction"); } for (InteractorXref xref : interaction.getXrefs()) { if (CvDatabase.IMEX_MI_REF.equals(xref.getCvDatabase().getIdentifier())) { return xref.getPrimaryId(); } } // Could not find an IMEx id return null; }
/** * Retreives Imex identifier stored in the Xrefs. * * @param interaction the interaction to search on. * @return an imex id or null if not found. */ public static String getImexIdentifier(Interaction interaction) { if (interaction == null) { throw new IllegalArgumentException("You must give a non null interaction"); } for (InteractorXref xref : interaction.getXrefs()) { if (CvDatabase.IMEX_MI_REF.equals(xref.getCvDatabase().getIdentifier())) { return xref.getPrimaryId(); } } // Could not find an IMEx id return null; }
public Collection<GeneralMessage> check( SmallMolecule smallMolecule ) throws SanityRuleException { Collection<GeneralMessage> messages = new ArrayList<GeneralMessage>(); final Collection<InteractorXref> identities = XrefUtils.getIdentityXrefs( smallMolecule ); switch( identities.size() ) { case 0: messages.add( new GeneralMessage( MessageDefinition.SMALL_MOLECULE_IDENTITY_MISSING, smallMolecule ) ); break; case 1: final InteractorXref xref = identities.iterator().next(); if ( ! CvObjectUtils.hasIdentity( xref.getCvDatabase(), CvDatabase.CHEBI_MI_REF ) ) { messages.add( new GeneralMessage(MessageDefinition.SMALL_MOLECULE_IDENTITY_INVALID_DB, smallMolecule ) ); } break; default: // more than 1 messages.add( new GeneralMessage( MessageDefinition.SMALL_MOLECULE_IDENTITY_MULTIPLE, smallMolecule ) ); } return messages; } }
/** * Retreives Imex identifier stored in the Xrefs. * * @param interaction the interaction to search on. * @return an imex id or null if not found. */ public static String getImexIdentifier( Interaction interaction ) { if ( interaction == null ) { throw new IllegalArgumentException( "You must give a non null interaction" ); } for ( InteractorXref xref : interaction.getXrefs() ) { CvObjectXref idCvDatabase = CvObjectUtils.getPsiMiIdentityXref( xref.getCvDatabase() ); if ( idCvDatabase.getPrimaryId().equals( CvDatabase.IMEX_MI_REF ) ) { return xref.getPrimaryId(); } } // Could not find an IMEx id return null; }
/** * Return the xref of the smallMolecule having as cvQualifier, the CvQualifier with psi-mi equal to * CvXrefQualifier.IDENTITY_MI_REF and as cvDatabase, the CvDatabase with psi-mi equal to CvDatabase.CHEBI_MI_REF * and returns it. Return null otherwise. * * @param smallMolecule a non null smallMolecule object. * @return the smallMolecule identity xref if the smallMolecule has one, null otherwise. */ public static InteractorXref getChebiXref(Interactor smallMolecule) { if (smallMolecule == null) { throw new NullPointerException("You must give a non null smallMolecule"); } Collection<InteractorXref> xrefs = smallMolecule.getXrefs(); for (InteractorXref xref : xrefs) { CvXrefQualifier qualifier = xref.getCvXrefQualifier(); if (qualifier != null) { String qualifierIdentity = qualifier.getIdentifier(); if (qualifierIdentity != null && CvXrefQualifier.IDENTITY_MI_REF.equals(qualifierIdentity)) { CvDatabase database = xref.getCvDatabase(); String databaseIdentity = database.getIdentifier(); if (databaseIdentity != null && CvDatabase.CHEBI_MI_REF.equals(databaseIdentity)) { return xref; } } } } return null; }
/** * Return the xref of the protein having as cvQualifier, the CvQualifier with psi-mi equal to * CvXrefQualifier.IDENTITY_MI_REF and as cvDatabase, the CvDatabase with psi-mi equal to CvDatabase.UNIPROT_MI_REF * and returns it. Return null otherwise. * * @param protein a non null Protein object. * @return the uniprotkb identity xref if the protein has one, null otherwise. */ public static InteractorXref getUniprotXref(Interactor protein) { if (protein == null) { throw new NullPointerException("Protein is null, shouldn't be null"); } Collection<InteractorXref> xrefs = protein.getXrefs(); for (InteractorXref xref : xrefs) { CvXrefQualifier qualifier = xref.getCvXrefQualifier(); if (qualifier != null) { String qualifierIdentity = qualifier.getIdentifier(); if (qualifierIdentity != null && CvXrefQualifier.IDENTITY_MI_REF.equals(qualifierIdentity)) { CvDatabase database = xref.getCvDatabase(); String databaseIdentity = database.getIdentifier(); if (databaseIdentity != null && CvDatabase.UNIPROT_MI_REF.equals(databaseIdentity)) { return xref; } } } } return null; }
/** * Return the xref of the protein having as cvQualifier, the CvQualifier with psi-mi equal to * CvXrefQualifier.IDENTITY_MI_REF and as cvDatabase, the CvDatabase with psi-mi equal to CvDatabase.UNIPROT_MI_REF * and returns it. Return null otherwise. * * @param protein a non null Protein object. * @return the uniprotkb identity xref if the protein has one, null otherwise. */ public static InteractorXref getUniprotXref(Interactor protein) { if (protein == null) { throw new NullPointerException("Protein is null, shouldn't be null"); } Collection<InteractorXref> xrefs = protein.getXrefs(); for (InteractorXref xref : xrefs) { CvXrefQualifier qualifier = xref.getCvXrefQualifier(); if (qualifier != null) { String qualifierIdentity = qualifier.getIdentifier(); if (qualifierIdentity != null && CvXrefQualifier.IDENTITY_MI_REF.equals(qualifierIdentity)) { CvDatabase database = xref.getCvDatabase(); String databaseIdentity = database.getIdentifier(); if (databaseIdentity != null && CvDatabase.UNIPROT_MI_REF.equals(databaseIdentity)) { return xref; } } } } return null; }
/** * Return the xref of the smallMolecule having as cvQualifier, the CvQualifier with psi-mi equal to * CvXrefQualifier.IDENTITY_MI_REF and as cvDatabase, the CvDatabase with psi-mi equal to CvDatabase.CHEBI_MI_REF * and returns it. Return null otherwise. * * @param smallMolecule a non null smallMolecule object. * @return the smallMolecule identity xref if the smallMolecule has one, null otherwise. */ public static InteractorXref getChebiXref(Interactor smallMolecule) { if (smallMolecule == null) { throw new NullPointerException("You must give a non null smallMolecule"); } Collection<InteractorXref> xrefs = smallMolecule.getXrefs(); for (InteractorXref xref : xrefs) { CvXrefQualifier qualifier = xref.getCvXrefQualifier(); if (qualifier != null) { String qualifierIdentity = qualifier.getIdentifier(); if (qualifierIdentity != null && CvXrefQualifier.IDENTITY_MI_REF.equals(qualifierIdentity)) { CvDatabase database = xref.getCvDatabase(); String databaseIdentity = database.getIdentifier(); if (databaseIdentity != null && CvDatabase.CHEBI_MI_REF.equals(databaseIdentity)) { return xref; } } } } return null; }
private Collection<ProteinImpl> getProteinByXref(String primaryId, CvDatabase database, CvXrefQualifier qualifier) { XrefDao<InteractorXref> xrefDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getXrefDao(InteractorXref.class); Collection<InteractorXref> xrefs = xrefDao.getByPrimaryId(primaryId, false); Collection<ProteinImpl> proteins = new ArrayList<ProteinImpl>(); for (InteractorXref xref : xrefs) { if ((null != database && database.equals(xref.getCvDatabase())) || (null == database && null == xref.getCvDatabase())) { if ((null != qualifier && qualifier.equals(xref.getCvXrefQualifier())) || (null == qualifier && null == xref.getCvXrefQualifier())) { proteins.add((ProteinImpl) xref.getParent()); } } } return proteins; }
private Collection<ProteinImpl> getProteinByXref(String primaryId, CvDatabase database, CvXrefQualifier qualifier) { XrefDao<InteractorXref> xrefDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getXrefDao(InteractorXref.class); Collection<InteractorXref> xrefs = xrefDao.getByPrimaryId(primaryId, false); Collection<ProteinImpl> proteins = new ArrayList<ProteinImpl>(); for (InteractorXref xref : xrefs) { if ((null != database && database.equals(xref.getCvDatabase())) || (null == database && null == xref.getCvDatabase())) { if ((null != qualifier && qualifier.equals(xref.getCvXrefQualifier())) || (null == qualifier && null == xref.getCvXrefQualifier())) { proteins.add((ProteinImpl) xref.getParent()); } } } return proteins; }
/** * Return the xref of the protein having as cvQualifier, the CvQualifier with psi-mi equal to * CvXrefQualifier.IDENTITY_MI_REF and as cvDatabase, the CvDatabase with psi-mi equal to CvDatabase.UNIPROT_MI_REF * and returns it. Return null otherwise. * @param protein a non null Protein object. * @return the uniprotkb identity xref if the protein has one, null otherwise. */ public static InteractorXref getUniprotXref(Protein protein){ if(protein == null){ throw new NullPointerException("Protein is null, shouldn't be null"); } Collection<InteractorXref> xrefs = protein.getXrefs(); for(InteractorXref xref : xrefs){ CvXrefQualifier qualifier = xref.getCvXrefQualifier(); if(qualifier != null){ CvObjectXref qualifierIdentityXref = CvObjectUtils.getPsiMiIdentityXref(qualifier); if(qualifierIdentityXref!= null && CvXrefQualifier.IDENTITY_MI_REF.equals(qualifierIdentityXref.getPrimaryId())){ CvDatabase database = xref.getCvDatabase(); CvObjectXref databaseIdentityXref = CvObjectUtils.getPsiMiIdentityXref(database); if(databaseIdentityXref != null && CvDatabase.UNIPROT_MI_REF.equals(databaseIdentityXref.getPrimaryId())){ return xref; } } } } return null; }
public Collection<GeneralMessage> check( NucleicAcid nucleicAcid ) throws SanityRuleException { Collection<GeneralMessage> messages = new ArrayList<GeneralMessage>(); Collection<InteractorXref> xrefs = nucleicAcid.getXrefs(); int identityCount = 0; for ( InteractorXref xref : xrefs ) { if ( xref.getCvXrefQualifier() != null ) { CvObjectXref qualifierIdentity = CvObjectUtils.getPsiMiIdentityXref( xref.getCvXrefQualifier() ); if ( qualifierIdentity != null && CvXrefQualifier.IDENTITY_MI_REF.equals( qualifierIdentity.getPrimaryId() ) ) { CvObjectXref databaseIdentity = CvObjectUtils.getPsiMiIdentityXref( xref.getCvDatabase() ); if ( cvDatabaseMis.contains( databaseIdentity.getPrimaryId() ) ) { identityCount++; } else { messages.add( new GeneralMessage(MessageDefinition.NUC_ACID_IDENTITY_INVALID_DB, nucleicAcid ) ); } } } } if ( identityCount > 1 ) { messages.add( new GeneralMessage( MessageDefinition.NUC_ACID_IDENTITY_MULTIPLE, nucleicAcid ) ); } else if ( identityCount == 0 ) { messages.add( new GeneralMessage( MessageDefinition.NUC_ACID_IDENTITY_MISSING, nucleicAcid ) ); } return messages; }
public Collection<GeneralMessage> check(Protein protein) throws SanityRuleException { Collection<GeneralMessage> messages = new ArrayList<GeneralMessage>(); if(!CommonMethods.isNoUniprotUpdate(protein)){ int uniprotIdentityCount = 0; Collection<InteractorXref> xrefs = protein.getXrefs(); for(InteractorXref xref : xrefs){ CvXrefQualifier qualifier = xref.getCvXrefQualifier(); if(qualifier != null){ CvObjectXref qualifierPsiMiXref = CvObjectUtils.getPsiMiIdentityXref(qualifier); if(qualifierPsiMiXref != null && CvXrefQualifier.IDENTITY_MI_REF.equals(qualifierPsiMiXref.getPrimaryId())){ CvObjectXref databasePsiMiXref = CvObjectUtils.getPsiMiIdentityXref(xref.getCvDatabase()); if(databasePsiMiXref != null && CvDatabase.UNIPROT_MI_REF.equals(databasePsiMiXref.getPrimaryId())){ uniprotIdentityCount++; } } } } if(uniprotIdentityCount == 0){ messages.add(new GeneralMessage(MessageDefinition.PROTEIN_UNIPROT_NO_XREF, protein)); }else if(uniprotIdentityCount > 1){ messages.add(new GeneralMessage(MessageDefinition.PROTEIN_UNIPROT_MULTIPLE_XREF, protein)); } } return messages; }
if (!hasFoundIdentity && ref.getCvDatabase() != null && CvDatabase.CHEBI_MI_REF.equals(ref.getCvDatabase().getIdentifier())){
/** * Get the uniprot primary ID from Protein and Splice variant. * * @param protein the Protein for which we want the uniprot ID. * * @return the uniprot ID as a String or null if none is found (should not occur) */ public String getUniprotID(final Protein protein) { if (protAcToUniprotIdCache.containsKey(protein.getAc())) { return protAcToUniprotIdCache.get(protein.getAc()); } String uniprotId = null; Collection<InteractorXref> xrefs = protein.getXrefs(); for (InteractorXref xref : xrefs) { if (getUniprot().getIdentifier().equals(xref.getCvDatabase().getIdentifier()) && getIdentity().equals(xref.getCvXrefQualifier())) { uniprotId = xref.getPrimaryId(); break; } } protAcToUniprotIdCache.put(protein.getAc(), uniprotId); return uniprotId; }
/** * Get the uniprot primary ID from Protein and Splice variant. * * @param protein the Protein for which we want the uniprot ID. * * @return the uniprot ID as a String or null if none is found (should not occur) */ public String getUniprotPrimaryAc(final Protein protein) { if (protAcToUniprotIdCache.containsKey(protein.getAc())) { return protAcToUniprotIdCache.get(protein.getAc()); } String uniprotId = null; Collection<InteractorXref> xrefs = protein.getXrefs(); for (InteractorXref xref : xrefs) { if (getUniprot().equals(xref.getCvDatabase()) && getIdentity().equals(xref.getCvXrefQualifier())) { uniprotId = xref.getPrimaryId(); break; } } protAcToUniprotIdCache.put(protein.getAc(), uniprotId); return uniprotId; } }
/** * Get the uniprot primary ID from Protein and Splice variant. * * @param protein the Protein for which we want the uniprot ID. * * @return the uniprot ID as a String or null if none is found (should not occur) */ public String getUniprotID(final Protein protein) { if (protAcToUniprotIdCache.containsKey(protein.getAc())) { return protAcToUniprotIdCache.get(protein.getAc()); } String uniprotId = null; Collection<InteractorXref> xrefs = protein.getXrefs(); CvDatabase uniprotCv = IntactContext.getCurrentInstance().getCvContext().getByMiRef(CvDatabase.class, CvDatabase.UNIPROT_MI_REF); CvXrefQualifier identityCv = IntactContext.getCurrentInstance().getCvContext().getByMiRef(CvXrefQualifier.class, CvXrefQualifier.IDENTITY_MI_REF); for (InteractorXref xref : xrefs) { if (uniprotCv.equals(xref.getCvDatabase()) && identityCv.equals(xref.getCvXrefQualifier())) { uniprotId = xref.getPrimaryId(); break; } } //ProteinDao proteinDao = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getProteinDao() ; //String uniprotId = proteinDao.getUniprotAcByProteinAc(protein.getAc()); protAcToUniprotIdCache.put(protein.getAc(), uniprotId); return uniprotId; }
/** * Add all the cross references with qualifier 'identity' to the list of identifiers of the protein (intact cross references are ignored) * @param refs : the refs of the protein * @param context : the context of the protein */ private void addIdentityCrossreferencesToContext(Collection<InteractorXref> refs, UpdateContext context){ for (InteractorXref ref : refs){ if (ref.getPrimaryId() != null){ if (ref.getCvXrefQualifier() != null){ CvXrefQualifier qualifier = ref.getCvXrefQualifier(); if (isIdentityCrossReference(qualifier)){ CvDatabase database = ref.getCvDatabase(); if (database != null){ if (database.getIdentifier() != null && !CvDatabase.INTACT_MI_REF.equals(database.getIdentifier())){ context.addIdentifier(database.getIdentifier(), ref.getPrimaryId()); } else if (database.getShortLabel() != null && !CvDatabase.INTACT.equals(database.getShortLabel())) { context.addIdentifier(database.getShortLabel(), ref.getPrimaryId()); } } } } } } }