public String getTaxid() { for ( CrossReference crossReference : identifiers ) { if( DEFAULT_DATABASE.equals(crossReference.getDatabase() ) ) { return crossReference.getIdentifier(); } } return null; }
/** * This methods can extract taxIds and organism names from a CrossReference. * It returns a String [] of length 2 with : * - taxId found in the cross reference * - organism name found in cross reference * * If no taxId/organism name can be found, the taxId/organism name which is returned is '-' * @param references : the organism cross references * @return a String [2] with the taxId of the organism and the organism name */ protected String [] extractOrganismFrom(Collection<CrossReference> references){ String taxId = "-"; String organismName = "-"; for (CrossReference ref : references){ // look for the taxId cross reference and get the identifier (taxId) and the organism name (text of a cross reference) if (WriterUtils.TAXID.equalsIgnoreCase(ref.getDatabase())){ taxId = ref.getIdentifier(); if (ref.getText() != null){ organismName = ref.getText(); } } } return new String [] {taxId, organismName}; }
public void enrich(CrossReference xref) throws SolrServerException { if (fieldEnricher.isExpandableOntology(xref.getDatabase())) { String id = xref.getIdentifier(); OntologyTerm ontologyTerm = fieldEnricher.findOntologyTerm(id, null); xref.setText(ontologyTerm.getName()); } }
if (!found && crossReference.getDatabase().equalsIgnoreCase(PSI_MI)) { names.setShortLabel(crossReference.getText()); names.setFullName(crossReference.getText()); dbRef.setId(crossReference.getIdentifier()); dbRef.setRefType(IDENTITY); dbRef.setRefTypeAc(IDENTITY_REF); String database = crossReference.getDatabase(); dbRef.setId(crossReference.getIdentifier()); dbRef.setDb(crossReference.getDatabase()); if (crossReference.hasText()) { Alias alias = new Alias(crossReference.getText()); if (names.getAliases().isEmpty()) { names.getAliases().add(alias);
public int compare(Interactor o1, Interactor o2) { if (o1 == null){ return -1; } else if (o2 == null){ return 1; } final Collection<CrossReference> type1Coll = o1.getInteractorTypes(); final Collection<CrossReference> type2Coll = o2.getInteractorTypes(); CrossReference type1 = (type1Coll != null && !type1Coll.isEmpty()) ? type1Coll.iterator().next() : null; CrossReference type2 = (type2Coll != null && !type2Coll.isEmpty()) ? type2Coll.iterator().next() : null; if (type1 != null && SMALLMOLECULE_MI_REF.equals(type1.getIdentifier())) { return 1; } else if (type2 != null && SMALLMOLECULE_MI_REF.equals(type2.getIdentifier())) { return -1; } return 0; } });
/** * @param collection The values can not be null. * @return */ public static String joinCrossReferencStyleCollection(List<CrossReference> collection) { StringBuilder sb = new StringBuilder(); if (collection != null && !collection.isEmpty()) { Iterator iterator = collection.iterator(); while (iterator.hasNext()) { Object field = iterator.next(); if (field instanceof CrossReference) { CrossReference crossReference = (CrossReference) field; if (crossReference.getDatabase() == null) { crossReference.setDatabase(UNKNOWN); } sb.append(joinAttributes(crossReference.getDatabase(), crossReference.getIdentifier(), crossReference.getText())); } if (iterator.hasNext()) { sb.append(FIELD_DELIMITER); } } } else { sb.append('-'); } return sb.toString(); }
CrossReference id = new CrossReferenceImpl(); id.setDatabase(defaultInstitution); id.setIdentifier(interaction.getAc()); if (refField != null && CvDatabase.IMEX.equalsIgnoreCase(refField.getDatabase()) && CvXrefQualifier.IMEX_PRIMARY.equalsIgnoreCase(refField.getText())){ refField.setText(null); binary.getInteractionAcs().add(refField); else if (refField != null && CvXrefQualifier.IDENTITY.equalsIgnoreCase(refField.getText())){ refField.setText(null); binary.getInteractionAcs().add(refField);
protected void processMiTerms(BinaryInteraction interaction, MiClusterContext context, String intactAc){ List<CrossReference> detectionMethods = interaction.getDetectionMethods(); Map<String, String> miTerms = context.getMiTerms(); for (CrossReference method : detectionMethods){ if (!miTerms.containsKey(method.getIdentifier())){ String methodName = method.getText() != null ? method.getText() : "-"; miTerms.put(method.getIdentifier(), methodName); } } List<CrossReference> types = interaction.getInteractionTypes(); for (CrossReference type : types){ if (!miTerms.containsKey(type.getIdentifier())){ String methodName = type.getText() != null ? type.getText() : "-"; miTerms.put(type.getIdentifier(), methodName); } } String detectionMI = detectionMethods.iterator().next().getIdentifier(); String typeMi = types.iterator().next().getIdentifier(); MethodTypePair entry = new MethodTypePair(detectionMI, typeMi); context.getInteractionToMethod_type().put(intactAc, entry); }
if (speciesSet.contains(crAElement.getText())) { isSpeciesA = true; break; if (speciesSet.contains(crBElement.getText())) { isSpeciesB = true; break; if (cR.getDatabase() != null) { peA.getSource().add(cR.getDatabase()); peB.getSource().add(cR.getDatabase()); interaction.getSource().add(cR.getDatabase());
public boolean matches( CrossReference cr ) { return databases.indexOf(cr.getDatabase() ) != -1; } }
Xref xref = null; if (tabCv.hasText()) { String shortLabel = tabCv.getText(); names = new Names(); names.setShortLabel(shortLabel); if (tabCv.getIdentifier() != null) { String id = tabCv.getIdentifier();
for(String methodId:encoreInteraction.getMethodToPubmed().keySet()){ CrossReference psiDetectionMethod = new CrossReferenceImpl(); psiDetectionMethod.setIdentifier(methodId); if(miMethodOntologyTerms.containsKey(methodId)){ psiDetectionMethod.setText(miMethodOntologyTerms.get(methodId)); psiDetectionMethod.setDatabase("psi-mi"); for(String typeId:encoreInteraction.getTypeToPubmed().keySet()){ CrossReference psiInteractionType = new CrossReferenceImpl(); psiInteractionType.setIdentifier(typeId); if(miTypeOntologyTerms.containsKey(typeId)){ psiInteractionType.setText(miTypeOntologyTerms.get(typeId)); psiInteractionType.setDatabase("psi-mi");
public boolean matches(CrossReference cr) { return texts.indexOf( cr.getText() ) != -1; } }
protected CrossReference createCrossReferenceFromAc(uk.ac.ebi.intact.model.Interactor mol) { CrossReference acField = new CrossReferenceImpl(); String db = defaultInstitution; acField.setDatabase(db); acField.setIdentifier(mol.getAc()); return acField; }
public CrossReference toCrossReference( O cvObject ) { if ( cvObject == null ) { throw new IllegalArgumentException( "CvObject must not be null. " ); } // name of the cv is the fullname String text = cvObject.getFullName()!= null ? cvObject.getFullName() : cvObject.getShortLabel(); String identity = cvObject.getIdentifier(); if(identity == null ) { throw new NullPointerException( cvObject.getClass().getSimpleName() + "("+ text +") didn't have an identity" ); } final CvObjectXref idXref = findMatchingIdentityXref(cvObject.getXrefs(), identity); //XrefUtils.getIdentityXref(cvObject, CvDatabase.PSI_MI_MI_REF); if (idXref != null){ try { CrossReference ref = crossRefConverter.createCrossReference(idXref, false); ref.setText(text); return ref; } catch ( Exception e ) { throw new RuntimeException( "An exception occured while building a cv object : " + text, e ); } } else { CrossReference ref = new CrossReferenceImpl(CrossReferenceConverter.DATABASE_UNKNOWN, identity, text); return ref; } }
if (!found && crossReference.getDatabase().equalsIgnoreCase(PSI_MI)) { String label = crossReference.getText(); if (label != null) { names.setShortLabel(label); dbRef.setDb(PSI_MI); dbRef.setDbAc(PSI_MI_REF); dbRef.setId(crossReference.getIdentifier()); dbRef.setRefType(IDENTITY); dbRef.setRefTypeAc(IDENTITY_REF); String database = crossReference.getDatabase(); dbRef.setId(crossReference.getIdentifier()); dbRef.setDb(crossReference.getDatabase()); if (crossReference.hasText()) { Alias alias = new Alias(crossReference.getText()); if (names.getAliases().isEmpty()) { names.getAliases().add(alias);
@Override public boolean canExportBinaryInteraction(BinaryInteraction<Interactor> interaction, ExportContext context) throws UniprotExportException { Set<CrossReference> detectionMethods = new HashSet(interaction.getDetectionMethods()); Set<String> intactIds = new HashSet<String>(); Set<String> invalidIntactIds = new HashSet<String>(); boolean passRules = false; for (CrossReference method : detectionMethods){ intactIds.clear(); int numberOfExperimentWithThisMethod = computeForBinaryInteractionNumberOfExperimentsHavingDetectionMethod(method.getIdentifier(), context, interaction, intactIds); if (hasPassedInteractionDetectionMethodRules(method.getIdentifier(), numberOfExperimentWithThisMethod)){ logger.info("The method " + method + " has passed the rules"); passRules = true; } else { logger.info("The method " + method + " doesn't pass the rules and will be removed"); invalidIntactIds.addAll(intactIds); } } if (passRules){ removeInteractionEvidencesFrom(interaction, invalidIntactIds, context); } return passRules; }
private String getSpecieName(Organism organism) { String name = null; if (!organism.getIdentifiers().isEmpty()) { final CrossReference first = organism.getIdentifiers().iterator().next(); name = first.getText(); if (name == null || StringUtils.isEmpty(name)) { name = first.getIdentifier(); } } if (name == null) { name = organism.getTaxid(); } return name; }
public BinaryInteraction createInteractionRandom() { BinaryInteraction bi = buildInteraction( createProteinInteractorRandom(), createProteinInteractorRandom() ); CrossReference source = pickRandom( sourceDatabases ); bi.setAuthors( createList( createAuthorRandom() ) ); bi.setConfidenceValues( createList( createConfidenceRandom() ) ); bi.setDetectionMethods( createList( createInteractionDetectionMethodRandom() ) ); bi.setInteractionAcs( createList( createCrossReference( source.getDatabase(), source.getText() + nextId() ) ) ); bi.setInteractionTypes( createList( createInteractionTypeRandom() ) ); bi.setPublications( createList( createCrossReference( "pubmed", String.valueOf( boundRandom( 100000, 999999 ) ) ) ) ); bi.setSourceDatabases( createList( source ) ); return bi; }
public int compare(CrossReference cr1, CrossReference cr2) { int idx1 = databases.indexOf(cr1.getDatabase()); int idx2 = databases.indexOf(cr2.getDatabase()); if( idx1 != -1 || idx2 != -1 ) { matchedAny = true; } int compare = 0; if (idx1 == -1 && idx2 == -1) { compare = 0; } else if (idx1 == -1) { compare = 1; // first is greater } else if (idx2 == -1) { compare = -1; // first is lower } else { compare = idx1 - idx2; // relative to their position in the ordered list of DBs } return compare; }