Split Strands Graph#

Graph#

class SplitStrandsGraph#

Graph containing only one DNA strand.

For this graph \(G = (V, E)\) we have:

  • \(\forall v \in V, \bar{v} \notin V\)

  • \(\forall e \in E, \bar{e} \notin E\)

Methods:

attr(attrname)

Return the value associated to attribute attrname.

attrs()

Return the dictionnary of all attributes.

edges()

Return the edge container.

set_attr(attrname, attrvalue)

Change the value of the attributes else create them.

vertices()

Return the vertices container.

attr(attrname)#

Return the value associated to attribute attrname.

Parameters:

attrname (str) – Attribute’s name

Returns:

Attribute value corresponding to the attribute name

Return type:

Any

Raises:

NoGraphAttribute – When there is no attribute key

attrs()#

Return the dictionnary of all attributes.

Returns:

Dictionnary of attribute name as key and their value

Return type:

dict

edges()#

Return the edge container.

Returns:

Edges container

Return type:

SplitStrandsEdges

set_attr(attrname, attrvalue)#

Change the value of the attributes else create them.

Parameters:
  • attrname (str) – Attribute’s name

  • attrvalue (Any) – Attribute’s value

vertices()#

Return the vertices container.

Returns:

Vertices container

Return type:

SplitStrandsVertices

Vertices Container#

class SplitStrandsVertices#

Unique oriented vertices container.

This vertices container is containing only one orientation for each of its vertex i.e. \(\forall v \in V, \bar{v} \notin V\)

Warning

You must not call this class. Use it only for typing or get an already existing object.

Methods:

__contains__(vertex)

Answer if vertex is in vertices container.

__iter__()

Iterate on oriented vertices.

__len__()

Return the number of oriented vertices.

add(orientation)

Add the vertex to the connected component record.

attr(vertex_index, attrname)

Return the value associated to vertex attribute attrname.

attrs(vertex_index)

Iterate over all vertex's attributes.

contains_indor(vertex)

Answer if oriented vertex in vertices container.

delete(vertex_index)

Remove vertex from vertices container.

delete_several(vertex_indices)

Remove vertices from vertices container.

new_attr(attrname, default)

Add an attribute entry.

orientation(vertex_index)

Return the orientation of vertex's index.

set_attr(vertex_index, attrname, attrvalue)

Change the value of the attributes else create them.

__contains__(vertex)#

Answer if vertex is in vertices container.

Returns:

Vertex is in vertices container

Return type:

bool

__iter__()#

Iterate on oriented vertices.

Yields:

IndexT – Vertices

__len__()#

Return the number of oriented vertices.

Returns:

Number of orient

Return type:

int

add(orientation)#

Add the vertex to the connected component record.

Parameters:

orientation (OrT) – New orientation to add to vertices container

Returns:

Last vertex’s index

Return type:

IndexT

attr(vertex_index, attrname)#

Return the value associated to vertex attribute attrname.

Parameters:
  • vertex_index (IndexT) – Vertex’s index

  • attrname (str) – Attribute name

Returns:

Attribute value corresponding to the attribute name

Return type:

Any

Raises:
attrs(vertex_index)#

Iterate over all vertex’s attributes.

Parameters:

vertex_index (IndexT) – Vertex’s index

Yields:
  • str – Attribute’s name

  • Any – Attribute’s value

Raises:

NoVertexIndex – If there is no vertex index

contains_indor(vertex)#

Answer if oriented vertex in vertices container.

Parameters:

vertex (IndOrT) – Oriented vertex

Returns:

Oriented vertex in vertices container

Return type:

bool

delete(vertex_index)#

Remove vertex from vertices container.

Parameters:

vertex_index (IndexT) – Vertex to delete

Raises:

NoVertexIndex – If vertex does not exist

Warning

This operation may invalidate vertex indices. In fact, deleting one vertex implies shifting all next indices. Because of this, keys should always be removed in decreasing index order:

>>> for vertex in sorted(vertices_to_del, reverse=True):
>>>     graph.vertices().delete(vertex)

Note

All next vertex indices are decreased in edges they belong. But concerning edge indices are not.

delete_several(vertex_indices)#

Remove vertices from vertices container.

Parameters:

vertex_indices (iterable of IndexT) – Vertices to delete

Raises:

NoVertexIndex – If one vertex does not exist

Warning

This operation may invalidate vertex indices. In fact, deleting one vertex implies shifting all next indices.

Notes

At the oposite of delete() method, it is not necessary to sort vertex_indices. This is done internally.

All next vertex indices are decreased in edges they belong. But concerning edge indices are not.

new_attr(attrname, default)#

Add an attribute entry.

Parameters:
  • attrname (str) – Attribute’s name

  • default (Any) – Default attribute value

Note

Before setting attribute to one vertex, it is necessary to add an attribute entry using this method.

orientation(vertex_index)#

Return the orientation of vertex’s index.

Parameters:

