def extend(self, extensions: List[Tuple[Node]],
ext_read_sets: List[Set[OrientedRead]]) -> 'HaplotypeSet':
"""Extend the haplotype set with a new set of paths."""
# Make a copy of itself for a new set
new_set = HaplotypeSet(self.ploidy, copy_from=self)
for hap_num, (extension, read_set) in enumerate(
zip(extensions, ext_read_sets)):
haplotype_nodes = new_set.haplotypes[hap_num]
# Add the nodes of the extension to each haplotype
# It's possible that the last node of this haplotype set
# (which is probably a bubble exit), is also the bubble entrance
# and thus our start node of our extension.
if (len(haplotype_nodes) > 0 and
haplotype_nodes[-1] == extension[0]):
haplotype_nodes.extend(extension[1:])
else:
haplotype_nodes.extend(extension)
new_set.read_sets[hap_num].update(read_set)
return new_set
评论列表
文章目录