# report

A “HMMReport” object represents the results of a Hmmer program search on a dataset with a hidden Markov model protein profile (see this section). This object has methods to extract and filter Hmmer raw outputs (see generated output files), and then build Hits relevant for system detection. For matches selected with the filtering parameters, “Hit” objects (`macsypy.HMMReport.Hit`) are built.

## report API reference

## HMMReport

class macsypy.report.HMMReport(gene: CoreGene, hmmer_output: str, cfg: Config)

  Handle the results from the HMM search. Extract a synthetic report from the raw hmmer output, after having applied a hit filtering. This class is an abstract class. There are two implementations of this abstract class depending on whether the input sequence dataset is “ordered” (“gembase” or “ordered_replicon” db_type) or not (“unordered” db_type).

  __init__(gene: CoreGene, hmmer_output: str, cfg: Config) → None
    Parameters:

      - gene – the gene corresponding to the profile search reported here

      - hmmer_output – The path to the raw Hmmer output file

      - cfg – the configuration object

  __str__() → str
    Returns:

      string representation of this report

  __weakref__

    list of weak references to the object

  _build_my_db(hmm_output: str) → dict[slice(<class 'str'>, None, None)]

    Build the keys of a dictionary object to store sequence identifiers of hits.

    Parameters:

      hmm_output (string) – the path to the hmmsearch output to parse.

    Returns:

      a dictionary containing a key for each sequence id of the hits

  _fill_my_db(db: dict[slice(<class 'str'>, tuple[int, int], None)]) → None

    Fill the dictionary with information on the matched sequences

    Parameters:

      db (dict) – the database containing all sequence id of the hits.

  abstractmethod _get_replicon_name(hit_id: str) → str

    This method is used by extract method and must be implemented by concrete class

    Parameters:

      hit_id (str) – the id of the current hit extract from hmm output.

    Returns:

      The name of the replicon

  _hit_start(line: str) → bool
    Parameters:

      line (string) – the line to parse

    Returns:

      True if it’s the beginning of a new hit in Hmmer raw output files. False otherwise

    Return type:

      boolean.

  _parse_hmm_body(hit_id: str, gene_profile_lg: int, seq_lg: int, coverage_threshold: float, replicon_name: str, position_hit: int, i_evalue_sel: float, b_grp: Iterator) → list[CoreHit]

    Parse the raw Hmmer output to extract the hits, and filter them with threshold criteria selected (“coverage_profile” and “i_evalue_select” command-line parameters)

    Parameters:

      - hit_id – the sequence identifier

      - gene_profile_lg – the length of the profile matched

      - seq_lg – the length of the sequence

      - coverage_threshold – the minimal coverage of the profile to be reached in the Hmmer alignment for hit selection.

      - replicon_name – the identifier of the replicon

      - position_hit – the rank of the sequence matched in the input dataset file

      - i_evalue_sel – the maximal i-evalue (independent evalue) for hit selection

      - b_grp (list of list of strings) – the Hmmer output lines to deal with (grouped by hit)

    Returns:

      a sequence of hits

    Return type:

      list of `macsypy.report.CoreHit` objects

  _parse_hmm_header(h_grp: Iterator) → str
    Parameters:

      h_grp (sequence of string (<itertools._grouper object at 0x7ff9912e3b50>)) – the sequence of string return by groupby function representing the header of a hit

    Returns:

      the sequence identifier from a set of lines that corresponds to a single hit

    Return type:

      string

  best_hit() → CoreHit | None

    Return the best hit among multiple hits

  extract() → None | list[CoreHit]

    Parse the output file of hmmer compute from an unordered genes base and produced a new synthetic report file.

  save_extract() → None

    Write the string representation of the extract report in a file. The name of this file is the concatenation of the gene name and of the “res_extract_suffix” from the config object

## GeneralHMMReport

class macsypy.report.GeneralHMMReport(gene: CoreGene, hmmer_output: str, cfg: Config)

  Handle HMM report. Extract a synthetic report from the raw hmmer output. Dedicated to any type of ‘unordered’ datasets.

  _get_replicon_name(hit_id: str) → str

    This method is used by extract method and must be implemented by concrete class

    Parameters:

      hit_id (str) – the id of the current hit extract from hmm output.

    Returns:

      The name of the replicon

## OrderedHMMReport

class macsypy.report.OrderedHMMReport(gene: CoreGene, hmmer_output: str, cfg: Config)

  Handle HMM report. Extract a synthetic report from the raw hmmer output. Dedicated to ‘ordered_replicon’ datasets.

  _get_replicon_name(hit_id: str) → str

    This method is used by extract method and must be implemented by concrete class

    Parameters:

      hit_id (str) – the id of the current hit extract from hmm output.

    Returns:

      The name of the replicon

## GembaseHMMReport

class macsypy.report.GembaseHMMReport(gene: CoreGene, hmmer_output: str, cfg: Config)

  Handle HMM report. Extract a synthetic report from the raw hmmer output. Dedicated to ‘gembase’ format datasets.

  _get_replicon_name(hit_id: str) → str

    This method is used by extract method and must be implemented by concrete class

    Parameters:

      hit_id (str) – the id of the current hit extract from hmm output.

    Returns:

      The name of the replicon

Fork me on GitHub