Skip to content

Commit 6147443

Browse files
committed
Honor direct flag when retrieving children via additional properties
1 parent 54b3bf5 commit 6147443

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/ubic/basecode/ontology/jena/JenaUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import java.util.*;
1414
import java.util.function.Predicate;
1515

16+
import static com.hp.hpl.jena.reasoner.ReasonerRegistry.makeDirect;
17+
1618
public class JenaUtils {
1719

1820
public static Collection<OntClass> getParents( OntModel model, Collection<OntClass> ontClasses, boolean direct, @Nullable Set<Restriction> additionalRestrictions ) {
@@ -80,6 +82,9 @@ public static Collection<OntClass> getChildren( OntModel model, Collection<OntCl
8082
timer.reset();
8183
timer.start();
8284
Property subClassOf = model.getProfile().SUB_CLASS_OF();
85+
if ( direct ) {
86+
subClassOf = ResourceFactory.createProperty( makeDirect( subClassOf.getURI() ) );
87+
}
8388
Set<Restriction> restrictions = UniqueExtendedIterator.create( additionalRestrictions.iterator() )
8489
.filterKeep( new RestrictionWithValuesFromFilter( terms ) )
8590
.toSet();

test/ubic/basecode/ontology/OntologyTermTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ public void testGetParentsHasPart() {
272272
public void testGetChildrenHasPart() {
273273
OntologyTerm t = uberon.getTerm( "http://purl.obolibrary.org/obo/UBERON_0000955" );
274274
assertNotNull( t );
275+
assertEquals( 76, t.getChildren( true ).size() );
275276
Collection<OntologyTerm> children = t.getChildren( false );
276277
assertEquals( 1496, children.size() );
277278
// via subclass of, insect adult brain

0 commit comments

Comments
 (0)