do the TPM calculation

def calculate(self):
      """do the TPM calculation"""
      self._calculated = True
      for name in self.transcripts:
         self.transcripts[name]['RPK'] = (float(self.transcripts[name]['count'])/float(self.transcripts[name]['length']))/float(1000)
      tot = 0.0
      for name in self.transcripts:
         tot += self.transcripts[name]['RPK']
      tot = tot/float(1000000)
      for name in self.transcripts:
         self.transcripts[name]['TPM'] = self.transcripts[name]['RPK']/tot
      """do the FPKM calculation"""
      tot = 0
      for name in self.transcripts: tot += self.transcripts[name]['count']
      tot = float(tot)/float(1000000)
      for name in self.transcripts:
         if tot > 0:
            rpm = float(self.transcripts[name]['count'])/float(tot)
            self.transcripts[name]['FPKM'] = 1000*rpm/self.transcripts[name]['length']