Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
61acb788
Commit
61acb788
authored
13 years ago
by
Tobias Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
fixes weight matrix problem for non-alpha characters (BZDNG-280)
parent
d968aa37
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/seq/alg/src/subst_weight_matrix.hh
+25
-6
25 additions, 6 deletions
modules/seq/alg/src/subst_weight_matrix.hh
modules/seq/alg/tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
modules/seq/alg/tests/CMakeLists.txt
with
26 additions
and
6 deletions
modules/seq/alg/src/subst_weight_matrix.hh
+
25
−
6
View file @
61acb788
...
...
@@ -47,24 +47,43 @@ public:
::
memset
(
weights_
,
0
,
sizeof
(
WeightType
)
*
ALPHABET_SIZE
*
ALPHABET_SIZE
);
}
/// \brief Get the substitution weight between two amino acids
///
/// If the amino acid single letter code is unknown (e.g. '?')
/// a weight of 0 is returned
WeightType
GetWeight
(
char
aa_one
,
char
aa_two
)
const
{
if
(
!
(
IsAlpha
(
aa_one
)
&&
IsAlpha
(
aa_two
)))
{
return
0
;
}
int
i
=
Index
(
aa_one
,
aa_two
);
assert
(
i
>=
0
&&
i
<
ALPHABET_SIZE
*
ALPHABET_SIZE
);
return
weights_
[
i
];
return
(
i
>=
0
&&
i
<
ALPHABET_SIZE
*
ALPHABET_SIZE
)
?
weights_
[
i
]
:
0
;
}
/// \brief Set the substitution weight between two amino acids
///
/// The weight is only set if the amino acid single letter code
/// is known (e.g. no weight is set for '?')
void
SetWeight
(
char
aa_one
,
char
aa_two
,
WeightType
weight
)
{
int
i
=
Index
(
aa_one
,
aa_two
);
assert
(
i
>=
0
&&
i
<
ALPHABET_SIZE
*
ALPHABET_SIZE
);
weights_
[
i
]
=
weight
;
if
((
IsAlpha
(
aa_one
)
&&
IsAlpha
(
aa_two
)))
{
int
i
=
Index
(
aa_one
,
aa_two
);
if
(
i
>=
0
&&
i
<
ALPHABET_SIZE
*
ALPHABET_SIZE
)
{
weights_
[
i
]
=
weight
;
}
}
}
private
:
int
Index
(
char
aa_one
,
char
aa_two
)
const
{
return
(
toupper
(
aa_one
)
-
'A'
)
*
ALPHABET_SIZE
+
(
toupper
(
aa_two
)
-
'A'
);
}
WeightType
weights_
[
ALPHABET_SIZE
*
ALPHABET_SIZE
];
/// \brief Check if uppercase character is one of [A-Z]
bool
IsAlpha
(
char
aa
)
const
{
return
(
toupper
(
aa
)
>=
'A'
&&
toupper
(
aa
)
<=
'Z'
);
}
WeightType
weights_
[
ALPHABET_SIZE
*
ALPHABET_SIZE
];
};
SubstWeightMatrixPtr
DLLEXPORT_OST_SEQ_ALG
...
...
This diff is collapsed.
Click to expand it.
modules/seq/alg/tests/CMakeLists.txt
+
1
−
0
View file @
61acb788
...
...
@@ -5,6 +5,7 @@ set(OST_SEQ_ALG_UNIT_TESTS
test_renumber.py
test_local_align.py
test_global_align.py
test_weight_matrix.py
)
ost_unittest
(
MODULE seq_alg SOURCES
"
${
OST_SEQ_ALG_UNIT_TESTS
}
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment