pygfa.serializer package

Submodules

pygfa.serializer.gfa1_serializer module

GFA1 Serializer for nodes, edge, Subgraphs and networkx graphs.

Can serialize either one of the object from the group mentioned before or from a dictionary with equivalent key.

exception pygfa.serializer.gfa1_serializer.GFA1SerializationError[source]

Bases: Exception

pygfa.serializer.gfa1_serializer.point_to_node(gfa_, node_id)[source]

Check if the given node_id point to a node in the gfa graph.

pygfa.serializer.gfa1_serializer.serialize_edge(edge_, identifier='no identifier given.')[source]

Converts to a GFA1 line the given edge.

Fragments and Gaps cannot be represented in GFA1 specification, so they are not serialized.

pygfa.serializer.gfa1_serializer.serialize_gfa(gfa_)[source]

Serialize a GFA object into a GFA1 file.

pygfa.serializer.gfa1_serializer.serialize_graph(graph, write_header=True)[source]

Serialize a networkx.MulitGraph object.

Parameters:graph – A networkx.MultiGraph instance.
Write_header:If set to True put a GFA1 header as first line.
pygfa.serializer.gfa1_serializer.serialize_node(node_, identifier='no identifier given.')[source]

Serialize to the GFA1 specification a Graph Element Node or a dictionary that has the same informations.

Parameters:
  • node – A Graph Element Node or a dictionary.
  • identifier – If set help gaining useful debug information.
Return “”:

If the object cannot be serialized to GFA.

pygfa.serializer.gfa1_serializer.serialize_subgraph(subgraph_, identifier='no identifier given.', gfa_=None)[source]

Serialize a Subgraph object or an equivalent dictionary.

pygfa.serializer.gfa2_serializer module

GFA2 Serializer for nodes, edge, Subgraphs and networkx graphs.

Can serialize either one of the object from the group mentioned before or from a dictionary with equivalent key.

exception pygfa.serializer.gfa2_serializer.GFA2SerializationError[source]

Bases: Exception

pygfa.serializer.gfa2_serializer.are_elements_oriented(subgraph_elements)[source]

Check wheter all the elements of a subgraph have an orientation value [+/-].

pygfa.serializer.gfa2_serializer.serialize_edge(edge_, identifier='no identifier given.')[source]

Converts to a GFA2 line the given edge.

pygfa.serializer.gfa2_serializer.serialize_gfa(gfa_)[source]

Serialize a GFA object into a GFA2 file.

TODO:
maybe process the header fields here
pygfa.serializer.gfa2_serializer.serialize_graph(graph, write_header=True)[source]

Serialize a networkx.MultiGraph or a derivative object.

Parameters:
  • graph – A networkx.MultiGraph instance.
  • write_header – If set to True put a GFA2 header as first line.
pygfa.serializer.gfa2_serializer.serialize_node(node_, identifier='no identifier given.')[source]

Serialize to the GFA2 specification a graph_element Node or a dictionary that has the same informations.

If sequence length is undefined (for example, after parsing a GFA1 Sequence line) a sequence length of 0 is automatically added in the serialization process.

Parameters:node – A Graph Element Node or a dictionary
Identifier:If set help gaining useful debug information.
Returns “”:If the object cannot be serialized to GFA.
pygfa.serializer.gfa2_serializer.serialize_subgraph(subgraph_, identifier='no identifier given.', gfa_=None)[source]

Serialize a Subgraph object or an equivalent dictionary.

Returns “”:If subgraph cannot be serialized.
TODO:Check with gfa for OGroup in UGroup. See GFA2 spec.

pygfa.serializer.utils module

Module contents