encode_utils.profiles¶
Contains a Profile
class for working with profiles on the ENCODE Portal. Note that
the terms ‘profile’ and ‘schema’ are used interchangeably in this package.
-
encode_utils.profiles.
DEBUG_LOGGER
= <Logger eu_debug.encode_utils.profiles (DEBUG)>¶ A debug
logging
instance.
-
encode_utils.profiles.
ERROR_LOGGER
= <Logger eu_error.encode_utils.profiles (ERROR)>¶ An error
logging
instance.
-
exception
encode_utils.profiles.
UnknownProfile
[source]¶ Bases:
Exception
Raised when the profile ID in question doesn’t match any known profile ID.
-
class
encode_utils.profiles.
Profiles
(dcc_url)[source]¶ Bases:
object
Encapsulates knowledge about the existing profiles on the Portal and contains useful methods for working with a given profile.
A defining purpose of this class is to validate the profile ID specified in a POST payload passed to
encode_utils.connection.Connection.post()
. This class is used to ensure that the profile specified there is a known profile on the Portal.Parameters: - dcc_url – str. The portal URL being submitted to.
- dcc_url – str. The dcc_url as specified by Connection.dcc_mode.url.
-
FILE_PROFILE_ID
= 'file'¶ Constant storing the file.json profile’s ID. This is asserted for inclusion in
Profile.PROFILES
.
-
SUBMITTED_FILE_PROP_NAME
= 'submitted_file_name'¶ Constant storing a property name of the file.json profile. The stored name is asserted for inclusion in the set of File properties.
-
MD5SUM_NAME_PROP_NAME
= 'md5sum'¶ Constant storing a property name of the file.json profile. The stored name is asserted for inclusion in the set of File properties.
-
FILE_SIZE_PROP_NAME
= 'file_size'¶ Constant sotring a property name of the file.json profile.
-
profiles
¶ Constant (dict) set to the return value of the function
self.get_profiles()
. See documentation there for details.
-
profiles_with_property
(property_name)[source]¶ Returns a list of profile names that have a given property.
Parameters: property_name – str. The name of the property. Returns: list of profile names.
-
get_profile_from_id
(at_id)[source]¶ Normalizes the profile_id so that it matches the format of the profile IDs stored in
self.profiles
, and ensures that the normalized profile ID is a member of this list.Parameters: at_id – str. An @id from the portal, e.g. /biosamples/ENCBS123ABC/
Returns: The normalized profile ID.
Return type: str
Raises: UnknownProfile
– The normalized profile ID is not a member of the list- self.profiles.
-
remove_duplicate_associations
(associations)[source]¶ Checks for duplicates in array properties containing string elements. Need to be careful as some cases can be tricky, i.e.
[‘/documents/id1’, ‘id1’]Such a duplicate should be identified and removed, leaving us with [“id1”].
Parameters: associations – list. Returns: Deduplicated list.