public int compare(InteractorXref o1, InteractorXref o2) { return o1.getPrimaryId().compareTo(o2.getPrimaryId()); } };
public int compare(InteractorXref o1, InteractorXref o2) { return o1.getPrimaryId().compareTo(o2.getPrimaryId()); } };
public int compare(InteractorXref o1, InteractorXref o2) { return o1.getPrimaryId().toLowerCase().compareTo(o2.getPrimaryId().toLowerCase()); } });
public int compare(InteractorXref o1, InteractorXref o2) { return o1.getPrimaryId().toLowerCase().compareTo(o2.getPrimaryId().toLowerCase()); } });
@Override public ProteinUpdateError createInvalidCollectionOfParentsError(String proteinAc, UpdateError errorLabel, Collection<InteractorXref> isoformParents, Collection<InteractorXref> chainParents) { InvalidCollectionOfParents error = new InvalidCollectionOfParents(null, proteinAc, errorLabel); for (InteractorXref ref : isoformParents){ error.getIsoformParents().add(ref.getPrimaryId()); } for (InteractorXref ref : chainParents){ error.getChainParents().add(ref.getPrimaryId()); } return error; }
@Override public ProteinUpdateError createMultiUniprotIdentitiesError(String proteinAc, Collection<InteractorXref> identities) { MultiUniprotIdentities error = new MultiUniprotIdentities(null, proteinAc); for (InteractorXref ref : identities){ error.getUniprotIdentities().add(ref.getPrimaryId()); } return error; }
public PersistentProteinEvent(ProteinUpdateProcess process, Protein protein){ super(process); this.proteinAc = protein != null ? protein.getAc() : null; InteractorXref uniprotXref = ProteinUtils.getUniprotXref(protein); if (uniprotXref != null){ this.uniprotAc = uniprotXref.getPrimaryId(); } else { this.uniprotAc = null; } this.message = 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; }
/** * 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; }
/** * Gets the Interactor Identifiers for that interaction * * @since 1.7.2 */ public static List<String> getInteractorPrimaryIDs(Interaction interaction) { final Collection<Component> components = interaction.getComponents(); List<String> ids = new ArrayList<String>(components.size()); for (Component component : components) { Interactor interactor = component.getInteractor(); final Collection<InteractorXref> idXrefs = XrefUtils.getIdentityXrefs(interactor); if (idXrefs.size() > 0) { final Iterator<InteractorXref> iterator = idXrefs.iterator(); ids.add(iterator.next().getPrimaryId()); if (log.isDebugEnabled()) { if (iterator.hasNext()) { log.debug("Interaction contains interactor with more than one identities. Interaction: " + interaction.getShortLabel() + "(" + interaction.getAc() + ") " + " - Xrefs: " + idXrefs); } } } } return ids; }
/** * Gets the Interactor Identifiers for that interaction * * @since 1.7.2 */ public static List<String> getInteractorPrimaryIDs(Interaction interaction) { final Collection<Component> components = interaction.getComponents(); List<String> ids = new ArrayList<String>(components.size()); for (Component component : components) { Interactor interactor = component.getInteractor(); final Collection<InteractorXref> idXrefs = XrefUtils.getIdentityXrefs(interactor); if (idXrefs.size() > 0) { final Iterator<InteractorXref> iterator = idXrefs.iterator(); ids.add(iterator.next().getPrimaryId()); if (log.isDebugEnabled()) { if (iterator.hasNext()) { log.debug("Interaction contains interactor with more than one identities. Interaction: " + interaction.getShortLabel() + "(" + interaction.getAc() + ") " + " - Xrefs: " + idXrefs); } } } } return ids; }
/** * 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; }
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); }
/** * 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; }
@Override @Transactional( "update" ) public void onDeadProteinFound(DeadUniprotEvent evt) throws ProcessorException { // reattach the updateProcess to the entity manager ProteinUpdateProcess updateProcess = IntactUpdateContext.getCurrentInstance().getUpdateFactory().getEntityManager().merge(this.updateProcess); Protein protein = evt.getProtein(); String identity = evt.getUniprotIdentityXref() != null ? evt.getUniprotIdentityXref().getPrimaryId() : null; Collection<InteractorXref> deletedXrefs = evt.getDeletedXrefs(); DeadProteinEvent proteinEvt = new DeadProteinEvent(updateProcess, protein, identity); if (deletedXrefs != null && !deletedXrefs.isEmpty()){ proteinEvt.addDeletedReferencesFromXref(deletedXrefs); } IntactUpdateContext.getCurrentInstance().getUpdateFactory().getDeadProteinEventDao().persist(proteinEvt); }
/** * 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; } }
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); } } }
@Override @Transactional( "update" ) public void onInvalidIntactParent(InvalidIntactParentFoundEvent evt) throws ProcessorException { // reattach the updateProcess to the entity manager ProteinUpdateProcess updateProcess = IntactUpdateContext.getCurrentInstance().getUpdateFactory().getEntityManager().merge(this.updateProcess); Protein protein = evt.getProtein(); String newParentAc = evt.getNewParentAc(); String oldParentAc = evt.getOldParentAc(); InteractorXref uniprotXref = ProteinUtils.getUniprotXref(evt.getProtein()); String uniprotAc= uniprotXref != null ? uniprotXref.getPrimaryId() : null; IntactTranscriptUpdateEvent protEvt = new IntactTranscriptUpdateEvent(updateProcess, protein, uniprotAc, oldParentAc, newParentAc); IntactUpdateContext.getCurrentInstance().getUpdateFactory().getIntactTranscriptEventDao().persist(protEvt); }
@Override @Transactional( "update" ) public void onSecondaryAcsFound(UpdateCaseEvent evt) throws ProcessorException { // reattach the updateProcess to the entity manager ProteinUpdateProcess updateProcess = IntactUpdateContext.getCurrentInstance().getUpdateFactory().getEntityManager().merge(this.updateProcess); Collection<Protein> secondaryProteins = evt.getSecondaryProteins(); Collection<ProteinTranscript> secondaryIsoforms = evt.getSecondaryIsoforms(); Collection<XrefUpdaterReport> secondaryXrefReports = evt.getXrefUpdaterReports(); for (Protein prot : secondaryProteins){ InteractorXref oldPrimary = ProteinUtils.getUniprotXref(prot); String oldAc = oldPrimary != null ? oldPrimary.getPrimaryId() : null; SecondaryProteinEvent protEvt = new SecondaryProteinEvent(updateProcess, prot, oldAc, evt.getProtein().getPrimaryAc()); IntactUpdateContext.getCurrentInstance().getUpdateFactory().getSecondaryProteinEventDao().persist(protEvt); } for (ProteinTranscript protTrans : secondaryIsoforms){ Protein prot = protTrans.getProtein(); InteractorXref oldPrimary = ProteinUtils.getUniprotXref(prot); String oldAc = oldPrimary != null ? oldPrimary.getPrimaryId() : null; SecondaryProteinEvent protEvt = new SecondaryProteinEvent(updateProcess, prot, oldAc, protTrans.getUniprotVariant().getPrimaryAc()); IntactUpdateContext.getCurrentInstance().getUpdateFactory().getSecondaryProteinEventDao().persist(protEvt); } }