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

Go to the SVN repository for this file.

1 /* $Id: mask_writer_seqloc.cpp 72378 2016-05-04 14:59:01Z camacho $
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
27  *
28  * File Description:
29  * CMaskWriterSeqLoc class member and method definitions.
30  *
31  */
32 #include <ncbi_pch.hpp>
36 #include <objmgr/bioseq_handle.hpp>
37 
40 
42  const string & format )
43 : CMaskWriter( arg_os )
44 {
45  if (format == "seqloc_asn1_bin") {
47  } else if (format == "seqloc_asn1_text") {
49  } else if (format == "seqloc_xml") {
51  } else {
52  throw runtime_error("Invalid output format: " + format);
53  }
54 }
55 
56 //-------------------------------------------------------------------------
57 void CMaskWriterSeqLoc::Print( objects::CBioseq_Handle& bsh,
58  const TMaskList & mask,
59  bool /* match_id */ )
60 {
61  if (mask.empty()) {
62  return;
63  }
64 
65  CPacked_seqint::TRanges masked_ranges;
66  masked_ranges.reserve(mask.size());
67  ITERATE(TMaskList, itr, mask) {
68  masked_ranges.push_back
69  (CPacked_seqint::TRanges::value_type(itr->first, itr->second));
70  }
71 
72  CConstRef<CSeq_id> id = bsh.GetSeqId();
73 
74  CSeq_loc seqloc(const_cast<CSeq_id&>(*id), masked_ranges);
75  switch (m_OutputFormat) {
76  case eSerial_AsnBinary:
77  os << MSerial_AsnBinary << seqloc;
78  break;
79  case eSerial_AsnText:
80  os << MSerial_AsnText << seqloc;
81  break;
82  case eSerial_Xml:
83  os << MSerial_Xml << seqloc;
84  break;
85  default:
86  throw runtime_error("Invalid output format!");
87  }
88 }
89 
90 
ncbi::TMaskedQueryRegions mask
ESerialDataFormat m_OutputFormat
Seq-loc output format.
CMaskWriterSeqLoc(CNcbiOstream &arg_os, const string &format)
Object constructor.
virtual void Print(objects::CBioseq_Handle &bsh, const TMaskList &mask, bool parsed_id=false)
Send the masking data to the output stream.
A base class for winmasker output writers.
Definition: mask_writer.hpp:52
CNcbiOstream & os
the standard C++ ostream object
vector< TMaskedInterval > TMaskList
A type representing the total of masking information about a sequence.
Definition: mask_writer.hpp:85
vector< CRange< TSeqPos > > TRanges
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define MSerial_AsnBinary
Definition: serialbase.hpp:697
#define MSerial_Xml
Definition: serialbase.hpp:698
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
@ eSerial_AsnText
ASN.1 text.
Definition: serialdef.hpp:73
@ eSerial_Xml
XML.
Definition: serialdef.hpp:75
@ eSerial_AsnBinary
ASN.1 binary.
Definition: serialdef.hpp:74
#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
USING_SCOPE(objects)
double value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:228
static Format format
Definition: njn_ioutil.cpp:53
Modified on Sun Mar 03 03:14:14 2024 by modify_doxy.py rev. 669887