bpp-core3  3.0.0
AAIndex1Entry.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 <Bpp/Io/FileTools.h>
6 #include <Bpp/Text/StringTokenizer.h>
7 #include <Bpp/Text/TextTools.h>
8 
9 #include "AAIndex1Entry.h"
10 
11 using namespace bpp;
12 using namespace std;
13 
14 AAIndex1Entry::AAIndex1Entry(std::istream& input) :
16  property_(20)
17 {
18  // Parse entry:
19  string line;
20  bool ok = false;
21  do
22  {
23  line = FileTools::getNextLine(input);
24  if (line[0] == 'I')
25  {
26  string line1 = FileTools::getNextLine(input);
27  string line2 = FileTools::getNextLine(input);
28  StringTokenizer st1(line1, " ");
29  StringTokenizer st2(line2, " ");
30  if (st1.numberOfRemainingTokens() != 10 || st1.numberOfRemainingTokens() != 10)
31  break;
32  // Amino acids are in the same order in the AAIndex1 database than in the ProteicAlphabet class:
33  for (unsigned int i = 0; i < 10; i++)
34  {
35  property_[i] = TextTools::toDouble(st1.nextToken());
36  }
37  for (unsigned int i = 10; i < 20; i++)
38  {
39  property_[i] = TextTools::toDouble(st2.nextToken());
40  }
41  // Jump to next entry...
42  FileTools::getNextLine(input);
43  ok = true;
44  }
45  }
46  while (!ok);
47  if (!ok)
48  throw IOException("AAIndex1Entry: invalid AAIndex1 entry.");
49 }
This alphabet is used to deal NumericAlphabet.
AAIndex1Entry(std::istream &input)
Create a new AAIndex1Entry from an input stream.
STL namespace.
std::vector< double > property_
Definition: AAIndex1Entry.h:20