NCBI C++ ToolKit
Functions
blast_util.c File Reference

Various BLAST utilities. More...

#include <algo/blast/core/blast_util.h>
#include <algo/blast/core/blast_filter.h>
#include <algo/blast/core/blast_stat.h>
+ Include dependency graph for blast_util.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Functions

void __sfree (void **x)
 Implemented in blast_util.c. More...
 
SSeqRange SSeqRangeNew (Int4 start, Int4 stop)
 Create a new SSeqRange structure with both fields initialized. More...
 
Int4 SSeqRangeArrayLessThanOrEqual (const SSeqRange *ranges, Int4 num_ranges, Int4 target)
 Returns the index of the range, such that this element is the first range that either contains the target or if no such range exists, the index of the first range, such that the target is less than this range. More...
 
static void s_BlastSequenceBlkFreeSeqRanges (BLAST_SequenceBlk *seq_blk)
 Auxiliary function to free the BLAST_SequenceBlk::seq_ranges field if applicable. More...
 
Int2 BlastSetUp_SeqBlkNew (const Uint1 *buffer, Int4 length, BLAST_SequenceBlk **seq_blk, Boolean buffer_allocated)
 Allocates memory for *sequence_blk and then populates it. More...
 
Int2 BlastSeqBlkNew (BLAST_SequenceBlk **retval)
 Allocates a new sequence block structure. More...
 
Int2 BlastSeqBlkSetSequence (BLAST_SequenceBlk *seq_blk, const Uint1 *sequence, Int4 seqlen)
 Stores the sequence in the sequence block structure. More...
 
Int2 BlastSeqBlkSetCompressedSequence (BLAST_SequenceBlk *seq_blk, const Uint1 *sequence)
 Stores the compressed nucleotide sequence in the sequence block structure for the subject sequence when BLASTing 2 sequences. More...
 
Int2 BlastSeqBlkSetSeqRanges (BLAST_SequenceBlk *seq_blk, SSeqRange *seq_ranges, Uint4 num_seq_ranges, Boolean copy_seq_ranges, ESubjectMaskingType mask_type)
 Sets the seq_range and related fields appropriately in the BLAST_SequenceBlk structure. More...
 
void BlastSequenceBlkClean (BLAST_SequenceBlk *seq_blk)
 Deallocate memory only for the sequence in the sequence block. More...
 
BLAST_SequenceBlkBlastSequenceBlkFree (BLAST_SequenceBlk *seq_blk)
 Deallocate memory for a sequence block. More...
 
void BlastSequenceBlkCopy (BLAST_SequenceBlk **copy, BLAST_SequenceBlk *src)
 Copies contents of the source sequence block without copying sequence buffers; sets all "field_allocated" booleans to FALSE, to make sure fields are not freed on the call to BlastSequenceBlkFree. More...
 
Int2 BlastProgram2Number (const char *program, EBlastProgramType *number)
 Set number for a given program type. More...
 
Int2 BlastNumber2Program (EBlastProgramType number, char **program)
 Return string name for program given a number. More...
 
static Uint1 s_CodonToAA (Uint1 *codon, const Uint1 *codes)
 Translate 3 nucleotides into an amino acid MUST have 'X' as unknown amino acid. More...
 
Int4 BLAST_GetTranslation (const Uint1 *query_seq, const Uint1 *query_seq_rev, Int4 nt_length, Int2 frame, Uint1 *prot_seq, const Uint1 *genetic_code)
 GetTranslation to get the translation of the nucl. More...
 
Int2 BlastCompressBlastnaSequence (BLAST_SequenceBlk *seq_blk)
 Adds a specialized representation of sequence data to a sequence block. More...
 
Int4 BLAST_TranslateCompressedSequence (Uint1 *translation, Int4 length, const Uint1 *nt_seq, Int2 frame, Uint1 *prot_seq)
 Translate a nucleotide sequence without ambiguity codes. More...
 
Int2 GetReverseNuclSequence (const Uint1 *sequence, Int4 length, Uint1 **rev_sequence_ptr)
 Reverse a nucleotide sequence in the blastna encoding, adding sentinel bytes on both ends. More...
 
Int1 BLAST_ContextToFrame (EBlastProgramType prog_number, Uint4 context_number)
 This function translates the context number of a context into the frame of the sequence. More...
 
Int2 BLAST_PackDNA (const Uint1 *buffer, Int4 length, EBlastEncoding encoding, Uint1 **packed_seq)
 Convert a sequence in ncbi4na or blastna encoding into a packed sequence in ncbi2na encoding. More...
 
size_t BLAST_GetTranslatedProteinLength (size_t nucleotide_length, unsigned int context)
 Calculates the length of frame for a translated protein. More...
 
Int2 BLAST_CreateMixedFrameDNATranslation (BLAST_SequenceBlk *query_blk, const BlastQueryInfo *query_info)
 Initialize the mixed-frame sequence for out-of-frame gapped extension. More...
 
static Uint1s_BlastGetTranslationTable (const Uint1 *genetic_code, Boolean reverse_complement)
 Gets the translation array for a given genetic code. More...
 
Int2 BLAST_GetAllTranslations (const Uint1 *nucl_seq, EBlastEncoding encoding, Int4 nucl_length, const Uint1 *genetic_code, Uint1 **translation_buffer_ptr, Uint4 **frame_offsets_ptr, Uint1 **mixed_seq_ptr)
 Translate nucleotide into 6 frames. More...
 
int Blast_GetPartialTranslation (const Uint1 *nucl_seq, Int4 nucl_length, Int2 frame, const Uint1 *genetic_code, Uint1 **translation_buffer_ptr, Int4 *protein_length, Uint1 **mixed_seq_ptr)
 Get one frame translation - needed when only parts of subject sequences are translated. More...
 
Int4 BLAST_FrameToContext (Int2 frame, EBlastProgramType program)
 Convert translation frame or strand into a context number suitable for indexing into the BlastQueryInfo::contexts array. More...
 
Int4 BSearchInt4 (Int4 n, Int4 *A, Int4 size)
 The following binary search routine assumes that array A is filled. More...
 
SBlastTargetTranslationBlastTargetTranslationFree (SBlastTargetTranslation *target_t)
 Free SBlastTargetTranslation. More...
 
Int2 BlastTargetTranslationNew (BLAST_SequenceBlk *subject_blk, const Uint1 *gen_code_string, EBlastProgramType program_number, Boolean is_ooframe, SBlastTargetTranslation **target)
 Sets up structure for target translation. More...
 
double * BLAST_GetStandardAaProbabilities ()
 Get the standard amino acid probabilities. More...
 
char * BLAST_StrToUpper (const char *string)
 Returns a copy of the input string with all its characters turned to uppercase. More...
 
unsigned int BLAST_GetNumberOfContexts (EBlastProgramType p)
 Get the number of contexts for a given program. More...
 
SBlastProgressSBlastProgressNew (void *user_data)
 Allocates and initializes a new SBlastProgress structure. More...
 
SBlastProgressSBlastProgressFree (SBlastProgress *progress_info)
 Deallocates a SBlastProgress structure. More...
 
void SBlastProgressReset (SBlastProgress *progress_info)
 Resets the progress structure to its original state (as if newly allocated) for a fresh start without touching the user_data field. More...
 

Detailed Description

Various BLAST utilities.

Definition in file blast_util.c.

Function Documentation

◆ __sfree()

void __sfree ( void **  x)

Implemented in blast_util.c.

See also
sfree

Definition at line 40 of file blast_util.c.

References free(), and NULL.

◆ BLAST_ContextToFrame()

Int1 BLAST_ContextToFrame ( EBlastProgramType  prog_number,
Uint4  context_number 
)

This function translates the context number of a context into the frame of the sequence.

Parameters
prog_numberInteger corresponding to the BLAST program
context_numberContext number
Returns
Sequence frame: -1,1 for nucleotides, -3,-2,-1,1,2,3 for translations, 0 for proteins and INT1_MAX in case of unsupported program

Definition at line 839 of file blast_util.c.

References abort(), Blast_QueryIsProtein(), eBlastTypeBlastn, eBlastTypeBlastx, eBlastTypeMapping, eBlastTypePhiBlastn, eBlastTypeRpsTblastn, eBlastTypeTblastx, INT1_MAX, NUM_FRAMES, and NUM_STRANDS.

