public String getBiologicalRoleMi() { if (biologicalRoleMi != null) { return biologicalRoleMi; } biologicalRoleMi = CvObjectUtils.getPsiMiIdentityXref(biologicalRole).getPrimaryId(); return biologicalRoleMi; }
public String getExperimentalRoleMi() { if (experimentalRoleMi != null) { return experimentalRoleMi; } experimentalRoleMi = CvObjectUtils.getPsiMiIdentityXref(experimentalRole).getPrimaryId(); return experimentalRoleMi; }
public static <X extends Xref> X getIdentityXref(AnnotatedObject<X,?> annotatedObject, CvDatabase cvDatabase) { String dbMi = CvObjectUtils.getPsiMiIdentityXref(cvDatabase).getPrimaryId(); for (X xref : annotatedObject.getXrefs()) { CvXrefQualifier qualifier = xref.getCvXrefQualifier(); if (qualifier != null && CvObjectUtils.getPsiMiIdentityXref(qualifier).getPrimaryId().equals(CvXrefQualifier.IDENTITY_MI_REF) && CvObjectUtils.getPsiMiIdentityXref(qualifier).getPrimaryId().equals(dbMi)) { return xref; } } return null; }
public static <X extends Xref> Collection<X> getIdentityXrefs(AnnotatedObject<X,?> annotatedObject) { Collection<X> xrefs = new ArrayList<X>(); for (X xref : annotatedObject.getXrefs()) { CvXrefQualifier qualifier = xref.getCvXrefQualifier(); if (qualifier != null && CvObjectUtils.getPsiMiIdentityXref(qualifier).getPrimaryId().equals(CvXrefQualifier.IDENTITY_MI_REF)) { xrefs.add(xref); } } return xrefs; }
private Collection<ExperimentXref> getAllPrimaryRefToPubmedAndDoi( Experiment experiment ) { Collection<ExperimentXref> xrefs = null; for ( ExperimentXref xref : experiment.getXrefs() ) { CvObjectXref cvDatabaseIdentity = CvObjectUtils.getPsiMiIdentityXref( xref.getCvDatabase() ); if ( cvDatabaseIdentity != null && ( CvDatabase.PUBMED_MI_REF.equals( cvDatabaseIdentity.getPrimaryId() ) || CvDatabase.DOI_MI_REF.equals( cvDatabaseIdentity.getPrimaryId() ) ) ) { CvObjectXref cvXrerQualifierIdentity = CvObjectUtils.getPsiMiIdentityXref( xref.getCvXrefQualifier() ); if ( cvXrerQualifierIdentity != null && CvXrefQualifier.PRIMARY_REFERENCE_MI_REF.equals( cvXrerQualifierIdentity.getPrimaryId() ) ) { if ( xrefs == null ) { xrefs = new ArrayList<ExperimentXref>(); } xrefs.add( xref ); } } } if ( xrefs == null ) return Collections.EMPTY_LIST; return xrefs; } }
/** * 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; }
/** * This class overwrites equals. To ensure proper functioning of HashTable, hashCode must be overwritten, too. * * @return hash code of the object. */ @Override public int hashCode() { int result = super.hashCode(); Xref idXref = CvObjectUtils.getPsiMiIdentityXref( this ); //need check as we still have no-arg constructor... if ( idXref != null ) { result = 29 * result + idXref.getPrimaryId().hashCode(); } else { result = 29 * result + ( ( getShortLabel() == null ) ? 31 : getShortLabel().hashCode() ); } return result; }
final CvObjectXref xref = CvObjectUtils.getPsiMiIdentityXref( interactor.getCvInteractorType() ); if ( xref == 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() ) { 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; }
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; }
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; }
protected String getIdValidationRegexp(AnnotatedObject<?,?> annotatedObject) { String regexp = null; for (Annotation annotation : annotatedObject.getAnnotations()) { if (annotation.getCvTopic() != null) { CvObjectXref idXref = CvObjectUtils.getPsiMiIdentityXref(annotation.getCvTopic()); if (idXref != null && idXref.getPrimaryId().equals(CvTopic.XREF_VALIDATION_REGEXP_MI_REF)) { regexp = annotation.getAnnotationText(); } } } return regexp; } }
/** * Gets the pubmed ID for an Experiment - whitout hitting the database * @param experiment the experiment to get the pubmed id from * @return the pubmed id */ public static String getPubmedId(Experiment experiment) { String pubmedId = null; Publication publication = experiment.getPublication(); if (publication != null) { pubmedId = publication.getShortLabel(); } if (pubmedId == null) { for (ExperimentXref xref : experiment.getXrefs()) { CvObjectXref idQualXref = CvObjectUtils.getPsiMiIdentityXref(xref.getCvXrefQualifier()); CvObjectXref idCvDatabase = CvObjectUtils.getPsiMiIdentityXref(xref.getCvDatabase()); if (idQualXref.getPrimaryId().equals(CvXrefQualifier.PRIMARY_REFERENCE_MI_REF) && idCvDatabase.getPrimaryId().equals(CvDatabase.PUBMED_MI_REF)) { pubmedId = xref.getPrimaryId(); } } } return pubmedId; }
Xref idXref = CvObjectUtils.getPsiMiIdentityXref( this ); Xref idOther = CvObjectUtils.getPsiMiIdentityXref( other );
CvObjectXref topicIdentityXref = CvObjectUtils.getPsiMiIdentityXref( annotation.getCvTopic() ); if ( topicIdentityXref != null ) { topicMi = topicIdentityXref.getPrimaryId();
CvObjectXref identityXref = CvObjectUtils.getPsiMiIdentityXref(role);
CvObjectXref aliasTypeIdentityXref = CvObjectUtils.getPsiMiIdentityXref(aliasType);
/** * TODO: attempt identityXref(mi first and ia next)-cvType and then label-cvType */ @Override protected CvObject fetchFromDataSource( CvObject intactObject ) { // First search by psi-mi identifier CvObjectXref identityXref = CvObjectUtils.getPsiMiIdentityXref(intactObject); if (identityXref != null) { String mi = identityXref.getPrimaryId(); CvObject cvObject = getIntactContext().getDataContext().getDaoFactory() .getCvObjectDao(intactObject.getClass()).getByPsiMiRef(mi); if (cvObject != null) { return cvObject; } } // Failed by MI, try by shortlabel return getIntactContext().getDataContext().getDaoFactory() .getCvObjectDao().getByShortLabel( intactObject.getClass(), intactObject.getShortLabel() ); } }
public static String createKey(AnnotatedObject ao) { String key; final String normalizedClassName = normalizeClassName(ao.getClass()); if (ao instanceof Component) { // So far, components have as shorltabel N/A => we need to create one that allows to discriminate them Component comp = (Component)ao; String label = comp.getInteraction().getShortLabel()+"_"+comp.getInteractor().getShortLabel(); key = normalizedClassName +":"+label; } else if (ao instanceof BioSource) { key = normalizedClassName +":"+((BioSource)ao).getTaxId(); } else if (ao instanceof CvObject) { CvObject cv = (CvObject)ao; CvObjectXref identity = CvObjectUtils.getPsiMiIdentityXref(cv); if (identity != null) { key = normalizedClassName +":"+identity.getPrimaryId(); } else { key = normalizedClassName +":"+ao.getShortLabel(); } } else if (ao instanceof Feature) { String label = ao.getShortLabel()+"_"+createKey(((Feature)ao).getComponent()); key = normalizedClassName+":"+label; } else { key = normalizedClassName +":"+ao.getShortLabel(); } return key; }
@Override protected Institution fetchFromDataSource(Institution intactObject) { InstitutionXref idXref = null; for (InstitutionXref xref : intactObject.getXrefs()) { if (CvObjectUtils.getPsiMiIdentityXref(xref.getCvDatabase()).getPrimaryId() .equals(CvDatabase.PSI_MI_MI_REF)) { idXref = xref; } } if (idXref != null) { return IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getInstitutionDao().getByXref(idXref.getPrimaryId()); } return IntactContext.getCurrentInstance().getDataContext().getDaoFactory() .getInstitutionDao().getByShortLabel(intactObject.getShortLabel()); }