src/hg/gbToFaRa/gbToFaRa.c 1.25

1.25 2010/02/06 05:53:35 markd
added option to include version in output fasta
Index: src/hg/gbToFaRa/gbToFaRa.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/gbToFaRa/gbToFaRa.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -b -B -U 4 -r1.24 -r1.25
--- src/hg/gbToFaRa/gbToFaRa.c	4 Apr 2006 16:47:33 -0000	1.24
+++ src/hg/gbToFaRa/gbToFaRa.c	6 Feb 2010 05:53:35 -0000	1.25
@@ -25,8 +25,15 @@
 #include "options.h"
 
 static char const rcsid[] = "$Id$";
 
+/* command line option specifications */
+static struct optionSpec optionSpecs[] = {
+    {"byOrganism", OPTION_STRING},
+    {"faInclVer", OPTION_BOOLEAN},
+    {NULL, 0}
+};
+
 enum formatType
 /* Are we working on genomic sequence or mRNA?  Need to write
  * one big .fa file, or a separate one for each sequence. */
     {
@@ -75,8 +82,10 @@
 struct kvt *kvt;	/* Key/Value Table - Gets filled in as we parse through the
                          * genBank record.  Sent to expression evaluator along with
 			 * filter.keyExp after genBank record is parsed. */
 
+static boolean gFaInclVer;  // include version in fasta
+
 struct gbField *newGbField(char *readName, char *writeName, 
     boolean trackVal, boolean multiLine, int initValSize)
 /* Make a new gbField struct. */
 {
@@ -1453,9 +1462,9 @@
                 bacWrite(faDir, accession, version, dna, dnaSize);
                 }
             else
 		{
-                faWriteNext(faFile, accession, dna, dnaSize);
+                faWriteNext(faFile, (gFaInclVer ? versionField->val : accession) , dna, dnaSize);
 		}
             }
         }
     if (!doneSequence)
@@ -1565,9 +1574,10 @@
          "   gbToFaRa filterFile faFile raFile taFile genBankFile(s)\n"
          "where filterFile is definition of which records and fields\n"
          "use /dev/null if you want no filtering.\n"
 	 "options:\n"
-	 "    -byOrganism=outputDir - Make separate files for each organism\n");
+	 "    -byOrganism=outputDir - Make separate files for each organism\n"
+	 "    -faInclVer - include version in fasta\n");
 }
 
 struct filter *makeFilter(char *fileName)
 /* Create filter from filter specification file. */
@@ -1638,14 +1648,15 @@
 struct hash *uniqHash = NULL;
 struct hash *estAuthorHash = NULL;
 struct hash *orgHash = NULL;
 
-optionHash(&argc, argv);
+optionInit(&argc, argv, optionSpecs);
 if (argc < 6)
     usage();
 
 gOutputDir = optionVal("byOrganism", NULL);
 gByOrganism = (gOutputDir != NULL);
+gFaInclVer = optionExists("faInclVer");
 
 filterName = argv[1];
 faName = argv[2];
 raName = argv[3];