def beta_phylogenetic_alt(table: BIOMV210Format, phylogeny: NewickFormat,
metric: str, n_jobs: int=1,
variance_adjusted: bool=False,
alpha: float=None,
bypass_tips: bool=False) -> skbio.DistanceMatrix:
metrics = phylogenetic_metrics_alt_dict()
generalized_unifrac = 'generalized_unifrac'
if metric not in metrics:
raise ValueError("Unknown metric: %s" % metric)
if alpha is not None and metric != generalized_unifrac:
raise ValueError('The alpha parameter is only allowed when the choice'
' of metric is generalized_unifrac')
# this behaviour is undefined, so let's avoid a seg fault
cpus = psutil.cpu_count(logical=False)
if n_jobs > cpus:
raise ValueError('The value of n_jobs cannot exceed the number of '
'processors (%d) available in this system.' % cpus)
if metric == generalized_unifrac:
alpha = 1.0 if alpha is None else alpha
f = partial(metrics[metric], alpha=alpha)
else:
f = metrics[metric]
# unifrac processes tables and trees should be filenames
return f(str(table), str(phylogeny), threads=n_jobs,
variance_adjusted=variance_adjusted, bypass_tips=bypass_tips)
评论列表
文章目录