for(String acc:mappingEcoreInteraction.getInteractorAccsA().values()){ if(encoreInteraction.getInteractorAccsA().containsValue(acc)){ swapInteractors = false; break swap_loop; mappingEcoreInteraction.addInteractorAccsA(encoreInteraction.getInteractorAccsB()); mappingEcoreInteraction.addInteractorAccsB(encoreInteraction.getInteractorAccsA()); mappingEcoreInteraction.addOtherInteractorAccsA(encoreInteraction.getOtherInteractorAccsB()); mappingEcoreInteraction.addOtherInteractorAccsB(encoreInteraction.getOtherInteractorAccsA()); mappingEcoreInteraction.addOrganismsA(encoreInteraction.getOrganismsB()); mappingEcoreInteraction.addOrganismsB(encoreInteraction.getOrganismsA()); } else{ mappingEcoreInteraction.addInteractorAccsA(encoreInteraction.getInteractorAccsA()); mappingEcoreInteraction.addInteractorAccsB(encoreInteraction.getInteractorAccsB()); mappingEcoreInteraction.addOtherInteractorAccsA(encoreInteraction.getOtherInteractorAccsA()); mappingEcoreInteraction.addOtherInteractorAccsB(encoreInteraction.getOtherInteractorAccsB()); mappingEcoreInteraction.addOrganismsA(encoreInteraction.getOrganismsA()); mappingEcoreInteraction.addOrganismsB(encoreInteraction.getOrganismsB()); mappingEcoreInteraction.addPublicationId(encoreInteraction.getPublicationIds()); mappingEcoreInteraction.addExperimentToPubmed(encoreInteraction.getExperimentToPubmed()); mappingEcoreInteraction.addExperimentToDatabase(encoreInteraction.getExperimentToDatabase()); processMethodAndType(encoreInteraction, mappingEcoreInteraction); mappingEcoreInteraction.addAuthors(encoreInteraction.getAuthors()); mappingEcoreInteraction.addConfidenceValues(encoreInteraction.getConfidenceValues()); mappingEcoreInteraction.addSourceDatabases(encoreInteraction.getSourceDatabases()); mappingEcoreInteraction.getDistinctPublications().addAll(encoreInteraction.getDistinctPublications()); return mappingEcoreInteraction;
@Override public boolean canExportEncoreInteraction(EncoreInteraction encore, ExportContext context) throws UniprotExportException { double score = FilterUtils.getMiClusterScoreFor(encore); if (score >= positive_export_threshold){ if (encore.getExperimentToDatabase() == null){ throw new UniprotExportException("The interaction " + encore.getId() + ":" + encore.getInteractorA() + "-" + encore.getInteractorB() +" doesn't have any references to IntAct."); } Set<String> intactInteractions = new HashSet<String>(); intactInteractions.addAll(encore.getExperimentToPubmed().keySet()); if (intactInteractions.isEmpty()){ throw new UniprotExportException("The interaction " + encore.getId() + ":" + encore.getInteractorA() + "-" + encore.getInteractorB() +" doesn't have any references to IntAct."); } for (String ac : intactInteractions){ if (!context.getSpokeExpandedInteractions().contains(ac)){ String type = context.getInteractionToMethod_type().get(ac).getType(); if (!type.equals(COLOCALIZATION)){ logger.info("The interaction " + encore.getId() + " passed the export rules with score = " + score); return true; } } } } return false; }
@Override protected void processMethodAndType(EncoreInteraction encoreInteraction, EncoreInteraction mappingEncoreInteraction) { mappingEncoreInteraction.addMethodToPubmed(encoreInteraction.getMethodToPubmed()); mappingEncoreInteraction.addTypeToPubmed(encoreInteraction.getTypeToPubmed()); }
String uniprot2; if (interaction.getInteractorAccsA().containsKey(WriterUtils.UNIPROT)){ uniprot1 = FilterUtils.extractUniprotAcFromAccs(interaction.getInteractorAccsA()); uniprot1 = FilterUtils.extractUniprotAcFromOtherAccs(interaction.getOtherInteractorAccsA()); if (interaction.getInteractorAccsB().containsKey(WriterUtils.UNIPROT)){ uniprot2 = FilterUtils.extractUniprotAcFromAccs(interaction.getInteractorAccsB()); uniprot2 = FilterUtils.extractUniprotAcFromOtherAccs(interaction.getOtherInteractorAccsB()); Set<String> pubmedIds = FilterUtils.extractPubmedIdsFrom(interaction.getPublicationIds());
String encoreInteractorA = encoreInteraction.getInteractorA(mappingIdDbNames); Map<String,String> encoreInteractorAccsA = encoreInteraction.getInteractorAccsA(); updateIdentifiers(psiIdentifierA, psiAlternativeIdentifierA, encoreInteractorAccsA, encoreInteractorA); List<CrossReference> psiIdentifierB= new ArrayList<CrossReference>(); List<CrossReference> psiAlternativeIdentifierB= new ArrayList<CrossReference>(); String encoreInteractorB = encoreInteraction.getInteractorB(mappingIdDbNames); Map<String,String> encoreInteractorAccsB = encoreInteraction.getInteractorAccsB(); updateIdentifiers(psiIdentifierB, psiAlternativeIdentifierB, encoreInteractorAccsB, encoreInteractorB); Map<String, List<String>> encoreOtherInteractorA = encoreInteraction.getOtherInteractorAccsA(); updateAlias(psiAliasA,encoreOtherInteractorA); List<Alias> psiAliasB = new ArrayList<Alias>(); Map<String, List<String>> encoreOtherInteractorB = encoreInteraction.getOtherInteractorAccsB(); updateAlias(psiAliasB,encoreOtherInteractorB); psiOrganismA.setIdentifiers(encoreInteraction.getOrganismsA()); Organism psiOrganismB = new OrganismImpl(); psiOrganismB.setIdentifiers(encoreInteraction.getOrganismsB()); for(MethodTypePair pair : encoreInteraction.getMethodTypePairListMap().keySet()){ Collection<String> pubmedIds = encoreInteraction.getMethodTypePairListMap().get(pair); Map<String, List<String>> experimentToDatabase = encoreInteraction.getExperimentToDatabase(); if(experimentToDatabase != null){ for(String expAc:experimentToDatabase.keySet()){ if(expAc == null || expAc.length()==0){ log.warn( "Could not process experimentAc ("+(expAc == null ? "null" : "'"+expAc+"'")+") of EncoreInteraction(id="+ encoreInteraction.getId()+") as it is null or empty " ); continue; // skip this experimentAC
if (interaction.getInteractorAccsA().containsKey(WriterUtils.UNIPROT)){ uniprot1 = FilterUtils.extractUniprotAcFromAccs(interaction.getInteractorAccsA()); uniprot1 = FilterUtils.extractUniprotAcFromOtherAccs(interaction.getOtherInteractorAccsA()); if (interaction.getInteractorAccsB().containsKey(WriterUtils.UNIPROT)){ uniprot2 = FilterUtils.extractUniprotAcFromAccs(interaction.getInteractorAccsB()); uniprot2 = FilterUtils.extractUniprotAcFromOtherAccs(interaction.getOtherInteractorAccsB()); if (interaction.getInteractorAccsA().containsKey(WriterUtils.INTACT)){ intact1 = FilterUtils.extractIntactAcFromAccs(interaction.getInteractorAccsA()); intact1 = FilterUtils.extractIntactAcFromOtherAccs(interaction.getOtherInteractorAccsA()); if (interaction.getInteractorAccsB().containsKey(WriterUtils.INTACT)){ intact2 = FilterUtils.extractIntactAcFromAccs(interaction.getInteractorAccsB()); intact2 = FilterUtils.extractIntactAcFromOtherAccs(interaction.getOtherInteractorAccsB()); organismsA = extractOrganismFrom(interaction.getOrganismsA()); organismsB = extractOrganismFrom(interaction.getOrganismsB()); if (interaction.getInteractorAccsA().containsKey(WriterUtils.UNIPROT)){ uniprot1 = FilterUtils.extractUniprotAcFromAccs(interaction.getInteractorAccsA()); uniprot1 = FilterUtils.extractUniprotAcFromOtherAccs(interaction.getOtherInteractorAccsA()); if (interaction.getInteractorAccsB().containsKey(WriterUtils.UNIPROT)){
protected void removeInteractionEvidencesFrom(EncoreInteraction encore, Set<String> wrongInteractions, ExportContext context){ List<CrossReference> publicationsToRemove = new ArrayList(encore.getPublicationIds()); List<String> publicationIdsToKeep = new ArrayList<String>(encore.getPublicationIds().size()); List<String> methodsToRemove = new ArrayList(encore.getMethodToPubmed().keySet()); List<String> typesToRemove = new ArrayList(encore.getTypeToPubmed().keySet()); Collection<String> validInteractions = CollectionUtils.subtract(encore.getExperimentToPubmed().keySet(), wrongInteractions); String pubmedId = encore.getExperimentToPubmed().get(interactionAc); for (CrossReference ref : encore.getPublicationIds()){ if (ref.getIdentifier().equals(pubmedId)){ publicationsToRemove.remove(ref); for (String method : encore.getMethodToPubmed().keySet()){ if (method.equals(detectionMI)){ methodsToRemove.remove(method); for (String type : encore.getTypeToPubmed().keySet()){ if (type.equals(typeMi)){ typesToRemove.remove(type); encore.getPublicationIds().removeAll(publicationsToRemove); encore.getMethodToPubmed().remove(methodToRemove); encore.getTypeToPubmed().remove(typeToRemove); for (Map.Entry<String, List<String>> entry : encore.getMethodToPubmed().entrySet()){ pubmedsToRemove.clear();
EncoreInteraction eI = this.getInteractionMapping().get(interactionId); logger.debug("= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ="); logger.debug("IntA: "+ eI.getInteractorA() + " , IntB: " + eI.getInteractorB()); Map<MethodTypePair, List<String>> methodTypeToPudmed = eI.getMethodTypePairListMap(); for(MethodTypePair methodType:methodTypeToPudmed.keySet()){ List<String> uniquePublications = eI.getMethodTypePairListMap().get(methodType); int numberOfPubmedIds = eI.getDistinctPublications().size(); List<Confidence> confidenceValues = eI.getConfidenceValues(); confidenceValueLoop: for(Confidence confidenceValue:confidenceValues){ confidenceValue.setValue(scoreResult.toString()); confidenceValue.setType(getScoreName()); eI.addConfidenceValue(confidenceValue);
int i = 0; for(EncoreInteraction eI:this.getInteractionMapping().values()){ List<Confidence> confidenceValues = eI.getConfidenceValues(); Double score = null; for(Confidence confidenceValue:confidenceValues){ logger.error("No score for this interaction: " + eI.getId()); scoreList[i] = eI.getId() + "-" +eI.getInteractorA() + "-" + eI.getInteractorB() + ":" + score; scoreListCSV = scoreListCSV + scoreList[i]; i++;
fstream.write(Integer.toString(eI.getId())); fstream.write("-"); fstream.write(eI.getInteractorA()); fstream.write("-"); fstream.write(eI.getInteractorB()); fstream.write(":" + score); fstream.write("\n");
@Override public boolean canExportEncoreInteraction(EncoreInteraction interaction, ExportContext context) throws UniprotExportException { Set<String> detectionMethods = new HashSet(interaction.getMethodToPubmed().keySet()); logger.info("Binary Interaction " + interaction.getId() + " : the method " + method + " has passed the rules"); passRules = true; logger.info("Binary Interaction " + interaction.getId() + " : the method " + method + " doesn't pass the rules and will be removed"); invalidIntactIds.addAll(validIntactIds);
public EncoreInteraction getEncoreInteractionForScoring(BinaryInteraction binaryInteraction) { EncoreInteraction encoreInteraction = new EncoreInteraction(); encoreInteraction.getDistinctPublications().add(pubmed); if (encoreInteraction.getMethodTypePairListMap().containsKey(pair)){ encoreInteraction.getMethodTypePairListMap().get(pair).add(pubmed); encoreInteraction.getMethodTypePairListMap().put(pair, pubmeds); if (encoreInteraction.getMethodTypePairListMap().containsKey(pair)){ encoreInteraction.getMethodTypePairListMap().get(pair).add(pubmed); encoreInteraction.getMethodTypePairListMap().put(pair, pubmeds); if (encoreInteraction.getMethodTypePairListMap().containsKey(pair)){ encoreInteraction.getMethodTypePairListMap().get(pair).add(pubmed); encoreInteraction.getMethodTypePairListMap().put(pair, pubmeds); if (encoreInteraction.getMethodTypePairListMap().containsKey(pair)){ encoreInteraction.getMethodTypePairListMap().get(pair).add(pubmed); encoreInteraction.getMethodTypePairListMap().put(pair, pubmeds); if (encoreInteraction.getMethodTypePairListMap().containsKey(pair)){ encoreInteraction.getMethodTypePairListMap().get(pair).add(pubmed); encoreInteraction.getMethodTypePairListMap().put(pair, pubmeds);
public double[] getScores(){ if(this.getInteractionMapping() == null){ runService(); } int scoreListSize = this.getInteractionMapping().size(); double [] scores = new double[scoreListSize]; int i = 0; for(EncoreInteraction eI:this.getInteractionMapping().values()){ List<Confidence> confidenceValues = eI.getConfidenceValues(); Double score = null; for(Confidence confidenceValue:confidenceValues){ if(confidenceValue.getType().equalsIgnoreCase(getScoreName())){ score = Double.parseDouble(confidenceValue.getValue()); } } if(score == null){ logger.error("No score for this interaction: " + eI.getId()); } scores[i] = score; i++; } return scores; }
Map<String, String> interactionToPubmed = interaction.getExperimentToPubmed(); Map<MethodTypePair, List<String>> distinctInformationDetails = interaction.getMethodTypePairListMap();
/** * * @param interaction * @return the computed Mi cluster score for this interaction */ public static double getMiClusterScoreFor(EncoreInteraction interaction){ List<Confidence> confidenceValues = interaction.getConfidenceValues(); return extractMiClusterScoreFrom(confidenceValues); }
@Override protected void processMethodAndType(EncoreInteraction encoreInteraction, EncoreInteraction mappingEncoreInteraction) { Map<MethodTypePair, List<String>> existingMethodTypeToPubmed = mappingEncoreInteraction.getMethodTypePairListMap(); for (Map.Entry<MethodTypePair, List<String>> entry : encoreInteraction.getMethodTypePairListMap().entrySet()){ if (existingMethodTypeToPubmed.containsKey(entry.getKey())){ List<String> existingPubmeds = existingMethodTypeToPubmed.get(entry.getKey()); List<String> newPubmeds = encoreInteraction.getMethodTypePairListMap().get(entry.getKey()); for (String pub : newPubmeds){ existingPubmeds.add(pub); } } else{ existingMethodTypeToPubmed.put(entry.getKey(), entry.getValue()); } } }
private int computeNumberOfExperimentsHavingDetectionMethod(String method, ExportContext context, EncoreInteraction interaction, Set<String> validIntactIds){ Map<MethodTypePair, List<String>> invertedMap = WriterUtils.invertMapFromKeySelection(context.getInteractionToMethod_type(), interaction.getExperimentToPubmed().keySet()); int numberOfExperiment = 0; for (Map.Entry<MethodTypePair, List<String>> entry : invertedMap.entrySet()){ if (entry.getKey().getMethod().equals(method)){ numberOfExperiment += entry.getValue().size(); validIntactIds.addAll(entry.getValue()); } } return numberOfExperiment; }
List<String> intact2; if (encore.getInteractorAccsA().containsKey(WriterUtils.INTACT)){ intact1 = FilterUtils.extractAllIntactAcFromAccs(encore.getInteractorAccsA()); intact1 = FilterUtils.extractAllIntactAcFromOtherAccs(encore.getOtherInteractorAccsA()); if (encore.getInteractorAccsB().containsKey(WriterUtils.INTACT)){ intact2 = FilterUtils.extractAllIntactAcFromAccs(encore.getInteractorAccsB()); intact2 = FilterUtils.extractAllIntactAcFromOtherAccs(encore.getOtherInteractorAccsB());
String uniprot2; if (interaction.getInteractorAccsA().containsKey(WriterUtils.UNIPROT)){ uniprot1 = FilterUtils.extractUniprotAcFromAccs(interaction.getInteractorAccsA()); uniprot1 = FilterUtils.extractUniprotAcFromOtherAccs(interaction.getOtherInteractorAccsA()); if (interaction.getInteractorAccsB().containsKey(WriterUtils.UNIPROT)){ uniprot2 = FilterUtils.extractUniprotAcFromAccs(interaction.getInteractorAccsB()); uniprot2 = FilterUtils.extractUniprotAcFromOtherAccs(interaction.getOtherInteractorAccsB()); String intact2; if (interaction.getInteractorAccsA().containsKey(WriterUtils.INTACT)){ intact1 = FilterUtils.extractIntactAcFromAccs(interaction.getInteractorAccsA()); intact1 = FilterUtils.extractIntactAcFromOtherAccs(interaction.getOtherInteractorAccsA()); if (interaction.getInteractorAccsB().containsKey(WriterUtils.INTACT)){ intact2 = FilterUtils.extractIntactAcFromAccs(interaction.getInteractorAccsB()); intact2 = FilterUtils.extractIntactAcFromOtherAccs(interaction.getOtherInteractorAccsB()); organismsA = extractOrganismFrom(interaction.getOrganismsA()); organismsB = extractOrganismFrom(interaction.getOrganismsB()); int numberEvidences = interaction.getExperimentToPubmed().size();
String score = null; for(Confidence confidenceValue:eI.getConfidenceValues()){ if(confidenceValue.getType().equalsIgnoreCase(getScoreName())){ score = confidenceValue.getValue();