1 /* $Id: phi_extend.c 500404 2016-05-04 14:59:01Z camacho $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Ilya Dondoshansky
27 *
28 */
29
30 /** @file phi_extend.c
31 * Word finder functions for PHI-BLAST
32 */
33
34 #include <algo/blast/core/phi_lookup.h>
35 #include <algo/blast/core/phi_extend.h>
36
37 /** Saves a pattern hit in a BlastInitHitList.
38 * @param offset_pair Pattern start and stop in subject [in]
39 * @param init_hitlist Initial hit list structure to save the hit in. [in] [out]
40 */
41 static Int2
s_PHISaveInitialHit(BlastInitHitList * init_hitlist,BlastOffsetPair * offset_pair)42 s_PHISaveInitialHit(BlastInitHitList* init_hitlist, BlastOffsetPair* offset_pair)
43 {
44 /* BlastOffsetPair is a union of two structures representing a pair of
45 offsets. Use common function BLAST_SaveInitialHit, with correct order of
46 offsets to be saved. */
47 return
48 BLAST_SaveInitialHit(init_hitlist, offset_pair->phi_offsets.s_start,
49 offset_pair->phi_offsets.s_end, NULL);
50 }
51
52 Int2
PHIBlastWordFinder(BLAST_SequenceBlk * subject,BLAST_SequenceBlk * query,BlastQueryInfo * query_info,LookupTableWrap * lookup_wrap,Int4 ** matrix,const BlastInitialWordParameters * word_params,Blast_ExtendWord * ewp,BlastOffsetPair * offset_pairs,Int4 max_hits,BlastInitHitList * init_hitlist,BlastUngappedStats * ungapped_stats)53 PHIBlastWordFinder(BLAST_SequenceBlk* subject,
54 BLAST_SequenceBlk* query,
55 BlastQueryInfo* query_info,
56 LookupTableWrap* lookup_wrap,
57 Int4** matrix, const BlastInitialWordParameters* word_params,
58 Blast_ExtendWord* ewp, BlastOffsetPair* offset_pairs,
59 Int4 max_hits, BlastInitHitList* init_hitlist,
60 BlastUngappedStats* ungapped_stats)
61 {
62 Int4 hits=0;
63 Int4 totalhits=0;
64 Int4 first_offset = 0;
65 Int4 last_offset = subject->length;
66
67 while(first_offset < last_offset)
68 {
69 Int4 hit_index;
70 /* scan the subject sequence for hits */
71
72 hits = PHIBlastScanSubject(lookup_wrap, query, subject, &first_offset,
73 offset_pairs, max_hits);
74
75 totalhits += hits;
76
77 /* Save all database pattern hits. */
78 for (hit_index = 0; hit_index < hits; ++hit_index) {
79 s_PHISaveInitialHit(init_hitlist, &offset_pairs[hit_index]);
80 } /* End loop over hits. */
81 } /* end while */
82
83 Blast_UngappedStatsUpdate(ungapped_stats, totalhits, 0, 0);
84 return 0;
85 }
86
87