Metadata#
- class biotite.structure.io.mol.Metadata(metadata=None)[source]#
Bases:
MutableMappingAdditional nonstructural data in an SD record.
The metadata is stored as key-value pairs. As SDF allows multiple different identifiers for keys, the keys are represented by
Metadata.Key.- Parameters:
- metadatadict, optional
The metadata as key-value pairs. Keys are instances of
Metadata.Key. Alternatively, keys can be given as strings, in which case the string is used as theMetadata.Key.name. Values are strings. Line breaks in values are allowed.
Notes
Key names may only contain alphanumeric characters, underscores and periods.
Examples
>>> metadata = Metadata({ ... "foo": "Lorem ipsum", ... Metadata.Key(number=42, name="bar"): "dolor sit amet,\nconsectetur" ... }) >>> print(metadata) > <foo> Lorem ipsum > DT42 <bar> dolor sit amet, consectetur >>> print(metadata["foo"]) Lorem ipsum >>> # Strings can be only used for access, if the key contains only a name >>> print("bar" in metadata) False >>> print(metadata[Metadata.Key(number=42, name="bar")]) dolor sit amet, consectetur
- class Key(*, number: ... = None, name: ... = None, registry_internal: ... = None, registry_external: ... = None)#
Bases:
objectA metadata key.
- Parameters:
- numberint, optional
number of the field in the database.
- namestr, optional
Name of the field. May only contain alphanumeric characters, underscores and periods.
- registry_internalint, optional
Internal registry number.
- registry_externalstr, optional
External registry number.
- Attributes:
- number, name, registry_internal, registry_external
The same as the parameters.
- static deserialize(text)#
Create a
Metadata.Keyobject by deserializing the given text content.- Parameters:
- textstr
The content to be deserialized.
- Returns:
- keyMetadata.Key
The parsed key.
- serialize()#
Convert this object into text content.
- Returns:
- contentstr
The serialized content.
- static deserialize(text)#
Create a
Metadataobjtect by deserializing the given text content.- Parameters:
- textstr
The content to be deserialized.
- Returns:
- metadataMetadata
The parsed metadata.
- serialize()#
Convert this object into text content.
- Returns:
- contentstr
The serialized content.