Referenced by BLAST_GetAllTranslations(), Blast_GetSeqLocInfoVector(), BlastHSPStreamMerge(), BlastMaskLocDNAToProtein(), BlastMaskLocProteinToDNA(), BlastQueryInfoNew(), BlastTargetTranslationNew(), BOOST_AUTO_TEST_CASE(), OffsetArrayToContextOffsets(), s_AddMask(), s_BlastSearchEngineCore(), and x_TestGetSeqLocInfoVector().

◆ BLAST_CreateMixedFrameDNATranslation()

Int2 BLAST_CreateMixedFrameDNATranslation ( BLAST_SequenceBlk query_blk,
const BlastQueryInfo query_info 
)

Initialize the mixed-frame sequence for out-of-frame gapped extension.

Parameters
query_blkSequence block containing the concatenated frames of the query. The mixed-frame sequence is saved here. [in] [out]
query_infoQuery information structure containing offsets into the* concatenated sequence. [in]

Definition at line 931 of file blast_util.c.

References buffer, CODON_LENGTH, context, BlastQueryInfo::contexts, i, BlastQueryInfo::last_context, malloc(), NULL, NULLB, offset, BLAST_SequenceBlk::oof_sequence, BLAST_SequenceBlk::oof_sequence_allocated, BlastContextInfo::query_length, BlastContextInfo::query_offset, QueryInfo_GetSeqBufLen(), BLAST_SequenceBlk::sequence, and TRUE.

Referenced by BLAST_MainSetUp(), and BOOST_AUTO_TEST_CASE().

◆ BLAST_FrameToContext()

Int4 BLAST_FrameToContext ( Int2  frame,
EBlastProgramType  program 
)

Convert translation frame or strand into a context number suitable for indexing into the BlastQueryInfo::contexts array.

Parameters
frameFrame (allowed values: 1,2,3,-1,-2,-3, 0) [in]
programType of BLAST program [in]
Returns
context number: 0 or 1 for nucleotide query/subjects, a value between 0 and 5 (inclusive) for translated query/subjects, and 0 for protein query/subjects.

Definition at line 1211 of file blast_util.c.

References ASSERT, Blast_QueryIsNucleotide(), Blast_QueryIsTranslated(), Blast_SubjectIsNucleotide(), and Blast_SubjectIsTranslated().

Referenced by BLAST_GetGappedScore(), Blast_HSPGetTargetTranslation(), BLAST_SmithWatermanGetGappedScore(), Blast_TracebackFromHSPList(), BlastRPSWordFinder(), and s_BlastHSPListRPSUpdate().

◆ BLAST_GetAllTranslations()

Int2 BLAST_GetAllTranslations ( const Uint1 nucl_seq,
EBlastEncoding  encoding,
Int4  nucl_length,
const Uint1 genetic_code,
Uint1 **  translation_buffer_ptr,
Uint4 **  frame_offsets_ptr,
Uint1 **  mixed_seq_ptr 
)

Translate nucleotide into 6 frames.

All frames are put into a translation buffer, with sentinel NULLB bytes in between. Array of offsets into the translation buffer is also returned. For out-of-frame gapping option, a mixed frame sequence is created.

Parameters
nucl_seqThe nucleotide sequence [in]
encodingSequence encoding: ncbi2na or ncbi4na [in]
nucl_lengthLength of the nucleotide sequence [in]
genetic_codeThe genetic code to be used for translations, in ncbistdaa encoding [in]
translation_buffer_ptrBuffer to hold the frames of the translated sequence. [out]
frame_offsets_ptrOffsets into the translation buffer for each frame. [out]
mixed_seq_ptrPointer to buffer for the mixed frame sequence [out]

Definition at line 1045 of file blast_util.c.

References BLAST_ContextToFrame(), BLAST_GetTranslation(), BLAST_TranslateCompressedSequence(), CODON_LENGTH, context, eBlastEncodingNcbi2na, eBlastEncodingNcbi4na, eBlastTypeBlastx, FALSE, free(), GetReverseNuclSequence(), i, malloc(), NULL, NULLB, NUM_FRAMES, offset, s_BlastGetTranslationTable(), sfree, and TRUE.

Referenced by BlastTargetTranslationNew(), BOOST_AUTO_TEST_CASE(), and s_BlastSearchEngineCore().

◆ BLAST_GetNumberOfContexts()

