src/hg/blastToPsl/blastXmlToPsl.c 1.2

1.2 2010/04/16 17:32:12 markd
add options to convert TBLASTN to codon nucleotide/nucleotide coordinates, fixed bug with tStart/tEnd extending beyond actual range
Index: src/hg/blastToPsl/blastXmlToPsl.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/blastToPsl/blastXmlToPsl.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -B -U 4 -r1.1 -r1.2
--- src/hg/blastToPsl/blastXmlToPsl.c	8 Feb 2010 03:04:22 -0000	1.1
+++ src/hg/blastToPsl/blastXmlToPsl.c	16 Apr 2010 17:32:12 -0000	1.2
@@ -23,22 +23,26 @@
   "               n >= 4 dumps the result of each query\n"
   "  -eVal=n n is e-value threshold to filter results. Format can be either\n"
   "          an integer, double or 1e-10. Default is no filter.\n"
   "  -pslx - create PSLX output (includes sequences for blocks)\n"
+  "  -convertToNucCoords - convert protein to nucleic alignments to nucleic\n"
+  "   to nucleic coordinates\n"
   "\n"
   "Output only results of last round from PSI BLAST\n");
 }
 
 static struct optionSpec options[] = {
     {"scores", OPTION_STRING},
     {"eVal", OPTION_DOUBLE},
     {"pslx", OPTION_BOOLEAN},
+    {"convertToNucCoords", OPTION_BOOLEAN},
     {NULL, 0},
 };
 
 static double eVal = -1; /* default Expect value signifying no filtering */
 static boolean pslxFmt = FALSE; /* output in pslx format */
 static int errCount = 0; /* count of  PSLs failing checks */
+static boolean convertToNucCoords = 1; /* adjust query coordinates */
 
 struct coords
 /* structure to return converted coordinates */
 {
@@ -66,9 +70,12 @@
 
 static unsigned getFlags(struct ncbiBlastBlastOutput *outputRec)
 /* determine blast algorithm and other flags */
 {
-return pslBuildGetBlastAlgo(outputRec->ncbiBlastBlastOutputProgram->text) | (pslxFmt ? bldPslx : 0);
+unsigned algo = pslBuildGetBlastAlgo(outputRec->ncbiBlastBlastOutputProgram->text);
+if (convertToNucCoords && (algo != tblastn))
+    errAbort("-convertToNucCoords only support for TBLASTN");
+return algo | (convertToNucCoords ? cnvNucCoords : 0) | (pslxFmt ? bldPslx : 0);
 }
 
 static void outputPsl(struct psl *psl, struct ncbiBlastHsp *hspRec, FILE* pslFh, FILE* scoreFh)
 /* output a psl and optional score */
@@ -195,8 +202,9 @@
 if (argc != 3)
     usage();
 eVal = optionDouble("eVal", eVal);
 pslxFmt = optionExists("pslx");
+convertToNucCoords = optionExists("convertToNucCoords");
 blastXmlToPsl(argv[1], argv[2], optionVal("scores", NULL));
 if (errCount > 0)
     errAbort("%d invalid PSLs created", errCount);
 return 0;