# serialization

This module is a technical module where we can find the different way to serialize the results:

> - the Systems found

> - The best solutions (best combination of systems)

> - The rejected candidates

## SystemSerializer

class macsypy.serialization.SystemSerializer

  handle the different way to serialize a system

  __weakref__

    list of weak references to the object

## TsvSystemSerializer

class macsypy.serialization.TsvSystemSerializer

  Handle System serialization in tsv format

  serialize(system: System, hit_system_tracker: HitSystemTracker) → str

    :param `macsypy.system.System` system: The system to serialize. :param hit_system_tracker: The hit_system_tracker which allow to know for each hit

    > in which system it is implied.

    Returns:

      a serialisation of this system in tabulated separated value format each line represent a hit and have the following structure:

        replicon\thit_id\tgene_name\thit_pos\tmodel_fqn\tsys_id\tsys_loci\tlocus_num\tsys_wholeness\tsys_score
        \tsys_occ\thit_gene_ref.alternate_of\thit_status\thit_seq_len\thit_i_eval\thit_score\thit_profile_cov
        \thit_seq_cov\tit_begin_match\thit_end_match\tcounterpart\tused_in_systems

    Return type:

      str

## TsvSolutionSerializer

class macsypy.serialization.TsvSolutionSerializer

  Handle Solution (list of Systems) serialization in tsv format

  __weakref__

    list of weak references to the object

  serialize(solution: Solution, sol_id: int, hit_system_tracker: HitSystemTracker) → str
    Parameters:

      - solution – the solution to serialize

      - sol_id – the solution identifier

      - hit_system_tracker

    Returns:

      a serialisation of this solution (a list of systems) in tabulated separated value format each line represent a hit and have the same structure as system serialization `macsypy.serialization.TsvSystemSerializer.serialize()` but with an extra column sol_id which is a technical id to identify the different solutions.

## TsvLikelySystemSerializer

class macsypy.serialization.TsvLikelySystemSerializer

  Handle potential System from unordered replicon serialization in tsv format

  serialize(system: LikelySystem, hit_system_tracker: HitSystemTracker) → str
    Parameters:

      - system – The likely system to serialize. Used only for unordered db-type

      - hit_system_tracker – The hit_system_tracker which allow to know for each hit in which system it is implied.

    Returns:

      a serialisation of this system in tabulated separated value format each line represent a hit and have the following structure:

        replicon\thit_id\tgene_name\thit_pos\tmodel_fqn\tsys_id\tsys_wholeness
        \thit_gene_ref.alternate_of\thit_status\thit_seq_len\thit_i_eval\thit_score\thit_profile_cov
        \thit_seq_cov\tit_begin_match\thit_end_match\t$used_in_systems

    Return type:

      str

## TsvRejectedCandidatesSerializer

class macsypy.serialization.TsvRejectedCandidatesSerializer

  Serialize Rejected Cluster in tsv format

  __weakref__

    list of weak references to the object

  serialize(candidates: list[RejectedCandidate]) → str
    Parameters:

      candidates – list of rejected candidates to serialize

## TsvSpecialHitSerializer

class macsypy.serialization.TsvSpecialHitSerializer

  Serialize special hits: `macsypy.hit.Loner` and `macsypy.hit.MultiSystem` in tsv format

  __weakref__

    list of weak references to the object

  serialize(best_hits: Iterable[Loner] | Iterable[MultiSystem])
    Parameters:

      best_hits (sequence of `macsypy.hit.Loner` or `macsypy.hit.MultiSystem` objects) – the special hits to serialized

## TxtSystemSerializer

class macsypy.serialization.TxtSystemSerializer

  Handle System serialization in text

  serialize(system: System, hit_system_tracker: HitSystemTracker) → str
    Returns:

      a string representation of system readable by human

## TxtLikelySystemSerializer

class macsypy.serialization.TxtLikelySystemSerializer

  Handle System serialization in text

  serialize(system: LikelySystem, hit_system_tracker: HitSystemTracker)
    Parameters:

      - system – The likely system to serialize. Used only for unordered db-type

      - hit_system_tracker – The hit_system_tracker which allow to know for each hit in which system it is implied.

    Returns:

      a string representation of system readable by human

## TxtUnikelySystemSerializer

class macsypy.serialization.TxtUnikelySystemSerializer

  Handle System serialization in text

  serialize(system: UnlikelySystem) → str
    Parameters:

      system – The unlikely system to serialize. (used only if db-type is “unordered_replicon”)

    Returns:

      a string representation of system readable by human

Fork me on GitHub