unsigned int BLAST_GetNumberOfContexts ( EBlastProgramType  program)

Get the number of contexts for a given program.

This corresponds to the number of translation frames or strands whenever applicable.

Returns
0 on unsupported program, non-zero otherwise

Definition at line 1373 of file blast_util.c.

References Blast_ProgramIsValid(), Blast_QueryIsNucleotide(), Blast_QueryIsTranslated(), NUM_FRAMES, and NUM_STRANDS.

Referenced by BlastHSPStreamMerge(), BlastQueryInfoGetEffSearchSpace(), BlastQueryInfoGetQueryLength(), BlastQueryInfoNew(), BlastQueryInfoSetEffSearchSpace(), BlastSetUp_GetFilteringLocations(), CBlastAncillaryData::CBlastAncillaryData(), GetNumberOfContexts(), and CBlastQueryFilteredFrames::GetNumFrames().

◆ Blast_GetPartialTranslation()

int Blast_GetPartialTranslation ( const Uint1 nucl_seq,
Int4  nucl_length,
Int2  frame,
const Uint1 genetic_code,
Uint1 **  translation_buffer_ptr,
Int4 protein_length,
Uint1 **  mixed_seq_ptr 
)

Get one frame translation - needed when only parts of subject sequences are translated.

Parameters
nucl_seqPointer to start of nucleotide sequence to be translated [in]
nucl_lengthLength of nucleotide sequence to be translated [in]
frameWhat frame to translate into [in]
genetic_codeWhat genetic code to use? [in]
translation_buffer_ptrPointer to buffer with translated sequence [out]
protein_lengthLength of the translation buffer [out]
mixed_seq_ptrPointer to buffer with mixed frame sequence, in case of out-of-frame gapping; buffer filled only if argument not NULL. [out]

Definition at line 1141 of file blast_util.c.

References BLAST_GetTranslation(), CODON_LENGTH, GetReverseNuclSequence(), malloc(), NULL, offset, and sfree.

Referenced by Blast_HSPGetPartialSubjectTranslation(), and s_SequenceGetTranslatedRange().

◆ BLAST_GetStandardAaProbabilities()

double* BLAST_GetStandardAaProbabilities ( void  )

Get the standard amino acid probabilities.

This is basically a wrapper for BlastScoreBlkNew() and Blast_ResFreqStdComp() from blast_stat.c with a more intention-revealing name :) Caller is responsible for deallocating return value via sfree().

Returns
NULL if there is not enough memory otherwise an array of length BLASTAA_SIZE, where each index corresponds to an amino acid as specified in the NCBIstdaa encoding.

Definition at line 1323 of file blast_util.c.

References BlastScoreBlk::alphabet_code, BlastScoreBlk::alphabet_size, Blast_ResFreqFree(), Blast_ResFreqNew(), Blast_ResFreqStdComp(), BLASTAA_SEQ_CODE, BLASTAA_SIZE, i, malloc(), NULL, Blast_ResFreq::prob, BlastScoreBlk::protein_alphabet, and TRUE.

Referenced by _PSISequenceWeightsNew(), CConservationScoringMethod::CConservationScoringMethod(), ColumnResidueProfile::getBackgroundResFreq(), GetStandardProbability(), Kappa_compactSearchItemsNew(), PSICreatePssmFromFrequencyRatios(), s_GetPosBasedStartFreqRatios(), and CConservationScoringMethod::x_Init().

◆ BLAST_GetTranslatedProteinLength()

size_t BLAST_GetTranslatedProteinLength ( size_t  nucleotide_length,
unsigned int  context 
)

Calculates the length of frame for a translated protein.

Parameters
nucleotide_lengthLength of the nucleotide sequence translated [in]
contextIndex of the translated frame (values: 0 to 5, inclusive) [in]
Returns
The requested length, or 0 if the nucleotide length is 0

Definition at line 923 of file blast_util.c.

References CODON_LENGTH, and context.

Referenced by SetupQueryInfo_OMF().

◆ BLAST_GetTranslation()

Int4 BLAST_GetTranslation ( const Uint1 query_seq,
const Uint1 query_seq_rev,
Int4  nt_length,
Int2  frame,
Uint1 buffer,
const Uint1 genetic_code 
)

GetTranslation to get the translation of the nucl.

