imcljs.path
adjust-path-to-last-class
(adjust-path-to-last-class model path)
Returns a path adjusted to its last class
(adjust-path-to-last-class im-model `Gene.organism.name`)
=> Organism.name
Make sure to add :type-constraints to the model if the path traverses a subclass
(see docstring of `walk` for more information).
attributes
(attributes model path)
Returns all attributes for a given string path.
Make sure to add :type-constraints to the model if the path traverses a subclass
(see docstring of `walk` for more information).
class
(class model path)
Returns the class represented by the path.
(class im-model `Gene.homologues.homologue.symbol`)
=> :Gene
Make sure to add :type-constraints to the model if the path traverses a subclass
(see docstring of `walk` for more information).
class-value
(class-value model class-kw field-kw)
Given a model and a field, return that field from the data model.
A field can be a reference, a collection, or an attribute
In the example :tissue is an attribute of the subclass :FlyAtlasResult
(referenced-class im-model :MicroArrayResult :tissue)
=> :Tissue
class?
(class? model path)
Returns true if path is a class.
(class im-model `Gene.diseases`)
=> true
(class im-model `Gene.diseases.name`)
=> false
Make sure to add :type-constraints to the model if the path traverses a subclass
(see docstring of `walk` for more information).
data-type
(data-type model path)
Return the java type of a path representing an attribute.
(attribute-type im-model `Gene.organism.shortName`)
=> java.lang.String
Make sure to add :type-constraints to the model if the path traverses a subclass
(see docstring of `walk` for more information).
display-name
(display-name model path)
Returns a vector of friendly names representing the path.
Make sure to add :type-constraints to the model if the path traverses a subclass
(see docstring of `walk` for more information).
friendly
(friendly model path & [exclude-root?])
Returns a path as a strong
Make sure to add :type-constraints to the model if the path traverses a subclass
(see docstring of `walk` for more information).
join-path
(join-path path-str)
Join a vector path of keywords to a string.
(join-path [:Gene :organism :shortName])
=> Gene.organism.shortName
one-of?
(one-of? col value)
properties
(properties model class-kw)
Given a model and a class, return its attributes, references and collections.
referenced-class
(referenced-class model field-kw class-kw)
Given a model, a reference/collection, and a class,
return the superclass of the reference/collection.
In the example :tissue is an attribute of the subclass :FlyAtlasResult
(referenced-class im-model :MicroArrayResult :tissue)
=> :Tissue
referenced-type
(referenced-type model field-kw class-kw)
Given a model, a class, and a collection or reference, return the class of the collection or reference.
(referenced-class im-model :Gene :homologues)
=> :Gene
referenced-values
(referenced-values model field-kw class-kw)
Given a model, a class, and a collection or reference, return the class of the collection or reference.
(referenced-class im-model :Gene :homologues)
=> :Gene
relationships
(relationships model path)
Returns all relationships (references and collections) for a given string path.
Make sure to add :type-constraints to the model if the path traverses a subclass
(see docstring of `walk` for more information).
split-path
(split-path path-str)
Split a string path into a vector of keywords.
(split-path `Gene.organism.shortName`)
=> [:Gene :organism :shortName]
subclasses
(subclasses model path)
Returns direct subclasses of the class.
Tip: To get descendant subclasses, you will need to create a graph out of all
the classes' extends key, which is costly and outside the scope of imcljs.
Make sure to add :type-constraints to the model if the path traverses a subclass
(see docstring of `walk` for more information).
trim-to-last-class
(trim-to-last-class model path)
Returns a path string trimmed to the last class
(trim-to-last-class im-model `Gene.homologues.homologue.symbol`)
=> Gene.homologues.homologue
Make sure to add :type-constraints to the model if the path traverses a subclass
(see docstring of `walk` for more information).
un-camel-case
(un-camel-case s)
walk
(walk model path & {:keys [walk-properties?]})
Return a vector representing each part of path.
If any part of the path is unresolvable then a nil is returned.
(walk im-model `Gene.organism.shortName`)
=> [{:name `Gene`, :collections {...}, :attributes {...}}
{:name `Organism`, :collections {...} :attributes {...}
{:name `shortName`, :type `java.lang.String`}]
If the path traverses a subclass, you'll need to add a `:type-constraints`
key to `model` with a value like
[{:path `Gene.interactions.participant2`, :type `Gene`}]
for the path to be resolvable.
(walk im-model-with-type-constraints
`Gene.interactions.participant2.proteinAtlasExpression.tissue.name`)
Optional keyword arguments:
walk-properties? - If true, each element will be the parent's property,
instead of the referencedType. The first element will still be a class as it
has no parent.