<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def subontology(self, nodes=None, minimal=False, relations=None):
 """ Return a new ontology that is an extract of this one Arguments --------- - nodes: list list of node IDs to include in subontology. If None, all are used - relations: list list of relation IDs to include in subontology. If None, all are used """

        g = None
        if nodes is not None:
            g = self.subgraph(nodes)
        else:
            g = self.get_graph()
        if minimal:
            from ontobio.slimmer import get_minimal_subgraph
            g = get_minimal_subgraph(g, nodes)

        ont = Ontology(graph=g, xref_graph=self.xref_graph) # TODO - add metadata
        if relations is not None:
            g = ont.get_filtered_graph(relations)
            ont = Ontology(graph=g, xref_graph=self.xref_graph)
        return ont