bpp-seq3  3.0.0
AAIndex2Entry.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #include "../Alphabet/AlphabetTools.h"
6 #include "AAIndex2Entry.h"
7 
8 using namespace bpp;
9 using namespace std;
10 
11 #include <Bpp/Io/FileTools.h>
12 #include <Bpp/Text/TextTools.h>
14 
15 AAIndex2Entry::AAIndex2Entry(std::istream& input, bool sym) :
17  property_(20, 20),
18  sym_(sym)
19 {
20  // Parse entry:
21  string line;
22  bool ok = false;
23  bool diag = false;
24  do
25  {
26  line = FileTools::getNextLine(input);
27  if (line[0] == 'M')
28  {
29  for (size_t i = 0; i < 20; ++i)
30  {
31  line = FileTools::getNextLine(input);
32  StringTokenizer st1(line, " ");
33  if (i == 0 && st1.numberOfRemainingTokens() == 1)
34  {
35  // Lower triangle only:
36  diag = true;
37  }
38  // Amino acids are in the same order in the AAIndex1 database than in the ProteicAlphabet class:
39  if (diag)
40  {
41  if (st1.numberOfRemainingTokens() != i + 1)
42  break;
43  for (size_t j = 0; j <= i; ++j)
44  {
46  }
47  }
48  else
49  {
50  if (st1.numberOfRemainingTokens() != 20)
51  break;
52  for (size_t j = 0; j < 20; ++j)
53  {
55  }
56  }
57  }
58  // Jump to next entry...
60  ok = true;
61  }
62  }
63  while (!ok);
64  if (!ok)
65  throw IOException("AAIndex2Entry: invalid AAIndex2 entry.");
66  if (!diag)
67  sym_ = false;
68 }
LinearMatrix< double > property_
Definition: AAIndex2Entry.h:21
AAIndex2Entry(std::istream &input, bool sym=true)
Create a new AAIndex2Entry from an input stream.
static std::string getNextLine(std::istream &in)
Virtual AlphabetIndex2 for proteic alphabet.
size_t numberOfRemainingTokens() const
const std::string & nextToken()
double toDouble(const std::string &s, char dec='.', char scientificNotation='e')
This alphabet is used to deal NumericAlphabet.