igvf_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.

igvf_utils.profiles.DEBUG_LOGGER = <Logger iu_debug.igvf_utils.profiles (DEBUG)>

A debug logging instance.

igvf_utils.profiles.ERROR_LOGGER = <Logger iu_error.igvf_utils.profiles (ERROR)>

An error logging instance.

exception igvf_utils.profiles.UnknownProfile[source]

Bases: Exception

Raised when the profile ID in question doesn’t match any known profile ID.

class igvf_utils.profiles.Profiles(igvf_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 igvf_utils.connection.Connection.post(). This class is used to ensure that the profile specified there is a known profile on the Portal.

Parameters:
  • igvf_url – str. The portal URL being submitted to.

  • igvf_urlstr. The igvf_url as specified by Connection.igvf_mode.url.

FILE_PROFILE_ID = ['alignment_file', 'configuration_file', 'genome_browser_annotation_file', 'image_file', 'index_file', 'matrix_file', 'model_file', 'reference_file', 'sequence_file', 'signal_file', 'tabular_file']

Constant storing the profile IDs of all subclasses of File. This is asserted for inclusion in Profile.PROFILES.

SUBMITTED_FILE_PROP_NAME = 'submitted_file_name'

Constant storing a property name of the File subclasses. 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 subclasses. The stored name is asserted for inclusion in the set of File properties.

FILE_SIZE_PROP_NAME = 'file_size'

Constant storing a property name of the File subclasses.

property 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_namestr. 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_idstr. 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:

associationslist.

Returns:

Deduplicated list.