def get_unannotated_intervals(self):
""" Return a list of Annotation objects corresponding to unannotated regions on the contig """
unannotated_intervals = []
annotation_indicator = np.zeros(len(self.sequence))
for annotation in self.annotations:
annotation_indicator[annotation.contig_match_start:annotation.contig_match_end] = 1
interval_start = 0
for annotated, region_iter in itertools.groupby(annotation_indicator, lambda x: x == 1):
region = list(region_iter)
if not annotated:
feature = vdj_reference.create_dummy_feature(display_name='UNANNOTATED',
region_type='UNANNOTATED',
sequence=None)
unannotated_intervals.append(Annotation(feature=feature,
cigar=None,
score=0,
annotation_length=len(region),
annotation_match_start=0,
annotation_match_end=len(region),
contig_match_start=interval_start,
contig_match_end=interval_start + len(region),
mismatches=[],
))
interval_start += len(region)
return unannotated_intervals
评论列表
文章目录