@@ -8,7 +8,7 @@
Loading
8 8
from __future__ import absolute_import
9 9
10 10
# Add imports here
11 -
import resppol.resppol
11 +
#import .resppol
12 12
13 13
# Handle versioneer
14 14
from ._version import get_versions

@@ -397,7 +397,10 @@
Loading
397 397
            raise Exception('Molecule either not found or does not have a 3D structure')
398 398
399 399
        # Check for strange atoms
400 +
        AtomicNumbers = []
400 401
        for atom in self.oemol.GetAtoms():
402 +
            AtomicNumbers.append(atom.GetAtomicNum())
403 +
401 404
            if atom.GetAtomicNum() not in biological_elements:
402 405
                log.warning("""I detect an atom with atomic number: {}
403 406
                Are you sure you want to include such an atom in your dataset?
@@ -437,7 +440,7 @@
Loading
437 440
        # Define all atomtypes for polarization
438 441
        for i, properties in enumerate(molecule_parameter_list[0]['vdW'].items()):
439 442
            atom_index, parameter = properties
440 -
            self.add_atom(i, atom_index, parameter.id)
443 +
            self.add_atom(i, atom_index[0], parameter.id, atomic_number = AtomicNumbers[atom_index[0]])
441 444
442 445
        self._natoms = len(self._atoms)
443 446
@@ -477,7 +480,7 @@
Loading
477 480
        atom_index2 = atom_indices[1]
478 481
        self._bonds.append(Bond(index, atom_index1, atom_index2, parameter_id))
479 482
480 -
    def add_atom(self, index, atom_index, parameter_id):
483 +
    def add_atom(self, index, atom_index, parameter_id, atomic_number=0):
481 484
        """
482 485
        Adds a atom object to the molecule
483 486
@@ -486,7 +489,7 @@
Loading
486 489
        :param parameter_id:
487 490
        :return:
488 491
        """
489 -
        self._atoms.append(Atom(index, atom_index[0], parameter_id))
492 +
        self._atoms.append(Atom(index, atom_index, parameter_id, atomic_number= atomic_number))
490 493
491 494
    def add_conformer_from_mol2(self, mol2file):
492 495
        """
@@ -728,10 +731,11 @@
Loading
728 731
729 732
    """
730 733
731 -
    def __init__(self, index, atom_index, parameter_id):
734 +
    def __init__(self, index, atom_index, parameter_id, atomic_number = 0):
732 735
        self._id = index
733 736
        self._atom = atom_index
734 737
        self._parameter_id = parameter_id
738 +
        self._atomic_number = atomic_number
735 739
736 740
737 741
# =============================================================================================
@@ -1000,13 +1004,14 @@
Loading
1000 1004
            for alpha in range(nbcc):
1001 1005
                self.A[alpha][alpha] = 1
1002 1006
        else:
1003 -
            for ESP in [self.baseESP] + self.polESPs: #lgtm [py/unused-loop-variable]
1004 -
                for j in range(self.natoms):
1007 +
            #for ESP in [self.baseESP] + self.polESPs: #lgtm [py/unused-loop-variable]
1008 +
            for j in range(self.natoms):
1005 1009
                    for k in range(self.natoms):
1006 1010
                        for alpha in range(nbcc):
1007 1011
                            for beta in range(nbcc):
1008 1012
                                self.A[alpha][beta] += T[j][alpha] * T[k][beta] * np.dot(self.dist[j],
1009 1013
                                                                                               self.dist[k])
1014 +
            self.A = self.A *(len(self.polESPs)+1)
1010 1015
        # Polarizabilities part
1011 1016
        self.D = np.zeros((nalpha, nalpha))
1012 1017
        if self._molecule._mode != 'bcconly':  # Mode is not optimizing polarizabilies
@@ -1301,6 +1306,24 @@
Loading
1301 1306
        del self.diatomic_distb_y
1302 1307
        del self.diatomic_distb_z
1303 1308
1309 +
    def write_res_esp(self, q_alpha= None ):
1310 +
        """
1311 +
        NOT FINISHED YET!!!
1312 +
1313 +
        Writes the residual ESP to a file.
1314 +
1315 +
        :param qd: list of float
1316 +
            Point charges and polarizabilities
1317 +
        :return:
1318 +
        """
1319 +
        if q_alpha is None:
1320 +
            q_alpha = self.q_alpha
1321 +
        atoms = []
1322 +
        for i,atom in enumerate(self.atom_positions.to('bohr').magnitude):
1323 +
            atoms.append([self._molecule._atoms[i]._atomic_number,atom])
1324 +
1325 +
        for ESP in [self.baseESP] + self.polESPs:
1326 +
            ESP.write_res_esp(q_alpha, atoms= atoms)
1304 1327
1305 1328
# =============================================================================================
1306 1329
# ESPGRID
@@ -1543,7 +1566,7 @@
Loading
1543 1566
        """
1544 1567
        if self._conformer._molecule._mode != 'alpha':  # Change that in bcc that this line is unnecessary
1545 1568
            self.calc_esp_q_alpha(q_alpha)
1546 -
            self.esp_values = np.subtract(self.esp_values.to('elementary_charge / angstrom').magnitude, self.q_pot)
1569 +
            self.esp_values = Q_(np.subtract(self.esp_values.to('elementary_charge / angstrom').magnitude, self.q_pot),'elementary_charge / angstrom')
1547 1570
1548 1571
    def calc_sse(self, q_alpha):
1549 1572
        """
@@ -1555,7 +1578,7 @@
Loading
1555 1578
        self.calc_esp_q_alpha(q_alpha)
1556 1579
        self.sse = np.square(self.esp_values.to('elementary_charge / angstrom').magnitude - self.q_pot).sum()
1557 1580
1558 -
    def write_res_esp(self, q_alpha):
1581 +
    def write_res_esp(self, q_alpha, atoms = []):
1559 1582
        """
1560 1583
        NOT FINISHED YET!!!
1561 1584
@@ -1566,18 +1589,19 @@
Loading
1566 1589
        :return:
1567 1590
        """
1568 1591
        self.calc_esp_q_alpha(q_alpha)
1569 -
        res_pot = self.esp_values - self.q_pot
1592 +
        res_pot = np.subtract(self.esp_values.to('elementary_charge / angstrom').magnitude, self.q_pot)
1593 +
        #res_pot = (self.esp_values - self.q_pot)#.to('elementary_charge / bohr').magnitude
1570 1594
        f = open(self.name + '.rgesp', 'w')
1571 1595
        f.write(' ESP FILE - ATOMIC UNITS\n')
1572 1596
        f.write(' CHARGE =  {0} - MULTIPLICITY =   1\n'.format(self._conformer._molecule._charge))
1573 1597
        f.write(' ATOMIC COORDINATES AND ESP CHARGES. #ATOMS =     {} \n'.format(np.sum(self.natoms)))
1574 -
        for i in range(self.conformer._natoms):
1598 +
        for i in range(self._conformer.natoms):
1575 1599
            f.write(
1576 -
                ' {} {} {} {} {}\n'.format(self.atoms[i], self.atomcrd[i][0], self.atomcrd[i][1], self.atomcrd[i][2],
1577 -
                                           self._conformer._moleccule.q_alpha[i]))
1578 -
        f.write(' ESP VALUES AND GRID POINT COORDINATES. #POINTS =   {}\n'.format(np.sum(self.npoints)))
1600 +
                ' {} {} {} {} {}\n'.format(atoms[i][0], atoms[i][1][0], atoms[i][1][1], atoms[i][1][2],
1601 +
                                           self._conformer._molecule.q_alpha[i]))
1602 +
        f.write(' ESP VALUES AND GRID POINT COORDINATES. #POINTS =   {}\n'.format(len(self.esp_values)))
1579 1603
        for i in range(len(self.esp_values)):
1580 -
            f.write(' {} {} {} {}\n'.format(res_pot[i], self.crd[i][0], self.crd[i][1], self.crd[i][2]))
1604 +
            f.write(' {} {} {} {}\n'.format(res_pot[i], self.positions[i][0], self.positions[i][1], self.positions[i][2]))
1581 1605
        f.close()
1582 1606
1583 1607
# =============================================================================================
@@ -1636,10 +1660,10 @@
Loading
1636 1660
1637 1661
        self.e_field_at_atom = np.zeros((3, self._conformer.natoms))
1638 1662
1639 -
"""
1663 +
1640 1664
if __name__ == '__main__':
1641 1665
    pass
1642 -
    
1666 +
    """
1643 1667
    datei = os.path.join(ROOT_DIR_PATH, 'resppol/tmp/phenol/conf0/mp2_0.mol2')
1644 1668
    test = TrainingSet(scf_scaleparameters=[0.0, 0.0, 0.5])
1645 1669
    test.add_molecule(datei)
@@ -1686,7 +1710,7 @@
Loading
1686 1710
    #print(test.q_alpha)
1687 1711
    print(test.molecules[0].conformers[0].baseESP.e_field_at_atom)
1688 1712
    print(test.molecules[0].conformers[0].polESPs[0].e_field_at_atom)
1689 -
    
1713 +
    """
1690 1714
1691 1715
    datei = os.path.join(ROOT_DIR_PATH, 'resppol/data/fast_test_data/test2.mol2')
1692 1716
    test = TrainingSet(mode='q_alpha',SCF= True, thole = True)
@@ -1702,7 +1726,7 @@
Loading
1702 1726
    test.molecules[0].conformers[0].baseESP.calc_esp_q_alpha(test.q_alpha)
1703 1727
    test.molecules[0].conformers[0].baseESP.calc_sse(test.q_alpha)
1704 1728
    test.molecules[0].conformers[0].baseESP.sub_esp_q_alpha(test.q_alpha)
1729 +
    test.molecules[0].conformers[0].write_res_esp()
1705 1730
    print(test.molecules[0].conformers[0].baseESP.q_pot)
1706 1731
1707 1732
    print(test.molecules[0].conformers[0].q_alpha)
1708 -
    """
Files Coverage
resppol 88.21%
Project Totals (2 files) 88.21%
258.1
TRAVIS_OS_NAME=osx
258.3
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
258.4
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
258.2
TRAVIS_OS_NAME=osx
1
# Codecov configuration to make it a bit less noisy
2
coverage:
3
  status:
4
    patch: false
5
    project:
6
      default:
7
        threshold: 50%
8
comment:
9
  layout: "header"
10
  require_changes: false
11
  branches: null
12
  behavior: default
13
  flags: null
14
  paths: null
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading