#$Author: sinnwell $
#
#$Date: 2006/04/26 19:18:52 $
#
#$Header: /people/biostat3/sinnwell/Projects/LDpairs/Make/RCS/gcode.q,v 1.2 2006/04/26 19:18:52 sinnwell Exp $
#
#$Id: gcode.q,v 1.2 2006/04/26 19:18:52 sinnwell Exp $
#
#$Locker:  $
#
#$Log: gcode.q,v $
#Revision 1.2  2006/04/26 19:18:52  sinnwell
#Zaykin spelled incorrectly
#
#Revision 1.1  2002/09/09 19:53:18  sinnwell
#Initial revision
#
gcode <- function(a1,a2) {

# gcode creates a unique index for a one-locus genotype 
# based on formula from:
#   Zaykin D., Zhivotovsky L. and Weir B, "Exact tests for
#   association between alleles at arbitrary numbers of
#   loci"  Human Identification: The Use of DNA Markers,
#   169-178, 1995.

  i <- ifelse(a1 < a2,a2,a1)
  j <- ifelse(a1 < a2,a1,a2)
  genocode <- i*(i-1)/2 + j
  return(genocode)

}
