|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/algo/blast/api/blast_input.c |
source navigation diff markup identifier search freetext search file search |
1 #ifndef SKIP_DOXYGEN_PROCESSING
2 static char const rcsid[] = "$Id: blast_input.c,v 1.32 2008/06/09 17:28:41 madden Exp $";
3 #endif /* SKIP_DOXYGEN_PROCESSING */
4 /* ===========================================================================
5 *
6 * PUBLIC DOMAIN NOTICE
7 * National Center for Biotechnology Information
8 *
9 * This software/database is a "United States Government Work" under the
10 * terms of the United States Copyright Act. It was written as part of
11 * the author's official duties as a United States Government employee and
12 * thus cannot be copyrighted. This software/database is freely available
13 * to the public for use. The National Library of Medicine and the U.S.
14 * Government have not placed any restriction on its use or reproduction.
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * Please cite the author in any work or product based on this material.
25 *
26 * Author: Ilya Dondoshansky
27 *
28 */
29
30 /** @file blast_input.c
31 * Reading FASTA sequences for BLAST
32 */
33
34 #include <objloc.h>
35 #include <tofasta.h>
36 #include <algo/blast/api/blast_input.h>
37 #include <algo/blast/api/blast_seq.h>
38 #include <algo/blast/core/blast_filter.h>
39 #include <algo/blast/core/blast_setup.h>
40 #include <algo/blast/core/blast_posit.h>
41 #include <objscoremat.h>
42 #include <asn.h>
43
44 /** @addtogroup CToolkitAlgoBlast
45 *
46 * @{
47 */
48
49 /** Maximal number of queries allowed in one SeqLoc chain (== 1/2 INT2_MAX) */
50 #define MAX_NUM_QUERIES 16383
51 /** Maximal total length of queries in a single SeqLoc chain. */
52 #define MAX_TOTAL_LENGTH 2000000
53
54 Int4
55 BLAST_GetQuerySeqLoc(FILE *infp, Boolean query_is_na, Uint1 strand,
56 Int4 max_total_length, Int4 start, Int4 end,
57 SeqLoc** lcase_mask, SeqLocPtr* query_slp,
58 Int4Ptr ctr, Int4* num_queries, Boolean believe_query,
59 Int4 genetic_code)
60 {
61 Int4 total_length=0; /* total number of letters read this call, also final
62 return value. */
63 SeqEntryPtr sep;
64 SeqLocPtr mask_slp, last_slp;
65 char prefix[4]; /* for FastaToSeqEntryForDb */
66 Int4 query_index = 0; /* number of sequences read. */
67 ValNodePtr vnp=NULL; /* used to keep lower-case masking SeqLoc's */
68 Int2 query_count; /* Query count on this call for FastaToSeqEntryForDb */
69
70 if (!query_slp)
71 {
72 ErrPostEx(SEV_FATAL, 0, 0, "NULL query_slp obtained in BLAST_GetQuerySeqLoc");
73 return -1;
74 }
75
76 if (!ctr) /* Not providing this can cause problems if multiple calls to this
77 function are made. */
78 {
79 ErrPostEx(SEV_FATAL, 0, 0, "ctr must be non-NULL in BLAST_GetQuerySeqLoc");
80 return -1;
81 }
82
83 if (max_total_length <= 0)
84 max_total_length = MAX_TOTAL_LENGTH;
85
86 *query_slp = NULL;
87 last_slp = NULL;
88
89 if (query_is_na && strand == Seq_strand_unknown)
90 strand = Seq_strand_both;
91
92 SeqMgrHoldIndexing(TRUE);
93 mask_slp = NULL;
94 if (lcase_mask) /* Make sure we don't get old (possibly freed) locations. */
95 *lcase_mask = NULL;
96
97 /* This is a workaround on the Int2 ctr input for FastaToSeqEntryForDb */
98 sprintf(prefix, "%ld", (long) (*ctr/MAX_NUM_QUERIES));
99 query_count = *ctr%MAX_NUM_QUERIES;
100
101 while ((sep=FastaToSeqEntryForDb(infp, query_is_na, NULL, believe_query, prefix,
102 &query_count, (lcase_mask ? &mask_slp : NULL))) != NULL)
103 {
104 BioseqPtr query_bsp;
105 Int4 from, to;
106
107 if (lcase_mask) /* Only keep if lcase masking is being read in. */
108 ValNodeAddPointer(&vnp, 0, mask_slp);
109 ++query_index;
110 mask_slp = NULL;
111
112 query_bsp = NULL;
113 if (query_is_na) {
114 SeqEntryExplore(sep, &query_bsp, FindNuc);
115 } else {
116 SeqEntryExplore(sep, &query_bsp, FindProt);
117 }
118
119 if (query_bsp == NULL) {
120 ErrPostEx(SEV_FATAL, 0, 0, "Unable to obtain bioseq for sequence number %ld", (long) query_count-1);
121 *ctr += query_index;
122 return -1;
123 }
124
125 if (query_bsp->length <= 0) {
126 ErrPostEx(SEV_WARNING, 0, 0, "Sequence number %ld had length %ld", (long) query_count-1, (long) query_bsp->length);
127 *ctr += query_index;
128 }
129
130
131
132 /* Original from and to are 1-offsets, except when they are 0's,
133 in which case they are start and end of sequence respectively */
134 from = ((start > 0) ? start - 1 : 0);
135 to = ((end > 0) ? end - 1 : query_bsp->length - 1);
136
137 to = MIN(to, query_bsp->length - 1);
138
139 /* If location starting offset is larger than sequence length, skip this
140 sequence. */
141 if (from > to)
142 continue;
143
144 /* Fill the query genetic code option. */
145 if (query_is_na && genetic_code > 0) {
146 BioSourcePtr source;
147 source = BioSourceNew();
148 source->org = OrgRefNew();
149 source->org->orgname = OrgNameNew();
150 source->org->orgname->gcode = genetic_code;
151 ValNodeAddPointer(&(query_bsp->descr), Seq_descr_source, source);
152 }
153
154 if ((strand == Seq_strand_plus) || (strand == Seq_strand_minus) ||
155 (from > 0) || (to < query_bsp->length - 1))
156 {
157 SeqLocPtr new_slp = SeqLocIntNew(from, to, strand,
158 SeqIdFindBest(query_bsp->id, SEQID_GI));
159 if (last_slp) {
160 last_slp->next = new_slp;
161 last_slp = last_slp->next;
162 } else {
163 *query_slp = last_slp = new_slp;
164 }
165 } else {
166 last_slp = ValNodeAddPointer(&last_slp, SEQLOC_WHOLE,
167 SeqIdDup(SeqIdFindBest(query_bsp->id, SEQID_GI)));
168 if (*query_slp == NULL)
169 *query_slp = last_slp;
170 }
171
172 total_length += query_bsp->length;
173 if (total_length > max_total_length || query_index >= MAX_NUM_QUERIES) {
174 break; /* Read maximum allowed amount of data. */
175 }
176 }
177
178 if (lcase_mask)
179 *lcase_mask = vnp;
180
181 SeqMgrHoldIndexing(FALSE);
182
183 if (num_queries)
184 *num_queries = query_index;
185
186 *ctr += query_index;
187
188 return total_length;
189 }
190
191
192 /**
193 * Read the query data stored in a PSI-BLAST checkpoint file.
194 *
195 * @param *pold_query_length length of the old query, as stored in the
196 * checkpoint file
197 * @param old_query a buffer of length at least query_length
198 * to hold the query data from the checkpoint
199 * file
200 * @param query_length the expected query length, and the length
201 * of the old_query buffer
202 * @param file the checkpoint file
203 * @return the number of query characters read,
204 * <= the value of the query_length parameter.
205 */
206 static int
207 s_GetOldQueryFromCheckpoint(Int4 * pold_query_length, Uint1 * old_query,
208 int query_length, FILE * file)
209 {
210 int i;
211 int num_read; /* number of query characters read from disk */
212
213 ASSERT(query_length > 0);
214 if (1 != fread(pold_query_length, sizeof(Int4), 1, file)) {
215 *pold_query_length = 0;
216 return 0;
217 }
218 /* Read at most query_length bytes, no matter what the value of
219 * *pold_query_length is */
220 num_read = (int)fread(old_query, sizeof(Uint1), query_length, file);
221 for (i = 0; i < num_read; i++) {
222 old_query[i] = AMINOACID_TO_NCBISTDAA[old_query[i]];
223 }
224 return num_read;
225 }
226
227
228 /**
229 * Compare the query to another sequence, typically a query stored in
230 * a PSI-BLAST checkpoint file. Warn if they don't match.
231 * @param query one query to be compared
232 * @param query_length the length of query and old_query
233 * @param old_query the other query
234 * @return 0 if the sequences match, -1 otherwise */
235 static Int4
236 s_ValidateOldQuery(const Uint1 query[], int query_length,
237 const Uint1 old_query[], int old_query_length)
238 {
239 int query_index;
240 /* Value for the X ambiguity character */
241 enum { eXchar = 21 };
242
243 if (query_length != old_query_length) {
244 ErrPostEx(SEV_WARNING, 0, 0, "Invalid usage of checkpoint recovery; "
245 "old query has length %ld, new query has length %ld",
246 (long) old_query_length, (long) query_length);
247 return -1;
248 }
249 for (query_index = 0; query_index < query_length; query_index++) {
250 if (old_query[query_index] != query[query_index]) {
251 char old_char = NCBISTDAA_TO_AMINOACID[old_query[query_index]];
252 char new_char = NCBISTDAA_TO_AMINOACID[query[query_index]];
253
254 if (old_query[query_index] != eXchar) {
255 if (query[query_index] == eXchar) {
256 ErrPostEx(SEV_WARNING, 0, 0,
257 "\nStored query has a %c at position "
258 "%d, while new query has a %c there.\n%c "
259 "appears in query sequence: The query "
260 "could be filtered. Run with \"-F F\" "
261 "option to turn the filter off.",
262 old_char, query_index, new_char, new_char);
263 } else {
264 ErrPostEx(SEV_WARNING, 0, 0,
265 "Stored query has a %c at position %d, "
266 "while new query has a %c there.",
267 old_char, query_index, new_char);
268 }
269 return -1;
270 } else { /* old_query[c] == eXchar */
271 ErrPostEx(SEV_WARNING, 0, 0,
272 "Stored query has a %c at position %d, "
273 "while new query has a %c there\n%c appears "
274 "in the stored query: The stored query may be "
275 "filtered. Run blastpgp with \"-F F\" option "
276 "to turn the filter off.",
277 old_char, query_index, new_char, old_char);
278 /* This is only a warning */
279 }
280 }
281 }
282 return 0;
283 }
284
285
286 /**
287 * Read frequency ratios from a PSI-BLAST checkpoint file; read the
288 * query data for the file before calling this routine.
289 *
290 * @param freq_ratios the frequency ratios [out]
291 * @param query_length the length of the query
292 * @param file file to read
293 *
294 * @return 0 on sucess, nonzero on error */
295 static int
296 s_PosReadFreqRatios(double ** freq_ratios,
297 int qlength,
298 FILE * file)
299 {
300 int query_index; /* Query position (column) in the PSSM */
301 int stdaa_index; /* Index in the ncbi_stdaa alphabet */
302 int trueaa_index; /* Index in the ARND... alphabet of true
303 amino acids */
304 /* conversion from 28 letter NCBIstdaa alphabet to 20 letter order
305 * for true amino acids: ARNDCQEGHILKMFPSTWYV. */
306 static int alphaConvert[BLASTAA_SIZE] =
307 {(-1), 0, (-1), 4, 3, 6, 13, 7, 8, 9, 11, 10, 12, 2, 14, 5, 1, 15,
308 16, 19, 17, (-1), 18, (-1), (-1), (-1), (-1), (-1)};
309 /* Buffer to hold frequency data in ARND... order */
310 double trueaa_buffer[PRO_TRUE_ALPHABET_SIZE];
311 int num_read; /* Number of items retrieved by a call to read */
312
313 for (query_index = 0; query_index < qlength; query_index++) {
314 num_read = (int)fread(trueaa_buffer, sizeof(double),
315 PRO_TRUE_ALPHABET_SIZE, file);
316 if (num_read < PRO_TRUE_ALPHABET_SIZE)
317 return -1;
318 for (stdaa_index = 0; stdaa_index < BLASTAA_SIZE; stdaa_index++) {
319 trueaa_index = alphaConvert[stdaa_index];
320 if (trueaa_index < 0) {
321 freq_ratios[query_index][stdaa_index] = 0.0;
322 } else {
323 freq_ratios[query_index][stdaa_index] =
324 trueaa_buffer[trueaa_index];
325 }
326 }
327 }
328 return 0;
329 }
330
331
332 /**
333 * Read frequency ratios from a standard format PSI-BLAST checkpoint file.
334 *
335 * @param freq_ratios the frequency ratios
336 * @param query_length the length of the query, and second dimension of
337 * freq_ratios
338 * @param query query sequence data
339 * @param file an open file to be read
340 * @param blast_msg a pointer to hold BLAST warnings.
341 *
342 * @return 0 on success, nonzero otherwise
343 */
344 static int
345 s_PosReadStdCheckpointFile(double ** freq_ratios,
346 int query_length,
347 const Uint1 * query,
348 FILE * file,
349 Blast_Message* *blast_msg)
350 {
351 int chkpt_query_length = 0; /* Length of the query saved in the
352 checkpoint file */
353 int num_read = 0; /* number if query characters actually read from
354 the checkpoint file */
355 int status = 0; /* error status */
356 /* Buffer to hold the query from the checkpoint file */
357 Uint1 * chkpt_query = NULL;
358
359 chkpt_query = calloc(query_length, sizeof(Uint1));
360 if (NULL != chkpt_query) {
361 num_read = s_GetOldQueryFromCheckpoint(&chkpt_query_length,
362 chkpt_query, query_length,
363 file);
364 }
365 if (NULL == chkpt_query || num_read < chkpt_query_length) {
366 Blast_MessageWrite(blast_msg, eBlastSevFatal,
367 kBlastMessageNoContext,
368 "Blast_PosReadCheckpoint: "
369 "Failed to reconstruct previous query\n");
370 goto error_return;
371 }
372 status = s_ValidateOldQuery(query, query_length,
373 chkpt_query, chkpt_query_length);
374 free(chkpt_query);
375
376 if (0 != status)
377 goto error_return;
378
379 status = s_PosReadFreqRatios(freq_ratios, query_length, file);
380 if (0 != status)
381 goto error_return;
382
383 return 0;
384 error_return:
385 Blast_MessageWrite(blast_msg, eBlastSevFatal,
386 kBlastMessageNoContext,
387 "Blast_PosReadCheckpoint: "
388 "Failed to recover data\n");
389 return -1;
390 }
391
392
393 /**
394 * Read frequency ratios from a standard format PSI-BLAST checkpoint file
395 * of the given name.
396 *
397 * @param freq_ratios the frequency ratios
398 * @param query_length the length of the query, and second dimension of
399 * freq_ratios
400 * @param query query sequence data
401 * @param file the name of the file to be read
402 * @param blast_msg a pointer to hold BLAST warnings.
403 *
404 * @return 0 on success, nonzero otherwise
405 */
406 static int
407 s_PosReadStdCheckpoint(Nlm_FloatHi ** freq_ratios,
408 int qlength,
409 const Uint1 * query,
410 const char * filename,
411 Blast_Message* *blast_msg)
412 {
413 FILE * file = fopen(filename, "rb");
414 int status, close_status;
415
416 if (!file) {
417 Blast_MessageWrite(blast_msg, eBlastSevFatal,
418 kBlastMessageNoContext,
419 "Blast_PosReadCheckpointFile: "
420 "Could not open checkpoint file\n");
421 return -1;
422 }
423 status = s_PosReadStdCheckpointFile(freq_ratios, qlength, query,
424 file, blast_msg);
425 close_status = fclose(file);
426
427 return (0 == status) ? close_status : status;
428 }
429
430
431 static int
432 s_PosReadAsnCheckpoint(double ** freq_ratios,
433 int query_length,
434 const Uint1 query[],
435 char fileName[],
436 int is_ascii_scoremat)
437 {
438 AsnIoPtr infile = NULL;
439 PssmWithParametersPtr scoremat = NULL;
440 PssmPtr pssm = NULL;
441 PssmIntermediateDataPtr freqs = NULL;
442 ValNodePtr freq_list;
443 Bioseq *bsp;
444 int i, j, c;
445 enum { eXchar = 21 };
446
447 if (is_ascii_scoremat) {
448 infile = AsnIoOpen(fileName, "r");
449 } else {
450 infile = AsnIoOpen(fileName, "rb");
451 }
452 if (infile == NULL) {
453 ErrPostEx(SEV_WARNING, 0, 0,"Could not open scoremat file\n");
454 return -1;
455 }
456
457 scoremat = PssmWithParametersAsnRead(infile, NULL);
458 AsnIoClose(infile);
459 if (scoremat == NULL) {
460 ErrPostEx(SEV_WARNING, 0, 0,
461 "Could not read scoremat from input file\n");
462 return 1;
463 }
464 pssm = scoremat->pssm;
465 if (pssm == NULL) {
466 ErrPostEx(SEV_WARNING, 0, 0,"Scoremat is empty\n");
467 PssmWithParametersFree(scoremat);
468 return -1;
469 }
470 freqs = pssm->intermediateData;
471 if (freqs == NULL) {
472 ErrPostEx(SEV_WARNING, 0, 0,
473 "Scoremat doesn't contain intermediate data\n");
474 PssmWithParametersFree(scoremat);
475 return -1;
476 }
477 if (freqs->freqRatios == NULL) {
478 ErrPostEx(SEV_WARNING, 0, 0,
479 "Scoremat does not contain frequency ratios\n");
480 PssmWithParametersFree(scoremat);
481 return -1;
482 }
483 if (pssm->numRows != BLASTAA_SIZE) {
484 ErrPostEx(SEV_WARNING, 0, 0, "Wrong alphabet size of %d in "
485 "input scoremat\n", pssm->numRows);
486 PssmWithParametersFree(scoremat);
487 return -1;
488 }
489 if (!pssm->query || !pssm->query->data.ptrvalue) {
490 ErrPostEx(SEV_WARNING, 0, 0,
491 "Missing sequence data in input scoremat\n");
492 PssmWithParametersFree(scoremat);
493 return -1;
494 }
495 bsp = (Bioseq *)(pssm->query->data.ptrvalue);
496 if (pssm->numColumns != bsp->length) {
497 ErrPostEx(SEV_WARNING, 0, 0, "Different sequence lengths "
498 "(%d and %d) in input scoremat\n", pssm->numColumns,
499 bsp->length);
500 PssmWithParametersFree(scoremat);
501 return -1;
502 }
503 if (pssm->numColumns != query_length) {
504 ErrPostEx(SEV_WARNING, 0, 0, "Scoremat sequence length "
505 "(%d) does not match query length (%d)\n",
506 pssm->numColumns, query_length);
507 PssmWithParametersFree(scoremat);
508 return -1;
509 }
510 if (!bsp->seq_data || !ISA_aa(bsp->mol)) {
511 ErrPostEx(SEV_WARNING, 0, 0,
512 "Sequence within checkpoint file has no data or is "
513 "not protein\n");
514 PssmWithParametersFree(scoremat);
515 return -1;
516 }
517
518 if (bsp->seq_data_type == Seq_code_gap) {
519 ErrPostEx(SEV_WARNING, 0, 0,"Seq_code_gap passed to s_PosReadAsnCheckpoint\n");
520 return -1;
521 }
522
523 BSSeek((ByteStorePtr) bsp->seq_data, 0, SEEK_SET);
524
525 /* Convert sequence data into Seq_code_ncbistdaa */
526 if (bsp->seq_data_type != Seq_code_ncbistdaa) {
527
528 ByteStore* new_byte_store = BSConvertSeq((ByteStorePtr) bsp->seq_data,
529 Seq_code_ncbistdaa,
530 bsp->seq_data_type,
531 bsp->length);
532 if ( !new_byte_store ) {
533 ErrPostEx(SEV_FATAL, 1, 0, "Failed to convert Bioseq in ASN.1"
534 " PSSM to Seq_code_ncbistdaa");
535 }
536 bsp->seq_data = (SeqDataPtr) new_byte_store;
537 bsp->seq_data_type = Seq_code_ncbistdaa;
538 BSSeek((ByteStorePtr) bsp->seq_data, 0, SEEK_SET);
539 }
540
541 /* verify the input query is the same as the sequence
542 within the checkpoint file */
543
544 for (i = 0; i < query_length; i++) {
545 c = BSGetByte((ByteStorePtr) bsp->seq_data);
546 if (c == EOF) {
547 ErrPostEx(SEV_WARNING, 0, 0, "Premature end of sequence data\n");
548 PssmWithParametersFree(scoremat);
549 return -1;
550 }
551 if (c != query[i]) {
552 char old_char = NCBISTDAA_TO_AMINOACID[query[i]];
553 char new_char = NCBISTDAA_TO_AMINOACID[c];
554 if (query[i] == eXchar) {
555 ErrPostEx(SEV_WARNING, 0, 0,
556 "Query sequence contains '%c' at position %d; "
557 "if filtering was used, rerun the search with "
558 "filtering turned off ('-F F')\n", old_char, i);
559 }
560 else {
561 ErrPostEx(SEV_WARNING, 0, 0,
562 "Query sequence contains '%c' at position %d, "
563 "while sequence withing checkpoint file contains "
564 "'%c' at this position\n",
565 old_char, i, new_char);
566 }
567 PssmWithParametersFree(scoremat);
568 return -1;
569 }
570 }
571
572 /* Read in the frequency ratios, verify they fall
573 in the correct range, and verify that the linked list
574 of residue frequencies is exactly as long as it should be */
575
576 freq_list = freqs->freqRatios;
577 /* This is bad */
578 if (pssm->byRow == FALSE) {
579 j = 0;
580 for (i = 0; i < pssm->numColumns; i++) {
581 for (j = 0; j < pssm->numRows; j++) {
582 if (freq_list == NULL)
583 break;
584 freq_ratios[i][j] = freq_list->data.realvalue;
585
586 if (freq_ratios[i][j] < 0.0) {
587 ErrPostEx(SEV_WARNING, 0, 0, "position frequency (%d,%d) "
588 "out of bounds\n", i, j);
589 PssmWithParametersFree(scoremat);
590 return -1;
591 }
592 freq_list = freq_list->next;
593 }
594 if (j < pssm->numRows)
595 break;
596 }
597 } else {
598 i = 0;
599 for (j = 0; j < pssm->numRows; j++) {
600 for (i = 0; i < pssm->numColumns; i++) {
601 if (freq_list == NULL)
602 break;
603 freq_ratios[i][j] = freq_list->data.realvalue;
604
605 if (freq_ratios[i][j] < 0.0) {
606 ErrPostEx(SEV_WARNING, 0, 0, "position frequency (%d,%d) "
607 "out of bounds\n", i, j);
608 PssmWithParametersFree(scoremat);
609 return -1;
610 }
611 freq_list = freq_list->next;
612 }
613 if (i < pssm->numColumns)
614 break;
615 }
616 }
617 if (i < pssm->numColumns || j < pssm->numRows) {
618 ErrPostEx(SEV_WARNING, 0, 0, "Not enough frequency "
619 "ratios in input scoremat\n");
620 PssmWithParametersFree(scoremat);
621 return -1;
622 }
623 if (freq_list != NULL) {
624 ErrPostEx(SEV_WARNING, 0, 0, "Too many frequency "
625 "ratios in input scoremat\n");
626 PssmWithParametersFree(scoremat);
627 return -1;
628 }
629 PssmWithParametersFree(scoremat);
630 return 0;
631 }
632
633
634 Blast_PsiCheckpointLoc *
635 Blast_PsiCheckpointLocNew(EPsiCheckpointType checkpoint_type,
636 char * filename)
637 {
638 Blast_PsiCheckpointLoc * psi_checkpoint =
639 malloc(sizeof(Blast_PsiCheckpointLoc));
640 if (psi_checkpoint) {
641 size_t length_filename = strlen(filename);
642 psi_checkpoint->filename = calloc(length_filename + 1, sizeof(char));
643 if (!psi_checkpoint->filename) {
644 free(psi_checkpoint);
645 psi_checkpoint = NULL;
646 }
647 memcpy(psi_checkpoint->filename, filename, length_filename + 1);
648 psi_checkpoint->checkpoint_type = checkpoint_type;
649 }
650 return psi_checkpoint;
651 }
652
653
654 void
655 Blast_PsiCheckpointLocFree(Blast_PsiCheckpointLoc ** ppsi_checkpoint)
656 {
657 Blast_PsiCheckpointLoc * psi_checkpoint = *ppsi_checkpoint;
658 if (psi_checkpoint) {
659 if (psi_checkpoint->filename) {
660 free(psi_checkpoint->filename);
661 }
662 free(psi_checkpoint);
663 }
664 *ppsi_checkpoint = NULL;
665 }
666
667
668 int
669 Blast_PosReadCheckpoint(double ** freq_ratios,
670 int query_length,
671 const Uint1 * query,
672 Blast_PsiCheckpointLoc * psi_checkpoint,
673 Blast_Message* *blast_msg)
674 {
675 int status;
676
677 switch(psi_checkpoint->checkpoint_type) {
678 case eStandardCheckpoint:
679 status = s_PosReadStdCheckpoint(freq_ratios, query_length,
680 query,
681 psi_checkpoint->filename,
682 blast_msg);
683 break;
684 case eAsnTextCheckpoint:
685 case eAsnBinaryCheckpoint:
686 {{
687 int is_ascii_checkpoint =
688 psi_checkpoint->checkpoint_type == eAsnTextCheckpoint;
689 status = s_PosReadAsnCheckpoint(freq_ratios,
690 query_length, query,
691 psi_checkpoint->filename,
692 is_ascii_checkpoint);
693 }}
694 break;
695 default:
696 ASSERT(0 && "Impossible type of checkpoint file");
697 status = -1;
698 break;
699 }
700 return status;
701 }
702 /* @} */
703
704 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |