-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #413 from monarch-initiative/getDomainItemsAnnotat…
…edByOntologyTerm extended interface of AssociationContainer by new method
- Loading branch information
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
phenol-analysis/src/main/java/org/monarchinitiative/phenol/analysis/util/Util.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.monarchinitiative.phenol.analysis.util; | ||
|
||
import org.monarchinitiative.phenol.analysis.ItemAnnotations; | ||
import org.monarchinitiative.phenol.ontology.algo.OntologyAlgorithm; | ||
import org.monarchinitiative.phenol.ontology.data.Ontology; | ||
import org.monarchinitiative.phenol.ontology.data.TermId; | ||
|
||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public class Util { | ||
|
||
public static Set<TermId> getDomainItemsAnnotatedByOntologyTerm(TermId termId, | ||
Ontology ontology, | ||
Map<TermId, ? extends ItemAnnotations<TermId>> gene2associationMap) { | ||
Set<TermId> domainItemSet = new HashSet<>(); | ||
// the following includes termId in the descendent set | ||
Set<TermId> descendentSet = OntologyAlgorithm.getDescendents(ontology, termId); | ||
|
||
for (Map.Entry<TermId, ? extends ItemAnnotations<TermId>> entry : gene2associationMap.entrySet()) { | ||
TermId gene = entry.getKey(); | ||
for (TermId ontologyTermId : entry.getValue().getAnnotatingTermIds()) { | ||
if (descendentSet.contains(ontologyTermId) || ontologyTermId.equals(termId)) { | ||
domainItemSet.add(gene); | ||
} | ||
} | ||
} | ||
|
||
return domainItemSet; | ||
} | ||
|
||
} |