sequence in the appropriate frame and with the appropriate GeneticCode. The function return an allocated char*, the caller must delete this. The first and last spaces of this char* contain NULLB's.

Parameters
query_seqForward strand of the nucleotide sequence [in]
query_seq_revReverse strand of the nucleotide sequence [in]
nt_lengthLength of the nucleotide sequence [in]
frameWhat frame to translate into? [in]
bufferPreallocated buffer for the translated sequence [in][out]
genetic_codeGenetic code to use for translation, in ncbistdaa encoding [in]
Returns
Length of the translated protein sequence.

Definition at line 428 of file blast_util.c.

References ABS, CODON_LENGTH, FENCE_SENTRY, IS_residue, NULLB, and s_CodonToAA().

Referenced by BLAST_GetAllTranslations(), Blast_GetPartialTranslation(), Blast_HSPGetTargetTranslation(), BlastTargetTranslationNew(), and SetupQueries_OMF().

◆ BLAST_PackDNA()

Int2 BLAST_PackDNA ( const Uint1 buffer,
Int4  length,
EBlastEncoding  encoding,
Uint1 **  packed_seq 
)

Convert a sequence in ncbi4na or blastna encoding into a packed sequence in ncbi2na encoding.

Needed for 2 sequences BLASTn comparison.

Parameters
bufferoriginal sequence data (one base per byte) [in]
lengthlength of the sequence data above [in]
encodingsource encoding of the sequence data above [in]
packed_seqoutput buffer containing compressed sequence. Its length will be (length/COMPRESSION_RATIO + 1), caller is responsible for deallocating it [out]
Returns
0 in case of success, -1 in case of memory allocation failure

Definition at line 870 of file blast_util.c.

References abort(), buffer, COMPRESSION_RATIO, eBlastEncodingNucleotide, malloc(), NCBI2NA_MASK, and NCBI4NA_TO_BLASTNA.

◆ BLAST_StrToUpper()

char* BLAST_StrToUpper ( const char *  string)

Returns a copy of the input string with all its characters turned to uppercase.

Useful for saving score matrix names. Caller is responsible for deallocating return value.

Parameters
stringstring to copy [in]
Returns
newly allocated string in upper case or NULL if string is NULL or out of memory

Definition at line 1352 of file blast_util.c.

References NULL, NULLB, strdup, and toupper().

Referenced by Blast_ScoreBlkMatrixInit(), and BLAST_ValidateOptions().

◆ BLAST_TranslateCompressedSequence()

Int4 BLAST_TranslateCompressedSequence ( Uint1 translation,
Int4  length,
const Uint1 nt_seq,
Int2  frame,
Uint1 prot_seq 
)

Translate a nucleotide sequence without ambiguity codes.

This is used for the first-pass translation of the database. The genetic code to be used is determined by the translation_table This function translates a packed (ncbi2na) nucl. alphabet. It views a basepair as being in one of four sets of 2-bits: |0|1|2|3||0|1|2|3||0|1|2|3||...

1st byte | 2 byte | 3rd byte...

A codon that starts at the beginning of the above sequence starts in state "0" and includes basepairs 0, 1, and 2. The next codon, in the same frame, after that starts in state "3" and includes 3, 0, and 1.

Optimization: changed the single main loop to

  • advance to state 0,
  • optimized inner loop does two (3 byte->4 codon) translation per iteration (loads are moved earlier so they can be done in advance.)
  • do remainder
Parameters
translationThe translation table [in]
lengthLength of the nucleotide sequence [in]
nt_seqThe original nucleotide sequence [in]
frameWhat frame to translate to? [in]
prot_seqPreallocated buffer for the (translated) protein sequence, with NULLB sentinels on either end. [out]

Definition at line 508 of file blast_util.c.

References ABS, CODON_LENGTH, NULL, and NULLB.

Referenced by BLAST_GetAllTranslations().

◆ BlastCompressBlastnaSequence()

Int2 BlastCompressBlastnaSequence ( BLAST_SequenceBlk seq_blk)

Adds a specialized representation of sequence data to a sequence block.

In the specialized representation, the byte at offset i packs together nucleotide bases i to i+3

Parameters
seq_blkstructure containing sequence data. Data is assumed to be in blastna format [in][out]

Definition at line 459 of file blast_util.c.

