def _init_genotypes(self):
"""Construct an array of genotype vectors, one per variant.
If it is found in cache, use the cached version,
otherwise recompute it and cache the result.
Either way, store a copy in local process memory.
"""
if self.genotypes_key in self.cache:
# Read cache, store in local memory
self._gt_types_bit = self._get_genotypes()
else:
# Regenerate, cache, and store in local memory
gt_types = extract_genotypes(db=self.db)
f = np.vectorize(variant_build_gt_type_bit, otypes=[np.uint8]) # apply to all array elements
self._gt_types_bit = f(gt_types)
self._gt_types_bit.flags.writeable = False # make it immutable
self._save_genotypes(self._gt_types_bit)
评论列表
文章目录