/** * TODO: base this methods on the interactor equals (except AC check) */ @Override protected BehaviourType syncedAndCandidateAreEqual(T synced, T candidate) { if (synced == null) return BehaviourType.NEW; if (synced.getXrefs().size() != candidate.getXrefs().size()) { return BehaviourType.UPDATE; } if (synced.getAliases().size() != candidate.getAliases().size()) { return BehaviourType.UPDATE; } return BehaviourType.IGNORE; }
@Override protected boolean update(T candidateObject, T objectToUpdate) throws PersisterException { Collection<InteractorXref> objToUpdateXrefs = objectToUpdate.getXrefs(); for (InteractorXref xref : candidateObject.getXrefs()) { if (!objToUpdateXrefs.contains(xref)) { objectToUpdate.addXref(xref); } } for (InteractorAlias alias : candidateObject.getAliases()) { objectToUpdate.addAlias(alias); } super.updateCommonAttributes(candidateObject, objectToUpdate); return true; } }
/** * 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; }
for ( Iterator iterator = interactor.getXrefs().iterator(); iterator.hasNext(); ) { Xref xref = (Xref) iterator.next();
for ( Iterator iterator = interactor.getXrefs().iterator(); iterator.hasNext(); ) { Xref xref = (Xref) iterator.next();
for ( Iterator iterator = interactor.getXrefs().iterator(); iterator.hasNext(); ) { Xref xref = (Xref) iterator.next();
/** * Enrich the mitab interactor following data best practices for nucleic acids * @param interactor * @param mitabInteractor * @return the standard InchiKey for the small molecule. Can be null if no standard inchi key available */ public void enrichInteractorFromIntact(uk.ac.ebi.intact.model.Interactor interactor, Interactor mitabInteractor){ if (interactor != null && mitabInteractor != null){ Collection<InteractorXref> interactorXrefs = interactor.getXrefs(); Collection<InteractorAlias> aliases = interactor.getAliases(); // xrefs boolean hasFoundIdentity = processXrefs(mitabInteractor, interactorXrefs); // ac and display long processAccessionAndDisplay(interactor, mitabInteractor, hasFoundIdentity); // convert aliases if (!aliases.isEmpty()){ processAliases(mitabInteractor, aliases); } // uses crc64 for checksum if (interactor instanceof Polymer){ Polymer polymer = (Polymer) interactor; if (polymer.getCrc64() != null){ Checksum checksum = new ChecksumImpl(InteractorConverter.CRC64, polymer.getCrc64()); mitabInteractor.getChecksums().add(checksum); } } } }
/** * Enrich the mitab interactor following data best practices for nucleic acids * @param gene * @param mitabInteractor * @return the standard InchiKey for the small molecule. Can be null if no standard inchi key available */ public void enrichGeneFromIntact(uk.ac.ebi.intact.model.Interactor gene, Interactor mitabInteractor){ hasFoundDisplayShort = false; if (gene != null && mitabInteractor != null){ Collection<InteractorXref> interactorXrefs = gene.getXrefs(); Collection<InteractorAlias> aliases = gene.getAliases(); // xrefs boolean hasFoundENSEMBLIdentity = processXrefs(mitabInteractor, interactorXrefs); // convert aliases if (!aliases.isEmpty()){ processAliases(mitabInteractor, aliases); } // ac and display long processAccessionAndDisplay(gene, mitabInteractor, hasFoundENSEMBLIdentity); // uses crc64 for checksum if (gene instanceof Polymer){ Polymer polymer = (Polymer) gene; if (polymer.getCrc64() != null){ Checksum checksum = new ChecksumImpl(InteractorConverter.CRC64, polymer.getCrc64()); mitabInteractor.getChecksums().add(checksum); } } } }
private void indexFields(SolrInputDocument solrDocument) throws SolrServerException { Interactor interactor = component.getInteractor(); if (interactor != null){ // index interactor ac indexInteractorAC(interactor, solrDocument); // index interactor names indexInteractorNames(interactor, solrDocument); // index interactor type enricher.enrichInteractorType(interactor.getCvInteractorType(), solrDocument); // index and enrich xrefs enricher.enrichInteractorXref(interactor.getXrefs(), solrDocument); } // index biological role if (component.getCvBiologicalRole() != null){ enricher.enrichBiologicalRole(component.getCvBiologicalRole(), solrDocument); } // index features indexfeatures(solrDocument); // enrich sons if necessary if (hasSons()){ for (TreeComponents t : sons){ t.indexFields(solrDocument); } } }