/** * Checks if the current protein is a chain * * @param protein the protein to check * @return true if the protein is a chain */ public static boolean isFeatureChain(Protein protein) { Collection<InteractorXref> xrefs = protein.getXrefs(); for (InteractorXref xref : xrefs) { if (xref.getCvXrefQualifier() != null) { String qualifierIdentity = xref.getCvXrefQualifier().getIdentifier(); if (CvXrefQualifier.CHAIN_PARENT_MI_REF.equals(qualifierIdentity)) { return true; } } } return false; }
/** * Checks if the current protein is a splice variant * * @param protein the protein to check * @return true if the protein is a splice variant */ public static boolean isSpliceVariant(Protein protein) { Collection<InteractorXref> xrefs = protein.getXrefs(); for (InteractorXref xref : xrefs) { if (xref.getCvXrefQualifier() != null) { String qualifierIdentity = xref.getCvXrefQualifier().getIdentifier(); if (CvXrefQualifier.ISOFORM_PARENT_MI_REF.equals(qualifierIdentity)) { return true; } } } return false; }
/** * Checks if the current protein is a splice variant * * @param protein the protein to check * @return true if the protein is a splice variant */ public static boolean isSpliceVariant(Protein protein) { Collection<InteractorXref> xrefs = protein.getXrefs(); for (InteractorXref xref : xrefs) { if (xref.getCvXrefQualifier() != null) { String qualifierIdentity = xref.getCvXrefQualifier().getIdentifier(); if (CvXrefQualifier.ISOFORM_PARENT_MI_REF.equals(qualifierIdentity)) { return true; } } } return false; }
/** * Checks if the current protein is a chain * * @param protein the protein to check * @return true if the protein is a chain */ public static boolean isFeatureChain(Protein protein) { Collection<InteractorXref> xrefs = protein.getXrefs(); for (InteractorXref xref : xrefs) { if (xref.getCvXrefQualifier() != null) { String qualifierIdentity = xref.getCvXrefQualifier().getIdentifier(); if (CvXrefQualifier.CHAIN_PARENT_MI_REF.equals(qualifierIdentity)) { return true; } } } return false; }
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; }
protected ProteinImpl getProteinTranscriptsMasterProtein( Protein proteinTranscript, String cvXRefQualifier) { if ( proteinTranscript == null ) { throw new NullPointerException( "proteinTranscript must not be null." ); } if ( cvXRefQualifier == null ) { throw new NullPointerException( "The Cv Xref qualifier must not be null." ); } String masterProtAc = null; for (InteractorXref xref : proteinTranscript.getXrefs()) { if (xref.getCvXrefQualifier() != null && cvXRefQualifier.equals(xref.getCvXrefQualifier().getIdentifier())) { if (masterProtAc == null) { masterProtAc = xref.getPrimaryId(); } else { throw new IntactException("This protein transcript contains more than one "+cvXRefQualifier+" xrefs: "+proteinTranscript.getShortLabel() ); } } } // search protein by AC return getByAc(masterProtAc); }
protected ProteinImpl getProteinTranscriptsMasterProtein( Protein proteinTranscript, String cvXRefQualifier) { if ( proteinTranscript == null ) { throw new NullPointerException( "proteinTranscript must not be null." ); } if ( cvXRefQualifier == null ) { throw new NullPointerException( "The Cv Xref qualifier must not be null." ); } String masterProtAc = null; for (InteractorXref xref : proteinTranscript.getXrefs()) { if (xref.getCvXrefQualifier() != null && cvXRefQualifier.equals(xref.getCvXrefQualifier().getIdentifier())) { if (masterProtAc == null) { masterProtAc = xref.getPrimaryId(); } else { throw new IntactException("This protein transcript contains more than one "+cvXRefQualifier+" xrefs: "+proteinTranscript.getShortLabel() ); } } } // search protein by AC return getByAc(masterProtAc); }
/** * 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; }
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; }
/** * 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; }
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(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; }
protected void fixSourceReferenceXrefsIfNecessary(Interaction interaction) { InteractorXref xrefToFix = null; if( ConverterContext.getInstance().isAutoFixInteractionSourceReference() ) { // Look up source reference xref and only try to fix identity if there is no source ref present. // if the qualifier is identity, we will check if the owner identity MI is the same as the database MI for (InteractorXref xref : interaction.getXrefs()) { if (xref.getCvXrefQualifier() != null && getInstitutionPrimaryId() != null && getInstitutionPrimaryId().equals( xref.getPrimaryId() ) && !CvXrefQualifier.SOURCE_REFERENCE_MI_REF.equals(xref.getCvXrefQualifier().getIdentifier())) { xrefToFix = xref; break; } } if ( xrefToFix != null ) { log.warn("Interaction identity xref found pointing to the source database. It should be of type 'source-reference'. Will be fixed automatically: "+xrefToFix); CvXrefQualifier sourceReference = CvObjectUtils.createCvObject(interaction.getOwner(), CvXrefQualifier.class, CvXrefQualifier.SOURCE_REFERENCE_MI_REF, CvXrefQualifier.SOURCE_REFERENCE); xrefToFix.setCvXrefQualifier(sourceReference); addMessageToContext(MessageLevel.WARN, "Interaction identity xref found pointing to the source database. It should be of type 'source-reference'. Fixed.", true); } } }
/** * 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; } }
/** * 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()); } } } } } } }
/** * 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; }