62 retval->
SetWhole().Assign(**seqids.begin());
71 if ( !blmsg || !query_info ) {
75 if (messages.size() != (
size_t) query_info->
num_queries) {
82 for (; blmsg; blmsg = blmsg->
next)
84 const int kContext = blmsg->
context;
93 messages[kCtxInfo[kContext].
query_index].push_back(sm);
100 query_messages->push_back(sm);
141 bool is_multi_threaded = num_threads > 1;
152 retval->m_InternalData->m_QueryInfo = query_data->
GetQueryInfo();
156 retval->m_Messages.Combine(m);
161 const string rps_dbname(name ? name :
"");
162 retval->m_InternalData->m_RpsData =
167 unique_ptr<const CBlastOptionsMemento> opts_memento
176 &lookup_segments, retval->m_Messages,
178 retval->m_InternalData->m_RpsData);
181 if(e.
GetMsg() == kCatchThisError) {
190 retval->m_InternalData->m_ScoreBlk.
Reset
195 "Multiple queries cannot be specified with a PSSM");
207 if ( !retval->m_QuerySplitter->IsQuerySplit() ) {
210 sbp, lookup_segments_wrap,
211 retval->m_InternalData->m_RpsData,
214 retval->m_InternalData->m_LookupTable.
Reset
222 retval->m_InternalData->m_Diagnostics.
Reset
230 retval->m_InternalData->m_Queries,
233 if (is_multi_threaded)
242 retval->m_InternalData->m_HspStream.
Reset
247 retval->m_Messages.Combine(m);
249 if (retval->m_QuerySplitter->IsQuerySplit()) {
254 retval->m_InternalData->m_Queries =
NULL;
257 retval->m_InternalData->m_FnInterrupt =
NULL;
278 for(
unsigned i = 0;
i < alignments.size();
i++) {
283 const size_t num_subjects = alignments.size()/query_ids.size();
284 for(
size_t i = 0;
i < alignments.size();
i += num_subjects) {
288 for (
size_t j = 0; j < num_subjects; j++) {
293 for(
size_t i = 0;
i < alignments.size();
i++) {
311 const vector<TSeqLocInfoVector>& subj_masks,
319 vector< CConstRef<CSeq_id> > qlocs;
322 qlocs.assign(alignments.size(), query_ids.front());
326 const size_t num_subjects = alignments.size()/query_ids.size();
327 for (
size_t i = 0;
i < alignments.size();
i += num_subjects) {
328 for (
size_t j = 0; j < num_subjects; j++) {
329 qlocs.push_back(query_ids[
i/num_subjects]);
334 copy(query_ids.begin(), query_ids.end(), back_inserter(qlocs));
341 result_type, ancillary_data);
347 if (messages.size() < alignments.size()) {
348 messages.resize(alignments.size());
360 if (subj_masks.size() == retval->
size()) {
362 (*retval)[
i].SetSubjectMasks(subj_masks[
i]);
371 bool assume_both_strands)
373 if (sloc_in.
Empty() ||
375 sloc_in->IsEmpty() ||
382 if (sloc_in->IsInt()) {
394 "Unsupported Seq-loc type used for mask");
402 objects::CSeq_interval * iv =
403 const_cast<objects::CSeq_interval*
>(& (**iter));
412 if (iv->CanGetStrand()) {
413 switch(iv->GetStrand()) {
429 "Unsupported strand type used for query");
433 do_pos = do_neg =
true;
437 if (assume_both_strands) {
438 do_pos = do_neg =
true;
471 retval.
Reset(
new objects::CSeq_loc);
472 retval->SetPacked_int(*psi);
User-defined methods of the data storage class.
Auxiliary functions for BLAST.
@ eTracebackSearch
Traceback stage.
BlastDiagnostics * Blast_DiagnosticsFree(BlastDiagnostics *diagnostics)
Free the BlastDiagnostics structure and all substructures.
Declares the BLAST exception class.
Declaration of ADT to save and retrieve lists of HSPs in the BLAST engine.
BlastHSPStream * BlastHSPStreamFree(BlastHSPStream *hsp_stream)
Frees the BlastHSPStream structure by invoking the destructor function set by the user-defined constr...
int BlastHSPStreamRegisterMTLock(BlastHSPStream *hsp_stream, MT_LOCK lock)
Attach a mutex lock to a stream to protect multiple access during writing.
int BlastHSPStreamRegisterPipe(BlastHSPStream *hsp_stream, BlastHSPPipe *pipe, EBlastStage stage)
Insert the user-specified pipe to the *end* of the pipeline.
Classes that capture the state of the BLAST options (or subsets of options) and restore them later (u...
const char * kBlastErrMsg_CantCalculateUngappedKAParams
#define Blast_PerrorWithLocation(msg, error_code, context)
Convenient define to call the function Blast_PerrorEx.
const int kBlastMessageNoContext
Declared in blast_message.h as extern const.
Blast_Message * Blast_MessageFree(Blast_Message *blast_msg)
Deallocates message memory.
C++ version of the initialization for the mutex locking interface.
Boolean Blast_ProgramIsPhiBlast(EBlastProgramType p)
Returns true if program is PHI-BLAST (i.e.
Boolean Blast_QueryIsProtein(EBlastProgramType p)
Returns true if the query is protein.
Boolean Blast_ProgramIsRpsBlast(EBlastProgramType p)
Returns true if program is RPS-BLAST (i.e.
EBlastProgramType
Defines the engine's notion of the different applications of the BLAST algorithm.
const unsigned int kQueryIndex
Index into multiple sequence alignment structure for the query sequence.
Definitions and functions associated with the BlastQueryInfo structure.
Declaration of ADT to retrieve sequences for the BLAST engine.
const char * BlastSeqSrcGetName(const BlastSeqSrc *seq_src)
Get the Blast Sequence source name (e.g.
BlastScoreBlk * BlastScoreBlkFree(BlastScoreBlk *sbp)
Deallocates BlastScoreBlk as well as all associated structures.
vector< CRef< objects::CSeq_align_set > > TSeqAlignVector
Vector of Seq-align-sets.
EResultType
Specifies the style of Seq-aligns that should be built from the internal BLAST data structures.
@ eSequenceComparison
Seq-aligns in the BLAST 2 Sequence style (one alignment per query-subject pair)
Class used to return ancillary data from a blast search, i.e.
Defines BLAST error codes (user errors included)
Wrapper for BlastSeqLoc structure.
Wrapper class for SBlastProgress .
Error or Warning Message from search.
Search Results for All Queries.
structure for seqloc info
Collection of masked regions for a single query sequence.
CRef< objects::CPacked_seqint > ConvertToCPacked_seqint() const
Converts this object to a CPacked_seqint (this is the convention used to encode masking locations in ...
typedef for the messages for an entire BLAST search, which could be comprised of multiple query seque...
void GetMessages(TSearchMessages &messages) const
Retrieve all error/warning messages.
CStructWrapper< BlastDiagnostics > TBlastDiagnostics
CRef< SBlastSetupData > BlastSetupPreliminarySearch(CRef< IQueryFactory > query_factory, CRef< CBlastOptions > options, size_t num_threads)
Set up internal data structures used by the BLAST CORE engine.
static BlastHSPPipe * CreateHspPipe(const CBlastOptionsMemento *opts_memento, BlastQueryInfo *query_info)
Create a pipe to be registered for use by stream.
void PsiBlastSetupScoreBlock(BlastScoreBlk *score_blk, CConstRef< objects::CPssmWithParameters > pssm, TSearchMessages &messages, CConstRef< CBlastOptions > options)
Setup CORE BLAST score block structure with data from the scoremat PSSM.
CRef< SBlastSetupData > BlastSetupPreliminarySearchEx(CRef< IQueryFactory > qf, CRef< CBlastOptions > options, CConstRef< CPssmWithParameters > pssm, BlastSeqSrc *seqsrc, size_t num_threads)
Extended interface to set up internal data structures used by the BLAST CORE engine.
static BlastDiagnostics * CreateDiagnosticsStructure()
Create and initialize the BlastDiagnostics structure for single-threaded applications.
void BuildBlastAncillaryData(EBlastProgramType program, const vector< CConstRef< CSeq_id > > &query_ids, const BlastScoreBlk *sbp, const BlastQueryInfo *qinfo, const TSeqAlignVector &alignments, const EResultType result_type, CSearchResultSet::TAncillaryVector &retval)
Builds an CSearchResultSet::TAncillaryVector.
void ClearDbIndexCallbacks(void)
TMaskedQueryRegions PackedSeqLocToMaskedQueryRegions(CConstRef< objects::CSeq_loc > sloc, EBlastProgramType program, bool assume_both_strands=false)
Auxiliary function to convert a Seq-loc describing masked query regions to a TMaskedQueryRegions obje...
string BlastErrorCode2String(Int2 error_code)
Returns a string containing a human-readable interpretation of the error_code passed as this function...
CStructWrapper< LookupTableWrap > TLookupTableWrap
const CBlastOptionsMemento * CreateSnapshot() const
Create a snapshot of the state of this object for internal use of its data structures (BLAST C++ APIs...
static CRef< CBlastRPSInfo > CreateRpsStructures(const string &rps_dbname, CRef< CBlastOptions > options)
Initializes RPS-BLAST data structures.
CStructWrapper< BlastHSPStream > TBlastHSPStream
CStructWrapper< BlastScoreBlk > TBlastScoreBlk
static void InitializeMegablastDbIndex(CRef< CBlastOptions > options)
Initialize a megablast BLAST database index.
virtual BLAST_SequenceBlk * GetSequenceBlk()=0
Accessor for the BLAST_SequenceBlk structure.
void Blast_Message2TSearchMessages(const Blast_Message *blmsg, const BlastQueryInfo *query_info, TSearchMessages &messages)
Converts the Blast_Message structure into a TSearchMessages object.
CRef< ILocalQueryData > MakeLocalQueryData(const CBlastOptions *opts)
Creates and caches an ILocalQueryData.
static BlastDiagnostics * CreateDiagnosticsStructureMT()
Create and initialize the BlastDiagnostics structure for multi-threaded applications.
static LookupTableWrap * CreateLookupTable(CRef< ILocalQueryData > query_data, const CBlastOptionsMemento *opts_memento, BlastScoreBlk *score_blk, CRef< CBlastSeqLocWrap > lookup_segments, const CBlastRPSInfo *rps_info=NULL, BlastSeqSrc *seqsrc=NULL, size_t num_threads=1)
Initialize the lookup table.
static BlastScoreBlk * CreateScoreBlock(const CBlastOptionsMemento *opts_memento, CRef< ILocalQueryData > query_data, BlastSeqLoc **lookup_segments, TSearchMessages &search_messages, TSeqLocInfoVector *masked_query_regions=NULL, const CBlastRPSInfo *rps_info=NULL)
Initializes the BlastScoreBlk.
EBlastProgramType GetProgramType() const
Returns the CORE BLAST notion of program type.
size_type size() const
Identical to GetNumResults, provided to facilitate STL-style iteration.
bool Validate() const
Validate the options.
virtual BlastQueryInfo * GetQueryInfo()=0
Accessor for the BlastQueryInfo structure.
vector< value_type >::size_type size_type
size_type type definition
CRef< objects::CSeq_loc > MaskedQueryRegionsToPackedSeqLoc(const TMaskedQueryRegions &sloc)
Interface to build a CSeq-loc from a TMaskedQueryRegion; note that conversion conversion in this dire...
void RemoveDuplicates()
Find and remove redundant messages.
void FlushSequenceData()
Frees the cached sequence data structure (as this is usually the larger data structure).
virtual size_t GetNumQueries()=0
Get the number of queries.
static BlastHSPWriter * CreateHspWriter(const CBlastOptionsMemento *opts_memento, BLAST_SequenceBlk *query, BlastQueryInfo *query_info)
Create a writer to be registered for use by stream.
static BlastHSPStream * CreateHspStream(const CBlastOptionsMemento *opts_memento, size_t number_of_queries, BlastHSPWriter *writer)
Create and initialize the BlastHSPStream structure.
void SetUpDbIndexCallbacks(void)
vector< CRef< CBlastAncillaryData > > TAncillaryVector
typedef for a vector of CRef<CBlastAncillaryData>
CRef< CSearchResultSet > BlastBuildSearchResultSet(const vector< CConstRef< CSeq_id > > &query_ids, const BlastScoreBlk *sbp, const BlastQueryInfo *qinfo, EBlastProgramType program, const TSeqAlignVector &alignments, TSearchMessages &messages, const vector< TSeqLocInfoVector > &subj_masks, const TSeqLocInfoVector *query_masks, const EResultType result_type)
Build a CSearchResultSet from internal BLAST data structures.
CConstRef< objects::CSeq_loc > CreateWholeSeqLocFromIds(const list< CRef< objects::CSeq_id > > seqids)
Create a single CSeq_loc of type whole from the first id in the list.
MT_LOCK Blast_CMT_LOCKInit(void)
Initialize a mutex locking mechanism for BLAST.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
const string & GetMsg(void) const
Get message string.
#define NCBI_RETHROW(prev_exception, exception_class, err_code, message)
Generic macro to re-throw an exception.
void SetPacked_int(TPacked_int &v)
bool Empty(void) const THROWS_NONE
Check if CConstRef is empty – not pointing to any object which means having a null value.
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
void Reset(void)
Reset reference object.
void Reset(void)
Reset reference object.
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty – pointing to an object and has a non-null value.
bool NotEmpty(void) const THROWS_NONE
Check if CConstRef is not empty – pointing to an object and has a non-null value.
int16_t Int2
2-byte (16-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define USING_SCOPE(ns)
Use the specified namespace.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
bool IsPacked_int(void) const
Check if variant Packed_int is selected.
const TPacked_int & GetPacked_int(void) const
Get the variant data.
@ eNa_strand_both
in forward orientation
@ e_not_set
No variant selected.
unsigned int
A callback function used to compare two keys in a database.
LookupTableWrap * LookupTableWrapFree(LookupTableWrap *lookup)
Deallocate memory for the lookup table.
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Declarations of auxiliary functions/classes for PSI-BLAST.
Defines a concrete strategy for the IBlastSeqInfoSrc interface for sequence identifiers retrieval fro...
vector< TMaskedQueryRegions > TSeqLocInfoVector
Collection of masked regions for all queries in a BLAST search.
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
The context related information.
Int4 query_index
Index of query (same for all frames)
Return statistics from the BLAST search.
Default implementation of BlastHSPStream.
The query related information.
BlastContextInfo * contexts
Information per context.
int num_queries
Number of query sequences.
struct SPHIQueryInfo * pattern_info
Counts of PHI BLAST pattern occurrences, used in PHI BLAST only.
Structure used for scoring calculations.
Used to hold a set of positions, mostly used for filtering.
Complete type definition of Blast Sequence Source ADT.
Structure to hold the a message from the core of the BLAST engine.
int context
Context, allows us to print message for query number.
EBlastSeverity severity
severity code
char * message
User message to be saved.
struct Blast_Message * next
next message in this list
Wrapper structure for different types of BLAST lookup tables.
Return type of BlastSetupPreliminarySearch.
In PHI BLAST, structure containing information about all pattern occurrences in query.