public boolean matches(CrossReference cr) { return texts.indexOf( cr.getText() ) != -1; } }
public int compare(CrossReference cr1, CrossReference cr2) { int idx1 = texts.indexOf(cr1.getText()); int idx2 = texts.indexOf(cr2.getText()); 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 text } return compare; }
/** * 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}; }
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; }
private void processClusterContext(MiClusterContext context, String interactionAc, Collection<BinaryInteraction> toBinary) { // process the context information List<CrossReference> detectionMethods = toBinary.iterator().next().getDetectionMethods(); String detectionMI = detectionMethods.iterator().next().getIdentifier(); if (!context.getMiTerms().containsKey(detectionMI)){ context.getMiTerms().put(detectionMI, detectionMethods.iterator().next().getText()); } List<CrossReference> interactionTypes = toBinary.iterator().next().getInteractionTypes(); String typeMi = interactionTypes.iterator().next().getIdentifier(); if (!context.getMiTerms().containsKey(typeMi)){ context.getMiTerms().put(typeMi, interactionTypes.iterator().next().getText()); } context.getInteractionToMethod_type().put(interactionAc, new MethodTypePair(detectionMI, typeMi)); if (toBinary.size() > 1){ context.getSpokeExpandedInteractions().add(interactionAc); } }
private Interaction createInteraction(BinaryInteraction binaryInteraction) { Interaction interaction = new Interaction(); String interactionType = "undefined"; List<CrossReference> crossReferenceListInteractionTypes = binaryInteraction.getInteractionTypes(); for (CrossReference crossReference : crossReferenceListInteractionTypes) { interactionType = crossReference.getText(); } if (ASSEMBLY_PATTERN.matcher(interactionType).matches()) { interaction = createAssembly(binaryInteraction); } else if (Pattern.matches("colocalization", interactionType)) { interaction = createColocalization(binaryInteraction); } return interaction; }
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); }
/** * @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(); }
if ( "gene name".equals( altIdentifier.getText() ) ) { if ( "uniprotkb".equals( altIdentifier.getDatabase() ) ) { interactorId = altIdentifier.getIdentifier().toLowerCase(); if ( interactor.hasOrganism() ) { for ( CrossReference organism : interactor.getOrganism().getIdentifiers() ) { String name = organism.getText(); if ( name != null ) { organismName = name.toLowerCase();
String shortLabel = tabCv.getText(); names = new Names(); names.setShortLabel(shortLabel);
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);
ontology.setSource(cR.getDatabase()); ontology.setId(cR.getIdentifier()); ontology.setName(cR.getText()); interaction.setOntology(ontology); } else if (source.equals("pubmed")) {
ontology.setSource(cR.getDatabase()); ontology.setId(cR.getIdentifier()); ontology.setName(cR.getText()); physicalEntity.setOntology(ontology); } else if (source.equals("pubmed")) {
List<CrossReference> crossReferenceListInteractorTypes = interactor.getInteractorTypes(); for (CrossReference crossReference : crossReferenceListInteractorTypes) { interactorType = crossReference.getText();
List<CrossReference> crossReferenceListInteractorTypes = interactor.getInteractorTypes(); for (CrossReference crossReference : crossReferenceListInteractorTypes) { interactorType = crossReference.getText();
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; }