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
>
13
#include <
Bpp/Text/StringTokenizer.h
>
14
15
AAIndex2Entry::AAIndex2Entry
(std::istream& input,
bool
sym) :
16
ProteicAlphabetIndex2
(),
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
{
45
property_
(i, j) =
TextTools::toDouble
(st1.
nextToken
());
46
}
47
}
48
else
49
{
50
if
(st1.
numberOfRemainingTokens
() != 20)
51
break
;
52
for
(
size_t
j = 0; j < 20; ++j)
53
{
54
property_
(i, j) =
TextTools::toDouble
(st1.
nextToken
());
55
}
56
}
57
}
58
// Jump to next entry...
59
FileTools::getNextLine
(input);
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
}
AAIndex2Entry.h
FileTools.h
StringTokenizer.h
TextTools.h
bpp::AAIndex2Entry::property_
LinearMatrix< double > property_
Definition:
AAIndex2Entry.h:21
bpp::AAIndex2Entry::AAIndex2Entry
AAIndex2Entry(std::istream &input, bool sym=true)
Create a new AAIndex2Entry from an input stream.
Definition:
AAIndex2Entry.cpp:15
bpp::AAIndex2Entry::sym_
bool sym_
Definition:
AAIndex2Entry.h:22
bpp::FileTools::getNextLine
static std::string getNextLine(std::istream &in)
bpp::IOException
bpp::ProteicAlphabetIndex2
Virtual AlphabetIndex2 for proteic alphabet.
Definition:
AlphabetIndex2.h:82
bpp::StringTokenizer
bpp::StringTokenizer::numberOfRemainingTokens
size_t numberOfRemainingTokens() const
bpp::StringTokenizer::nextToken
const std::string & nextToken()
bpp::TextTools::toDouble
double toDouble(const std::string &s, char dec='.', char scientificNotation='e')
bpp
This alphabet is used to deal NumericAlphabet.
Bpp
Seq
AlphabetIndex
AAIndex2Entry.cpp
Generated on Fri Jul 19 2024 12:16:01 for bpp-seq3 by
1.9.1