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
0cedf7b1
Unverified
Commit
0cedf7b1
authored
Jun 15, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alternate sheet writing, again
parent
7460007b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
122 additions
and
90 deletions
+122
-90
src/dssp-io.cpp
+30
-18
src/dssp.cpp
+92
-72
No files found.
src/dssp-io.cpp
View file @
0cedf7b1
...
...
@@ -340,7 +340,7 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
for
(
auto
&
res
:
dssp
)
{
if
(
res
.
type
()
!=
dssp
::
structure_type
::
Strand
)
if
(
res
.
type
()
!=
dssp
::
structure_type
::
Strand
and
res
.
type
()
!=
dssp
::
structure_type
::
Betabridge
)
continue
;
strands
[{
res
.
sheet
(),
res
.
strand
()}].
emplace_back
(
res
);
...
...
@@ -377,7 +377,7 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
if
(
strand
.
front
().
sheet
()
!=
sheetNr
)
continue
;
std
::
string
strandID
=
"strand_"
+
cif
::
cif_id_for_number
(
strand
.
front
().
strand
()
-
1
);
std
::
string
strandID
=
cif
::
cif_id_for_number
(
strand
.
front
().
strand
()
-
1
);
std
::
sort
(
strand
.
begin
(),
strand
.
end
(),
[](
dssp
::
residue_info
const
&
a
,
dssp
::
residue_info
const
&
b
)
{
return
a
.
nr
()
<
b
.
nr
();
});
...
...
@@ -409,7 +409,8 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
for
(
int
i
:
{
0
,
1
})
{
const
auto
&
[
bp
,
ladder
,
parallel
]
=
res
.
bridge_partner
(
i
);
if
(
not
bp
or
bp
.
type
()
!=
dssp
::
structure_type
::
Strand
)
// if (not bp or bp.type() != dssp::structure_type::Strand)
if
(
not
bp
)
continue
;
auto
s1
=
res
.
strand
();
...
...
@@ -431,13 +432,13 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
bool
parallel
=
parallel_test
>
0
;
std
::
string
strandID_1
=
"strand_"
+
cif
::
cif_id_for_number
(
s1
-
1
);
std
::
string
strandID_2
=
"strand_"
+
cif
::
cif_id_for_number
(
s2
-
1
);
std
::
string
strandID_1
=
cif
::
cif_id_for_number
(
s1
-
1
);
std
::
string
strandID_2
=
cif
::
cif_id_for_number
(
s2
-
1
);
struct_sheet_order
.
emplace
({
{
"sheet_id"
,
sheetID
},
{
"range_id_1"
,
"strand_"
+
strandID_1
},
{
"range_id_2"
,
"strand_"
+
strandID_2
},
{
"range_id_1"
,
strandID_1
},
{
"range_id_2"
,
strandID_2
},
{
"sense"
,
parallel
>
0
?
"parallel"
:
"anti-parallel"
}
});
...
...
@@ -748,14 +749,21 @@ void writeLadders(cif::datablock &db, const dssp &dssp)
// Write out the DSSP ladders
struct
ladder_info
{
ladder_info
(
const
std
::
string
&
label
,
bool
parallel
,
const
dssp
::
residue_info
&
a
,
const
dssp
::
residue_info
&
b
)
:
label
(
label
)
ladder_info
(
int
label
,
int
sheet
,
bool
parallel
,
const
dssp
::
residue_info
&
a
,
const
dssp
::
residue_info
&
b
)
:
ladder
(
label
)
,
sheet
(
sheet
)
,
parallel
(
parallel
)
,
pairs
({
{
a
,
b
}
})
{
}
std
::
string
label
;
bool
operator
<
(
const
ladder_info
&
rhs
)
const
{
return
ladder
<
rhs
.
ladder
;
}
int
ladder
;
int
sheet
;
bool
parallel
;
std
::
vector
<
std
::
pair
<
dssp
::
residue_info
,
dssp
::
residue_info
>>
pairs
;
};
...
...
@@ -771,12 +779,10 @@ void writeLadders(cif::datablock &db, const dssp &dssp)
if
(
not
p
)
continue
;
auto
label
=
cif
::
cif_id_for_number
(
ladder
);
bool
is_new
=
true
;
for
(
auto
&
l
:
ladders
)
{
if
(
l
.
la
bel
!=
label
)
if
(
l
.
la
dder
!=
ladder
)
continue
;
assert
(
l
.
parallel
==
parallel
);
...
...
@@ -796,10 +802,12 @@ void writeLadders(cif::datablock &db, const dssp &dssp)
if
(
not
is_new
)
continue
;
ladders
.
emplace_back
(
la
bel
,
parallel
,
res
,
p
);
ladders
.
emplace_back
(
la
dder
,
res
.
sheet
()
-
1
,
parallel
,
res
,
p
);
}
}
std
::
sort
(
ladders
.
begin
(),
ladders
.
end
());
auto
&
dssp_struct_ladder
=
db
[
"dssp_struct_ladder"
];
for
(
const
auto
&
l
:
ladders
)
...
...
@@ -807,7 +815,11 @@ void writeLadders(cif::datablock &db, const dssp &dssp)
const
auto
&
[
beg1
,
beg2
]
=
l
.
pairs
.
front
();
const
auto
&
[
end1
,
end2
]
=
l
.
pairs
.
back
();
dssp_struct_ladder
.
emplace
({
{
"id"
,
l
.
label
},
dssp_struct_ladder
.
emplace
({
{
"id"
,
cif
::
cif_id_for_number
(
l
.
ladder
)
},
{
"sheet_id"
,
cif
::
cif_id_for_number
(
l
.
sheet
)
},
{
"range_1"
,
cif
::
cif_id_for_number
(
beg1
.
strand
()
-
1
)
},
{
"range_2"
,
cif
::
cif_id_for_number
(
beg2
.
strand
()
-
1
)
},
{
"type"
,
l
.
parallel
?
"parallel"
:
"anti-parallel"
},
{
"beg_1_label_comp_id"
,
beg1
.
compound_id
()
},
...
...
@@ -939,7 +951,7 @@ void writeSummary(cif::datablock &db, const dssp &dssp)
// prime the category with the field labels we need, this is to ensure proper order in writing out the data.
for
(
auto
label
:
{
"entry_id"
,
"label_comp_id"
,
"label_asym_id"
,
"label_seq_id"
,
"secondary_structure"
,
"ss_bridge"
,
"helix_3_10"
,
"helix_alpha"
,
"helix_pi"
,
"helix_pp"
,
"bend"
,
"chirality"
,
"
ladder_1"
,
"ladder_2"
,
"sheet
"
,
"accessibility"
,
"TCO"
,
"kappa"
,
"alpha"
,
"phi"
,
"psi"
,
"x_ca"
,
"y_ca"
,
"z_ca"
})
for
(
auto
label
:
{
"entry_id"
,
"label_comp_id"
,
"label_asym_id"
,
"label_seq_id"
,
"secondary_structure"
,
"ss_bridge"
,
"helix_3_10"
,
"helix_alpha"
,
"helix_pi"
,
"helix_pp"
,
"bend"
,
"chirality"
,
"
sheet"
,
"strand"
,
"ladder_1"
,
"ladder_2
"
,
"accessibility"
,
"TCO"
,
"kappa"
,
"alpha"
,
"phi"
,
"psi"
,
"x_ca"
,
"y_ca"
,
"z_ca"
})
dssp_struct_summary
.
add_column
(
label
);
for
(
auto
res
:
dssp
)
...
...
@@ -1026,11 +1038,11 @@ void writeSummary(cif::datablock &db, const dssp &dssp)
{
"bend"
,
bend
},
{
"chirality"
,
chirality
},
{
"sheet"
,
res
.
sheet
()
?
cif
::
cif_id_for_number
(
res
.
sheet
()
-
1
)
:
"."
},
{
"strand"
,
res
.
strand
()
?
cif
::
cif_id_for_number
(
res
.
strand
()
-
1
)
:
"."
},
{
"ladder_1"
,
ladders
[
0
]
},
{
"ladder_2"
,
ladders
[
1
]
},
{
"sheet"
,
res
.
sheet
()
?
cif
::
cif_id_for_number
(
res
.
sheet
()
-
1
)
:
"."
},
{
"x_ca"
,
cax
,
1
},
{
"y_ca"
,
cay
,
1
},
{
"z_ca"
,
caz
,
1
},
...
...
src/dssp.cpp
View file @
0cedf7b1
...
...
@@ -1104,85 +1104,105 @@ void CalculateBetaSheets(std::vector<residue> &inResidues, statistics &stats, st
}
}
// Construct the 'strands'
// For mmCIF output, this is needed and since we now have the information available
// it is best to do the calculation here.
// strands are ranges of residues of length > 1 that form beta bridges in a sheet.
// Second attempt to create 'strands'. A strand is a range of residues
// without a gap in between in the same chain that belong to the same sheet.
int
strand
=
0
;
for
(
uint32_t
iSheet
=
1
;
iSheet
<
sheet
;
++
iSheet
)
{
std
::
vector
<
std
::
tuple
<
uint32_t
,
uint32_t
>>
strands
;
for
(
auto
&
bridge
:
bridg
es
)
int
lastNr
=
-
1
;
for
(
auto
&
res
:
inResidu
es
)
{
if
(
bridge
.
s
heet
!=
iSheet
)
if
(
res
.
mS
heet
!=
iSheet
)
continue
;
for
(
auto
&
range
:
{
bridge
.
i
,
bridge
.
j
})
{
auto
imin
=
range
.
front
();
auto
imax
=
range
.
back
();
if
(
imin
==
imax
)
continue
;
if
(
imin
>
imax
)
std
::
swap
(
imin
,
imax
);
auto
ii
=
find_if
(
strands
.
begin
(),
strands
.
end
(),
[
a
=
imin
,
b
=
imax
]
(
std
::
tuple
<
uint32_t
,
uint32_t
>
&
t
)
{
auto
&&
[
start
,
end
]
=
t
;
bool
result
=
false
;
if
(
start
<=
b
and
end
>=
a
)
{
result
=
true
;
if
(
start
>
a
)
start
=
a
;
if
(
end
<
b
)
end
=
b
;
}
return
result
;
});
if
(
ii
==
strands
.
end
())
strands
.
emplace_back
(
imin
,
imax
);
}
}
std
::
sort
(
strands
.
begin
(),
strands
.
end
());
// collapse ranges that overlap
if
(
strands
.
size
()
>
1
)
{
auto
si
=
strands
.
begin
();
while
(
std
::
next
(
si
)
!=
strands
.
end
())
{
auto
&&
[
afirst
,
alast
]
=
*
si
;
auto
&&
[
bfirst
,
blast
]
=
*
(
std
::
next
(
si
));
if
(
alast
>=
bfirst
)
{
bfirst
=
afirst
;
si
=
strands
.
erase
(
si
);
continue
;
}
++
si
;
}
}
for
(
size_t
i
=
0
;
i
<
strands
.
size
();
++
i
)
{
const
auto
&
[
first
,
last
]
=
strands
[
i
];
for
(
auto
nr
=
first
;
nr
<=
last
;
++
nr
)
{
assert
(
inResidues
[
nr
].
mStrand
==
0
);
inResidues
[
nr
].
SetStrand
(
i
+
1
);
}
if
(
lastNr
+
1
<
res
.
mNumber
)
++
strand
;
res
.
mStrand
=
strand
;
lastNr
=
res
.
mNumber
;
}
}
// // Construct the 'strands'
// // For mmCIF output, this is needed and since we now have the information available
// // it is best to do the calculation here.
// // strands are ranges of residues of length > 1 that form beta bridges in a sheet.
// for (uint32_t iSheet = 1; iSheet < sheet; ++iSheet)
// {
// std::vector<std::tuple<uint32_t,uint32_t>> strands;
// for (auto &bridge : bridges)
// {
// if (bridge.sheet != iSheet)
// continue;
// for (auto &range : { bridge.i, bridge.j})
// {
// auto imin = range.front();
// auto imax = range.back();
// // if (imin == imax)
// // continue;
// if (imin > imax)
// std::swap(imin, imax);
// auto ii = find_if(strands.begin(), strands.end(), [a = imin, b = imax] (std::tuple<uint32_t,uint32_t> &t)
// {
// auto &&[start, end] = t;
// bool result = false;
// if (start <= b and end >= a)
// {
// result = true;
// if (start > a)
// start = a;
// if (end < b)
// end = b;
// }
// return result;
// });
// if (ii == strands.end())
// strands.emplace_back(imin, imax);
// }
// }
// std::sort(strands.begin(), strands.end());
// // collapse ranges that overlap
// if (strands.size() > 1)
// {
// auto si = strands.begin();
// while (std::next(si) != strands.end())
// {
// auto &&[afirst, alast] = *si;
// auto &&[bfirst, blast] = *(std::next(si));
// if (alast >= bfirst)
// {
// bfirst = afirst;
// si = strands.erase(si);
// continue;
// }
// ++si;
// }
// }
// for (size_t i = 0; i < strands.size(); ++i)
// {
// const auto &[first, last] = strands[i];
// for (auto nr = first; nr <= last; ++nr)
// {
// assert(inResidues[nr].mStrand == 0);
// inResidues[nr].SetStrand(i + 1);
// }
// }
// }
}
// --------------------------------------------------------------------
...
...
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