In [1]:
# Import deriva modules
from deriva.core import ErmrestCatalog, get_credential
In [2]:
# Connect with the deriva catalog
protocol = 'https'
hostname = 'www.facebase.org'
catalog_number = 1
credential = get_credential(hostname)
catalog = ErmrestCatalog(protocol, hostname, catalog_number, credential)
In [3]:
# Get the path builder interface for this catalog
pb = catalog.getPathBuilder()
In [4]:
pb.schemas.keys()
Out[4]:
Here we will get a handle to the isa schmea.
In [5]:
isa = pb.schemas['isa']
PROTIP: Jupyter Notebook supports <tab> completion. Press the <tab> key
after typing the brackets of a dictionary to see the keys. Typing
pb.schemas[<tab>] will give you a dropdown of schema names. Note that the notebook
interpretter will not know anything about your objects until you have executed a
step with them. So instantiate an object in one step, and then you can use tab-completion
in the following steps.
An alternative way to get a handle to the same schema object is directly as a property of the path builder object itself. However, this only works for schema names that are valid python identifiers.
A valid python identifier may start with '_' or a letter as its first
character and have '_', letters, or numbers for the rest of its characters.
'dataset', 'assay', 'Molecule_Type', etc.'Sample 1 Type', 'Control?', '# of reads', etc.IMPORTANT Similar access methods will be demonstrated for tables and columns below. Since not all catalog model names are valid python identifiers when you use this method, you may not see your catalog's complete data model. However, the notation is more compact and ideal for cases where your model uses (all or mostly) valid python identifiers in its model element names.
In [6]:
isa = pb.isa # same schema object we got from the previous step
In [7]:
isa.tables.keys()
Out[7]:
Similarly we can get a table from the schema's tables property in
both of the demonstrated methods.
In [8]:
dataset = isa.tables['dataset']
# or
dataset = isa.dataset
In [9]:
dataset.column_definitions.keys()
Out[9]:
Again, we have the following methods to get handles to the table's column objects.
In [10]:
accession = dataset.column_definitions['accession']
# or
accession = dataset.accession
The model introspection provided in the datapath module (i.e., the PathBuilder) is intended for the narrowly scoped usage required for building paths and accessing data from ERMrest catalogs. It is not intended for general introspection of catalogs and therefore does not include details such as constraints, annotations, ACLs, column data types, etc.
In [ ]: