~ubuntu-branches/ubuntu/saucy/ncbi-tools6/saucy-proposed

« back to all changes in this revision

Viewing changes to algo/blast/core/blast_util.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2009-08-11 22:03:47 UTC
  • mfrom: (1.4.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20090811220347-g4b6lzdvphvvbpiu
* New upstream release.
* debian/libncbi6.symbols: update accordingly.
* debian/control: clean up obsolete or redundant relationship declarations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: blast_util.c,v 1.127 2009/02/03 18:14:30 kazimird Exp $
 
1
/* $Id: blast_util.c,v 1.128 2009/05/27 17:39:36 kazimird Exp $
2
2
 * ===========================================================================
3
3
 *
4
4
 *                            PUBLIC DOMAIN NOTICE
34
34
 
35
35
#ifndef SKIP_DOXYGEN_PROCESSING
36
36
static char const rcsid[] = 
37
 
    "$Id: blast_util.c,v 1.127 2009/02/03 18:14:30 kazimird Exp $";
 
37
    "$Id: blast_util.c,v 1.128 2009/05/27 17:39:36 kazimird Exp $";
38
38
#endif /* SKIP_DOXYGEN_PROCESSING */
39
39
 
40
40
#include <algo/blast/core/blast_util.h>
80
80
    }
81
81
    /* if the target isn't in the range at index b and there is still more
82
82
     * data, return the next element */
83
 
    if (target > ranges[b].right && b < num_ranges) {
 
83
    if ( (target > ranges[b].right) && (b < (num_ranges-1) ) ) {
84
84
        return b + 1;
85
85
    } else {
86
86
        return b;
102
102
    }
103
103
}
104
104
 
105
 
/** Allocate and populate the seq_ranges field of the BLAST_SequenceBlk with
106
 
 * default values as to indicate that the entire sequence should be searched 
107
 
 * @note assumes the BLAST_SequenceBlk::length has been initialized
108
 
 * @param seq_blk the data structure to populate [in|out]
109
 
 * @return 0 on success, BLASTERR_MEMORY if memory allocation fails
110
 
 */
111
 
static Int2
112
 
s_BlastSeqBlkSetLookupTableRangesToIndex(BLAST_SequenceBlk* seq_blk)
113
 
{
114
 
    static const Uint4 kDfltSize = 1;
115
 
    if (seq_blk->seq_ranges != NULL) {
116
 
        return 0;
117
 
    }
118
 
 
119
 
    s_BlastSequenceBlkFreeSeqRanges(seq_blk);
120
 
    seq_blk->seq_ranges = (SSeqRange*) calloc(kDfltSize, 
121
 
                                              sizeof(*seq_blk->seq_ranges));
122
 
    if ( !seq_blk->seq_ranges ) {
123
 
        return BLASTERR_MEMORY;
124
 
    }
125
 
    seq_blk->seq_ranges[0].left = 0;
126
 
    seq_blk->seq_ranges[0].right = seq_blk->length;
127
 
    seq_blk->num_seq_ranges = kDfltSize;
128
 
    seq_blk->seq_ranges_allocated = TRUE;
129
 
 
130
 
    return 0;
131
 
}
132
 
 
133
105
Int2
134
106
BlastSetUp_SeqBlkNew (const Uint1* buffer, Int4 length,
135
107
   BLAST_SequenceBlk* *seq_blk, Boolean buffer_allocated)
153
125
    }
154
126
    
155
127
    (*seq_blk)->length = length;
156
 
 
157
 
    if (s_BlastSeqBlkSetLookupTableRangesToIndex(*seq_blk) != 0) {
158
 
        return -1;
159
 
    }
160
128
   
161
129
    return 0;
162
130
}
188
156
    seq_blk->sequence = (Uint1*) sequence + 1;
189
157
    seq_blk->length = seqlen;
190
158
    seq_blk->oof_sequence = NULL;
191
 
    if (s_BlastSeqBlkSetLookupTableRangesToIndex(seq_blk) != 0) {
192
 
        return -1;
193
 
    }
194
159
 
195
160
    return 0;
196
161
}
206
171
    seq_blk->sequence = (Uint1*) sequence;
207
172
    seq_blk->oof_sequence = NULL;
208
173
 
209
 
    if (s_BlastSeqBlkSetLookupTableRangesToIndex(seq_blk) != 0) {
210
 
        return -1;
211
 
    }
212
 
 
213
174
    return 0;
214
175
}
215
176