def score(self):
def frame_score(reads, mean_reads):
return math.pow((reads - mean_reads), 2) / mean_reads
transcript, intervals = self.transcript_intervals
gene_type, chrom, strand, gene_id, transcript_id, feature = transcript.split(":")
if "ORFscore" in self.methods:
psite_reads = self.reads()
if psite_reads == "NA":
return "NA"
else:
frames_mean = sum(psite_reads) / float(len(psite_reads))
score = math.log(math.fsum([frame_score(psite_reads[0], frames_mean), frame_score(psite_reads[1], frames_mean), frame_score(psite_reads[2], frames_mean), 1]), 2)
return score if (psite_reads[0] > psite_reads[1]) and (psite_reads[0] > psite_reads[2]) else -score
else:
return "NA"