src/hg/oneShot/tdbRewriteViewsToSubtracks/tdbRewriteViewsToSubtracks.c 1.5

1.5 2010/01/04 19:12:40 kent
Merging viewInTheMiddle branch.
Index: src/hg/oneShot/tdbRewriteViewsToSubtracks/tdbRewriteViewsToSubtracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/oneShot/tdbRewriteViewsToSubtracks/tdbRewriteViewsToSubtracks.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -b -B -U 4 -r1.4 -r1.5
--- src/hg/oneShot/tdbRewriteViewsToSubtracks/tdbRewriteViewsToSubtracks.c	14 Dec 2009 03:14:06 -0000	1.4
+++ src/hg/oneShot/tdbRewriteViewsToSubtracks/tdbRewriteViewsToSubtracks.c	4 Jan 2010 19:12:40 -0000	1.5
@@ -84,16 +84,8 @@
 fputs(tag->text, f);
 }
 #endif
 
-int raTagCmp(const void *va, const void *vb)
-/* Compare two raTags. */
-{
-const struct raTag *a = *((struct raTag **)va);
-const struct raTag *b = *((struct raTag **)vb);
-return strcmp(a->name, b->name);
-}
-
 void recordLocationReport(struct raRecord *rec, FILE *out)
 /* Write out where record ends. */
 {
 fprintf(out, "in stanza from lines %d-%d of %s\n", 
@@ -375,19 +367,8 @@
     }
 return NULL;
 }
 
-boolean sameTagInOtherRecord(struct raTag *tag, struct raRecord *r)
-/* Return TRUE if tag exists in record r, and has same value in r. */
-{
-struct raTag *t = raRecordFindTag(r, tag->name);
-if (t == NULL)
-    return FALSE;
-if (!sameString(t->val, tag->val))
-    return FALSE;
-return TRUE;
-}
-
 void raRecordWriteTags(struct raRecord *r, FILE *f)
 /* Write out tags in record to file, including preceding spaces. */
 {
 /* Write all tags. */
@@ -429,9 +410,12 @@
 struct raTag *t;
 for (t = r->tagList; t != NULL; t = t->next)
     raTagWriteIndented(t, f, indent);
 if (r->endComments)
+    {
+    spaceOut(f, indent);
     fputs(r->endComments, f);
+    }
 }
 
 struct raTag *findViewSubGroup(struct raRecord *r)
 /* Find tag that is one of the subGroup tags with first word view.  May return NULL. */
@@ -461,9 +445,10 @@
 	char *s = firstTagInText(t->text);
 	mustWrite(f, t->text, s - t->text);
 	spaceOut(f, 4);
 	fprintf(f, "subTrack %s", viewTrackName);
-	int i;	/* Skip over two words we've already written. */
+	/* Skip over subTrack and name in original text. */
+	int i;
 	for (i=0; i<2; ++i)
 	    {
 	    s = skipLeadingSpaces(s);
 	    s = skipToSpaces(s);
@@ -495,11 +480,13 @@
 struct raTag *viewSubGroupTag = findViewSubGroup(complexRecord);
 if (viewSubGroupTag == NULL)
     recordAbort(complexRecord, "Can't find view subGroup#");
 char *line = lmCloneString(lm, viewSubGroupTag->val);
+/*  line looks something like: 
+ *       view Views FiltTransfrags=Filtered_Transfrags Transfrags=Raw_Transfrags */
 char *viewWord = nextWord(&line);
 assert(sameString(viewWord, "view"));
-char *viewLabelWord = nextWord(&line);
+nextWord(&line);	// Just skip over name to label views with
 struct slPair *viewList = NULL;
 char *thisEqThat;
 while ((thisEqThat = nextWord(&line)) != NULL)
     {
@@ -641,9 +628,9 @@
     {
     if (recordInParentFile)
         recordAbort(r, "Can't handle settingsByViews with records in parent file levels");
     /* We are the parent. */
-    fprintf(f, "# Rewriting parent with subGroup view %s\n", r->key);
+    // fprintf(f, "# Rewriting parent with subGroup view %s\n", r->key);
     rewriteSettingsByViewComplex(file, r, f, lm);
     }
 else if (subTrack)
     {
@@ -656,10 +643,9 @@
         {
 	if (rParent->file != r->file)
 	    recordAbort(r, "complex parent %s not in same file as subTrack %s", 
 	    	rParent->key, r->key);
-	fprintf(f, "# Omitting child (%s) of parent (%s) with views\n", 
-		r->key, rParent->key);
+	// fprintf(f, "# Omitting child (%s) of parent (%s) with views\n", r->key, rParent->key);
 	}
     else
         {
 	raRecordWriteTags(r, f);
@@ -719,8 +705,9 @@
 struct lm *rootLm = lmInit(0);
 char rootName[PATH_LEN];
 safef(rootName, sizeof(rootName), "%s/%s", inDir, trackFile);
 struct raLevel *rootLevel = raLevelRead(rootName, rootLm);
+rewriteLevel(rootLevel, outDir, rootLm);
 
 /* Make subdirectory list. */
 struct fileInfo *org, *orgList = listDirX(inDir, "*", FALSE);
 for (org = orgList; org != NULL; org = org->next)