src/hg/makeDb/mdbUpdate/mdbPrint.c 1.2

1.2 2010/04/23 02:56:21 tdreszer
Made RA style the default output
Index: src/hg/makeDb/mdbUpdate/mdbPrint.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/makeDb/mdbUpdate/mdbPrint.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -B -U 4 -r1.1 -r1.2
--- src/hg/makeDb/mdbUpdate/mdbPrint.c	13 Apr 2010 19:59:16 -0000	1.1
+++ src/hg/makeDb/mdbUpdate/mdbPrint.c	23 Apr 2010 02:56:21 -0000	1.2
@@ -13,9 +13,9 @@
 {
 errAbort(
   "mdbPrint - Prints metadata objects and variables from the mdb metadata table.\n"
   "usage:\n"
-  "   mdbPrint {db} [-table=] [-byVar] [-ra/-countObjs/-countVars/-countVals]\n"
+  "   mdbPrint {db} [-table=] [-byVar] [-ra/-line/-countObjs/-countVars/-countVals]\n"
   "                 [-all]\n"
   "                 [-obj= [-var= [-val=]]]\n"
   "                 [-var= [-val=]]\n"
   "                 [-vars=\"var1=val1 var2=val2...]\n"
@@ -24,10 +24,11 @@
   "    -table   Table to query metadata from.  Default is the sandbox version of\n"
   "             '" MDB_DEFAULT_NAME "'.\n"
   "    -byVar   Print each var and val, then all objects that match,\n"
   "             as opposed to printing objects and all the var=val pairs that match.\n"
-  "    -ra      Print each obj with a set of indented var val pairs on separate lines.\n"
-  "             With -byVar prints pseudo-RA style with 2 levels of indentation.\n"
+  "    -ra      Default. Print each obj with a set of indented var val pairs on separate\n"
+  "             lines. With -byVar prints pseudo-RA style with multiple objects per stanza.\n"
+  "    -line    Print each obj and all var=val pairs on a single line.\n"
   "    -countObjs   Just print count of objects returned in the query.\n"
   "    -countVars   Just print count of variables returned in the query.\n"
   "    -countVals   Just print count of values returned in the query.\n"
   "  Four alternate ways to select metadata:\n"
@@ -36,29 +37,30 @@
   "    -var={varName}  Request a single variable.  Can be narrowed by val.\n"
   "    -vars={var=val...}  Request a combination of var=val pairs.\n\n"
   "                    Use of 'var!=val', 'var=v%%' and 'var=?' are supported.\n"
   "There are two basic views of the data: by objects and by variables.  The default view "
-  "is by object.  Each line of output will contain an object and all it's var=val pairs "
-  "as a 'formatted metadata' line.  In 'byVar' view, a single line per var=val and then "
-  "a space seperated list of each objects is printed.  RA style will place each object "
-  "and var val on a separate line with indentation.  Alternatively, request only counting "
-  "of objects, variables or values.\n"
+  "is by object.  Each object will print out in an RA style stanza (by default) or as "
+  "a single line of output containing all var=val pairs. In 'byVar' view, each RA style "
+  "stanza holds a var val pair and all objects belonging to that pair on separate lines.  "
+  "Linear 'byVar' view puts the entire var=val pair on one line.  Alternatively, request "
+  "only counting of objects, variables or values.\n"
   "HINT: Use '%%' in any obj, var or val as a wildcard for selection.\n\n"
   "Examples:\n"
   "  mdbPrint hg19 -vars=\"grant=Snyder cell=GM12878 antibody=CTCF\"\n"
   "           Return all objs that satify ALL of the constraints.\n"
-  "  mdbPrint mm9 -byVar -vars=\"grant=Snyder cell=GM12878 antibody=?\"\n"
-  "           Return each var=val pair and ANY objects that have the constraint.\n"
-  "  mdbPrint hg18 -obj=wgEncodeUncFAIREseqPeaksPanislets\n"
-  "           Return the formatted metadata line for the one object.\n"
+  "  mdbPrint mm9 -vars=\"grant=Snyder cell=GM12878 antibody=?\" -byVar\n"
+  "           Return each all vars for all objects with the constraint.\n"
+  "  mdbPrint hg18 -obj=wgEncodeUncFAIREseqPeaksPanislets -line\n"
+  "           Return a single formatted metadata line for one object.\n"
   "  mdbPrint hg18 -countObjs -var=cell -val=GM%%\n"
   "           Return the count of objects which have a declared cell begining with 'GM'.\n"
   );
 }
 
 static struct optionSpec optionSpecs[] = {
     {"table",    OPTION_STRING}, // default "mdb"
     {"ra",       OPTION_BOOLEAN},// ra format
+    {"line",     OPTION_BOOLEAN},// linear format
     {"countObjs",OPTION_BOOLEAN},// returns only count of objects
     {"countVars",OPTION_BOOLEAN},// returns only count of variables
     {"countVals",OPTION_BOOLEAN},// returns only count of values
     {"all",      OPTION_BOOLEAN},// query entire table
@@ -88,9 +90,11 @@
     }
 
 char *db        = argv[1];
 char *table     = optionVal("table",NULL);
-boolean raStyle = optionExists("ra");
+boolean raStyle = TRUE;
+if(optionExists("line") && !optionExists("ra"))
+    raStyle = FALSE;
 boolean cntObjs = optionExists("countObjs");
 boolean cntVars = optionExists("countVars");
 boolean cntVals = optionExists("countVals");
 boolean byVar   = optionExists("byVar");