1. def score(self):
    2. def frame_score(reads, mean_reads):
    3. return math.pow((reads - mean_reads), 2) / mean_reads
    4. transcript, intervals = self.transcript_intervals
    5. gene_type, chrom, strand, gene_id, transcript_id, feature = transcript.split(":")
    6. if "ORFscore" in self.methods:
    7. psite_reads = self.reads()
    8. if psite_reads == "NA":
    9. return "NA"
    10. else:
    11. frames_mean = sum(psite_reads) / float(len(psite_reads))
    12. 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)
    13. return score if (psite_reads[0] > psite_reads[1]) and (psite_reads[0] > psite_reads[2]) else -score
    14. else:
    15. return "NA"