Commit 7d2a7c14 by Maarten L. Hekkelman

Update for changes in libcifpp v5

parent 701ff3d3
...@@ -121,62 +121,59 @@ float cosinus_angle(const point &p1, const point &p2, const point &p3, const poi ...@@ -121,62 +121,59 @@ float cosinus_angle(const point &p1, const point &p2, const point &p3, const poi
return result; return result;
} }
enum residue_type enum residue_type : char
{ {
kUnknownResidue, kUnknownResidue = 'X',
// //
kAlanine, // A ala kAlanine = 'A', // ala
kArginine, // R arg kArginine = 'R', // arg
kAsparagine, // N asn kAsparagine = 'N', // asn
kAsparticAcid, // D asp kAsparticAcid = 'D', // asp
kCysteine, // C cys kCysteine = 'C', // cys
kGlutamicAcid, // E glu kGlutamicAcid = 'E', // glu
kGlutamine, // Q gln kGlutamine = 'Q', // gln
kGlycine, // G gly kGlycine = 'G', // gly
kHistidine, // H his kHistidine = 'H', // his
kIsoleucine, // I ile kIsoleucine = 'I', // ile
kLeucine, // L leu kLeucine = 'L', // leu
kLysine, // K lys kLysine = 'K', // lys
kMethionine, // M met kMethionine = 'M', // met
kPhenylalanine, // F phe kPhenylalanine = 'F', // phe
kProline, // P pro kProline = 'P', // pro
kSerine, // S ser kSerine = 'S', // ser
kThreonine, // T thr kThreonine = 'T', // thr
kTryptophan, // W trp kTryptophan = 'W', // trp
kTyrosine, // Y tyr kTyrosine = 'Y', // tyr
kValine, // V val kValine = 'V', // val
kResidueTypeCount
}; };
struct struct
{ {
residue_type type; residue_type type;
char code;
char name[4]; char name[4];
} const kResidueInfo[] = { } const kResidueInfo[] = {
{ kUnknownResidue, 'X', "UNK" }, { kUnknownResidue, "UNK" },
{ kAlanine, 'A', "ALA" }, { kAlanine, "ALA" },
{ kArginine, 'R', "ARG" }, { kArginine, "ARG" },
{ kAsparagine, 'N', "ASN" }, { kAsparagine, "ASN" },
{ kAsparticAcid, 'D', "ASP" }, { kAsparticAcid, "ASP" },
{ kCysteine, 'C', "CYS" }, { kCysteine, "CYS" },
{ kGlutamicAcid, 'E', "GLU" }, { kGlutamicAcid, "GLU" },
{ kGlutamine, 'Q', "GLN" }, { kGlutamine, "GLN" },
{ kGlycine, 'G', "GLY" }, { kGlycine, "GLY" },
{ kHistidine, 'H', "HIS" }, { kHistidine, "HIS" },
{ kIsoleucine, 'I', "ILE" }, { kIsoleucine, "ILE" },
{ kLeucine, 'L', "LEU" }, { kLeucine, "LEU" },
{ kLysine, 'K', "LYS" }, { kLysine, "LYS" },
{ kMethionine, 'M', "MET" }, { kMethionine, "MET" },
{ kPhenylalanine, 'F', "PHE" }, { kPhenylalanine, "PHE" },
{ kProline, 'P', "PRO" }, { kProline, "PRO" },
{ kSerine, 'S', "SER" }, { kSerine, "SER" },
{ kThreonine, 'T', "THR" }, { kThreonine, "THR" },
{ kTryptophan, 'W', "TRP" }, { kTryptophan, "TRP" },
{ kTyrosine, 'Y', "TYR" }, { kTyrosine, "TYR" },
{ kValine, 'V', "VAL" } { kValine, "VAL" }
}; };
residue_type MapResidue(std::string_view inName) residue_type MapResidue(std::string_view inName)
...@@ -320,7 +317,7 @@ struct residue ...@@ -320,7 +317,7 @@ struct residue
} }
else if (type != "H") else if (type != "H")
{ {
mSideChain.emplace_back(point { x, y, z }); mSideChain.emplace_back(point{ x, y, z });
ExtendBox(mSideChain.back(), kRadiusSideAtom + 2 * kRadiusWater); ExtendBox(mSideChain.back(), kRadiusSideAtom + 2 * kRadiusWater);
} }
} }
...@@ -565,7 +562,7 @@ MSurfaceDots::MSurfaceDots(int32_t N) ...@@ -565,7 +562,7 @@ MSurfaceDots::MSurfaceDots(int32_t N)
float lat = std::asin((2.0f * i) / P); float lat = std::asin((2.0f * i) / P);
float lon = static_cast<float>(std::fmod(i, kGoldenRatio) * 2 * kPI / kGoldenRatio); float lon = static_cast<float>(std::fmod(i, kGoldenRatio) * 2 * kPI / kGoldenRatio);
mPoints.emplace_back(point { std::sin(lon) * std::cos(lat), std::cos(lon) * std::cos(lat), std::sin(lat) }); mPoints.emplace_back(point{ std::sin(lon) * std::cos(lat), std::cos(lon) * std::cos(lat), std::sin(lat) });
} }
} }
...@@ -1784,6 +1781,11 @@ std::string DSSP::residue_info::compound_id() const ...@@ -1784,6 +1781,11 @@ std::string DSSP::residue_info::compound_id() const
return m_impl->mCompoundID; return m_impl->mCompoundID;
} }
char DSSP::residue_info::compound_letter() const
{
return MapResidue(compound_id());
}
int DSSP::residue_info::seq_id() const int DSSP::residue_info::seq_id() const
{ {
return m_impl->mSeqID; return m_impl->mSeqID;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#pragma once #pragma once
#include <cif++/cif.hpp> #include <cif++.hpp>
namespace dssp namespace dssp
{ {
...@@ -126,6 +126,7 @@ class DSSP ...@@ -126,6 +126,7 @@ class DSSP
int seq_id() const; int seq_id() const;
std::string alt_id() const; std::string alt_id() const;
std::string compound_id() const; std::string compound_id() const;
char compound_letter() const; // Single letter for residue compound type, or 'X' in case it is not known
std::string auth_asym_id() const; std::string auth_asym_id() const;
int auth_seq_id() const; int auth_seq_id() const;
...@@ -241,7 +242,7 @@ class DSSP ...@@ -241,7 +242,7 @@ class DSSP
enum class pdb_record_type { HEADER, COMPND, SOURCE, AUTHOR }; enum class pdb_record_type { HEADER, COMPND, SOURCE, AUTHOR };
std::string get_pdb_header_line(pdb_record_type pdb_record) const; std::string get_pdb_header_line(pdb_record_type pdb_record) const;
private: private:
struct DSSP_impl *m_impl; struct DSSP_impl *m_impl;
}; };
......
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
#include <boost/date_time/gregorian/formatters.hpp> #include <boost/date_time/gregorian/formatters.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <cif++/structure/Compound.hpp> // #include <cif++/structure/Compound.hpp>
#include <cif++/utilities.hpp> #include <cif++.hpp>
#include "dssp_wrapper.hpp" #include "dssp_wrapper.hpp"
#include "revision.hpp" #include "revision.hpp"
...@@ -60,9 +60,7 @@ std::string ResidueToDSSPLine(const dssp::DSSP::residue_info &info) ...@@ -60,9 +60,7 @@ std::string ResidueToDSSPLine(const dssp::DSSP::residue_info &info)
if (residue.asym_id().length() > 1) if (residue.asym_id().length() > 1)
throw std::runtime_error("This file contains data that won't fit in the original DSSP format"); throw std::runtime_error("This file contains data that won't fit in the original DSSP format");
char code = 'X'; char code = residue.compound_letter();
if (mmcif::kAAMap.find(residue.compound_id()) != mmcif::kAAMap.end())
code = mmcif::kAAMap.at(residue.compound_id());
if (code == 'C') // a cysteine if (code == 'C') // a cysteine
{ {
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#pragma once #pragma once
#include <cif++/dssp/DSSP.hpp> #include "DSSP.hpp"
void writeDSSP(const dssp::DSSP& dssp, std::ostream& os); void writeDSSP(const dssp::DSSP& dssp, std::ostream& os);
void annotateDSSP(cif::datablock &db, const dssp::DSSP& dssp, bool writeOther, std::ostream& os); void annotateDSSP(cif::datablock &db, const dssp::DSSP& dssp, bool writeOther, std::ostream& os);
......
1 A _
2 A _
3 A _
4 A _
5 A E
6 A E
7 A E
8 A E
9 A E
10 A E
11 A E
12 A E
13 A E
14 A S
15 A H
16 A H
17 A H
18 A H
19 A H
20 A H
21 A H
22 A T
23 A T
24 A _
25 A _
26 A H
27 A H
28 A H
29 A H
30 A H
31 A H
32 A H
33 A H
34 A H
35 A H
36 A H
37 A T
38 A S
39 A _
40 A E
41 A E
42 A E
43 A E
44 A E
45 A E
46 A E
47 A T
48 A T
49 A E
50 A E
51 A E
52 A E
53 A E
54 A E
55 A E
56 A _
57 A S
58 A S
59 A _
60 A E
61 A E
62 A E
63 A E
64 A E
65 A E
66 A E
67 A T
68 A T
69 A S
70 A _
71 A E
72 A E
73 A E
74 A E
75 A _
76 A T
77 A T
78 A S
79 A _
80 A E
81 A E
82 A E
83 A E
84 A E
85 A E
86 A E
87 A E
88 A E
89 A E
90 A T
91 A T
92 A E
93 A E
94 A E
95 A E
96 A E
97 A E
98 A E
99 A E
100 A S
101 A S
102 A S
103 A _
104 A _
105 A _
106 A _
107 A E
108 A E
109 A E
110 A E
111 A E
112 A E
113 A E
114 A _
115 A T
116 A T
117 A S
118 A _
119 A E
120 A E
121 A E
122 A E
123 A E
124 A E
125 A E
126 A T
127 A T
128 A E
129 A E
130 A E
131 A E
132 A E
133 A E
134 A E
135 A E
136 A E
137 A _
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 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.
*/
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include <boost/test/included/unit_test.hpp>
#include <charconv>
#include <stdexcept>
#include <cif++/cif.hpp>
#include <cif++/dssp/DSSP.hpp>
namespace tt = boost::test_tools;
std::filesystem::path gTestDir = std::filesystem::current_path(); // filled in first test
// --------------------------------------------------------------------
cif::file operator""_cf(const char *text, size_t length)
{
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
{
this->setg(text, text, text + length);
}
} buffer(const_cast<char *>(text), length);
std::istream is(&buffer);
return cif::file(is);
}
// --------------------------------------------------------------------
bool init_unit_test()
{
cif::VERBOSE = 1;
// not a test, just initialize test dir
if (boost::unit_test::framework::master_test_suite().argc == 2)
gTestDir = boost::unit_test::framework::master_test_suite().argv[1];
// do this now, avoids the need for installing
cif::add_file_resource("mmcif_pdbx.dic", gTestDir / ".." / "rsrc" / "mmcif_pdbx.dic");
// initialize CCD location
cif::add_file_resource("components.cif", gTestDir / ".." / "data" / "ccd-subset.cif");
return true;
}
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(dssp_1)
{
cif::file f(gTestDir / "1cbs.cif");
BOOST_ASSERT(f.is_valid());
std::ifstream t(gTestDir / "1cbs-dssp-test.tsv");
dssp::DSSP dssp(f.front(), 1, 3, true);
for (auto residue : dssp)
{
std::string line;
getline(t, line);
std::cout << line << std::endl;
auto f = cif::split(line, "\t");
BOOST_CHECK_EQUAL(f.size(), 3);
if (f.size() != 3)
continue;
int seqID;
std::from_chars(f[0].begin(), f[0].end(), seqID);
std::string asymID{ f[1] };
std::string secstr{ f[2] };
if (secstr == "_")
secstr = " ";
BOOST_CHECK_EQUAL(residue.asym_id(), asymID);
BOOST_CHECK_EQUAL(residue.seq_id(), seqID);
BOOST_CHECK_EQUAL((char)residue.type(), secstr.front());
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment