~sfiorucci/ptools/test_seb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// $Id$
#include "pairlist.h"

namespace PTools
{


AttractPairList::AttractPairList(const AttractRigidbody & receptor , const AttractRigidbody & ligand, dbl cutoff )
{
    mp_ligand = &ligand;
    mp_receptor = &receptor;
    squarecutoff = cutoff*cutoff;
    no_update = false;
    update();
}




AttractPairList::AttractPairList(const AttractRigidbody & receptor, const AttractRigidbody & ligand)
{

    mp_ligand = &ligand;
    mp_receptor = &receptor;
    no_update = true ; //if infinite cutoff

    for (uint i = 0 ; i < mp_ligand->Size(); i++)
        for (uint j = 0; j < mp_receptor->Size(); j++)
        {
            vectl.push_back(i);
            vectr.push_back(j);
        }

}

AttractPairList::~AttractPairList()
{

}


/**
   Very basic implementation of an atom pairlist.
*/
void AttractPairList::update()
{


    if (no_update) return ;
    vectl.clear(); // clears the pairlist
    vectr.clear();

    //basic implementation of a pairlist generation:

    std::vector<uint> activelig;
    std::vector<uint> activerec;

    for (uint i=0; i<mp_ligand->Size(); i++)
    {
        if (mp_ligand->isAtomActive(i))
        {
            activelig.push_back(i);
        }
    }

    for (uint i=0; i<mp_receptor->Size(); i++)
    {
        if (mp_receptor->isAtomActive(i))
        {
            activerec.push_back(i);
        }
    }

    uint activeligsize = activelig.size();
    uint activerecsize = activerec.size();


    for (uint ii = 0 ; ii < activeligsize ; ii++)
    {

        for (uint jj = 0; jj < activerecsize; jj++)
        {
            uint i=activelig[ii];
            uint j=activerec[jj];


            Coord3D c1 = mp_ligand->GetCoords(i) ;
            Coord3D c2 = mp_receptor->GetCoords(j);
            if (Norm2(c1-c2) <= squarecutoff)
            {
                vectl.push_back(i);
                vectr.push_back(j);
            }


        }
    }


}


void AttractPairList::addPair(const AttractRigidbody & ligand, const AttractRigidbody & receptor, const AtomPair& pair)
{
    if (&ligand==mp_ligand && &receptor==mp_receptor)
    {
        vectl.push_back(pair.atlig);
        vectr.push_back(pair.atrec);
    }
    else
    {
        std::cerr << "error in PairList::add() : wrong receptor or ligand " << std::endl;
        abort();
    }
};








} //namespace PTools