#!/usr/bin/perl -w
use strict;
my$tline="";
my@tlist=();
my$tempi=0;
my$tempj=0;
my$tempk=0;
my$pline="";
my@plist=();
my$tid=0;
my%tidx=();
my$egID=0;
my$egPosition="";
my$egTIR=0;
my$egDR=0;
my$egTIRIdent=0;
my$egDRIdent=0;
my$egTIRLeft="";
my$egTIRRight="";
my$egDRLeft="";
my$egDRRight="";
my$tScore=0;
((@ARGV==1)or(@ARGV==2))or die""."Error in syntax!\n"."   ./testScore.pl <inputdata.dat> [Mode]\n";
my$egMode=0;
if(@ARGV==2){$egMode=$ARGV[1];}open(efIn,"$ARGV[0]")or die"Error when loading data!\n";
while(<efIn>){$tline=$_;$tline=~s/[\r\n]//g;
if($tline=~/^\/\/$/){$tScore=&efScore($egMode);
print"Test score: $tScore\n";
print"Position => [$egPosition]              TIR => [$egTIR][$egTIRIdent]             DR => [$egDR][$egDRIdent]\n";
print"TIR => [$egTIRLeft] [$egTIRRight]\n";
print"DR => [$egDRLeft] [$egDRRight]\n";
print"--------------------------------------------------------------------------------------------------------------------\n";
$egID=0;$egPosition="";
$egTIR=0;$egTIRIdent=0;$egTIRLeft="";$egTIRRight="";
$egDR=0;$egDRIdent=0;$egDRLeft="";$egDRRight="";}elsif($tline=~/^ID\t(\d+)$/){$egID=$1;}elsif($tline=~/^POSITION\t(\d+\-\d+)$/){$egPosition=$1;}elsif($tline=~/^DR\t(\d+)$/){$egDR=$1;}elsif($tline=~/^TIR\t(\d+)$/){$egTIR=$1;}elsif($tline=~/^DRIDENT\t([\.\d]+)$/){$egDRIdent=$1;}elsif($tline=~/^TIRIDENT\t([\.\d]+)$/){$egTIRIdent=$1;}elsif($tline=~/^TIRLEFT\t([A-Za-z]+)$/){$egTIRLeft=$1;}elsif($tline=~/^TIRRIGHT\t([A-Za-z]+)$/){$egTIRRight=$1;}elsif($tline=~/^DRLEFT\t([A-Za-z]+)$/){$egDRLeft=$1;}elsif($tline=~/^DRRIGHT\t([A-Za-z]+)$/){$egDRRight=$1;}}close(efIn);
sub efScore{my($tMode)=@_;
my$aScore=0;
my$egRatio=1;
if($tMode==0){$aScore=$egTIRIdent+$egDRIdent;}elsif($tMode==1){$aScore=$egTIR*$egTIRIdent+$egDR*$egDRIdent;}elsif($tMode==2){$aScore=$egTIRIdent*$egDRIdent;}elsif($tMode==3){$aScore=$egTIR*$egTIRIdent+$egRatio*$egDR*$egDRIdent;}elsif($tMode==4){$aScore=$egTIR+$egDR;}return$aScore;}
