Reference
Annotation
Class that holds a single annotation entry.
Annotation entries are of the type "term[modifier1,modifier2]".
Source code in src/annotations/annotations.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
__init__(annotation_string)
Create an annotation entry object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
annotation_string
|
str | None
|
An annotation string of the form "term[modifier1,modifier2]". |
required |
Source code in src/annotations/annotations.py
match(term, require_modifiers, exclude_modifiers, *args, **kwargs)
Returns whether this annotation matches the given term. Optionally allows specifying modifiers that need to be present or cannot be present for a positive match.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
term
|
str
|
Annotation term to match. |
required |
require_modifiers
|
set[str] | None
|
Set of modifiers that need to be present for a
positive match. No required modifiers assumed if |
required |
exclude_modifiers
|
set[str] | None
|
Set of modifiers that lead to a negative match if any of them are present. |
required |
Source code in src/annotations/annotations.py
strip_modifiers(modifiers=None)
Returns a new Annotation with the given modifiers removed (if
present), or all modifiers removed if modifiers is None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modifiers
|
set[str] | None
|
Set of modifiers to be removed, or |
None
|
Source code in src/annotations/annotations.py
AnnotationCollection
Bases: Set
Object that parses and processes localisation (or other) annotation strings of the form ".
Source code in src/annotations/annotations.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
__contains__(item)
Returns whether the annotation collection contains the given annotation entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
str | Annotation
|
Either a string of the form "term[modifier1,modifier2]" or
an |
required |
Source code in src/annotations/annotations.py
__init__(annotations_string, annotation_factory=_annotation_factory, annotation_factory_extra_args=())
Creates a new AnnotationCollection from the given annotation
string.
Typical usage example
annotation = AnnotationCollection("cytoplasm[points,weak],nucleoplasm")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
annotations_string
|
str
|
Annotation string of the form "cytoplasm[points,weak],nucleoplasm". |
required |
annotation_factory
|
Callable[[str], Annotation]
|
Optional. A way to specify the function to call to produce a single annotation entry in the collection. |
_annotation_factory
|
Source code in src/annotations/annotations.py
filter_by_modifiers(require_modifiers=None, exclude_modifiers=None)
Returns a new AnnotationCollection containing the Annotation
objects that fulfill the given criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
require_modifiers
|
set[str] | None
|
Set of modifiers that need to be present. No
required modifiers assumed if |
None
|
exclude_modifiers
|
set[str] | None
|
Set of modifiers that cannot be present. |
None
|
Source code in src/annotations/annotations.py
match(term, require_modifiers=None, exclude_modifiers=None, *args, **kwargs)
Returns whether any Annotation in the collection matches the given
term. Optionally allows specifying modifiers that need to be present
or cannot be present for a positive match.
Internally, this calls Annotation.match on each of the Annotation
objects in the collection until it finds a positive match.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
term
|
str
|
Annotation term to match. |
required |
require_modifiers
|
set[str] | None
|
Set of modifiers that need to be present for a
positive match. No required modifiers assumed if |
None
|
exclude_modifiers
|
set[str] | None
|
Set of modifiers that lead to a negative match if any of them are present. |
None
|
Source code in src/annotations/annotations.py
new_from_collection(annotations)
Returns a new AnnotationCollection from the given list of
Annotation objects.
Source code in src/annotations/annotations.py
strip_modifiers(modifiers=None)
Returns a new AnnotationCollection with the given modifiers
removed from the Annotations. Removes all modifiers if modifiers is
None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modifiers
|
set[str] | None
|
Set of modifiers to be removed, or |
None
|
Source code in src/annotations/annotations.py
Ontology
Describes an Annotation ontology tree.
Source code in src/annotations/ontology.py
entries = {}
instance-attribute
Name to entry mapping of all ontology entries.
root_entries = []
instance-attribute
The root entries of the ontology.
OntologyAnnotation
Bases: Annotation
Annotation object that is connected to an annotation ontology.
Source code in src/annotations/ontology.py
__init__(annotation_string, ontology)
Create an annotation entry object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
annotation_string
|
str
|
An annotation string of the form "term[modifier1,modifier2]". |
required |
ontology
|
Ontology
|
Ontology to use for the annotation. |
required |
Source code in src/annotations/ontology.py
OntologyAnnotationCollection
Bases: AnnotationCollection
Annotation collection that is connected to an annotation ontology.
Source code in src/annotations/ontology.py
__init__(annotations_string, ontology)
Create an annotation entry object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
annotations_string
|
str
|
Annotation string of the form "cytoplasm[points,weak],nucleoplasm". |
required |
ontology
|
Ontology
|
Ontology to use for the annotations. |
required |
Source code in src/annotations/ontology.py
match(term, require_modifiers=None, exclude_modifiers=None, recursive=True, *args, **kwargs)
Returns whether any Annotation in the collection matches the given
term. Optionally allows specifying modifiers that need to be present
or cannot be present for a positive match. This also matches any
children of the given ontology term recursively if recursive is
True (the default).
Internally, this calls Annotation.match on each of the Annotation
objects in the collection until it finds a positive match.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
term
|
str
|
Annotation term to match. |
required |
require_modifiers
|
set[str] | None
|
Set of modifiers that need to be present for a
positive match. No required modifiers assumed if |
None
|
exclude_modifiers
|
set[str] | None
|
Set of modifiers that lead to a negative match if any of them are present. |
None
|
recursive
|
bool
|
Whether to match the children of the given ontology term as well. |
True
|
Source code in src/annotations/ontology.py
new_from_collection(annotations)
Returns a new OntologyAnnotationCollection from the given list of
OntologyAnnotation objects.
Source code in src/annotations/ontology.py
OntologyEntry
Describes an entry / level of an annotation ontology.
Source code in src/annotations/ontology.py
__init__(name, synonyms=None, comment=None, ident=None, goterm=None, examples=None)
Create a new ontology entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the entry. |
required |
synonyms
|
tuple[str] | None
|
Tuple of synonyms of the entry. |
None
|
comment
|
str | None
|
Comment associated with the entry. |
None
|
ident
|
str | None
|
N/A |
None
|
goterm
|
str | None
|
GO term identifier. |
None
|
examples
|
list[str] | None
|
List of examples that can be associated with this entry. |
None
|
Source code in src/annotations/ontology.py
add_child(child)
match_term(term, recursive=True)
Returns whether the given term matches the entry's name. Returns
True if any of the entries descendents match if recursive is
True
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
term
|
str
|
Term to check then name against. |
required |
recursive
|
bool
|
Whether to recursively check the entries children. |
True
|