Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dssp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
dssp
Commits
a9b0b4bf
Unverified
Commit
a9b0b4bf
authored
Jun 06, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pipe lines
parent
95cfecd5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
182 additions
and
32 deletions
+182
-32
src/dssp.cpp
+51
-32
src/queue.hpp
+131
-0
No files found.
src/dssp.cpp
View file @
a9b0b4bf
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
// Calculate DSSP-like secondary structure information
// Calculate DSSP-like secondary structure information
#include "dssp.hpp"
#include "dssp.hpp"
#include "queue.hpp"
#include <deque>
#include <deque>
#include <iomanip>
#include <iomanip>
...
@@ -40,6 +41,8 @@ using helix_type = dssp::helix_type;
...
@@ -40,6 +41,8 @@ using helix_type = dssp::helix_type;
using
helix_position_type
=
dssp
::
helix_position_type
;
using
helix_position_type
=
dssp
::
helix_position_type
;
using
chain_break_type
=
dssp
::
chain_break_type
;
using
chain_break_type
=
dssp
::
chain_break_type
;
using
queue_type
=
blocking_queue
<
std
::
tuple
<
uint32_t
,
uint32_t
>>
;
// --------------------------------------------------------------------
// --------------------------------------------------------------------
const
double
const
double
...
@@ -765,36 +768,22 @@ double CalculateHBondEnergy(residue &inDonor, residue &inAcceptor)
...
@@ -765,36 +768,22 @@ double CalculateHBondEnergy(residue &inDonor, residue &inAcceptor)
// --------------------------------------------------------------------
// --------------------------------------------------------------------
void
CalculateHBondEnergies
(
std
::
vector
<
residue
>
&
inResidues
)
void
CalculateHBondEnergies
(
std
::
vector
<
residue
>
&
inResidues
,
queue_type
&
q1
)
{
{
if
(
cif
::
VERBOSE
)
for
(;;)
std
::
cerr
<<
"calculating hbond energies"
<<
std
::
endl
;
{
const
auto
&
[
i
,
j
]
=
q1
.
pop
();
// Calculate the HBond energies
std
::
unique_ptr
<
cif
::
progress_bar
>
progress
;
if
(
i
==
0
and
j
==
0
)
if
(
cif
::
VERBOSE
==
0
)
break
;
progress
.
reset
(
new
cif
::
progress_bar
((
inResidues
.
size
()
*
(
inResidues
.
size
()
-
1
)
/
2
),
"calculate hbond energies"
));
for
(
uint32_t
i
=
0
;
i
+
1
<
inResidues
.
size
();
++
i
)
{
auto
&
ri
=
inResidues
[
i
];
auto
&
ri
=
inResidues
[
i
];
for
(
uint32_t
j
=
i
+
1
;
j
<
inResidues
.
size
();
++
j
)
{
auto
&
rj
=
inResidues
[
j
];
auto
&
rj
=
inResidues
[
j
];
if
(
distance_sq
(
ri
.
mCAlpha
,
rj
.
mCAlpha
)
<
kMinimalCADistance
*
kMinimalCADistance
)
{
CalculateHBondEnergy
(
ri
,
rj
);
CalculateHBondEnergy
(
ri
,
rj
);
if
(
j
!=
i
+
1
)
if
(
j
!=
i
+
1
)
CalculateHBondEnergy
(
rj
,
ri
);
CalculateHBondEnergy
(
rj
,
ri
);
}
}
if
(
progress
)
progress
->
consumed
(
1
);
}
}
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
...
@@ -869,7 +858,7 @@ bool Linked(const bridge &a, const bridge &b)
...
@@ -869,7 +858,7 @@ bool Linked(const bridge &a, const bridge &b)
// --------------------------------------------------------------------
// --------------------------------------------------------------------
void
CalculateBetaSheets
(
std
::
vector
<
residue
>
&
inResidues
,
statistics
&
stats
)
void
CalculateBetaSheets
(
std
::
vector
<
residue
>
&
inResidues
,
statistics
&
stats
,
std
::
vector
<
std
::
tuple
<
uint32_t
,
uint32_t
>>
&
q
)
{
{
if
(
cif
::
VERBOSE
)
if
(
cif
::
VERBOSE
)
std
::
cerr
<<
"calculating beta sheets"
<<
std
::
endl
;
std
::
cerr
<<
"calculating beta sheets"
<<
std
::
endl
;
...
@@ -877,16 +866,9 @@ void CalculateBetaSheets(std::vector<residue> &inResidues, statistics &stats)
...
@@ -877,16 +866,9 @@ void CalculateBetaSheets(std::vector<residue> &inResidues, statistics &stats)
// Calculate Bridges
// Calculate Bridges
std
::
vector
<
bridge
>
bridges
;
std
::
vector
<
bridge
>
bridges
;
std
::
unique_ptr
<
cif
::
progress_bar
>
progress
;
for
(
const
auto
&
[
i
,
j
]
:
q
)
if
(
cif
::
VERBOSE
==
0
)
progress
.
reset
(
new
cif
::
progress_bar
(((
inResidues
.
size
()
-
5
)
*
(
inResidues
.
size
()
-
4
)
/
2
),
"calculate beta sheets"
));
for
(
uint32_t
i
=
1
;
i
+
4
<
inResidues
.
size
();
++
i
)
{
{
auto
&
ri
=
inResidues
[
i
];
auto
&
ri
=
inResidues
[
i
];
for
(
uint32_t
j
=
i
+
3
;
j
+
1
<
inResidues
.
size
();
++
j
)
{
auto
&
rj
=
inResidues
[
j
];
auto
&
rj
=
inResidues
[
j
];
bridge_type
type
=
TestBridge
(
ri
,
rj
);
bridge_type
type
=
TestBridge
(
ri
,
rj
);
...
@@ -929,7 +911,6 @@ void CalculateBetaSheets(std::vector<residue> &inResidues, statistics &stats)
...
@@ -929,7 +911,6 @@ void CalculateBetaSheets(std::vector<residue> &inResidues, statistics &stats)
bridges
.
push_back
(
bridge
);
bridges
.
push_back
(
bridge
);
}
}
}
}
}
// extend ladders
// extend ladders
std
::
sort
(
bridges
.
begin
(),
bridges
.
end
());
std
::
sort
(
bridges
.
begin
(),
bridges
.
end
());
...
@@ -1563,11 +1544,49 @@ void DSSP_impl::calculateSecondaryStructure()
...
@@ -1563,11 +1544,49 @@ void DSSP_impl::calculateSecondaryStructure()
mSSBonds
.
emplace_back
(
&*
r1
,
&*
r2
);
mSSBonds
.
emplace_back
(
&*
r1
,
&*
r2
);
}
}
CalculateHBondEnergies
(
mResidues
);
// Calculate the HBond energies
CalculateBetaSheets
(
mResidues
,
mStats
);
queue_type
q1
,
q2
;
std
::
vector
<
std
::
tuple
<
uint32_t
,
uint32_t
>>
near
;
std
::
thread
hbond_thread
(
std
::
bind
(
&
CalculateHBondEnergies
,
std
::
ref
(
mResidues
),
std
::
ref
(
q1
)));
std
::
unique_ptr
<
cif
::
progress_bar
>
progress
;
if
(
cif
::
VERBOSE
==
0
)
progress
.
reset
(
new
cif
::
progress_bar
((
mResidues
.
size
()
*
(
mResidues
.
size
()
-
1
)
/
2
),
"calculate hbond energies"
));
for
(
uint32_t
i
=
0
;
i
+
1
<
mResidues
.
size
();
++
i
)
{
auto
&
ri
=
mResidues
[
i
];
for
(
uint32_t
j
=
i
+
1
;
j
<
mResidues
.
size
();
++
j
)
{
auto
&
rj
=
mResidues
[
j
];
if
(
distance_sq
(
ri
.
mCAlpha
,
rj
.
mCAlpha
)
<
kMinimalCADistance
*
kMinimalCADistance
)
{
q1
.
push
({
i
,
j
});
near
.
emplace_back
(
i
,
j
);
}
if
(
progress
)
progress
->
consumed
(
1
);
}
}
q1
.
push
({
0
,
0
});
hbond_thread
.
join
();
std
::
thread
bsheet_thread
(
std
::
bind
(
&
CalculateBetaSheets
,
std
::
ref
(
mResidues
),
std
::
ref
(
mStats
),
std
::
ref
(
near
)));
// CalculateHBondEnergies(mResidues);
// CalculateBetaSheets(mResidues, mStats);
CalculateAlphaHelices
(
mResidues
,
mStats
);
CalculateAlphaHelices
(
mResidues
,
mStats
);
CalculatePPHelices
(
mResidues
,
mStats
,
m_min_poly_proline_stretch_length
);
CalculatePPHelices
(
mResidues
,
mStats
,
m_min_poly_proline_stretch_length
);
bsheet_thread
.
join
();
if
(
cif
::
VERBOSE
>
1
)
if
(
cif
::
VERBOSE
>
1
)
{
{
for
(
auto
&
r
:
mResidues
)
for
(
auto
&
r
:
mResidues
)
...
...
src/queue.hpp
0 → 100644
View file @
a9b0b4bf
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021 NKI/AVL, Netherlands Cancer Institute
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <condition_variable>
#include <mutex>
#include <queue>
template
<
typename
T
,
size_t
N
=
100
>
class
blocking_queue
{
public
:
void
push
(
T
const
&
value
)
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_guard
);
while
(
m_queue
.
size
()
>=
N
)
m_full_signal
.
wait
(
lock
);
m_queue
.
push
(
value
);
m_empty_signal
.
notify_one
();
}
T
pop
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_guard
);
while
(
m_queue
.
empty
())
m_empty_signal
.
wait
(
lock
);
auto
value
=
m_queue
.
front
();
m_queue
.
pop
();
m_full_signal
.
notify_one
();
return
value
;
}
template
<
class
Rep
,
class
Period
>
std
::
tuple
<
bool
,
T
>
pop
(
const
std
::
chrono
::
duration
<
Rep
,
Period
>&
wait_for
)
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_guard
);
while
(
m_queue
.
empty
())
{
auto
now
=
std
::
chrono
::
system_clock
::
now
();
if
(
m_empty_signal
.
wait_until
(
lock
,
now
+
wait_for
)
==
std
::
cv_status
::
timeout
)
return
{
true
,
T
{}
};
}
auto
value
=
m_queue
.
front
();
m_queue
.
pop
();
m_full_signal
.
notify_one
();
return
{
false
,
value
};
}
bool
is_full
()
const
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_guard
);
return
m_queue
.
size
()
>=
N
;
}
private
:
std
::
queue
<
T
>
m_queue
;
mutable
std
::
mutex
m_guard
;
std
::
condition_variable
m_empty_signal
,
m_full_signal
;
};
template
<
typename
T
,
size_t
N
=
10
>
class
non_blocking_queue
{
public
:
bool
push
(
T
const
&
value
)
{
bool
result
=
false
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_guard
);
if
(
m_queue
.
size
()
<
N
)
{
m_queue
.
push
(
value
);
m_empty_signal
.
notify_one
();
result
=
true
;
}
return
result
;
}
T
pop
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_guard
);
while
(
m_queue
.
empty
())
m_empty_signal
.
wait
(
lock
);
auto
value
=
m_queue
.
front
();
m_queue
.
pop
();
return
value
;
}
private
:
std
::
queue
<
T
>
m_queue
;
mutable
std
::
mutex
m_guard
;
std
::
condition_variable
m_empty_signal
;
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment