<commit_before>#ifndef MJOLNIR_FORCEFIELD_PWMCOS_PWMCOS_POTENTIAL_HPP
#define MJOLNIR_FORCEFIELD_PWMCOS_PWMCOS_POTENTIAL_HPP
#include <mjolnir/math/math.hpp>
#include <mjolnir/util/logger.hpp>
#include <mjolnir/core/Unit.hpp>
#include <mjolnir/core/System.hpp>
#include <mjolnir/core/ExclusionList.hpp>
#include <cstdint>

namespace mjolnir
{

// Protein-DNA PWM-based interaction that represents sequence specificity of a
// protein.
// This is an implementation of the potential developed in the following paper.
// - C.Tan, and S.Takada (2018) JCTC
//
// ```toml
// [[forcefields.global]]
// interaction = "PWMcos"
// potential   = "PWMcos"
// spatial_partition.type   = "CellList"
// spatial_partition.margin = 1.0
// sigma        = 1.0     # distance sensitivity
// phi          = 0.17453 # angle sensitivity
// energy_unit  = 0.593   # overall energy coefficient (normally kBT)
// energy_shift = 0.0     # overall energy shift
// cutoff       = 5.0     # 5sigma
// parameters  = [
// {index =    0, kind = "DNA", S = 1,         B5 = 3, base = "A"},
// {index =    3, kind = "DNA", S = 4, B3 = 0, B5 = 6, base = "T"},
// # ...
// {index = 1000, kind = "Protein", CaN =  999, CaC = 1001, gamma = 1.2, epsilon = -0.4, r0 = 5.0, theta1_0 = 1.57, theta2_0 = 1.57, theta3_0 = 3.14, A = 0.5, C = 0.1, G = 0.4, T = 0.2},
// {index = 1023, kind = "Protein", CaN = 1022, CaC = 1024, gamma = 1.2, epsilon = -0.4, r0 = 6.0, theta1_0 = 1.57, theta2_0 = 1.57, theta3_0 = 3.14, A = 0.2, C = 0.4, G = 0.1, T = 0.4},
// # ...
// ]
// ```

namespace parameter_PWMcos
{
enum class base_kind : std::uint8_t
{
    A = 0,
    C = 1,
    G = 2,
    T = 3,
    X = 255,
};
template<typename charT, typename traits>
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const base_kind bk)
{
    switch(bk)
    {
        case base_kind::A: {os << 'A'; return os;}
        case base_kind::C: {os << 'C'; return os;}
        case base_kind::G: {os << 'G'; return os;}
        case base_kind::T: {os << 'T'; return os;}
        case base_kind::X: {os << 'X'; return os;}
        default: {os << "invalid PWMcos base kind"; return os;}
    }
    return os;
}
} // parameter_PWMcos

template<typename traitsT>
class PWMcosPotential
{
  public:
    using traits_type = traitsT;
    using real_type   = typename traits_type::real_type;
    using self_type   = PWMcosPotential<traits_type>;
    using base_kind   = parameter_PWMcos::base_kind;

    struct contact_parameter_type
    {
        std::uint32_t Ca, CaN, CaC;
        real_type gamma, epsilon, r0, theta1_0, theta2_0, theta3_0;
        real_type r_cut_sq;
        std::array<real_type, 4> PWM;
    };
    struct dna_parameter_type
    {
        base_kind     base;
        std::uint32_t B, S, B5, B3;

        dna_parameter_type() : base(base_kind::X),
            B(invalid()), S(invalid()), B5(invalid()), B3(invalid())
        {}
        ~dna_parameter_type() = default;
        dna_parameter_type(const dna_parameter_type&) = default;
        dna_parameter_type(dna_parameter_type&&)      = default;
        dna_parameter_type& operator=(const dna_parameter_type&) = default;
        dna_parameter_type& operator=(dna_parameter_type&&)      = default;
    };
    struct parameter_type
    {
        std::uint32_t dna_index;
    };
    struct pair_parameter_type
    {
        base_kind     base;
        std::uint32_t S, B5, B3;