vertex_index (IndexT) – Vertex’s index

Returns:

Vertex’s index orientation

Return type:

OrT

Raises:

NoVertexIndex – If there is no vertex index

set_attr(vertex_index, attrname, attrvalue)#

Change the value of the attributes else create them.

Parameters:
  • vertex_index (IndexT) – Vertex’s index

  • attrname (str) – Attribute’s name

  • attrvalue (Any) – Attribute’s value

Raises:

Note

Be sure having added an attribute entry using the method new_attr()

Edges Container#

class SplitStrandsEdges#

Unique oriented edges container.

This edges container is containing only one orientation for each of its edge i.e. \(\forall e \in E, \bar{e} \notin E\)

Warning

You must not instantiate a Edges object. Use it only for typing or get an already instanciated object.

Methods:

__contains__(edge)

Return True if the indices edge is in edges container.

__iter__()

Iterate over indices edges with edge index.

__len__()

Return the number of edges.

add(first_vertex, second_vertex)

Add edge to edges.

attr(edge_index, attrname)

Return the edge attribute attrname.

attrs(edge_index)

Iterate over all edge's attributes.

delete(first_vertex, second_vertex, edge_index)

Remove the edge.

eindor_to_eind(first_vertex, second_vertex)

Iterate over edge index from indices edge.

neighbours(vertex)

Iterate over vertex's adjacencies vertices.

new_attr(attrname, default)

Add an attribute entry.

preds(vertex)

Iterate over vertex's predecessors.

set_attr(edge_index, attrname, attrvalue)

Change the value of one attribute.

succs(vertex)

Iterate over vertex's successors.

__contains__(edge)#

Return True if the indices edge is in edges container.

Parameters:

edge (EIndT) – Indices edge

Returns:

Indices edge in edges container

Return type:

bool

__iter__()#

Iterate over indices edges with edge index.

Yields:

EIndIndT – Indices edges with their edge index

__len__()#

Return the number of edges.

Returns:

Number of edges

Return type:

int

Notes

\(\forall e \in E, \bar{e} \notin E\)

add(first_vertex, second_vertex)#

Add edge to edges.

Parameters:
  • first_vertex (IndexT) – First vertex

  • second_vertex (IndexT) – Second vertex

Returns:

Edge index

Return type:

IndexT

Raises:

NoVertexIndex – If one vertex does not exist

attr(edge_index, attrname)#

Return the edge attribute attrname.

Parameters:
  • edge_index (IndexT) – Edge’s index

  • attrname (str) – Attribute name

Returns:

Attribute value

Return type:

Any

Raises:

Note

A removed edge still have a recorded attribute.

attrs(edge_index)#

Iterate over all edge’s attributes.

Parameters:

edge_index (IndexT) – Edge’s index

Yields:
  • str – Attribute’s name

  • Any – Attribute’s value

Raises:

NoEdgeIndex – If there is no edge index

Note

A removed edge still have a recorded attribute.

delete(first_vertex, second_vertex, edge_index)#

Remove the edge.

Parameters:
  • first_vertex (IndexT) – First vertex

  • second_vertex (IndexT) – Second vertex

  • edge_index (IndexT) – Edge’s index

Raises:

Note

When deleting, the edge is replacing by the last one in adjancy list, and the last element of the adjancy list is removed.

eindor_to_eind(first_vertex, second_vertex)#

Iterate over edge index from indices edge.

Parameters:
  • first_vertex (IndexT) – First vertex

  • second_vertex (IndexT) – Second vertex

Yields:

IndexT – Edge index

Raises:

NoVertexIndex – One of the vertex in edge does not exist

neighbours(vertex)#

Iterate over vertex’s adjacencies vertices.

Parameters:

vertex (IndexT) – Vertex’s index

Yields:

IndIndT – Adjacent vertices’s index with edge index

Raises:

NoVertexIndex – If vertex does not exist

new_attr(attrname, default)#

Add an attribute entry.

Parameters:
  • attrname (str) – Attribute’s name

  • default (Any) – Default attribute value

Note

Before setting attribute to one edge, it is necessary to add an attribute entry using this method.

preds(vertex)#

Iterate over vertex’s predecessors.

Parameters:

vertex (IndexT) – Vertex’s index

Yields:

IndIndT – Predecessor vertex’s index with edge index

Raises:

NoVertexIndex – If vertex does not exist

set_attr(edge_index, attrname, attrvalue)#

Change the value of one attribute.

Parameters:
  • edge_index (IndexT) – Edge’s index

  • attrname (str) – Attribute’s name

  • attrvalue (Any) – Attribute’s value

Raises:

Note

Be sure having added an attribute entry using the method new_attr()

succs(vertex)#

Iterate over vertex’s successors.

Parameters:

vertex (IndexT) – Vertex’s index

Yields:

IndIndT – Successors vertex’s index with edge index

Raises:

NoVertexIndex – If vertex does not exist