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

Go to the SVN repository for this file.

1 /* $Id: Linkage_evidence.cpp 100707 2023-08-31 20:11:46Z lavr $
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: .......
27  *
28  * File Description:
29  * .......
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using the following specifications:
34  * 'seq.asn'.
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 
40 #include <iterator>
41 // generated includes
43 
44 // generated classes
45 
46 // user-added includes
47 #include <corelib/ncbistr.hpp>
48 
50 
51 BEGIN_objects_SCOPE // namespace ncbi::objects::
52 
53 // destructor
55 {
56 }
57 
59  TLinkage_evidence& output_result,
60  const string& linkage_evidence )
61 {
62  // basically just a wrapper for the other function which does
63  // the convenience of splitting the string
64  vector<string> linkage_evidence_vec;
65  NStr::Split(linkage_evidence, ";", linkage_evidence_vec);
66  return GetLinkageEvidence( output_result, linkage_evidence_vec );
67 }
68 
69 
71  TLinkage_evidence& output_result,
72  const vector<string> &linkage_evidence )
73 {
74  static const map<string, EType> kStringToEType {
75  {"paired-ends", eType_paired_ends},
76  {"align_genus", eType_align_genus},
77  {"align_xgenus", eType_align_xgenus},
78  {"align_trnscpt", eType_align_trnscpt},
79  {"within_clone", eType_within_clone},
80  {"clone_contig", eType_clone_contig},
81  {"map", eType_map},
82  {"strobe", eType_strobe},
83  {"unspecified", eType_unspecified},
84  {"pcr", eType_pcr},
85  {"proximity_ligation", eType_proximity_ligation}
86  };
87 
88  TLinkage_evidence temp_vector;
89  for (const auto& evidence : linkage_evidence) {
90 
91  auto it = kStringToEType.find(evidence);
92  if (it == kStringToEType.end()) {
93  return false;
94  }
96  new_evid->SetType(it->second);
97  temp_vector.push_back(std::move(new_evid));
98 
99  }
100 
101  output_result.insert(end(output_result),
102  make_move_iterator(begin(temp_vector)),
103  make_move_iterator(end(temp_vector)));
104  return true;
105 }
106 
108  string & output_result,
109  const TLinkage_evidence & linkage_evidence )
110 {
111 
112  static const map<EType, string> kETypeToString {
113  {eType_paired_ends, "paired-ends"},
114  {eType_align_genus, "align_genus"},
115  {eType_align_xgenus, "align_xgenus"},
116  {eType_align_trnscpt, "align_trnscpt"},
117  {eType_within_clone, "within_clone"},
118  {eType_clone_contig, "clone_contig"},
119  {eType_map, "map"},
120  {eType_strobe, "strobe"},
121  {eType_unspecified, "unspecified"},
122  {eType_pcr, "pcr"},
123  {eType_proximity_ligation, "proximity_ligation"}
124  };
125 
126  bool all_converted_okay = true;
127 
128  for (const auto& evid : linkage_evidence) {
129 
130  const char* evid_str=nullptr;
131 
132  if (evid->IsSetType()) {
133  auto it = kETypeToString.find(static_cast<EType>(evid->GetType()));
134  if (it != kETypeToString.end()) {
135  evid_str = it->second.c_str();
136  }
137  }
138  if(!evid_str) {
139  evid_str = "UNKNOWN";
140  all_converted_okay = false;
141  }
142  if( ! output_result.empty() ) {
143  output_result += ';';
144  }
145  output_result += evid_str;
146  }
147 
148  return all_converted_okay;
149 }
150 
151 END_objects_SCOPE // namespace ncbi::objects::
152 
154 
155 /* Original file checksum: lines: 57, chars: 1737, CRC32: da3bca7d */
User-defined methods of the data storage class.
list< CRef< CLinkage_evidence > > TLinkage_evidence
static bool GetLinkageEvidence(TLinkage_evidence &output_result, const string &linkage_evidence)
static bool VecToString(string &output_result, const TLinkage_evidence &linkage_evidence)
CRef –.
Definition: ncbiobj.hpp:618
Definition: map.hpp:338
The NCBI C++ standard methods for dealing with std::string.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
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:3457
Modified on Thu Mar 28 17:06:03 2024 by modify_doxy.py rev. 669887