void flipstrand(char *fsname, SNP **snpm, int numsnps) // move alleles to opposite strand { FILE *fff ; char line[MAXSTR] ; char *spt[MAXFF] ; char *ss ; int nsplit, n, k ; SNP *cupt ; if (fsname == NULL) return ; openit (fsname, &fff, "r") ; freesnpindex() ; while (fgets(line, MAXSTR, fff) != NULL) { nsplit = splitup(line, spt, MAXFF) ; if (nsplit==0) continue ; if (spt[0][0] == '#') { freeup(spt, nsplit) ; continue ; } k = snpindex(snpm, numsnps, spt[0]) ; if (k>=0) { cupt = snpm[k] ; cupt -> alleles[0] = compbase(cupt -> alleles[0]) ; cupt -> alleles[1] = compbase(cupt -> alleles[1]) ; } freeup(spt, nsplit) ; } fclose (fff) ; }
int checkmatch(SNP *cupt1, SNP *cupt2) { char a1, a2, b1 , b2 ; if (docheck == NO) return 1 ; if (cupt1 -> alleles == NULL) return -1 ; if (cupt2 -> alleles == NULL) return -1 ; a1 = cupt1 -> alleles[0] ; a2 = cupt1 -> alleles[1] ; b1 = cupt2 -> alleles[0] ; b2 = cupt2 -> alleles[1] ; if ((a1 == 'X') && (a2 == 'X') && (strandcheck)) return -1 ; // flipcheck impossible if (strandcheck) { if ((a1 == 'A') && (a2 == 'T')) return -1 ; if ((a1 == 'T') && (a2 == 'A')) return -1 ; if ((a1 == 'C') && (a2 == 'G')) return -1 ; if ((a1 == 'G') && (a2 == 'C')) return -1 ; if ((b1 == 'A') && (b2 == 'T')) return -1 ; if ((b1 == 'T') && (b2 == 'A')) return -1 ; if ((b1 == 'C') && (b2 == 'G')) return -1 ; if ((b1 == 'G') && (b2 == 'C')) return -1 ; } if ((a1 == b1) && (a2 == 'X')) { cupt1 -> alleles[1] = b2 ; return 1 ; } if ((a1 == b2) && (a2 == 'X')) { cupt1 -> alleles[1] = b1 ; return 2 ; } if ((a1 == b1) && (a2 == b2)) return 1 ; if ((a1 == b2) && (a2 == b1)) return 2 ; if ((a1 == b1) && (b2 =='X')) return 1 ; if ((a2 == b1) && (b2 =='X')) return 2 ; if (strandcheck == NO) return 0 ; b1 = compbase(b1) ; b2 = compbase(b2) ; if ((a1 == b1) && (a2 == 'X')) { cupt1 -> alleles[1] = b2 ; return 1 ; } if ((a1 == b2) && (a2 == 'X')) { cupt1 -> alleles[1] = b1 ; return 2 ; } if ((a1 == b1) && (a2 == b2)) return 1 ; if ((a1 == b2) && (a2 == b1)) return 2 ; if ((a1 == b1) && (b2 =='X')) return 1 ; if ((a2 == b1) && (b2 =='X')) return 2 ; return 0 ; }