def create_pic_distribution( seqs, distrib_fhand=None, plot_fhand=None, summary_fhand=None, read_groups=None, group_kind=None, groups=None ): "It creates the distribution of the pic (not takes in account ref allele)" title = "pic" if groups and group_kind: title = "pic (%s: %s)" % (group_kind, ",".join(groups)) pics = CachedArray("f") for seq in seqs: for snv in seq.get_features("snv"): if not group_kind and "pic" in snv.qualifiers: pic = snv.qualifiers["pic"] else: pic = calculate_pic(snv, group_kind=group_kind, groups=groups) if pic is not None: pics.append(pic) if list(pics): create_distribution( pics, labels={"title": title}, distrib_fhand=distrib_fhand, bins=None, plot_fhand=plot_fhand, range_=None, summary_fhand=summary_fhand, calculate_freqs=False, remove_outliers=False, )
def calculate_pics_group(seqs, groups=None, group_kind=None): 'It calculates the snv heterozygosity of a given group' pic_profile = {} for seq in seqs: for snv in seq.get_features('snv'): pic = calculate_pic(snv, group_kind=group_kind, groups=groups) if pic is not None: location = snv.location.start.position seq_name = seq.name if seq_name not in pic_profile: pic_profile[seq_name] = [] pic_profile[seq_name].append((location, pic)) return pic_profile