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

Go to the SVN repository for this file.

1 /* $Id: splign_simple.cpp 44221 2009-12-22 16:44:40Z kapustin $
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: Philip Johnson
27 *
28 * File Description:
29 * CSplignSimple -- simple wrapper to splign that uses BLAST & the object
30 * manager
31 *
32 * ---------------------------------------------------------------------------
33 */
34 
35 #include <ncbi_pch.hpp>
36 #include "messages.hpp"
37 
43 
47 #include <objmgr/scope.hpp>
48 #include <objmgr/bioseq_handle.hpp>
49 #include <objmgr/seq_vector.hpp>
50 #include <objmgr/util/sequence.hpp>
51 
52 #ifdef _DEBUG
53 #include <serial/serial.hpp>
54 #include <serial/objostr.hpp>
55 #endif
56 
59 
60 
61 /*---------------------------------------------------------------------------*/
62 // PRE : transcript location, genomic location (maximum span), scope in
63 // which transcript & genomic sequence can be resolved
64 // POST: blast & splign initialized
67  const CSeq_loc& genomic,
68  CScope& scope) :
69  m_Splign(new CSplign),
70  m_Blast(new blast::CBl2Seq(blast::SSeqLoc(transcript, scope),
71  blast::SSeqLoc(genomic, scope),
72  blast::eMegablast)),
73  m_TranscriptId(&sequence::GetId(transcript, &scope)),
74  m_GenomicId (&sequence::GetId(genomic, &scope))
75 {
77  m_Splign->SetScope().Reset(&scope);
79 }
80 
81 
83 {
84  return m_Splign;
85 }
86 
88 {
89  return m_Splign;
90 }
91 
93 {
94  return m_Blast;
95 }
96 
98 {
99  return m_Blast;
100 }
101 
102 /*---------------------------------------------------------------------------*/
103 // PRE : splign & blast objects initialized
104 // POST: split results
106 {
108 
109  TSeqAlignVector sav (m_Blast->Run());
110  CSplign::THitRefs hitrefs;
111  ITERATE(TSeqAlignVector, ii, sav) {
112  if((*ii)->IsSet()) {
113  const CSeq_align_set::Tdata &sas0 = (*ii)->Get();
114  ITERATE(CSeq_align_set::Tdata, sa_iter, sas0) {
115  CSplign::THitRef hitref (new CSplign::THit(**sa_iter));
116  if(hitref->GetQueryStrand() == false) {
117  hitref->FlipStrands();
118  }
119  hitrefs.push_back(hitref);
120  }
121  }
122  }
123 
124  if(hitrefs.size()) {
125  m_Splign->Run(&hitrefs);
126  }
127 
128  return m_Splign->GetResult();
129 }
130 
131 /*---------------------------------------------------------------------------*/
132 // PRE : splign run
133 // POST: splign results (if any) as Seq_align_set/Dense_seg
136 {
137  CSplignFormatter sf (*m_Splign);
138  sf.SetSeqIds(m_TranscriptId, m_GenomicId);
139  CRef<CSeq_align_set> sas (sf.AsSeqAlignSet(0, flags));
140 
141  return sas;
142 }
143 
CConstRef –.
Definition: ncbiobj.hpp:1211
const TResults & GetResult(void) const
Definition: splign.hpp:292
CRef< blast::CBl2Seq > m_Blast
Runs the BLAST algorithm between 2 sequences.
Definition: bl2seq.hpp:57
vector< CRef< objects::CSeq_align_set > > TSeqAlignVector
Vector of Seq-align-sets.
void SetSeqIds(CConstRef< objects::CSeq_id > id1, CConstRef< objects::CSeq_id > id2)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:795
static CRef< CSplicedAligner > s_CreateDefaultAligner(void)
Definition: splign.cpp:233
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
list< CRef< CSeq_align > > Tdata
CRef< TAligner > & SetAligner(void)
Access the spliced aligner core object.
Definition: splign.cpp:211
CRef< objects::CSeq_align_set > GetResultsAsAln(CSplignFormatter::EAsnFlags flags=CSplignFormatter::eAF_Disc) const
Format the resulting alignment as a seq-align-set.
vector< SAlignedCompartment > TResults
Definition: splign.hpp:289
CRef< blast::CBl2Seq > & SetBlast(void)
void PreserveScope(bool preserve=true)
Controls whether to clean the scope object's cache on a new sequence.
Definition: splign.cpp:580
CRef< objects::CSeq_align_set > AsSeqAlignSet(const CSplign::TResults *results=0, int flags=eAF_SplicedSegWithParts) const
Format alignment as a seq-align-set.
CRef< objects::CScope > & SetScope(void)
Definition: splign.cpp:574
void Run(THitRefs *hitrefs)
Definition: splign.cpp:1121
CConstRef< blast::CBl2Seq > GetBlast(void) const
const CSplign::TResults & Run(void)
CRef< CSplign > m_Splign
CScope –.
Definition: scope.hpp:90
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found...
Structure to represent a single sequence to be fed to BLAST.
Definition: sseqloc.hpp:47
CSplignSimple(const objects::CSeq_loc &transcript, ETranscriptQuality tq, const objects::CSeq_loc &genomic, objects::CScope &scope)
CRef< CSplign > & SetSplign(void)
CConstRef< CSplign > GetSplign(void) const
vector< THitRef > THitRefs
Definition: splign.hpp:285
Nucl-Nucl (traditional megablast)
Definition: blast_types.hpp:65
CSplign is the central library object for computing spliced cDNA-to-genomic alignments.
Definition: splign.hpp:69
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
USING_SCOPE(objects)
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:768
Modified on Thu Feb 22 13:23:35 2018 by modify_doxy.py rev. 546573