This is a set of functions that I have been using to process an owl graph. Given base name and folder path, it loads and parse a local rdf/xml file and prints some of its content (object properties, individuals, etc).
The code contains the following functions:
create_class_by_nameCreate a class given a nameget_classesGet all classeshas_object_propertiesCheck if instance has object propertiesis_domain_or_rangeReturns true if item is domain or range individual.get_object_propertiesGet all the object properties of the ontologyget_data_propertiesGet all the data properties of the ontologycheck_instanceFind an instance by string nameget_instance_classesGet classes of an instanceget_class_by_nameGet a class by its string nameattach_instance_to_classAttach an instance to a classget_individualsGet all the individuals in the ontologyadd_data_propertyAdd one or more values as data properties of a specific type to an instanceget_uriCreate a uri given the base name and class namecreate_instance_of_classCreate an instance of a classremove_superclassesRemove the superclasses of a given class if they are superclasses of a given super class (if we'd want to attach the given class to the given superclass)attach_class_to_subclassGiven a class name and that class super class name, and a sub class, assign the super class of that subclass, creating it if necessary. There can be more than one super class to assign (csv string).attach_class_to_superclassSame as ```attach_class_to_subclass`` but for subclass,get_classGiven a class name and its super class name, we create that new class if it does not exist or we return the existing oneadd_object_propertyGiven an instance (domain) and an object property, assign another instance by name as range of the domain instance object property. There can be more than one (comma separated).is_instance_of_classReturns True if the instance is of the class name. If descendants input argument is set to True then it looks for the subclasses too.