open SUBF, 'true_AC.txt' or die $!;                                                                         
my $n=0;                                                                                                   
@subfamily;                                                                                                
while (my $line=<SUBF>) {                                                                                  
                         chomp $line;                                                                      
                         $subfamily[$n]=$line;                                                             
                         $n++;                                                                             
                        }                                                                                  
close SUBF;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
open (RES, '>for_ROC.txt');                                
print RES "Threshold  TP  FP  FN  TP/(TP+FN)  TP/(TP+FP)\n";
for ($threshold=2; $threshold < 20.91; $threshold=$threshold+0.01) {
                                                                     open FIND, 'results_AC.txt' or die $!;                                                                                            
                                                                     @temporary=@subfamily;                                                                                                            
                                                                     my $fp=0;                                                                                                                         
                                                                     my $tp=0;                                                                                                                         
                                                                     my $fn=0;                                                                                                                         
                                                                     my $splice;                                                                                                                       
                                                                     while (my $str=<FIND>) {                                                                                                          
                                                                                             $str=~m#^([0-9\.]+)\s+([A-Z0-9_]+)#;                                                                            
                                                                                             if ($1 >= $threshold) {                                                                                   
                                                                                                                    my $hit=0;                                                                         
                                                                                                                    for (my $c=0; $c<scalar @temporary; $c++) {                                        
                                                                                                                                                               if ($temporary[$c] eq $2) {             
                                                                                                                                                                                            $hit=1;    
                                                                                                                                                                                            $splice=$c;
                                                                                                                                                                                            last;      
                                                                                                                                                                                         }             
                                                                                                                                                              }                                        
                                                                                                                    if ($hit==0) {$fp++;}                                                              
                                                                                                                    elsif ($hit==1) {                                                                  
                                                                                                                                     $tp++;                                                            
                                                                                                                                     splice @temporary, $splice, 1;                                    
                                                                                                                                    }                                                                  
                                                                                                                                                                                                       
                                                                                                                  }                                                                                    
                                                                                             else {last;}                                                                                              
                                                                                            }                                                                                                          
                                                                     @fn=@temporary;                                                                                                                   
                                                                     $fn=@fn;                                                                                                                          
                                                                     close FIND;                                                                                                                                                                                             
                                                                     print RES "$threshold  $tp  $fp  $fn ".$tp/($tp+$fn)." ".$tp/($tp+$fp)."\n";                                                                                                                                                                                    
                                                                   }
close RES;                                                                                               
