1 /* $Id: traceback_stage.hpp 457458 2015-01-23 12:27:33Z madden $
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: Christiam Camacho, Kevin Bealer
27  *
28  */
29 
30 /** @file traceback_stage.hpp
31  * NOTE: This file contains work in progress and the APIs are likely to change,
32  * please do not rely on them until this notice is removed.
33  */
34 
35 #ifndef ALGO_BLAST_API___TRACEBACK_STAGE_HPP
36 #define ALGO_BLAST_API___TRACEBACK_STAGE_HPP
37 
38 #include <algo/blast/api/setup_factory.hpp>
39 #include <algo/blast/api/query_data.hpp>
40 #include <algo/blast/api/uniform_search.hpp>
41 #include <objtools/blast/seqdb_reader/seqdb.hpp>
42 #include <objects/scoremat/PssmWithParameters.hpp>
43 
44 /** @addtogroup AlgoBlast
45  *
46  * @{
47  */
48 
49 BEGIN_NCBI_SCOPE
50 BEGIN_SCOPE(blast)
51 
52 // Forward declaration
53 class IBlastSeqInfoSrc;
54 
55 class NCBI_XBLAST_EXPORT CBlastTracebackSearch : public CObject, public CThreadable
56 {
57 public:
58     /// Create a BlastSeqSrc re-using an already created BlastSeqSrc
59     /// @note We don't own the BlastSeqSrc
60     CBlastTracebackSearch(CRef<IQueryFactory>   qf,
61                           CRef<CBlastOptions>   opts,
62                           BlastSeqSrc         * seqsrc,
63                           CRef<IBlastSeqInfoSrc> seqinfosrc,
64                           CRef<TBlastHSPStream> hsps,
65                           CConstRef<objects::CPssmWithParameters> pssm = null);
66 
67     /// Use the internal data and return value of the preliminary
68     /// search to proceed with the traceback.
69     CBlastTracebackSearch(CRef<IQueryFactory> query_factory,
70                           CRef<SInternalData> internal_data,
71                           CRef<CBlastOptions>   opts,
72                           CRef<IBlastSeqInfoSrc> seqinfosrc,
73                           TSearchMessages& search_msgs);
74 
75     /// Destructor.
76     virtual ~CBlastTracebackSearch();
77 
78     /// Run the traceback search.
79     CRef<CSearchResultSet> Run();
80 
81     /// Runs the traceback but only returns the HSP's and not the Seq-Align.
82     BlastHSPResults* RunSimple();
83 
84     /// Specifies how the Seq-align-set returned as part of the
85     /// results is formatted.
86     void SetResultType(EResultType type);
87 
88     /// Sets the m_DBscanInfo field.
89     void SetDBScanInfo(CRef<SDatabaseScanData> dbscan_info);
90 
91     /// Retrieve any error/warning messages that occurred during the search
92     TSearchMessages GetSearchMessages() const;
93 
94 private:
95     /// Common initialization performed when doing traceback only
96     void x_Init(CRef<IQueryFactory>   qf,
97                 CRef<CBlastOptions>   opts,
98                 CConstRef<objects::CPssmWithParameters> pssm,
99                 const string        & dbname,
100                 CRef<TBlastHSPStream> hsps);
101 
102     /// Prohibit copy constructor
103     CBlastTracebackSearch(CBlastTracebackSearch &);
104     /// Prohibit assignment operator
105     CBlastTracebackSearch & operator =(CBlastTracebackSearch &);
106 
107     // C++ data
108 
109     /// The query to search for.
110     CRef<IQueryFactory>             m_QueryFactory;
111 
112     /// The options with which this search is configured.
113     CRef<CBlastOptions>             m_Options;
114 
115     /// Fields and data from the preliminary search.
116     CRef<SInternalData>             m_InternalData;
117 
118     /// Options from the preliminary search.
119     const CBlastOptionsMemento*     m_OptsMemento;
120 
121     /// Warnings and Errors
122     TSearchMessages m_Messages;
123 
124     /// Pointer to the IBlastSeqInfoSrc object to use to generate the
125     /// Seq-aligns
126     CRef<IBlastSeqInfoSrc> m_SeqInfoSrc;
127 
128     /// Determines if BLAST database search or BLAST 2 sequences style of
129     /// results should be produced
130     EResultType m_ResultType;
131 
132     /// Tracks information from database scanning phase.  Right now only used
133     /// for the number of occurrences of a pattern in phiblast run.
134     CRef<SDatabaseScanData> m_DBscanInfo;
135 };
136 
137 
138 inline TSearchMessages
GetSearchMessages() const139 CBlastTracebackSearch::GetSearchMessages() const
140 {
141     return m_Messages;
142 }
143 
144 END_SCOPE(BLAST)
145 END_NCBI_SCOPE
146 
147 /* @} */
148 
149 #endif /* ALGO_BLAST_API___TRACEBACK_STAGE__HPP */
150 
151