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

Go to the SVN repository for this file.

1 /* $Id: gff_util.cpp 86362 2019-05-02 15:04:11Z ludwigf $
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: Frank Ludwig
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbifile.hpp>
36 #include "gff_util.hpp"
37 
39 
42 
43 // ============================================================================
44 bool
46  const vector<string>& gffColumns,
47  bool& scoreIsPresent,
48  double& scoreValue)
49 // ============================================================================
50 {
51  auto score = gffColumns[5];
52  if (score == ".") {
53  scoreIsPresent = false;
54  return true;
55  }
56 
57  try {
58  scoreValue = NStr::StringToDouble(score);
59  }
60  catch(std::exception&) {
61  return false;
62  }
63  scoreIsPresent = true;
64  return true;
65 }
66 
67 // ============================================================================
68 bool
70  const vector<string>& gffColumns,
71  std::string& phase)
72 // ============================================================================
73 {
74  phase = gffColumns[7];
75  vector<string> valid = {".", "0", "1", "2"};
76  auto validIt = find(valid.begin(), valid.end(), phase);
77  return (validIt != valid.end());
78 }
79 
80 // ============================================================================
83  const std::string& phase)
84 // ============================================================================
85 {
86  vector<CCdregion::TFrame> frameValues = {
88 
89  if (phase == ".") {
91  }
92  else {
93  return frameValues[phase[0] - '0'];
94  }
95 }
96 
static bool InitializeFrame(const std::vector< std::string > &, std::string &)
Definition: gff_util.cpp:69
static CCdregion::TFrame PhaseToFrame(const std::string &)
Definition: gff_util.cpp:82
static bool InitializeScore(const std::vector< std::string > &, bool &, double &)
Definition: gff_util.cpp:45
string
Definition: cgiapp.hpp:687
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
static double StringToDouble(const CTempStringEx str, TStringToNumFlags flags=0)
Convert string to double.
Definition: ncbistr.cpp:1387
@ eFrame_not_set
not set, code uses one
Definition: Cdregion_.hpp:95
@ eFrame_three
reading frame
Definition: Cdregion_.hpp:98
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
Modified on Fri Dec 01 04:46:59 2023 by modify_doxy.py rev. 669887