        pair_parameter_type(): base(base_kind::X),
            S(invalid()), B5(invalid()), B3(invalid())
        {}
        ~pair_parameter_type() = default;
        pair_parameter_type(const base_kind     b,  const std::uint32_t s,
                            const std::uint32_t b5, const std::uint32_t b3)
            noexcept : base(b), S(s), B5(b5), B3(b3)
        {}
        pair_parameter_type(const pair_parameter_type&) = default;
        pair_parameter_type(pair_parameter_type&&)      = default;
        pair_parameter_type& operator=(const pair_parameter_type&) = default;
        pair_parameter_type& operator=(pair_parameter_type&&)      = default;
    };
    using container_type = std::vector<parameter_type>;
<commit_msg>feat: add constructor to PWM::dna_parameter_type<commit_after>#ifndef MJOLNIR_FORCEFIELD_PWMCOS_PWMCOS_POTENTIAL_HPP
#define MJOLNIR_FORCEFIELD_PWMCOS_PWMCOS_POTENTIAL_HPP
#include <mjolnir/math/math.hpp>
#include <mjolnir/util/logger.hpp>
#include <mjolnir/core/Unit.hpp>
#include <mjolnir/core/System.hpp>
#include <mjolnir/core/ExclusionList.hpp>
#include <cstdint>

namespace mjolnir
{

// Protein-DNA PWM-based interaction that represents sequence specificity of a
// protein.
// This is an implementation of the potential developed in the following paper.
// - C.Tan, and S.Takada (2018) JCTC
//
// ```toml
// [[forcefields.global]]
// interaction = "PWMcos"
// potential   = "PWMcos"
// spatial_partition.type   = "CellList"
// spatial_partition.margin = 1.0
// sigma        = 1.0     # distance sensitivity
// phi          = 0.17453 # angle sensitivity
// energy_unit  = 0.593   # overall energy coefficient (normally kBT)
// energy_shift = 0.0     # overall energy shift
// cutoff       = 5.0     # 5sigma
// parameters  = [
// {index =    0, kind = "DNA", S = 1,         B5 = 3, base = "A"},
// {index =    3, kind = "DNA", S = 4, B3 = 0, B5 = 6, base = "T"},
// # ...
// {index = 1000, kind = "Protein", CaN =  999, CaC = 1001, gamma = 1.2, epsilon = -0.4, r0 = 5.0, theta1_0 = 1.57, theta2_0 = 1.57, theta3_0 = 3.14, A = 0.5, C = 0.1, G = 0.4, T = 0.2},
// {index = 1023, kind = "Protein", CaN = 1022, CaC = 1024, gamma = 1.2, epsilon = -0.4, r0 = 6.0, theta1_0 = 1.57, theta2_0 = 1.57, theta3_0 = 3.14, A = 0.2, C = 0.4, G = 0.1, T = 0.4},
// # ...
// ]
// ```

namespace parameter_PWMcos
{
enum class base_kind : std::uint8_t
{
    A = 0,
    C = 1,
    G = 2,
    T = 3,
    X = 255,
};
template<typename charT, typename traits>
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const base_kind bk)
{
    switch(bk)
    {
        case base_kind::A: {os << 'A'; return os;}
        case base_kind::C: {os << 'C'; return os;}
        case base_kind::G: {os << 'G'; return os;}
        case base_kind::T: {os << 'T'; return os;}
        case base_kind::X: {os << 'X'; return os;}
        default: {os << "invalid PWMcos base kind"; return os;}
    }
    return os;
}
} // parameter_PWMcos

template<typename traitsT>
class PWMcosPotential
{
  public:
    using traits_type = traitsT;
    using real_type   = typename traits_type::real_type;
    using self_type   = PWMcosPotential<traits_type>;
    using base_kind   = parameter_PWMcos::base_kind;

    struct contact_parameter_type
    {
        std::uint32_t Ca, CaN, CaC;
        real_type gamma, epsilon, r0, theta1_0, theta2_0, theta3_0;
        real_type r_cut_sq;
        std::array<real_type, 4> PWM;
    };
    struct dna_parameter_type
    {
        base_kind     base;
        std::uint32_t B, S, B5, B3;

        dna_parameter_type() : base(base_kind::X),
            B(invalid()), S(invalid()), B5(invalid()), B3(invalid())
        {}
        dna_parameter_type(const base_kind bk, const std::uint32_t b,
            const std::uint32_t s, const std::uint32_t b5, const std::uint32_t b3)
            : base(bk), B(b), S(s), B5(b5), B3(b3)
        {}
        ~dna_parameter_type() = default;
        dna_parameter_type(const dna_parameter_type&) = default;
        dna_parameter_type(dna_parameter_type&&)      = default;
        dna_parameter_type& operator=(const dna_parameter_type&) = default;
        dna_parameter_type& operator=(dna_parameter_type&&)      = default;
    };
    struct parameter_type
    {
        std::uint32_t dna_index;
    };
    struct pair_parameter_type
    {
        base_kind     base;
        std::uint32_t S, B5, B3;

        pair_parameter_type(): base(base_kind::X),
            S(invalid()), B5(invalid()), B3(invalid())
        {}
        ~pair_parameter_type() = default;
        pair_parameter_type(const base_kind     b,  const std::uint32_t s,
                            const std::uint32_t b5, const std::uint32_t b3)
            noexcept : base(b), S(s), B5(b5), B3(b3)
        {}
        pair_parameter_type(const pair_parameter_type&) = default;
        pair_parameter_type(pair_parameter_type&&)      = default;
        pair_parameter_type& operator=(const pair_parameter_type&) = default;
        pair_parameter_type& operator=(pair_parameter_type&&)      = default;
    };
    using container_type = std::vector<parameter_type>;

{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.0391742904058175, 'mean_word_length': 2.7187091146969036, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2485179', 'n_tokens_mistral': 3313, 'n_tokens_neox': 3055, 'n_words': 710}