#ifndef _COMMONDEFS_H #define _COMMONDEFS_H 1 /* Output from p2c, the Pascal-to-C translator */ /* From input file "ilink.p" */ /* This file contains definitions for a modified version of the ILINK program*/ /* The modifications are described in the papers: */ /* R. W. Cottingham, Jr., R. M. Idury, and A. A. Schaffer */ /* Faster Sequential Genetic Linkage Computations */ /* American Journal of Human Genetics, 53(1993), pp. 252-263*/ /* and A. A. Schaffer, S. K. Gupta, K. Shriram, and R. W. Cottingham, Jr., */ /* Avoiding Recomputation in Linkage Analysis, */ /* Human Heredity 44(1994), pp. 225-237. */ #include /* Shriram: begin */ #include #include #include #include #include #include /* Shriram: end */ #define true 1 #define false 0 #ifndef NULL #define NULL 0 #endif /*From p2c.h*/ #ifndef FileNotFound #define FileNotFound 10 #endif #ifndef EXIT_FAILURE #ifdef vms #define EXIT_SUCCESS 1 #define EXIT_FAILURE (02000000000L) #define unlink delete #else #define EXIT_SUCCESS 0 #define EXIT_FAILURE (-1) #endif /*from p2c.h*/ #endif #ifndef STAT_SUCCESS #define STAT_SUCCESS 0 #endif #ifndef Void #define Void void #endif #ifndef Local #define Local static #endif #ifndef Free #define Free free #endif #ifndef Malloc #define Malloc malloc #endif #define version 5.1 /*PRESENT VERSION OF LINKAGE*/ #define fastversion 2.2 /*PRESENT VERSION OF FASTLINK*/ /*A. A. Schaffer*/ #define DIAGNOSTIC true /*should we test settings of constants*/ /*MAXIMUM NUMBER OF RECOMBINATION PROBABILITIES*/ /*THE FOLLOWING SHOULD BE LARGER THAN MININT*/ #ifndef maxcensor #define maxcensor 70000L /*MAXIMUM FOR CENSORING ARRAY*/ #endif #ifndef maxsys #define maxsys 40 /*MAXIMUM NUMBER OF SYSTEMS*/ #endif #ifndef maxlocus #define maxlocus 8 /*MAXIMUM NUMBER OF LOCI */ #endif #define maxrec maxlocus /*MAXIMUM POSSIBLE NUMBER OF RECOMB/MEI*/ #ifndef maxseg #define maxseg 128 /* (maxlocus-1) */ /* = 2 I.E. 2 TO THE POWER maxlocus-1 */ #endif #ifndef BIGMAXSEG #define BIGMAXSEG 16384 #endif #ifndef BIGMAXLOCUS #define BIGMAXLOCUS 15 #endif #ifndef maxall #define maxall 16 /*MAX NUMBER OF ALLELES AT A SINGLE LOCUS*/ #endif #ifndef maxhap #define maxhap 200 /*MAXIMUM NUMBER OF HAPLOTYPES*/ /* = n1 x n2 x ... ETC. WHERE ni = NUMBER OF ALLELES LOCUS I*/ #endif #define maxfem maxhap * (maxhap + 1) / 2 /*MAXIMUM NUMBER OF JOINT GENOTYPES FOR A FEMALE*/ /* = maxhap x (maxhap + 1 ) /2 */ #define maxmal maxfem /*MAXIMUM NUMBER OF JOINT GENOTYPES FOR A MALE*/ /* = maxfem (AUTOSOMAL) OR maxhap (SEXLINKED)*/ #ifndef maxind #define maxind 1000 /*MAXIMUM NUMBER OF INDIVIDUALS*/ #endif #ifndef maxped #define maxped 150 /*MAXIMUM NUMBER OF PEDIGREES*/ #endif #ifndef maxchild #define maxchild 16 /*MAXIMUM NUMBER OF FULLSIBS IN A SIBSHIP*/ #endif #ifndef maxloop #define maxloop 2 /*MAXIMUM NUMBER OF LOOPS PER PEDIGREE*/ #endif #define minfreq 0.0 #define affall 2 /*DISEASE ALLELE FOR QUANTITATIVE TRAITS OR AFFECTION STATUS*/ /* QUANTITATIVE TRAIT */ #define maxtrait 3 /*MAXIMUM NUMBER OF QUANTITATIVE FACTORS AT A SINGLE LOCUS*/ #define missval 0.0 /*MISSING VALUES FOR QUANTITATIVE TRAITS */ /* AFFECTION STATUS */ #define missaff 0 /*MISSING VALUE FOR AFFECTION STATUS */ #define affval 2 /*CODE FOR AFFECTED INDIVIDUAL*/ #ifndef maxliab #define maxliab 120 /*MAXIMUM NUMBER OF LIABILITY CLASSES */ #endif /* BINARY (FACTOR UNION) SYSTEM */ #ifndef maxfact #define maxfact 15 #endif /*MAXIMUM NUMBER OF BINARY CODES AT A SINGLE LOCUS*/ /* OTHERS */ #define scalemult 2.0 /*SCALE WEIGHT FOR EACH LOCUS INCLUDED*/ /*TRUE IF ESTIMATING PARAMETERS OTHER THAN REC*/ #ifndef fitmodel #define fitmodel false #endif /*Note: It is probably a bad idea to change dostream to false if using LINKMAP*/ #ifndef dostream #define dostream true /*STREAM FILE OUTPUT*/ #endif #define zerolike (-1.0e20) /*FOR INCONSISTENT DATA OR RECOMBINATION */ /* Shriram: begin Shriram's additions commented out #ifdef M_LN10 #define log10_ M_LN10 #else */ #define log10_ 2.30259 /* #endif Shriram: end */ #define minint (-32767) /*MINIMUM ALLOWED INTEGER*/ /*GRADIENT APPROXIMATIONS*/ #ifndef approximate #define approximate false #endif /*next two typedefs come from p2c*/ typedef char boolean; typedef short unschar; typedef struct gennurec { int genenumber[maxhap][maxhap]; } gennurec; typedef struct approxrec { unschar approxarray[maxped][maxfem]; } approxrec; typedef struct censorrec { boolean censor[maxcensor - minint]; } censorrec; typedef char hapvector[maxlocus]; typedef double genotype[maxfem]; typedef double covmatrix[maxtrait][maxtrait]; typedef int mutarray[3][2]; typedef double thesemeans[maxtrait]; typedef thesemeans means[maxall + 1][maxall]; typedef enum { auto_, /* autosomal, regular inheritance */ mauto, /* autosomal, mutation model */ sex, /* sexlinked, regular inheritance */ msex /* sexlinked, mutation model */ } pathway; typedef enum { peelup, peeldown } direction; typedef int binset; typedef binset phenarray[maxall]; typedef enum { affection, quantitative, binary_, null_ } locustype; typedef struct locusvalues { int nallele, format; double freq[maxall]; struct locusvalues *privlocus; locustype which; union { struct { double pen[maxall + 1][maxall][3][maxliab]; long nclass; } U0; struct { long ntrait; means pm; covmatrix vmat; double det, contrait, conmat; } U1; phenarray allele; } UU; } locusvalues; typedef struct phenotype { locustype which; binset phenf; double x[maxtrait]; boolean missing; int aff; long liability; } phenotype; typedef phenotype *hindphen[maxsys]; typedef phenotype *indphen[maxlocus]; /* a structure of type 'thisarray' stores the conditional genotype probabilities for an individual. The probabilities are stored in the array genarray. We expect this array to be sparse. The field sparseflag is a boolean array such that sparseflag[i] is nonzero if and only if genarray[i] is nonzero. */ typedef struct thisarray { unsigned char sparseflag[maxfem]; genotype genarray; } thisarray; typedef boolean possvect[maxall][maxall]; typedef possvect possarray[maxlocus]; typedef struct information { possarray possible; } information; /* a record of type thisperson stores information about one person in one pedigree */ typedef struct thisperson { int id, ped, inloop; struct thisperson *pa; /* father */ struct thisperson *ma; /* mother */ struct thisperson *foff; /* first offspring */ struct thisperson *nextpa; /* next (half)-sibling with the same father */ struct thisperson *nextma; /* next (half)-sibling with the same mother */ thisarray *gen; /* genotype information */ hindphen holdphen; indphen phen; phenotype *privphen; boolean unknown, multi, done, up, male, firstpass; /* next three added by A. A. Schaffer */ boolean newgenexists; boolean loopdepend; /* true if genotype of loopbreaker depends on this */ boolean loopneeded; /* true if genotype of this depends on loopbreaker */ information *store; } thisperson; typedef int subhap[maxseg]; typedef double thetarray[maxlocus]; /* typedef double happrob[maxneed]; */ unsigned nuneed; /* Introduced by R. M. Idury, actual size of segprob arrays */ unsigned nuprobclass; /* Introduced by A. A. Schaffer, actual number of probclasses */ typedef struct thetavalues { thetarray theta; double *segprob; } thetavalues; /*The following declarations help store a partial correspondence between genotypes and haplotypes, haps1 between base[i] and fence[i] stores the left haplotypes that genotype i can pass on to a child; haps2 stores the right haplotypes; hind stores the index into an array of recombination probabilities indicating the probability of this haplotype getting passed on from genotype i. currentfence is used as a counter to fill haps1, haps2, hind, base, and fence. */ unsigned currentfence; /* R. M. Idury */ unsigned int base[maxfem], fence[maxfem]; /*R. M. Idury*/ unsigned short *haps1, *haps2; unsigned int *hind; /* The arrays invgenenum1 and invgenenum2 store an effective inverse to the genenumber mapping above. They convert an index into genenumber into two haplotypes */ unsigned invgenenum1[maxfem], invgenenum2[maxfem]; /* R. M. Idury */ pathway thispath; boolean informative[maxped]; boolean rare[maxfem], risk1[maxfem], risk2[maxfem]; boolean riskmale[maxhap]; approxrec *approxstruct; censorrec *censorstruct; int thisc; boolean malechild[maxchild]; thisarray *thischild[maxchild]; thisperson *childarray[maxchild]; /*A. A. Schaffer*/ int nchild; int segstart[maxfem]; unsigned int probstart[maxfem], probend[maxfem]; boolean nohom[maxlocus]; locusvalues *thislocus[maxlocus]; int increment[maxlocus], order[maxlocus]; /*PEOPLE*/ thisperson *person[maxind + 1]; thisperson *proband[maxped]; thisperson *looppers[maxped][maxloop][2]; /*MUTATION */ unschar muthap[maxhap]; gennurec *gennustruct; /*RECOMBINATION*/ int maxclasssize, maxisozygclass; /* 2^no. of loci, square of maxsegsize*/ unsigned *segindex; double *tempseg, *tempseg2; double *segval; thetavalues *maletheta, *femaletheta; /*FREQUENCIES */ thisarray *hapfreq; /*RISK*/ char riskall; /*OTHERS*/ int risksys, mutsys, mlocus, lastpriv, i; int nuhap; int fgeno, mgeno; int nuped, totperson; double segscale, mutmale, mutfemale, like, alike, distratio; boolean interfer, disequi, sexlink, risk, sexdif, readfemale, dolod, firstapprox, lasttime; boolean firsttime; /* true if in or before first likelihood evaluation */ FILE *outfile, *ipedfile, *datafile, *stream, *speedfile; /*ILINK*/ FILE *final; boolean mapping; /*Added by A. A. Schaffer to keep track of which traversal we are on for handling a loop*/ char loopfirstgen; /* false if doing a traveral for the loopbreaker and it is not the first genotype of the innermost loop breaker */ char looplastgen; /* Local variables for seg: */ struct LOC_seg { struct LOC_likelihood *LINK; /* information for pedigree */ thisperson **p; /* in segdown(): father in segup(): parent connecting traversal */ thisperson **q; /* mate of p */ thisperson **r; /* first child of p and q */ thisperson *child, *father, *mother; /* same people as p, q, and r */ int fseg, sseg, sstart, send, fstart, fend, firstseg, secondseg; int nfirst; /* number of genotypes of gender of p */ int nsecond; /* number of genotypes of gender of q */ double pf, ps; thetavalues *firstsex; /* theta info for gender of p */ thetavalues *secondsex; /* theta info for gender of q */ } ; /*Local variables for likelihood*/ struct LOC_likelihood { int thisped; thisperson *proband; int loopgen[maxloop]; double homo, hetero; int nuscale; thisarray *holdpoint[maxloop]; } ; /*Local variables for inputdata*/ struct LOC_inputdata { long nfactor[maxlocus]; }; /*Local variables for readloci*/ struct LOC_readloci { struct LOC_inputdata *LINK; long i, whichtype, nupriv; }; /*The following definitions are needed to do checkpointing*/ /* K. Shriram: begin */ #define DateTimeStampStringLength 27 /* see ctime()'s man page */ #define SystemCallStringLength 1024 /* length of arg for system() */ char systemCallString [ SystemCallStringLength ] ; #define ensureWrite(f) { fflush ( (f) ) ; fsync ( fileno ( f ) ) ; } FILE * checkpointDatafile ; /* K. Shriram: end */ #endif /* _COMMONDEFS_H */ extern void getprobtable(); extern void segup(); extern void segdown(); extern void segsexup(); extern void segsexdown(); extern void performCheckpoint(); extern void recoverCheckpoint (); extern void getvect(); extern void recombination(); extern void getlocations(); extern void readspeed(); extern void invert(); extern void cleanup(); extern void initseg(); extern void exitseg(); extern void getgeneindices(); extern void seg(); extern void likelihood(); extern void segsexctop(); extern void segsextop(); extern void segctop(); extern void segtop(); extern void segcapprox(); extern void msegsexdown(); extern void msegdown(); extern double mapfunction(); extern double getdist(); extern double invdist(); extern void setparam(); extern void inputdata(); extern void oldsegsexup(); extern void oldsegup();