//DD_Rtn_Mean_Dist //RAM, Nov 1, 2015 //pass 4 location (allele locations), return mean distance among them // called by any method that needs to calculate the mean distance between 4 alleles C_INTEGER($1;$2;$3;$4) //these are the alleles, so just keep these as names C_REAL($Mean;$0) C_TEXT($Pair;$link) ARRAY TEXT($aPairs;6) ARRAY REAL($aDist;6) C_INTEGER($i) $link:="_" // make a pairID out of each of the possible combinations of 4 alleles $aPairs{1}:=String($1)+$link+String($2) $aPairs{2}:=String($1)+$link+String($3) $aPairs{3}:=String($1)+$link+String($4) $aPairs{4}:=String($2)+$link+String($3) $aPairs{5}:=String($2)+$link+String($4) $aPairs{6}:=String($3)+$link+String($4) $Mean:=0 For ($i;1;6) //Find the distance between these two alleles in the Distance table QUERY([Distances];[Distances]Pair=$aPairs{$i}) $Dist:=[Distances]Distance $Mean:=$Mean+$Dist End for $0:=$Mean/6 // return the mean distance (sum of all distances divided by the 6 possible combinations)