src/lib/blastParse.c 1.23
1.23 2009/04/12 05:48:42 markd
fixed bug parsing PSI BLAST output with no hits
Index: src/lib/blastParse.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/blastParse.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -b -B -U 4 -r1.22 -r1.23
--- src/lib/blastParse.c 12 Apr 2009 03:47:20 -0000 1.22
+++ src/lib/blastParse.c 12 Apr 2009 05:48:42 -0000 1.23
@@ -304,34 +304,48 @@
}
return bq;
}
+static char *findNextGapped(struct blastFile *bf, struct blastQuery *bq)
+/* scan for next gapped alignment, return line or NULL if not hit */
+{
+while (TRUE)
+ {
+ if (!bfSkipBlankLines(bf))
+ return NULL;
+ char *line = bfNextLine(bf);
+ /*
+ * the last condition was added to deal with the new blast output format and is meant to find lines such as this one:
+ * TBLASTN 2.2.15 [Oct-15-2006]
+ * I am hoping that by looking for only "BLAST" this will work with things like blastp, blastn, psi-blast, etc
+ */
+ if (startsWith(" Database:", line) || (stringIn("BLAST", line) != NULL))
+ {
+ lineFileReuse(bf->lf);
+ return NULL;
+ }
+ if (line[0] == '>')
+ return line;
+ if (isRoundLine(line))
+ parseRoundLine(line, bq);
+ }
+}
+
struct blastGappedAli *blastFileNextGapped(struct blastFile *bf, struct blastQuery *bq)
/* Read in next gapped alignment. Does *not* put it on bf->gapped list.
* Return NULL at EOF or end of query. */
{
-char *line;
char *words[16];
int wordCount;
struct blastGappedAli *bga;
struct blastBlock *bb;
int lenSearch;
verbose(TRACE_LEVEL, "blastFileNextGapped\n");
-/* First line should be query. */
-if (!bfSkipBlankLines(bf))
- return NULL;
-line = bfNextLine(bf);
-/*
-the last condition was added to deal with the new blast output format and is meant to find lines such as this one:
-TBLASTN 2.2.15 [Oct-15-2006]
-I am hoping that by looking for only "BLAST" this will work with things like blastp, blastn, psi-blast, etc
-*/
-if (startsWith(" Database:", line) || (stringIn("BLAST", line) != NULL))
+char *line = findNextGapped(bf, bq);
+if (line == NULL)
return NULL;
-if (line[0] != '>')
- bfError(bf, "Expecting >target");
AllocVar(bga);
bga->query = bq;
bga->targetName = cloneString(line+1);