phylox.rearrangement.move.Move

class phylox.rearrangement.move.Move(*args, **kwargs)

Bases: object

A move is a rearrangement operation on a phylogenetic network.

Parameters:
  • move_type – the type of move (phylox.rearrangement.movetype.MoveType).

  • kwargs – the parameters of the move, depending on the move type.

__init__(*args, **kwargs)

Methods

__init__(*args, **kwargs)

invert([network])

Inverts the move.

is_type(move_type)

Checks if the move is of a given type.

random_move

rename_nodes(isomorphism)

Renames the nodes in the move using an isomorphism mapping between two networks.

is_type(move_type)

Checks if the move is of a given type.

Parameters:

move_type – the move type to check (phylox.rearrangement.movetype.MoveType).

Returns:

True if the move is of the given type, False otherwise.

Example:

>>> from phylox.rearrangement.move import Move
>>> move = Move(
...     move_type=MoveType.TAIL,
...     origin=(2,5),
...     moving_edge=(1,3),
...     target=(2,4),
... )
>>> move.is_type(MoveType.TAIL)
True
>>> move.is_type(MoveType.RSPR)
True
>>> move.is_type(MoveType.HEAD)
False
>>> move.is_type(MoveType.VERT)
False
rename_nodes(isomorphism)

Renames the nodes in the move using an isomorphism mapping between two networks.

Parameters:

isomorphism – a dictionary, containing a bijective mapping from nodes of the networks to another set.

Returns:

a new move with the nodes renamed.

invert(network=None)

Inverts the move.

Parameters:

network – a phylogenetic network (phylox.DiNetwork) in which to invert the move. (needed for VMIN moves)

Returns:

a new move that is the inverse of the current move.

classmethod random_move(network, available_tree_nodes=None, available_reticulations=None, move_type_probabilities={MoveType.HEAD: 0.4, MoveType.TAIL: 0.4, MoveType.VMIN: 0.1, MoveType.VPLU: 0.1}, seed=None)

Generates a random move for the given network. The move may not be valid.

Parameters:
  • network – a phylogenetic network (phylox.DiNetwork).

  • available_tree_nodes – a list of available tree nodes to use for the move.

  • available_reticulations – a list of available reticulations to use for the move.

  • move_type_probabilities – a dictionary of move type probabilities.

Returns:

a random move (phylox.rearrangement.move.Move).

Example:

>>> from phylox import DiNetwork
>>> from phylox.rearrangement.move import Move
>>> network = DiNetwork(
...     edges=[(0,1),(1,2),(1,3),(2,3),(2,4),(3,5)],
... )
>>> move = Move.random_move(
...     network,
...     move_type_probabilities={
...         MoveType.TAIL: 0.5,
...         MoveType.HEAD: 0.5,
...     },
... )
>>> move.is_type(MoveType.RSPR)
True