def ga_matches(self, candidate):
'''
OTUs that meet the genetic and abundance criteria
candidate: OTU
sequence to evaluate
'''
# find abundance matches
min_abundance = self.min_fold * candidate.abundance
abundance_matches = [otu for otu in self.otus if otu.abundance > min_abundance]
if self.log is not None:
print(candidate.name, 'abundance_check', *[otu.name for otu in abundance_matches], sep='\t', file=self.log)
if len(abundance_matches) == 0:
return []
else:
# find genetic matches (in order of decreasing genetic distance)
matches_distances = [(otu.distance_to(candidate), otu) for otu in abundance_matches]
matches_distances.sort(key=lambda x: (x[0], -x[1].abundance, x[1].name))
matches = [otu for dist, otu in matches_distances if dist < self.max_dist]
if self.log is not None:
print(candidate.name, 'genetic_check', *[otu.name for otu in matches], sep='\t', file=self.log)
return matches
评论列表
文章目录