NCBI C++ ToolKit
ngalign.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: ngalign.cpp 72271 2016-04-27 16:55:47Z boukn $
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: Nathan Bouk
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbiexpt.hpp>
34 #include <corelib/ncbi_system.hpp>
35 #include <corelib/ncbi_signal.hpp>
36 #include <math.h>
38 
41 #include <objmgr/scope.hpp>
51 #include <objmgr/seq_vector.hpp>
52 
54 
55 
58 
59 
62 USING_SCOPE(blast);
63 
64 
66  CGC_Assembly* GenColl,
67  bool AllowDupes)
68  : m_Scope(&Scope), m_AllowDupes(AllowDupes), m_GenColl(GenColl)
69 {
70 }
71 
73 {
74 }
75 
77 {
78  m_Query = Set;
79 }
80 
81 
83 {
84  m_Subject = Set;
85 }
86 
87 
89 {
91 }
92 
93 
95 {
96  m_Aligners.push_back(CIRef<IAlignmentFactory>(Aligner));
97 }
98 
99 
101 {
102  m_Scorers.push_back(CIRef<IAlignmentScorer>(Scorer));
103 }
104 
105 
106 
107 
108 const char* IAlignmentFilter::KFILTER_SCORE = "filter_score";
109 
111 {
112  return x_Align_Impl();
113 }
114 
115 
117 {
118 
119  TAlignResultsRef FilterResults(new CAlignResultsSet),
120  AccumResults(new CAlignResultsSet(m_GenColl, m_AllowDupes));
121 
123  if (CSignal::IsSignaled()) {
124  NCBI_THROW(CException, eUnknown, "trapped signal");
125  }
126 
127  TAlignResultsRef CurrResults;
128  CurrResults = (*AlignIter)->GenerateAlignments(*m_Scope, m_Query, m_Subject,
129  AccumResults);
130 
131  NON_CONST_ITERATE(TScorers, ScorerIter, m_Scorers) {
132  (*ScorerIter)->ScoreAlignments(CurrResults, *m_Scope);
133  }
134 
135 //cerr << MSerial_AsnText << *CurrResults->ToSeqAlignSet();
136 // AccumResults->Insert(CurrResults);
137  NON_CONST_ITERATE(TFilters, FilterIter, m_Filters) {
138  (*FilterIter)->FilterAlignments(CurrResults, FilterResults, *m_Scope);
139  }
140  AccumResults->Insert(CurrResults);
141  }
142 
143  TAlignSetRef Results;
144  if(m_AllowDupes) {
145  Results = AccumResults->ToSeqAlignSet();
146  } else {
147  Results = AccumResults->ToBestSeqAlignSet();
148  }
149 
150  if(!Results.IsNull()) {
152  ITERATE(CSeq_align_set::Tdata, AlignIter, Results->Get()) {
153  const CSeq_align& Align = **AlignIter;
154  string FastaId = Align.GetSeq_id(0).AsFastaString();
155  ITERATE(TFactories, FactoryIter, m_Aligners) {
156  int Value;
157  if(Align.GetNamedScore((*FactoryIter)->GetName(), Value)) {
158  extra.Print((*FactoryIter)->GetName(), FastaId);
159  }
160  }
161  }
162  }
163 
164  return Results;
165 }
166 
167 
169 
static CRef< CScope > m_Scope
Declares the CBl2Seq (BLAST 2 Sequences) class.
Declares the CBlastNucleotideOptionsHandle class.
Declares the CBlastOptionsHandle and CBlastOptionsFactory classes.
Definitions of special type used in BLAST.
Main argument class for BLASTN application.
Temporary object for holding extra message arguments.
Definition: ncbidiag.hpp:1828
list< CIRef< IAlignmentScorer > > TScorers
Definition: ngalign.hpp:95
CRef< objects::CGC_Assembly > m_GenColl
Definition: ngalign.hpp:88
CRef< objects::CScope > m_Scope
Definition: ngalign.hpp:86
TScorers m_Scorers
Definition: ngalign.hpp:98
virtual TAlignSetRef x_Align_Impl()
Definition: ngalign.cpp:116
void SetQuery(ISequenceSet *Set)
Definition: ngalign.cpp:76
void SetSubject(ISequenceSet *Set)
Definition: ngalign.cpp:82
virtual ~CNgAligner()
Definition: ngalign.cpp:72
list< CIRef< IAlignmentFactory > > TFactories
Definition: ngalign.hpp:94
CIRef< ISequenceSet > m_Subject
Definition: ngalign.hpp:91
TAlignSetRef Align()
Definition: ngalign.cpp:110
bool m_AllowDupes
Definition: ngalign.hpp:87
CIRef< ISequenceSet > m_Query
Definition: ngalign.hpp:90
void AddFilter(IAlignmentFilter *Filter)
Definition: ngalign.cpp:88
TFilters m_Filters
Definition: ngalign.hpp:96
void AddAligner(IAlignmentFactory *Aligner)
Definition: ngalign.cpp:94
void AddScorer(IAlignmentScorer *Scorer)
Definition: ngalign.cpp:100
list< CIRef< IAlignmentFilter > > TFilters
Definition: ngalign.hpp:93
TFactories m_Aligners
Definition: ngalign.hpp:97
CScope –.
Definition: scope.hpp:92
static const char * KFILTER_SCORE
Declares the CDiscNucleotideOptionsHandle class.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
CDiagContext_Extra & Print(const string &name, const string &value)
The method does not print the argument, but adds it to the string.
Definition: ncbidiag.cpp:2622
CDiagContext & GetDiagContext(void)
Get diag context instance.
Definition: logging.cpp:818
CDiagContext_Extra Extra(void) const
Create a temporary CDiagContext_Extra object.
Definition: ncbidiag.hpp:2095
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:735
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
static bool IsSignaled(TSignalMask signals=eSignal_Any)
Check that any of specified signals is received.
list< CRef< CSeq_align > > Tdata
Main class to perform a BLAST search on the local machine.
Magic spell ;-) needed for some weird compilers... very empiric.
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2107
Setup interrupt signal handling.
Defines NCBI C++ exception handling.
void Filter(TTimeline &timeline, TServers &servers)
USING_SCOPE(objects)
Modified on Tue May 21 11:01:24 2024 by modify_doxy.py rev. 669887