546a7af0889cda13e7b8b46b2783698c76abc038
angie
  Fri Jul 1 16:19:13 2011 -0700
Feature #986 (VCF): When converting VCF to pgSnp for display, abbreviate long alleles.
diff --git src/hg/hgTracks/vcfTrack.c src/hg/hgTracks/vcfTrack.c
index cf61389..429a863 100644
--- src/hg/hgTracks/vcfTrack.c
+++ src/hg/hgTracks/vcfTrack.c
@@ -15,33 +15,58 @@
 #include "udc.h"
 #endif//def USE_TABIX && KNETFILE_HOOKS
 
 #ifdef USE_TABIX
 
 //#*** TODO: use trackDb/cart setting or something
 static boolean doHapClusterDisplay = TRUE;
 static boolean colorHapByRefAlt = TRUE;
 
 static struct pgSnp *vcfFileToPgSnp(struct vcfFile *vcff)
 /* Convert vcff's records to pgSnp; don't free vcff until you're done with pgSnp
  * because it contains pointers into vcff's records' chrom. */
 {
 struct pgSnp *pgsList = NULL;
 struct vcfRecord *rec;
+int maxLen = 33;
 for (rec = vcff->records;  rec != NULL;  rec = rec->next)
     {
     struct pgSnp *pgs = pgSnpFromVcfRecord(rec);
+    // Insertion sequences can be quite long; abbreviate here for display.
+    int len = strlen(pgs->name);
+    if (len > maxLen)
+	{
+	if (strchr(pgs->name, '/') != NULL)
+	    {
+	    char *copy = cloneString(pgs->name);
+	    char *allele[8];
+	    int cnt = chopByChar(copy, '/', allele, pgs->alleleCount);
+	    int maxAlLen = maxLen / pgs->alleleCount;
+	    pgs->name[0] = '\0';
+	    int i;
+	    for (i = 0;  i < cnt;  i++)
+		{
+		if (i > 0)
+		    safencat(pgs->name, len+1, "/", 1);
+		if (strlen(allele[i]) > maxAlLen-3)
+		    strcpy(allele[i]+maxAlLen-3, "...");
+		safencat(pgs->name, len+1, allele[i], maxAlLen);
+		}
+	    }
+	else
+	    strcpy(pgs->name+maxLen-3, "...");
+	}
     slAddHead(&pgsList, pgs);
     }
 slReverse(&pgsList);
 return pgsList;
 }
 
 
 // Center-weighted alpha clustering of haplotypes -- see Redmine #3711, #2823 note 7
 // It might be nice to use an allele-frequency representation here instead of [ACGTN] strings
 // with "N" for missing info or differences, but keep it simple.
 
 struct cwaExtraData
 /* Helper data for hacTree clustering of haplotypes by center-weighted alpha distance */
     {
     int center;    // index from which each point's contribution to distance is to be weighted