References BLAST_SequenceBlk::compressed_nuc_seq, BLAST_SequenceBlk::compressed_nuc_seq_start, i, len, BLAST_SequenceBlk::length, malloc(), MIN, and BLAST_SequenceBlk::sequence.

Referenced by s_BlastSmallNaLookupFinalize().

◆ BlastNumber2Program()

Int2 BlastNumber2Program ( EBlastProgramType  number,
char **  program 
)

Return string name for program given a number.

Return is zero on success.

Parameters
numberEnumerated value of program [in]
programstring name of program (memory should be deallocated by called) [out]

Definition at line 312 of file blast_util.c.

References eBlastTypeBlastn, eBlastTypeBlastp, eBlastTypeBlastx, eBlastTypeMapping, eBlastTypePhiBlastn, eBlastTypePhiBlastp, eBlastTypePsiBlast, eBlastTypePsiTblastn, eBlastTypeRpsBlast, eBlastTypeRpsTblastn, eBlastTypeTblastn, eBlastTypeTblastx, NULL, number, and strdup.

Referenced by Blast_ProgramNameFromType(), CRedoAlignmentTestFixture::runRedoAlignmentCoreUnitTest(), and s_ImportSearchStrategy().

◆ BlastProgram2Number()

Int2 BlastProgram2Number ( const char *  program,
EBlastProgramType number 
)

Set number for a given program type.

Return is zero on success.

Parameters
programstring name of program [in]
numberEnumerated value of program [out]

Definition at line 278 of file blast_util.c.

References eBlastTypeBlastn, eBlastTypeBlastp, eBlastTypeBlastx, eBlastTypeMapping, eBlastTypePhiBlastn, eBlastTypePhiBlastp, eBlastTypePsiBlast, eBlastTypePsiTblastn, eBlastTypeRpsBlast, eBlastTypeRpsTblastn, eBlastTypeTblastn, eBlastTypeTblastx, eBlastTypeUndefined, NULL, number, and strcasecmp.

Referenced by NetworkProgram2BlastProgramType().

◆ BlastSeqBlkNew()

Int2 BlastSeqBlkNew ( BLAST_SequenceBlk **  retval)

◆ BlastSeqBlkSetCompressedSequence()

Int2 BlastSeqBlkSetCompressedSequence ( BLAST_SequenceBlk seq_blk,
const Uint1 sequence 
)

Stores the compressed nucleotide sequence in the sequence block structure for the subject sequence when BLASTing 2 sequences.

