parsers

Description

Contains modules for working with output files of **BLUPF90 utilities:**

  • Module for reading(parsing) the parameter file - configuration file param.txt.

  • Modules for reading(parsing) the file with the results of calculation of variants (ai)remlf90.log.

  • Module for reading(parsing) the file with pedigree renaddxx.ped.

  • Module for reading(parsing) file with ebv (Estimate Breeding Value) solution results.

Modules

class bpf90tools.parsers.IParser[source]

Bases: ABC

Abstract class for file parsers.

Defines an interface for classes that must implement methods for processing and reading files.

_abc_impl = <_abc._abc_data object>
abstract _read(file) None[source]

Reads the contents of the specified file.

abstract parse_file(file: str) None[source]

Processes the specified file.

class bpf90tools.parsers.Keywords[source]

Bases: object

A class that stores sets of keywords used in various genetic analysis programs.

This class defines keyword sets for different software tools, such as RENUMF90, BLUPF90, REMLF90, and AIREMLF90. These keywords are used in parameter files to control various settings and options.

AIREMLF90_keyword = {'OPTION EM-REML', 'OPTION SNP_file', 'OPTION approx_loglike', 'OPTION constant_var', 'OPTION conv_crit', 'OPTION fact_once', 'OPTION hetres_pol', 'OPTION hetres_pos', 'OPTION maxrounds', 'OPTION missing', 'OPTION se_covar_function', 'OPTION sol', 'OPTION tol', 'OPTION use_yams'}
BLUPF90_keyword = {'OPTION blksize', 'OPTION conv_crit', 'OPTION fixed_var', 'OPTION hetres_int', 'OPTION maxrounds', 'OPTION r_factor', 'OPTION sol', 'OPTION solv_method', 'OPTION use_yams'}
REMLF90_keyword = {'OPTION', 'OPTION SNP_file', 'OPTION constant_var', 'OPTION conv_crit', 'OPTION maxrounds', 'OPTION missing', 'OPTION sol', 'OPTION use_yams'}
RENUMF90_keyword = {'(CO)VARIANCES', '(CO)VARIANCES_MPE', '(CO)VARIANCES_PE', 'COMBINE', 'DATAFILE', 'EFFECT', 'FIELDS_PASSED TO OUTPUT', 'FILE', 'FILE_POS', 'GEN_INT', 'INBREEDING', 'NESTED', 'OPTION alpha_size', 'OPTION max_field_readline', 'OPTION max_string_readline', 'OPTIONAL', 'PED_DEPTH', 'RANDOM', 'REC_SEX', 'RESIDUAL_VARIANCE', 'SKIP_HEADER', 'SNP_FILE', 'TRAITS', 'UPG_TYPE', 'WEIGHT(S)'}
property complex_par: set[str]

Returns a set of keywords that are more complex and may take multiple parameters.

property single_par: set[str]

Returns a set of keywords that typically take a single parameter.

property unique_keywords: set[str]

Returns a set of all unique keywords from all keyword groups.

class bpf90tools.parsers.PParams[source]

Bases: IParser, Keywords, CheckMixin

This is a class that processes a parameter file which is a configuration file for calculating blupf90.

_abc_impl = <_abc._abc_data object>
_read(pth_file: str | Path) None | list[source]

Reading a file.

Parameters:

pth_file – The path to the file.

Returns:

Return the list line.

property params: dict[str, list]

Method that returns data - a dictionary of keywords and their values.

parse_file(pth_file: str | Path) bool[source]

Parsing the param.txt file.

Parameters:

pth_file – The path to the file param.txt.

Returns:

Throws an exception when an error occurs.

class bpf90tools.parsers.PPed[source]

Bases: IParser, CheckMixin

Pedigree file processing renadd.ped which is obtained as a result of processing by renumf90 program. Example file: renadd02.ped

_abc_impl = <_abc._abc_data object>
_read(file: Path) None[source]

Reading a file.

Parameters:

file – The path to the file.

parse_file(pth_file: str | Path) bool[source]

The parsing data files pedigree.

Parameters:

pth_file – The path to file renadd.ped - pedigree.

Returns:

Throws an exception when an error occurs.

property values: DataFrame | None

Return of dataframe - [‘nomer’, ‘ID’].

class bpf90tools.parsers.PSolution(varg: float = None)[source]

Bases: IParser, CheckMixin

Processing the file with results of the assessment.

_abc_impl = <_abc._abc_data object>
_read(pth_file: Path) None[source]

Reading a file.

Parameters:

pth_file – The path to the file.

static _rel_from_sep(se_data: float, var_gen: float) float[source]

Derivation of the reliability of the estimate from its standard deviation.

Parameters:
  • se_data – Standard deviation calculated by blupf90.

  • var_gen – Genetic variance calculated by remlf90.

Returns:

The return reliability.

property _varg: float | None
parse_file(file: str | Path) bool[source]

Handler for a file with the results of evaluations of breeding values.

Parameters:

file – Path to file solutions.

Returns:

Returns true if file parsing was successful, false if it failed.

property solutions: DataFrame | None
class bpf90tools.parsers.PVar[source]

Bases: IParser, CheckMixin

Processing the file method (ai)remlf90 in which the variance information is stored.

_abc_impl = <_abc._abc_data object>
_heritability() None[source]

Heritability, the degree of conditionality of the phenotypic variability of any trait in an animal population by genotypic differences between individuals.

_next_value(elem: str) int[source]

Determines the index of the next element in the list.

Parameters:

elem – List item.

Returns:

Return the index of the next element.

_read(file: Path) None[source]

Reading a file.

Parameters:

file – The path to the file.

parse_file(pth_file: str | Path) bool[source]

Parsing the log file of the (ai)remlf90.exe(sh) program.

Parameters:

pth_file – The path to the file log.

property values: Variance | None
class bpf90tools.parsers.Variance(*, varG: float = None, varE: float = None, aic: float = None, bic: float = None, heritability: float = None)[source]

Bases: BaseModel

_abc_impl = <_abc._abc_data object>
aic: float
bic: float
heritability: float
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

varE: float
varG: float