src/algo/align/splign/splign_simple.cpp

Go to the documentation of this file.
00001 /*  $Id: splign_simple.cpp 140886 2008-09-22 17:18:48Z kapustin $
00002 * ===========================================================================
00003 *
00004 *                            PUBLIC DOMAIN NOTICE
00005 *               National Center for Biotechnology Information
00006 *
00007 *  This software/database is a "United States Government Work" under the
00008 *  terms of the United States Copyright Act.  It was written as part of
00009 *  the author's official duties as a United States Government employee and
00010 *  thus cannot be copyrighted.  This software/database is freely available
00011 *  to the public for use. The National Library of Medicine and the U.S.
00012 *  Government have not placed any restriction on its use or reproduction.
00013 *
00014 *  Although all reasonable efforts have been taken to ensure the accuracy
00015 *  and reliability of the software and data, the NLM and the U.S.
00016 *  Government do not and cannot warrant the performance or results that
00017 *  may be obtained by using this software or data. The NLM and the U.S.
00018 *  Government disclaim all warranties, express or implied, including
00019 *  warranties of performance, merchantability or fitness for any particular
00020 *  purpose.
00021 *
00022 *  Please cite the author in any work or product based on this material.
00023 *
00024 * ===========================================================================
00025 *
00026 * Author: Philip Johnson
00027 *
00028 * File Description:
00029 *   CSplignSimple -- simple wrapper to splign that uses BLAST & the object
00030 *   manager
00031 *
00032 * ---------------------------------------------------------------------------
00033 */
00034 
00035 #include <ncbi_pch.hpp>
00036 #include "messages.hpp"
00037 
00038 #include <algo/align/splign/splign_simple.hpp>
00039 #include <algo/align/splign/splign_formatter.hpp>
00040 #include <algo/align/nw/nw_spliced_aligner16.hpp>
00041 #include <algo/align/nw/align_exception.hpp>
00042 #include <algo/align/util/blast_tabular.hpp>
00043 
00044 #include <objects/seqloc/Seq_loc.hpp>
00045 #include <objects/seqalign/Seq_align.hpp>
00046 #include <objects/seqalign/Dense_seg.hpp>
00047 #include <objmgr/scope.hpp>
00048 #include <objmgr/bioseq_handle.hpp>
00049 #include <objmgr/seq_vector.hpp>
00050 #include <objmgr/util/sequence.hpp>
00051 
00052 #ifdef _DEBUG
00053 #include <serial/serial.hpp>
00054 #include <serial/objostr.hpp>
00055 #endif
00056 
00057 BEGIN_NCBI_SCOPE
00058 USING_SCOPE(objects);
00059 
00060 
00061 /*---------------------------------------------------------------------------*/
00062 // PRE : transcript location, genomic location (maximum span), scope in
00063 // which transcript & genomic sequence can be resolved
00064 // POST: blast & splign initialized
00065 CSplignSimple::CSplignSimple(const CSeq_loc& transcript,
00066                              ETranscriptQuality tq,
00067                              const CSeq_loc& genomic,
00068                              CScope& scope) :
00069     m_Splign(new CSplign),
00070     m_Blast(new blast::CBl2Seq(blast::SSeqLoc(transcript, scope),
00071                                blast::SSeqLoc(genomic, scope),
00072                                blast::eMegablast)),
00073     m_TranscriptId(&sequence::GetId(transcript, &scope)),
00074     m_GenomicId   (&sequence::GetId(genomic, &scope))
00075 {    
00076     m_Splign->SetAligner() = CSplign::s_CreateDefaultAligner(tq == eTQ_Low);
00077     m_Splign->SetScope().Reset(&scope);
00078     m_Splign->PreserveScope();
00079 }
00080 
00081 
00082 CRef<CSplign>& CSplignSimple::SetSplign(void) 
00083 {
00084     return m_Splign;
00085 }
00086 
00087 CConstRef<CSplign> CSplignSimple::GetSplign(void) const
00088 {
00089     return m_Splign;
00090 }
00091 
00092 CRef<blast::CBl2Seq>& CSplignSimple::SetBlast(void)
00093 {
00094     return m_Blast;
00095 }
00096 
00097 CConstRef<blast::CBl2Seq> CSplignSimple::GetBlast(void) const
00098 {
00099     return m_Blast;
00100 }
00101 
00102 /*---------------------------------------------------------------------------*/
00103 // PRE : splign & blast objects initialized
00104 // POST: split results
00105 const CSplign::TResults& CSplignSimple::Run(void)
00106 {
00107     USING_SCOPE(blast);
00108 
00109     TSeqAlignVector sav (m_Blast->Run());
00110     CSplign::THitRefs hitrefs;
00111     ITERATE(TSeqAlignVector, ii, sav) {
00112         if((*ii)->IsSet()) {
00113             const CSeq_align_set::Tdata &sas0 = (*ii)->Get();
00114             ITERATE(CSeq_align_set::Tdata, sa_iter, sas0) {
00115                     CSplign::THitRef hitref (new CSplign::THit(**sa_iter));
00116                     if(hitref->GetQueryStrand() == false) {
00117                         hitref->FlipStrands();
00118                     }
00119                     hitrefs.push_back(hitref);
00120             }
00121         }
00122     }
00123 
00124     if(hitrefs.size()) {
00125         m_Splign->Run(&hitrefs);
00126     }
00127 
00128     return m_Splign->GetResult();
00129 }
00130 
00131 /*---------------------------------------------------------------------------*/
00132 // PRE : splign run
00133 // POST: splign results (if any) as Seq_align_set/Dense_seg
00134 CRef<CSeq_align_set> CSplignSimple::GetResultsAsAln(void) const
00135 {
00136     CSplignFormatter sf (*m_Splign);
00137     sf.SetSeqIds(m_TranscriptId, m_GenomicId);
00138     CRef<CSeq_align_set> sas (sf.AsSeqAlignSet(0, CSplignFormatter::eAF_Disc));
00139 
00140     return sas;
00141 }
00142 
00143 END_NCBI_SCOPE
00144 
00145 

Generated on Sun Dec 6 22:16:45 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:20:49 2009 by modify_doxy.py rev. 173732