Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bmDCA
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Jerry Dinan
bmDCA
Commits
72879851
Commit
72879851
authored
4 years ago
by
sudorook
Browse files
Options
Downloads
Patches
Plain Diff
add functions to compute hamming distance pairs for an MSA
parent
18ada0d3
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/msa.cpp
+35
-0
35 additions, 0 deletions
src/msa.cpp
src/msa.hpp
+4
-0
4 additions, 0 deletions
src/msa.hpp
with
39 additions
and
0 deletions
src/msa.cpp
+
35
−
0
View file @
72879851
...
...
@@ -351,3 +351,38 @@ MSA::writeSequenceWeights(std::string output_file)
output_stream
<<
sequence_weights
.
at
(
i
)
<<
std
::
endl
;
}
};
void
MSA
::
computeHammingDistances
(
void
)
{
hamming_distances
=
arma
::
Col
<
double
>
(
M
,
arma
::
fill
::
zeros
);
arma
::
Mat
<
int
>
alignment_T
=
alignment
.
t
();
int
*
i_ptr
=
nullptr
;
int
*
j_ptr
=
nullptr
;
int
count
=
0
;
double
id
=
0
;
for
(
int
i
=
0
;
i
<
M
;
i
++
)
{
i_ptr
=
alignment_T
.
colptr
(
i
);
for
(
int
j
=
i
+
1
;
j
<
M
;
j
++
)
{
count
=
0
;
j_ptr
=
alignment_T
.
colptr
(
j
);
for
(
int
n
=
0
;
n
<
N
;
n
++
)
{
if
(
*
(
i_ptr
+
n
)
==
*
(
j_ptr
+
n
))
{
count
++
;
}
}
id
=
(
double
)
count
/
N
;
if
(
id
>
hamming_distances
.
at
(
i
))
{
hamming_distances
.
at
(
i
)
=
id
;
}
}
}
};
void
MSA
::
writeHammingDistances
(
std
::
string
output_file
)
{
std
::
ofstream
output_stream
(
output_file
);
for
(
int
i
=
0
;
i
<
M
;
i
++
)
{
output_stream
<<
hamming_distances
.
at
(
i
)
<<
std
::
endl
;
}
};
This diff is collapsed.
Click to expand it.
src/msa.hpp
+
4
−
0
View file @
72879851
...
...
@@ -16,11 +16,14 @@ public:
int
N
;
// number of positions
int
Q
;
// number of amino acids
arma
::
Col
<
double
>
hamming_distances
;
MSA
(
std
::
string
,
bool
=
true
,
bool
=
false
,
double
=
0.8
);
MSA
(
std
::
string
,
std
::
string
,
bool
=
false
);
void
printAlignment
();
void
writeMatrix
(
std
::
string
);
void
writeSequenceWeights
(
std
::
string
);
void
writeHammingDistances
(
std
::
string
);
private:
std
::
vector
<
SeqRecord
>
seq_records
;
...
...
@@ -30,6 +33,7 @@ private:
void
readSequenceWeights
(
std
::
string
);
void
makeNumericalMatrix
(
void
);
void
computeSequenceWeights
(
double
);
void
computeHammingDistances
(
void
);
};
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
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