Sails::Glycan
struct Sails::Glycan
Glycan represents a glycan structure.
The Glycan class is responsible for constructing and managing a glycan structure composed of sugars. It provides methods for adding linkages between sugars, adding sugars to the glycan, printing the glycan structure, generating a DOT string representation of the glycan, writing the glycan to a DOT file, performing breadth-first search (BFS) traversal on the glycan structure, retrieving terminal sugars, and performing depth-first search (DFS) traversal on the glycan structure.
Summary
Members | Descriptions |
---|---|
Internal glycosite [[maybe_unused]] | |
| Root glycosite |
| Root sugar |
| Adjaceny list describing links between sugar pointers |
| List of linkages used when creating link records |
| Sugars map used to store sugars in scope until the Glycan is destroyed |
| Internal structure pointer - used so that the structure is updated with the caller's structure |
| Internal residue database - used to write local dot files [[DEPRECATED]] |
| Sugar counts (e.g. {NAG: 1,BMA: 2}) |
| Sugar order (e.g. {NAG, NAG, BMA, MAN, MAN}) |
| |
| |
| Returns an iterator to the beginning of the map. |
| Returns a iterator to the end of the map. |
| Checks if the container is empty. |
| Returns the size of the sugar list. |
| Returns the number of sugars. |
| Returns the names of unique sugars. |
| Returns the order of the sugars sites. |
| Returns the DFS order of the sugars sites. |
| Returns the order of the sugars. |
| Returns the order of the sugars in DFS order. |
| Returns the number of unique sugars. |
| Returns the number of linkages. |
| Returns internal adjacency list. |
| Returns the linkages in this glycan. |
| Returns the sugars in this glycan. |
| Adds linkage between two sugars. |
| Adds a sugar molecule to be stored in this glycan. |
| Remove a sugar molecule from the structure and update the adjacency list. |
| Finds the previous sugar molecule linked to the given sugar molecule. |
| Prints the adjacency list of the glycan structure. |
| Prints the sugars contained within glycan structure. |
| Retrieves a DOT representation of the glycan structure. |
| Writes a dot file at the specified path. |
Performs a breadth-first search (BFS) traversal on the glycan structure starting from the specified root sugar. | |
| This function retrieves all the terminal sugars in a tree structure starting from the given root sugar. |
| Performs a depth-first search (DFS) on a graph of sugar molecules, starting from a given sugar and collecting terminal sugars. |
| Performs a depth-first search (DFS) on a graph of sugar molecules, starting from a given sugar and collecting terminal sugars. |
| Get the structure associated with the glycan. |
| Get the structure ptr associated with the glycan. |
Subtract operator for Glycan objects. | |
| Return the initial sugar ptr for this glycan |
Members
public
Glycosite
glycosite
Internal glycosite [[maybe_unused]]
public
Glycosite
root_glycosite
Root glycosite
public
Sugar
*
root_sugar
Root sugar
public std::map<
Sugar](Sails--Sugar.md#structSails_1_1Sugar) *, std::set< [Sugar
* > >
adjacency_list
Adjaceny list describing links between sugar pointers
public std::vector<
Linkage
>
linkage_list
List of linkages used when creating link records
public std::map<
Glycosite](Sails--Glycosite.md#structSails_1_1Glycosite), std::unique_ptr< [Sugar
> >
sugars
Sugars map used to store sugars in scope until the Glycan is destroyed
public gemmi::Structure *
m_structure
Internal structure pointer - used so that the structure is updated with the caller's structure
public ResidueDatabase
m_database
Internal residue database - used to write local dot files [[DEPRECATED]]
public std::map< std::string, int >
sugar_counts
Sugar counts (e.g. {NAG: 1,BMA: 2})
public std::vector<
Glycosite
>
sugar_order
Sugar order (e.g. {NAG, NAG, BMA, MAN, MAN})
public
Glycan
() = default
public inline
Glycan
(const
Glycan
& other)
public inline
Glycan
(gemmi::Structure * structure, ResidueDatabase & database,
Glycosite
& glycosite)
public inline std::map<
Glycosite](Sails--Glycosite.md#structSails_1_1Glycosite), std::unique_ptr< [Sugar
> >::const_iterator
begin
() const
Returns an iterator to the beginning of the map.
Returns a constant iterator that points to the first element of the map. This iterator can be used to traverse the map in a forward direction.
Returns
A constant iterator that points to the first element of the map.
The map must not be modified while iterating over it using this iterator.
public inline std::map<
Glycosite](Sails--Glycosite.md#structSails_1_1Glycosite), std::unique_ptr< [Sugar
> >::const_iterator
end
() const
Returns a iterator to the end of the map.
Returns a constant iterator that points to the last element of the map. This iterator can be used to compare with other iterators to check if it has reached the end of the map.
Returns
A constant iterator pointing to the end of the map.
The map must not be modified while iterating over it using this iterator.
public inline bool
empty
() const
Checks if the container is empty.
The empty
method checks if the container is empty. It returns true
if the container doesn't contain any elements, and false
otherwise.
Returns
true
if the container is empty, false
otherwise.
public inline size_t
size
() const
Returns the size of the sugar list.
The size of the sugar list represents the number of elements stored in it.
Returns
The size of the sugar list as a size_t
value.
public inline int
sugar_count
() const
Returns the number of sugars.
The size of the sugar list represents the number of sugar elements stored in it.
Returns
The number of sugars.
public inline std::vector< std::string >
get_unique_sugar_names
() const
Returns the names of unique sugars.
Returns
A vector of strings of unique sugars.
public inline std::vector<
Sails::Glycosite
>
get_sugar_site_order
() const
Returns the order of the sugars sites.
Returns
A vector of Glycosites in order
public inline std::vector<
Sails::Glycosite
>
get_sugar_site_dfs_order
()
Returns the DFS order of the sugars sites.
Returns
A vector of Glycosites in DFS order
public inline std::vector< std::string >
get_sugar_name_order
() const
Returns the order of the sugars.
Returns
A vector of names of sugars in order e.g. NAG,NAG,BMA,MAN
public inline std::vector< std::string >
get_sugar_name_dfs_order
()
Returns the order of the sugars in DFS order.
Returns
A vector of names of sugars in order e.g. NAG,NAG,BMA,MAN
public inline size_t
unique_sugar_count
() const
Returns the number of unique sugars.
Returns
The number of unique sugars
public inline int
linkage_count
() const
Returns the number of linkages.
Returns
The number of linkages.
public inline const std::map<
Sugar](Sails--Sugar.md#structSails_1_1Sugar) *, std::set< [Sugar
* > > *
get_adjacency_list
() const
Returns internal adjacency list.
Returns
A map of sugar ptrs to a set of linked sugar ptrs.
public inline const std::vector<
Linkage
> *
get_linkage_list
() const
Returns the linkages in this glycan.
Returns
A ptr to a vector of linkages.
public inline const std::map<
Glycosite](Sails--Glycosite.md#structSails_1_1Glycosite), std::unique_ptr< [Sugar
> > *
get_sugars
() const
Returns the sugars in this glycan.
Returns
A ptr to a all sugars in this glycan.
public inline void
add_linkage
(
Glycosite
& sugar_1,
Glycosite
& sugar_2, const std::string & donor_atom, const std::string & acceptor_atom)
Adds linkage between two sugars.
This function creates a linkage between two sugars by the seqId. Sugars must have been added with add_sugar before this function is called, if not, an error is raised.
Parameters
sugar_1_key
The ID of the first sugar object.sugar_2_key
The ID of the second sugar object.donor_atom
acceptor_atom
The specified sugar keys must be valid IDs of existing sugar objects.
Returns
void
public inline void
add_sugar
(const std::string & atom, int seqId,
Glycosite
& site)
Adds a sugar molecule to be stored in this glycan.
The add_sugar method adds a sugar molecule to the collection of sugars. If the sugar molecule with the given seqId already exists in the collection, it will not be overwritten.
Parameters
atom
The type of atom in the sugar molecule.seqId
The sequence ID of the sugar molecule.site
The glycosite of the sugar molecule.
public inline
Sugar
*
remove_sugar
(
Sugar
* sugar, bool erase_from_structure)
Remove a sugar molecule from the structure and update the adjacency list.
The remove_sugar function removes a sugar molecule with the specified sequence ID from the structure and updates the adjacency list accordingly. It returns a pointer to the sugar molecule that was linked to the removed sugar molecule.
Parameters
sugar
A pointer to the sugar molecule to be removed.erase_from_structure
Whether to erase the corresponding residue from the structure member.
Returns
A pointer to the sugar molecule that was linked to the removed sugar molecule, or nullptr if no sugar molecule was linked.
public inline std::optional<
Sugar
* >
find_previous_sugar
(
Sugar
* sugar) const
Finds the previous sugar molecule linked to the given sugar molecule.
The find_previous_sugar method searches for the previous sugar molecule linked to the given sugar molecule within the adjacency list. It iterates through the adjacency list and checks if the given sugar molecule is found as an acceptor in any of the pair values. If found, it returns the corresponding donor sugar molecule. If no previous sugar is found, it returns std::nullopt.
Parameters
sugar
A pointer to the sugar molecule for which to find the previous sugar molecule.
Returns
An optional pointer to the previous sugar molecule linked to the given sugar, or std::nullopt if not found.
public void
print_list
() const
Prints the adjacency list of the glycan structure.
The print_list() function iterates over the adjacency list of the glycan structure and prints each sugar and its linked siblings. It retrieves the residue information from the gemmi::Structure and gemmi::Residue objects and prints them as part of the output. The output is printed to the console.
Returns
void
public void
print_sugars
()
Prints the sugars contained within glycan structure.
Returns
void
public std::string
get_dot_string
()
Retrieves a DOT representation of the glycan structure.
The get_dot_string() function generates a DOT string representation of the glycan structure. The function uses the adjacency list to traverse the sugars and their linked siblings to construct the DOT string. The DOT string represents the relationships between sugars as edges and the sugars themselves as nodes.
Returns
A string containing the DOT representation of the glycan structure.
public void
write_dot_file
(const std::string & path)
Writes a dot file at the specified path.
This function takes a path to a dot file as input and writes a dot file at the specified location. The dot file is used for creating graphs using Graphviz graph visualization software.
Parameters
path
The path to the dot file to be written.
public void
bfs
(
Sugar
* root)
Performs a breadth-first search (BFS) traversal on the glycan structure starting from the specified root sugar.
The bfs() function implements the breadth-first search algorithm to traverse the glycan structure in a level-wise manner. It starts from the root sugar and visits all its linked sugars before moving on to the next level of sugars. The function uses a queue to keep track of the sugars to be visited and a set to keep track of visited sugars. It also uses a map to store the level of each sugar in the traversal.
Parameters
root
A pointer to the root sugar from which the traversal starts.
Returns
void
public std::vector<
Sugar
* >
get_terminal_sugars
(
Glycosite
& root_seq_id)
This function retrieves all the terminal sugars in a tree structure starting from the given root sugar.
The function takes a pointer to the root sugar of a tree structure as input and returns a collection of all the terminal sugars in that tree structure.
Parameters
root
The seqId to the root residue of the tree structure.
Exceptions
std::runtime_error
If supplied root_seq_id is invalid.
Returns
A collection of terminal sugars in the tree structure.
public void
dfs
(
Sugar
* current_sugar, std::vector<
Sugar
* > & terminal_sugars, int depth)
Performs a depth-first search (DFS) on a graph of sugar molecules, starting from a given sugar and collecting terminal sugars.
Parameters
current_sugar
- The current sugar molecule being visited.terminal_sugars
- A vector to store the terminal sugar molecules found.depth
- The depth of the current search
public void
dfs_sites
(
Sugar
* current_sugar, std::vector<
Glycosite
> & sites, int depth)
Performs a depth-first search (DFS) on a graph of sugar molecules, starting from a given sugar and collecting terminal sugars.
Parameters
current_sugar
- The current sugar molecule being visited.sites
- A vector to store the sitesdepth
- The depth of the current search
public inline gemmi::Structure
get_structure
() const
Get the structure associated with the glycan.
This method returns the gemmi::Structure object associated with the glycan.
Returns
The gemmi::Structure object associated with the glycan.
See also: gemmi::Structure
public inline gemmi::Structure *
get_structure_ptr
() const
Get the structure ptr associated with the glycan.
This method returns a ptr to the gemmi::Structure object associated with the glycan.
Returns
The gemmi::Structure ptr associated with the glycan.
See also: gemmi::Structure
public std::set<
Glycosite
>
operator-
(const
Glycan
& glycan)
Subtract operator for Glycan objects.
The operator- subtracts the glycosites of two Glycan objects and returns the set of unique glycosites that exist in the first Glycan object but not in the second Glycan object.
Parameters
Returns
The set of unique glycosites that exist in the first Glycan object but not in the second Glycan object.
The function is marked with [[nodiscard]] to indicate that the return value should not be ignored.
public inline
Sugar
*
initial_sugar
() const
Return the initial sugar ptr for this glycan