mgkit.snps.filter module

SNPs filtering functions

mgkit.snps.filter.filter_genesyn_by_coverage(gene_syn, min_cov=None)

Checks if the coverage of the provided gene_syn is at least min_cov

Parameters:
  • gene_synGeneSyn instance
  • min_cov (int) – minimum coverage allowed (included)
Returns:

True if the gene has enough coverage

Return type:

bool

Raises:

FilterFails – if min_cov is None

mgkit.snps.filter.filter_genesyn_by_gene_id(gene_syn, gene_ids=None, exclude=False, id_func=None)

Checks if the gene_id is listed in the filter_list.

Parameters:
  • gene_synGeneSyn instance
  • gene_ids (iterable) – list of gene IDs to include/exclude
  • exclude (bool) – if the filter is reversed
Returns:

if the exclude is True, the gene_id must appear in the gene_ids, if False, returns True only if gene_id is NOT in gene_ids.

Return type:

bool

Raises:

FilterFails – if gene_ids is None

mgkit.snps.filter.filter_genesyn_by_taxon_id(gene_syn, taxonomy=None, filter_list=None, exclude=False, func=None)

Checks if the taxon_id attribute of gene_syn is the filter_list. Excelude reverses the result. If func is supplied, it’s used to traverse the taxonomy.

Parameters:
  • gene_synGeneSyn instance
  • taxonomy – a valid taxonomy (instance of UniprotTaxonomy)
  • filter_list (iterable) – list of taxon IDs to include/exclude
  • exclude (bool) – if the filter is reversed
  • func (func) – is_ancestor()
Returns:

if the exclude is True, the gene_id must appear in the gene_ids, if False, returns True only if gene_id is NOT in gene_ids.

Return type:

bool

Raises:

FilterFails – if filter_list is None or taxonomy is None and func is not None

mgkit.snps.filter.get_default_filters(taxonomy, **kwargs)

Retuns a list of filters that are used by default. it needs a valid taxonomy and gets the default arguments from mgkit.consts.DEFAULT_SNP_FILTER.

mgkit.snps.filter.pipe_filters(iterable, *funcs)

Pipes a list of filter to iterable, using the python ifilter function in the itertools module.