bda72d5101dc3eb814a30d6cafbe4bfab6a4d553 angie Fri Jun 14 11:16:43 2013 -0700 Fix corner case (deletion falls across exon boundary; normally we wantto trim the part of the allele that falls outside, but for the deletion the allele is ""). diff --git src/hg/lib/variant.c src/hg/lib/variant.c index 72c470d..5014abd 100644 --- src/hg/lib/variant.c +++ src/hg/lib/variant.c @@ -1,44 +1,39 @@ /* variant.c -- routines to convert other variant formats to a generic * variant structure */ #include "common.h" #include "variant.h" struct allele *alleleClip(struct allele *allele, int sx, int ex, struct lm *lm) /* Return new allele pointing to new variant, both clipped to region defined by [sx,ex). */ { struct variant *oldVariant = allele->variant; int start = oldVariant->chromStart; int end = oldVariant->chromEnd; -int oldVariantWidth = end - start; int delFront = 0; int delRear = 0; if (start < sx) { - if (oldVariantWidth != allele->length) /* FIXME */ - errAbort("cannot clip alleles that are a different length than variant region"); - delFront = sx - start; + delFront = min(sx - start, allele->length); start = sx; } if (end > ex) { - if (oldVariantWidth != allele->length) /* FIXME */ - errAbort("cannot clip alleles that are a different length than variant region"); - delRear = end - ex; + delRear = min(end - ex, allele->length - delFront); end = ex; } struct variant *newVariant; lmAllocVar(lm, newVariant); newVariant->chrom = lmCloneString(lm, oldVariant->chrom); newVariant->chromStart = start; newVariant->chromEnd = end; newVariant->numAlleles = 1; struct allele *newAllele; lmAllocVar(lm, newAllele); newVariant->alleles = newAllele; newAllele->variant = newVariant; newAllele->length = allele->length - delRear - delFront;