Code to compute tscores