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

Go to the SVN repository for this file.

1 /* $Id:
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 offical 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: Amelia Fong
27 *
28 * ===========================================================================
29 */
30 
31 /// @file: tabular.cpp
32 /// Formatting of pairwise sequence alignments in tabular form.
33 /// One line is printed for each alignment with tab-delimited fielalnVec.
34 
35 #include <ncbi_pch.hpp>
36 
38 #include <serial/iterator.hpp>
40 
43 
45  const string & custom_spec,
47  CSAM_Formatter(out,scope),
48  m_refRow(1)
49 {
51  x_ProcessCustomSpec(custom_spec, info);
52 }
53 
55 {
56  if(m_refRow == 1) {
57  CSeq_align_set sorted;
58  sorted.Set() = aln.Get();
61  }
62  else {
64  }
65 }
66 
68 {
69  if (aln.Get().front()->GetSegs().Which() == CSeq_align::C_Segs::e_Dendiag){
70  CSeq_align_set d_aln;
71  ITERATE(CSeq_align_set::Tdata, itr, aln.Get()){
73  CDense_seg::TScores & scores = dense_seg->SetSegs().SetDenseg().SetScores();
74  dense_seg->SetScore().swap(scores);
75  d_aln.Set().push_back(dense_seg);
76  }
77  x_Print(d_aln);
78  }
79  else {
80  x_Print(aln);
81  }
82 }
83 
84 void CBlast_SAM_Formatter::x_ProcessCustomSpec(const string & custom_spec,
86 {
87  vector<string> format_tokens;
88  NStr::Split(custom_spec, " ", format_tokens);
90  m_refRow = 1;
91  ITERATE (vector<string>, iter, format_tokens) {
92  if("SR" == *iter) {
93  m_refRow = 0;
94  }
95  if ("SQ" == *iter) {
97  }
98  }
99 
100  if(m_refRow == 1) {
103  }
104 }
105 
106 
void x_ProcessCustomSpec(const string &custom_spec, const CSAM_Formatter::SProgramInfo &info)
Definition: sam.cpp:84
void Print(const CSeq_align_set &aln)
Definition: sam.cpp:67
CBlast_SAM_Formatter(CNcbiOstream &out, CScope &scope, const string &custom_spec, const CSAM_Formatter::SProgramInfo &info)
Definition: sam.cpp:44
unsigned int m_refRow
Definition: sam.hpp:55
void x_Print(const CSeq_align_set &aln)
Definition: sam.cpp:54
CScope –.
Definition: scope.hpp:92
std::ofstream out("events_result.xml")
main entry point for tests
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
void SetGroupOrder(EGroupOrder go, const string &go_value=kEmptyStr)
Set GO tag value.
SProgramInfo & SetProgram(void)
void SetFlag(EFlags flag)
CSAM_Formatter & Print(const CSeq_align &aln, const CSeq_id &query_id)
void SetSortOrder(ESortOrder so, const string &so_value=kEmptyStr)
Set SO tag value.
@ eSO_Coordinate
SO:coordinate.
@ eGO_Reference
GO:reference.
@ fSAM_SeqData
Print sequence data.
@ fSAM_PlainSeqIds
Drop type prefix in seq-ids.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3461
Tdata & Set(void)
Assign a value to data member.
TScore & SetScore(void)
Assign a value to Score data member.
Definition: Seq_align_.hpp:902
void SetSegs(TSegs &value)
Assign a value to Segs data member.
Definition: Seq_align_.cpp:310
vector< CRef< CScore > > TScores
Definition: Dense_seg_.hpp:110
list< CRef< CSeq_align > > Tdata
const Tdata & Get(void) const
Get the member data.
static MDB_envinfo info
Definition: mdb_load.c:37
static CRef< CSeq_align > CreateDensegFromDendiag(CSeq_align const &aln)
static bool SortHspByMasterStartAscending(const SHspInfo *info1, const SHspInfo *info2)
USING_SCOPE(objects)
Formatting of pairwise sequence alignments in SAM form.
Modified on Sun Jun 23 05:18:32 2024 by modify_doxy.py rev. 669887