Track

Tracks represent annotations associated with the full length of the protein (i.e. per-residue sequence annotations). Tracks are added to proteins using the Protein.add_track() function, or using functions in the shephard.interfaces.si_tracks module.

Tracks must have a track name, as well as either a per-residue symbol annotation or per-residue value annotation, meaning Tracks can be either symbol tracks of value tracks.

Tracks for a given protein can be called using the protein.track(<track name>) function.

Tracks can be removed from proteins using Protein.remove_track() function.

class Track(name, protein, values=None, symbols=None, attribute_dictionary=None)[source]

Track Properties

name()

[Property]: Returns the track name

values()

[Property]: Returns a list that matches the complete set of values for this track. If no values are assigned returns None

symbols()

[Property]: Returns a list that matches the complete set of symbols for this track. If no symbols are assigned returns None

protein()

[Property]: Returns the Protein that this Track is associated with

track_type()

[Property]: Returns the track type. Will always be one of ‘values’ or ‘symbols’.

Track Functions

symbol(self, position, safe=True)

Returns a single symbol from the passed position :param position: Starting position of interest. :type position: int :param safe: Flag which if true with throw an exception if a

symbol is requested from a symbol track.

Returns:

Returns a symbol associated with the passed position

Return type:

str

value(self, position, safe=True)

Returns a single value from the passed position.

Parameters:
  • position (int) – Starting position of interest.

  • safe (bool (default = True)) – Flag which if true with throw an exception if a value is requested from a symbol track.

Returns:

Returns a value associated with the passed position

Return type:

float

symbols_region(self, start, end=None)

Returns a single symbol or a subregion of symbols, depending on if a start and end position are provided or just a start position.

Parameters:
  • start (int) – Starting position of interest.

  • end (int) – Ending position of interest.

Returns:

Returns a list of values that maps to the residues in the intervening region defined by start and end).

Return type:

list

values_region(self, start, end=None)

Returns a single value or a subregion of values, depending on if a start and end position are provided or just a start position

Parameters:
  • start (int) – Starting position of interest

  • end (int) – Ending position of interest. If not provided then only the

Returns:

Returns a list of values that maps to the residues in the intervening region defined by start and end)

Return type:

list

Track Attribute Functions

attributes()

[Property]: Provides a list of the keys associated with every attribute associated with this Track.

Returns:

returns a list of the attribute keys associated with the protein.

Return type:

list

attribute(self, name, safe=True)

Function that returns a specific attribute as defined by the name.

Recall that attributes are name : value pairs, where the ‘value’ can be anything and is user defined. This function will return the value associated with a given name.

NOTE: Track attributes cannot be loaded or saved to file when Tracks are read/written via interfaces.si_track.

Parameters:

name (str) – The attribute name. A list of valid names can be found by calling the <Track>.attributes() (which returns a list of the valid names).

safebool (default = True)

Flag which if true with throw an exception if an attribute with the same name already exists.

Returns:

Will either return whatever was associated with that attribute (which could be anything) or None if that attribute is missing.

Return type:

Unknown

add_attribute(self, name, val, safe=True)

Function that adds an attribute. Note that if safe is true, this function will raise an exception if the attribute is already present. If safe=False, then an existing value will be overwritten.

NOTE: Track attributes cannot be loaded or saved to file when Tracks are read/written via interfaces.si_track.

Parameters:
  • name (str) – The parameter name that will be used to identify it

  • val (<anything>) – An object or primitive we wish to associate with this attribute

  • safe (bool (default = True)) – Flag which if True with throw an exception if an attribute with the same name already exists, otherwise the newly introduced attribute will overwrite the previous one.

Return type:

None - but adds an attribute to the calling object.

remove_attribute(self, name, safe=True)

Function that removes a given attribute from the Track based on the passed attribute name. If the passed attribute does not exist or is not associate with the Track then this will trigger an exception unless safe=False.

Parameters:
  • name (str) – The parameter name that will be used to identify it

  • safe (bool (default = True)) – Flag which if True with throw an exception if an attribute this name does not exists. If set to False then if an attribute is not found it is simply ignored

Returns:

No return type but will remove an attribute from the protein if present.

Return type:

None