Commit 7f820449 by Maarten L. Hekkelman

formatting

parent ecb2cf5f
/*- /*-
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
* *
* Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute * Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this * 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer * list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * 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 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
...@@ -29,150 +29,151 @@ ...@@ -29,150 +29,151 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <string>
#include <stdexcept> #include <stdexcept>
#include <string>
namespace mmcif namespace mmcif
{ {
enum AtomType : uint8_t enum AtomType : uint8_t
{ {
Nn = 0, // Unknown Nn = 0, // Unknown
H = 1, // Hydro­gen H = 1, // Hydro­gen
He = 2, // He­lium He = 2, // He­lium
Li = 3, // Lith­ium Li = 3, // Lith­ium
Be = 4, // Beryl­lium Be = 4, // Beryl­lium
B = 5, // Boron B = 5, // Boron
C = 6, // Carbon C = 6, // Carbon
N = 7, // Nitro­gen N = 7, // Nitro­gen
O = 8, // Oxy­gen O = 8, // Oxy­gen
F = 9, // Fluor­ine F = 9, // Fluor­ine
Ne = 10, // Neon Ne = 10, // Neon
Na = 11, // So­dium Na = 11, // So­dium
Mg = 12, // Magne­sium Mg = 12, // Magne­sium
Al = 13, // Alumin­ium Al = 13, // Alumin­ium
Si = 14, // Sili­con Si = 14, // Sili­con
P = 15, // Phos­phorus P = 15, // Phos­phorus
S = 16, // Sulfur S = 16, // Sulfur
Cl = 17, // Chlor­ine Cl = 17, // Chlor­ine
Ar = 18, // Argon Ar = 18, // Argon
K = 19, // Potas­sium K = 19, // Potas­sium
Ca = 20, // Cal­cium Ca = 20, // Cal­cium
Sc = 21, // Scan­dium Sc = 21, // Scan­dium
Ti = 22, // Tita­nium Ti = 22, // Tita­nium
V = 23, // Vana­dium V = 23, // Vana­dium
Cr = 24, // Chrom­ium Cr = 24, // Chrom­ium
Mn = 25, // Manga­nese Mn = 25, // Manga­nese
Fe = 26, // Iron Fe = 26, // Iron
Co = 27, // Cobalt Co = 27, // Cobalt
Ni = 28, // Nickel Ni = 28, // Nickel
Cu = 29, // Copper Cu = 29, // Copper
Zn = 30, // Zinc Zn = 30, // Zinc
Ga = 31, // Gallium Ga = 31, // Gallium
Ge = 32, // Germa­nium Ge = 32, // Germa­nium
As = 33, // Arsenic As = 33, // Arsenic
Se = 34, // Sele­nium Se = 34, // Sele­nium
Br = 35, // Bromine Br = 35, // Bromine
Kr = 36, // Kryp­ton Kr = 36, // Kryp­ton
Rb = 37, // Rubid­ium Rb = 37, // Rubid­ium
Sr = 38, // Stront­ium Sr = 38, // Stront­ium
Y = 39, // Yttrium Y = 39, // Yttrium
Zr = 40, // Zirco­nium Zr = 40, // Zirco­nium
Nb = 41, // Nio­bium Nb = 41, // Nio­bium
Mo = 42, // Molyb­denum Mo = 42, // Molyb­denum
Tc = 43, // Tech­netium Tc = 43, // Tech­netium
Ru = 44, // Ruthe­nium Ru = 44, // Ruthe­nium
Rh = 45, // Rho­dium Rh = 45, // Rho­dium
Pd = 46, // Pallad­ium Pd = 46, // Pallad­ium
Ag = 47, // Silver Ag = 47, // Silver
Cd = 48, // Cad­mium Cd = 48, // Cad­mium
In = 49, // Indium In = 49, // Indium
Sn = 50, // Tin Sn = 50, // Tin
Sb = 51, // Anti­mony Sb = 51, // Anti­mony
Te = 52, // Tellurium Te = 52, // Tellurium
I = 53, // Iodine I = 53, // Iodine
Xe = 54, // Xenon Xe = 54, // Xenon
Cs = 55, // Cae­sium Cs = 55, // Cae­sium
Ba = 56, // Ba­rium Ba = 56, // Ba­rium
La = 57, // Lan­thanum La = 57, // Lan­thanum
Hf = 72, // Haf­nium Hf = 72, // Haf­nium
Ta = 73, // Tanta­lum Ta = 73, // Tanta­lum
W = 74, // Tung­sten W = 74, // Tung­sten
Re = 75, // Rhe­nium Re = 75, // Rhe­nium
Os = 76, // Os­mium Os = 76, // Os­mium
Ir = 77, // Iridium Ir = 77, // Iridium
Pt = 78, // Plat­inum Pt = 78, // Plat­inum
Au = 79, // Gold Au = 79, // Gold
Hg = 80, // Mer­cury Hg = 80, // Mer­cury
Tl = 81, // Thallium Tl = 81, // Thallium
Pb = 82, // Lead Pb = 82, // Lead
Bi = 83, // Bis­muth Bi = 83, // Bis­muth
Po = 84, // Polo­nium Po = 84, // Polo­nium
At = 85, // Asta­tine At = 85, // Asta­tine
Rn = 86, // Radon Rn = 86, // Radon
Fr = 87, // Fran­cium Fr = 87, // Fran­cium
Ra = 88, // Ra­dium Ra = 88, // Ra­dium
Ac = 89, // Actin­ium Ac = 89, // Actin­ium
Rf = 104, // Ruther­fordium Rf = 104, // Ruther­fordium
Db = 105, // Dub­nium Db = 105, // Dub­nium
Sg = 106, // Sea­borgium Sg = 106, // Sea­borgium
Bh = 107, // Bohr­ium Bh = 107, // Bohr­ium
Hs = 108, // Has­sium Hs = 108, // Has­sium
Mt = 109, // Meit­nerium Mt = 109, // Meit­nerium
Ds = 110, // Darm­stadtium Ds = 110, // Darm­stadtium
Rg = 111, // Roent­genium Rg = 111, // Roent­genium
Cn = 112, // Coper­nicium Cn = 112, // Coper­nicium
Nh = 113, // Nihon­ium Nh = 113, // Nihon­ium
Fl = 114, // Flerov­ium Fl = 114, // Flerov­ium
Mc = 115, // Moscov­ium Mc = 115, // Moscov­ium
Lv = 116, // Liver­morium Lv = 116, // Liver­morium
Ts = 117, // Tenness­ine Ts = 117, // Tenness­ine
Og = 118, // Oga­nesson Og = 118, // Oga­nesson
Ce = 58, // Cerium Ce = 58, // Cerium
Pr = 59, // Praseo­dymium Pr = 59, // Praseo­dymium
Nd = 60, // Neo­dymium Nd = 60, // Neo­dymium
Pm = 61, // Prome­thium Pm = 61, // Prome­thium
Sm = 62, // Sama­rium Sm = 62, // Sama­rium
Eu = 63, // Europ­ium Eu = 63, // Europ­ium
Gd = 64, // Gadolin­ium Gd = 64, // Gadolin­ium
Tb = 65, // Ter­bium Tb = 65, // Ter­bium
Dy = 66, // Dyspro­sium Dy = 66, // Dyspro­sium
Ho = 67, // Hol­mium Ho = 67, // Hol­mium
Er = 68, // Erbium Er = 68, // Erbium
Tm = 69, // Thulium Tm = 69, // Thulium
Yb = 70, // Ytter­bium Yb = 70, // Ytter­bium
Lu = 71, // Lute­tium Lu = 71, // Lute­tium
Th = 90, // Thor­ium Th = 90, // Thor­ium
Pa = 91, // Protac­tinium Pa = 91, // Protac­tinium
U = 92, // Ura­nium U = 92, // Ura­nium
Np = 93, // Neptu­nium Np = 93, // Neptu­nium
Pu = 94, // Pluto­nium Pu = 94, // Pluto­nium
Am = 95, // Ameri­cium Am = 95, // Ameri­cium
Cm = 96, // Curium Cm = 96, // Curium
Bk = 97, // Berkel­ium Bk = 97, // Berkel­ium
Cf = 98, // Califor­nium Cf = 98, // Califor­nium
Es = 99, // Einstei­nium Es = 99, // Einstei­nium
Fm = 100, // Fer­mium Fm = 100, // Fer­mium
Md = 101, // Mende­levium Md = 101, // Mende­levium
No = 102, // Nobel­ium No = 102, // Nobel­ium
Lr = 103, // Lawren­cium Lr = 103, // Lawren­cium
D = 129, // Deuterium D = 129, // Deuterium
}; };
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// AtomTypeInfo // AtomTypeInfo
enum RadiusType { enum RadiusType
{
eRadiusCalculated, eRadiusCalculated,
eRadiusEmpirical, eRadiusEmpirical,
eRadiusCovalentEmpirical, eRadiusCovalentEmpirical,
...@@ -188,12 +189,12 @@ enum RadiusType { ...@@ -188,12 +189,12 @@ enum RadiusType {
struct AtomTypeInfo struct AtomTypeInfo
{ {
AtomType type; AtomType type;
std::string name; std::string name;
std::string symbol; std::string symbol;
float weight; float weight;
bool metal; bool metal;
float radii[eRadiusTypeCount]; float radii[eRadiusTypeCount];
}; };
extern const AtomTypeInfo kKnownAtoms[]; extern const AtomTypeInfo kKnownAtoms[];
...@@ -205,25 +206,25 @@ class AtomTypeTraits ...@@ -205,25 +206,25 @@ class AtomTypeTraits
{ {
public: public:
AtomTypeTraits(AtomType a); AtomTypeTraits(AtomType a);
AtomTypeTraits(const std::string& symbol); AtomTypeTraits(const std::string &symbol);
AtomType type() const { return mInfo->type; } AtomType type() const { return mInfo->type; }
std::string name() const { return mInfo->name; } std::string name() const { return mInfo->name; }
std::string symbol() const { return mInfo->symbol; } std::string symbol() const { return mInfo->symbol; }
float weight() const { return mInfo->weight; } float weight() const { return mInfo->weight; }
bool isMetal() const { return mInfo->metal; } bool isMetal() const { return mInfo->metal; }
static bool isElement(const std::string& symbol); static bool isElement(const std::string &symbol);
static bool isMetal(const std::string& symbol); static bool isMetal(const std::string &symbol);
float radius(RadiusType type = eRadiusSingleBond) const float radius(RadiusType type = eRadiusSingleBond) const
{ {
if (type >= eRadiusTypeCount) if (type >= eRadiusTypeCount)
throw std::invalid_argument("invalid radius requested"); throw std::invalid_argument("invalid radius requested");
return mInfo->radii[type] / 100.f; return mInfo->radii[type] / 100.f;
} }
// data type encapsulating the Waasmaier & Kirfel scattering factors // data type encapsulating the Waasmaier & Kirfel scattering factors
// in a simplified form (only a and b). // in a simplified form (only a and b).
// Added the electrion scattering factors as well // Added the electrion scattering factors as well
...@@ -231,15 +232,18 @@ class AtomTypeTraits ...@@ -231,15 +232,18 @@ class AtomTypeTraits
{ {
double a[6], b[6]; double a[6], b[6];
}; };
// to get the Cval and Siva values, use this constant as charge: // to get the Cval and Siva values, use this constant as charge:
enum { kWKSFVal = -99 }; enum
{
const SFData& wksf(int charge = 0) const; kWKSFVal = -99
const SFData& elsf() const; };
const SFData &wksf(int charge = 0) const;
const SFData &elsf() const;
private: private:
const struct AtomTypeInfo* mInfo; const struct AtomTypeInfo *mInfo;
}; };
} } // namespace mmcif
/*- /*-
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
* *
* Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute * Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this * 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer * list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * 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 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
#pragma once #pragma once
#include <unordered_map>
#include <filesystem> #include <filesystem>
#include <stdexcept> #include <stdexcept>
#include <unordered_map>
#include "cif++/Structure.hpp" #include "cif++/Structure.hpp"
...@@ -38,39 +38,40 @@ namespace mmcif ...@@ -38,39 +38,40 @@ namespace mmcif
class BondMapException : public std::runtime_error class BondMapException : public std::runtime_error
{ {
public: public:
BondMapException(const std::string& msg) BondMapException(const std::string &msg)
: runtime_error(msg) {} : runtime_error(msg)
{
}
}; };
class BondMap class BondMap
{ {
public: public:
BondMap(const Structure& p); BondMap(const Structure &p);
BondMap(const BondMap&) = delete; BondMap(const BondMap &) = delete;
BondMap& operator=(const BondMap&) = delete; BondMap &operator=(const BondMap &) = delete;
bool operator()(const Atom& a, const Atom& b) const bool operator()(const Atom &a, const Atom &b) const
{ {
return isBonded(index.at(a.id()), index.at(b.id())); return isBonded(index.at(a.id()), index.at(b.id()));
} }
bool is1_4(const Atom& a, const Atom& b) const bool is1_4(const Atom &a, const Atom &b) const
{ {
uint32_t ixa = index.at(a.id()); uint32_t ixa = index.at(a.id());
uint32_t ixb = index.at(b.id()); uint32_t ixb = index.at(b.id());
return bond_1_4.count(key(ixa, ixb)); return bond_1_4.count(key(ixa, ixb));
} }
// links coming from the struct_conn records: // links coming from the struct_conn records:
std::vector<std::string> linked(const Atom& a) const; std::vector<std::string> linked(const Atom &a) const;
// This list of atomID's is comming from either CCD or the CCP4 dictionaries loaded // This list of atomID's is comming from either CCD or the CCP4 dictionaries loaded
static std::vector<std::string> atomIDsForCompound(const std::string& compoundID); static std::vector<std::string> atomIDsForCompound(const std::string &compoundID);
private:
private:
bool isBonded(uint32_t ai, uint32_t bi) const bool isBonded(uint32_t ai, uint32_t bi) const
{ {
return bond.count(key(ai, bi)) != 0; return bond.count(key(ai, bi)) != 0;
...@@ -82,20 +83,19 @@ class BondMap ...@@ -82,20 +83,19 @@ class BondMap
std::swap(a, b); std::swap(a, b);
return static_cast<uint64_t>(a) | (static_cast<uint64_t>(b) << 32); return static_cast<uint64_t>(a) | (static_cast<uint64_t>(b) << 32);
} }
std::tuple<uint32_t,uint32_t> dekey(uint64_t k) const std::tuple<uint32_t, uint32_t> dekey(uint64_t k) const
{ {
return std::make_tuple( return std::make_tuple(
static_cast<uint32_t>(k >> 32), static_cast<uint32_t>(k >> 32),
static_cast<uint32_t>(k) static_cast<uint32_t>(k));
);
} }
uint32_t dim; uint32_t dim;
std::unordered_map<std::string,uint32_t> index; std::unordered_map<std::string, uint32_t> index;
std::set<uint64_t> bond, bond_1_4; std::set<uint64_t> bond, bond_1_4;
std::map<std::string,std::set<std::string>> link; std::map<std::string, std::set<std::string>> link;
}; };
} } // namespace mmcif
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