This facility provides ANSI C and FORTRAN access to the inbreeding coefficient algorithm as described in Meuwissen and Luo(1992). The developer first allocates memory to contain a pedigree with a call to an initialization routine. Animals are then added to the pedigree in numerical order and finally the developer makes use of routines for accessing information in the pedigree. The functions can be used to compute inbreeding coefficients and relationships and are especially useful for animal breeding simulation studies.
ANSI C Facilities:
#include <cgilc.h>
int xpdinit(int n);
int xpdfree();
float xpdadd(int is,int id);
float xpdrel(int is,int id);
float xpdd(int i);
float xpdf(int i);
int xpdsire(int i);
int xpddam(int i);
The function xpdinit allocates the memory structures for the pedigree and the integer n specifies the maximum number of animals that can be accomodated. The return value is 0 if sufficient system resources are available otherwise -1. The memory used can be deallocated with a call to the xpdfree function.
Animals are added to the pedigree with repeated calls to the xpdadd function which must be done in numerical order from 1 to n. The two integer arguments specify the sire and dam number of the animal being added. The float return value is the inbreeding coefficient of the animal being added. If an error is encountered the function returns -2.0.
Once the pedigree is built (or partially built) one can use the remaining functions to obtain various pedigree numbers as follows:
C Example:
The following example C program reads a typical pedigree file "pop1.d" (which contains id, sire, dam in numerical order from 1 to n) adding the animals to the pedigree structure and printing the inbreeding coefficients as it goes. At the end all of the relationships are printed.
#include <stdio.h>
#include <stdlib.h>
#include <cgilc.h>
main()
{
int i,j,k,isir,idam,nr;
float fi,sumc;
FILE *fin;
/* read pedigree, calculate and output coefficients
*/
fin=fopen("pop1.d","r");
xpdinit(10000); /* allow for 10000 animals
*/
/* read file and compute inbreeding coeff's
*/
nr=0;
while( 3 == fscanf(fin,"%d %d %d",&i,&j,&k)
) {
nr++;
fi = xpdadd(j,k); /* add individual i to the
pedigree */
printf("%6d %6d %6d %12.6f\n" ,i,j,k,fi );
}
/* now compute all relationships */
for(i=1;i<=nr;i++){
printf("\n------Rel %d ",i);
for(j=i;j<=nr;j++){
fi=xpdrel(i,j);
printf("%6.4f ",fi);
}
printf("\n");
}
}
The above program can be compiled on the CGIL HPUX systems as follows:
cc -Ae test.c -l cgilc
FORTRAN users may also use these facilities as follows:
call fxini(n)# initialize the pedigree
call fxadd(isire,idam,fi) # add an individual,
inbreeding coeff is in fi
call fxrel(I,j,r) # get relationship between
I and j
call fxdd(I,j,d) # get within family additive
genetic variance
call fxsire(I,isire) # get sire of individual
I
call fxdam(I,idam) # get dam of individual
I
call fxfree # free memory structures
Compile FORTRAN as follows:
f77 test.f -lcgil
Bibliography:
Meuwissen, T. and Z. Luo. 1992. Computing inbreeding coefficients in large populations. GSE 24:4 p 305-313.