# 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 (if defined)

## TsvSystemSerializer

class macsypy.serialization.TsvSystemSerializer

  Handle System serialization in tsv format

  serialize(system, hit_system_tracker)

    :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

  __init__()

    Constructor

  __weakref__

    list of weak references to the object (if defined)

  serialize(solution, sol_id, hit_system_tracker)
    Parameters

      - solution (list of `macsypy.system.System` object) – the solution to serialize

      - sol_id (int) – the solution identifier

      - hit_system_tracker (`macsypy.system.HitSystemTracker` object) –

    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 identified the different solutions.

## TsvLikelySystemSerializer

class macsypy.serialization.TsvLikelySystemSerializer

  Handle potential System from unordered replicon serialization in tsv format

  serialize(system, hit_system_tracker)
    :param `macsypy.system.LikelySystem` system: The likely system to serialize.

      Use only for unordered db-type

    Parameters

      hit_system_tracker (`macsypy.system.HitSystemTracker` object) – 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 (if defined)

  serialize(candidates)
    Parameters

      candidates ([ `macsypy.system.RejectedCandidate` object, …]) – 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 (if defined)

  serialize(best_hits)
    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, hit_system_tracker)
    Returns

      a string representation of system readable by human

## TxtLikelySystemSerializer

class macsypy.serialization.TxtLikelySystemSerializer

  Handle System serialization in text

  serialize(system, hit_system_tracker)
    :param `macsypy.system.LikelySystem` system: The likely system to serialize.

      Use only for unordered db-type

    Parameters

      hit_system_tracker (`macsypy.system.HitSystemTracker` object) – 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)
    Parameters

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

    Returns

      a string representation of system readable by human