This sequence should be encoded in eBlastEncodingNcbi2na and NOT have sentinel bytes (as this encoding doesn't allow them).

Parameters
seq_blkThe sequence block structure to modify [in/out]
sequenceActual sequence buffer. [in]

Definition at line 167 of file blast_util.c.

References NULL, BLAST_SequenceBlk::oof_sequence, BLAST_SequenceBlk::sequence, BLAST_SequenceBlk::sequence_allocated, and TRUE.

Referenced by BOOST_AUTO_TEST_CASE(), NuclWordFinderTextFixture::setupSequences(), TestFixture::SetUpSubject(), and SetupSubjects_OMF().

◆ BlastSeqBlkSetSeqRanges()

Int2 BlastSeqBlkSetSeqRanges ( BLAST_SequenceBlk seq_blk,
SSeqRange seq_ranges,
Uint4  num_seq_ranges,
Boolean  copy_seq_ranges,
ESubjectMaskingType  mask_type 
)

Sets the seq_range and related fields appropriately in the BLAST_SequenceBlk structure.

Parameters
seq_blkThe sequence block structure to modify [in/out]
seq_rangessequence ranges to copy [in]
num_seq_rangesnumber of elements in array above [in]
copy_seq_rangesset to TRUE if seq_ranges should be copied to the
mask_typeeither kSoftDBMask or kHardDBMask [in] BLAST_SequenceBlk and assume its ownership, set to FALSE if the pointer should be copied and the ownership of the seq_ranges remains in the caller's possession.
Note
this function will free the memory previously allocated to BLAST_SequenceBlk::seq_ranges (if applicable) and overwrite it with the seq_ranges argument. This might invalidate BLAST_SequenceBlk structures that were copied off of this one.

Definition at line 182 of file blast_util.c.

References ASSERT, calloc(), FALSE, BLAST_SequenceBlk::length, BLAST_SequenceBlk::mask_type, BLAST_SequenceBlk::num_seq_ranges, s_BlastSequenceBlkFreeSeqRanges(), BLAST_SequenceBlk::seq_ranges, BLAST_SequenceBlk::seq_ranges_allocated, tmp, and TRUE.

Referenced by AascanTestFixture::AascanTestFixture(), BOOST_AUTO_TEST_CASE(), CompressedAascanTestFixture::CompressedAascanTestFixture(), s_SeqDbGetSequence(), SetupSubjects_OMF(), and TestFixture::SkipMaskedRangesCore().

◆ BlastSeqBlkSetSequence()

Int2 BlastSeqBlkSetSequence ( BLAST_SequenceBlk seq_blk,
const Uint1 sequence,
Int4  seqlen 
)

◆ BlastSequenceBlkClean()

void BlastSequenceBlkClean ( BLAST_SequenceBlk seq_blk)

◆ BlastSequenceBlkCopy()

void BlastSequenceBlkCopy ( BLAST_SequenceBlk **  copy,
BLAST_SequenceBlk src 
)

Copies contents of the source sequence block without copying sequence buffers; sets all "field_allocated" booleans to FALSE, to make sure fields are not freed on the call to BlastSequenceBlkFree.

Parameters
copyNew sequence block [out]
srcInput sequence block [in]

Definition at line 259 of file blast_util.c.

References ASSERT, BlastMemDup(), copy(), and FALSE.

Referenced by s_MultiSeqGetSequence(), and s_QueryFactoryGetSequence().

◆ BlastSequenceBlkFree()

BLAST_SequenceBlk* BlastSequenceBlkFree ( BLAST_SequenceBlk seq_blk)

◆ BlastSetUp_SeqBlkNew()

Int2 BlastSetUp_SeqBlkNew ( const Uint1 buffer,
Int4  length,
BLAST_SequenceBlk **  seq_blk,
Boolean  buffer_allocated 
)

Allocates memory for *sequence_blk and then populates it.

Parameters
bufferstart of sequence [in]
lengthquery sequence length [in]
seq_blkSequenceBlk to be allocated and filled in [out]
buffer_allocatedIs the buffer allocated? If yes, 'sequence_start' is the start of the sequence, otherwise it is 'sequence'. [in]
Deprecated:
Use BlastSeqBlkNew and BlastSeqBlkSet* functions instead

Definition at line 101 of file blast_util.c.

References ASSERT, BlastSeqBlkNew(), buffer, FALSE, NULL, and TRUE.

Referenced by NtlookupTestFixture::debruijnInit(), AalookupTestFixture::GetSeqBlk(), s_SeqDbGetSequence(), and s_VDBSRC_GetSequence().

◆ BlastTargetTranslationFree()

SBlastTargetTranslation* BlastTargetTranslationFree ( SBlastTargetTranslation target_t)

◆ BlastTargetTranslationNew()

Int2 BlastTargetTranslationNew ( BLAST_SequenceBlk subject_blk,
const Uint1 gen_code_string,
EBlastProgramType  program_number,
Boolean  is_ooframe,
SBlastTargetTranslation **  target 
)

◆ BSearchInt4()

Int4 BSearchInt4 ( Int4  n,
Int4 A,
Int4  size 
)

The following binary search routine assumes that array A is filled.

Definition at line 1231 of file blast_util.c.

References b, n, and ncbi::grid::netcache::search::fields::size.

◆ GetReverseNuclSequence()

Int2 GetReverseNuclSequence ( const Uint1 sequence,
Int4  length,
Uint1 **  rev_sequence_ptr 
)

Reverse a nucleotide sequence in the blastna encoding, adding sentinel bytes on both ends.

Parameters
sequenceForward strand of the sequence [in]
lengthLength of the sequence plus 1 for the sentinel byte [in]
rev_sequence_ptrReverse strand of the sequence [out]

Definition at line 807 of file blast_util.c.

References FENCE_SENTRY, malloc(), and NULLB.

Referenced by BLAST_GetAllTranslations(), Blast_GetPartialTranslation(), Blast_HSPGetTargetTranslation(), and BlastTargetTranslationNew().

◆ s_BlastGetTranslationTable()

static Uint1* s_BlastGetTranslationTable ( const Uint1 genetic_code,
Boolean  reverse_complement 
)
static

Gets the translation array for a given genetic code.

This array is optimized for the NCBI2na alphabet. The reverse complement can also be spcified.

Parameters
genetic_codeGenetic code string in ncbistdaa encoding [in]
reverse_complementGet translation table for the reverse strand? [in]
Returns
The translation table.

Definition at line 990 of file blast_util.c.

References calloc(), NULL, and reverse_complement().

Referenced by BLAST_GetAllTranslations().

◆ s_BlastSequenceBlkFreeSeqRanges()

static void s_BlastSequenceBlkFreeSeqRanges ( BLAST_SequenceBlk seq_blk)
static

Auxiliary function to free the BLAST_SequenceBlk::seq_ranges field if applicable.

Parameters
seq_blkThe sequence block structure to manipulate [in|out]

Definition at line 90 of file blast_util.c.

References ASSERT, FALSE, BLAST_SequenceBlk::num_seq_ranges, BLAST_SequenceBlk::seq_ranges, BLAST_SequenceBlk::seq_ranges_allocated, and sfree.

Referenced by BlastSeqBlkSetSeqRanges(), and BlastSequenceBlkClean().

◆ s_CodonToAA()

static Uint1 s_CodonToAA ( Uint1 codon,
const Uint1 codes 
)
static

Translate 3 nucleotides into an amino acid MUST have 'X' as unknown amino acid.

Parameters
codon3 values in ncbi4na code
codesGeneic code string to use (must be in ncbistdaa encoding!)
Returns
Amino acid in ncbistdaa

Definition at line 370 of file blast_util.c.

References AMINOACID_TO_NCBISTDAA, FENCE_SENTRY, i, and taa.

Referenced by BLAST_GetTranslation().

◆ SBlastProgressFree()

SBlastProgress* SBlastProgressFree ( SBlastProgress progress_info)

Deallocates a SBlastProgress structure.

Implemented in blast_util.c

Definition at line 1397 of file blast_util.c.

References NULL, and sfree.

◆ SBlastProgressNew()

SBlastProgress* SBlastProgressNew ( void *  user_data)

Allocates and initializes a new SBlastProgress structure.

Parameters
user_datauser-provided data (not owned by the resulting structure) [in] Implemented in blast_util.c

Definition at line 1387 of file blast_util.c.

References calloc(), NULL, and SBlastProgress::user_data.

Referenced by CPrelimSearchThread::CPrelimSearchThread(), CBlastPrelimSearch::SetInterruptCallback(), and SplitQuery_CreateChunkData().

◆ SBlastProgressReset()

void SBlastProgressReset ( SBlastProgress progress_info)

Resets the progress structure to its original state (as if newly allocated) for a fresh start without touching the user_data field.

Definition at line 1406 of file blast_util.c.

References ePrelimSearch, and SBlastProgress::stage.

Referenced by CPrelimSearchRunner::operator()().

◆ SSeqRangeArrayLessThanOrEqual()

Int4 SSeqRangeArrayLessThanOrEqual ( const SSeqRange ranges,
Int4  num_ranges,
Int4  target 
)

Returns the index of the range, such that this element is the first range that either contains the target or if no such range exists, the index of the first range, such that the target is less than this range.

Precondition
ranges array is sorted on the starting coordinates (i.e.: SSeqRange::left)
Parameters
rangesarray of SSeqRange structures to search [in]
num_rangesnumber of elements in the ranges array [in]
targetelement to look for [in]
Returns
the index of interest in the ranges array or -1 if the function was called with invalid parameters

Definition at line 56 of file blast_util.c.

References b, and NULL.

Referenced by BOOST_AUTO_TEST_CASE().

◆ SSeqRangeNew()

SSeqRange SSeqRangeNew ( Int4  start,
Int4  stop 
)

Create a new SSeqRange structure with both fields initialized.

Parameters
startthe start of the range [in]
stopthe end of the range [in]

Definition at line 47 of file blast_util.c.

References SSeqRange::left, and SSeqRange::right.

Referenced by BOOST_AUTO_TEST_CASE().

Modified on Sun May 19 04:45:21 2024 by modify_doxy.py rev. 669887