2f19b4081ef0f0d93daf8f7ff1c26cf8879a4d14 braney Thu Apr 26 17:26:10 2012 -0700 more work on #6152. Now with in-frame deletions! diff --git src/hg/lib/variant.c src/hg/lib/variant.c index fcbefbf..47dbe50 100644 --- src/hg/lib/variant.c +++ src/hg/lib/variant.c @@ -38,30 +38,41 @@ newVariant->chromStart = start; newVariant->chromEnd = end; newVariant->numAlleles = 1; struct allele *newAllele; AllocVar(newAllele); newVariant->alleles = newAllele; newAllele->variant = newVariant; newAllele->length = allele->length - delRear - delFront; assert(newAllele->length > 0); newAllele->sequence = cloneString(&allele->sequence[delFront]); newAllele->sequence[newAllele->length] = 0; // cut off delRear part return newAllele; } +static char *makeDashes(int count) +{ +char *ret = needMem(count + 1); +char *ptr = ret; + +while(count--) + *ptr++ = '-'; + +return ret; +} + struct variant *variantFromPgSnp(struct pgSnp *pgSnp) /* convert pgSnp record to variant record */ { struct variant *variant; // this is probably the wrong way to do this. Alleles in // variant should be their size in query bases int alleleLength = pgSnp->chromEnd - pgSnp->chromStart; // We have a new variant! AllocVar(variant); variant->chrom = cloneString(pgSnp->chrom); variant->chromStart = pgSnp->chromStart; variant->chromEnd = pgSnp->chromEnd; variant->numAlleles = pgSnp->alleleCount; @@ -76,32 +87,42 @@ char *thisAlleleString = nextAlleleString; // advance pointer to next variant string // probably there's some kent routine to do this behind the curtain nextAlleleString = strchr(thisAlleleString, '/'); if (nextAlleleString) // null out '/' and move to next char { *nextAlleleString = 0; nextAlleleString++; } // this check probably not right, could be different per allele int alleleStringLength = strlen(thisAlleleString); if (alleleStringLength != alleleLength) + { + // check for special case of single '-' + if (sameString("-", thisAlleleString)) + { + thisAlleleString = makeDashes(alleleLength); + alleleStringLength = alleleLength; + } + else errAbort("length of allele number %d is %d, should be %d", alleleNumber, alleleStringLength, alleleLength); + } // we have a new allele! struct allele *allele; AllocVar(allele); slAddHead(&variant->alleles, allele); allele->variant = variant; allele->length = alleleStringLength; + toLowerN(thisAlleleString, alleleStringLength); allele->sequence = cloneString(thisAlleleString); } slReverse(&variant->alleles); return variant; }