def ic_at(motif, other, offset): ''' Caculates the information content, ic, for a specific alignment. The approach makes a temporary motif object containing the overlapping sequences in the alignemnt and taking the average of the pssm. Parameters ---------- motif, other: Motif objects The motifs of interest offset: int The offset value that results in the alignment of interest. ''' #Pull the sequences containined in the aligned region of the motifs from each of the motif instances. alignment_len = min(len(motif) - offset, len(other)) motif_seqs = [ site[offset:alignment_len + offset] for site in motif.instances ] other_seqs = [site[:alignment_len] for site in other.instances] # Create the motif and compute the IC amotif = Motif(instances=Instances(motif_seqs + other_seqs)) amotif.pseudocounts = dict(A=0.25, C=0.25, G=0.25, T=0.25) #print('Motif Seqs: ' , motif_seqs) #print('Other Seqs: ' , other_seqs) #print('Offset ', offset) #print('IC: ' , amotif.pssm.mean(), '\n\n') return amotif.pssm.mean()