Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing bug from issue #50 #51

Merged
merged 1 commit into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions PyContact/core/ContactAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ def analyze_psf_dcd_grid(self, psf, dcd, cutoff, hbondcutoff, hbondcutangle, sel
# pass positions and distance to cython
natoms1 = len(sel1.atoms)
natoms2 = len(sel2.atoms)
pos1 = np.reshape(sel1.positions, (1, natoms1 * 3))
pos2 = np.reshape(sel2.positions, (1, natoms2 * 3))
pos1 = np.array(np.reshape(sel1.positions, (1, natoms1 * 3)), dtype=np.float64)
pos2 = np.array(np.reshape(sel2.positions, (1, natoms2 * 3)), dtype=np.float64)
xyz1 = np.array(pos1, dtype=np.float32)
xyz2 = np.array(pos2, dtype=np.float32)
# 2d array with index of atom1 being the index of the first dimension
Expand Down Expand Up @@ -383,7 +383,9 @@ def analyze_psf_dcd_grid(self, psf, dcd, cutoff, hbondcutoff, hbondcutangle, sel
continue
# distance = distarray[idx1, idx2]
# weight = self.weight_function(distance)
distance = np.linalg.norm(pos1[0][3*idx1:3*idx1+3] - pos2[0][3*idx2:3*idx2+3])
dvec = pos1[0][3*idx1:3*idx1+3] - pos2[0][3*idx2:3*idx2+3]
distance = np.sqrt(dvec.dot(dvec))
# print(dvec, distance, dvec.dtype)
# if (distance - distarray[idx1, idx2]) > 0.001:
# print("Error in distance calculations!")
# return
Expand Down Expand Up @@ -454,8 +456,8 @@ def analyze_psf_dcd_grid(self, psf, dcd, cutoff, hbondcutoff, hbondcutangle, sel
dist = np.linalg.norm(pos1[0][3*conv_hatom:3*conv_hatom+3] - pos2[0][3*idx2:3*idx2+3])
if (dist <= hbondcutoff):
donorPosition = sel1.positions[idx1]
hydrogenPosition = sel1.positions[conv_hatom]
acceptorPosition = sel2.positions[idx2]
hydrogenPosition = np.array(sel1.positions[conv_hatom], dtype=np.float64)
acceptorPosition = np.array(sel2.positions[idx2], dtype=np.float64)
v1 = hydrogenPosition - acceptorPosition
v2 = hydrogenPosition - donorPosition
v1norm = np.linalg.norm(v1)
Expand Down Expand Up @@ -483,8 +485,8 @@ def analyze_psf_dcd_grid(self, psf, dcd, cutoff, hbondcutoff, hbondcutangle, sel
dist = np.linalg.norm(pos1[0][3*idx1:3*idx1+3] - pos2[0][3*conv_hatom:3*conv_hatom+3])
if (dist <= hbondcutoff):
donorPosition = sel2.positions[idx2]
hydrogenPosition = sel2.positions[conv_hatom]
acceptorPosition = sel1.positions[idx1]
hydrogenPosition = np.array(sel2.positions[conv_hatom], dtype=np.float64)
acceptorPosition = np.array(sel1.positions[idx1], dtype=np.float64)
v1 = hydrogenPosition - acceptorPosition
v2 = hydrogenPosition - donorPosition
v1norm = np.linalg.norm(v1)
Expand Down
15 changes: 8 additions & 7 deletions PyContact/core/multi_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def loop_trajectory_grid(sel1c, sel2c, indices1, indices2, config, suppl, selfIn
currentFrameContacts = []
natoms1 = len(s1)
natoms2 = len(s2)
pos1 = np.reshape(s1, (1, natoms1 * 3))
pos2 = np.reshape(s2, (1, natoms2 * 3))
pos1 = np.array(np.reshape(s1, (1, natoms1 * 3)), dtype=np.float64)
pos2 = np.array(np.reshape(s2, (1, natoms2 * 3)), dtype=np.float64)
xyz1 = np.array(pos1, dtype=np.float32)
xyz2 = np.array(pos2, dtype=np.float32)
# 2d array with index of atom1 being the index of the first dimension
Expand All @@ -96,7 +96,8 @@ def loop_trajectory_grid(sel1c, sel2c, indices1, indices2, config, suppl, selfIn
continue
# distance = distarray[idx1, idx2]
# weight = weight_function(distance)
distance = np.linalg.norm(pos1[0][3*idx1:3*idx1+3] - pos2[0][3*idx2:3*idx2+3])
dvec = pos1[0][3*idx1:3*idx1+3] - pos2[0][3*idx2:3*idx2+3]
distance = np.sqrt(dvec.dot(dvec))
# if (distance - distarray[idx1, idx2]) > 0.001:
# print("Error in distance calculations!")
# return
Expand Down Expand Up @@ -165,8 +166,8 @@ def loop_trajectory_grid(sel1c, sel2c, indices1, indices2, config, suppl, selfIn
dist = np.linalg.norm(pos1[0][3*conv_hatom:3*conv_hatom+3] - pos2[0][3*idx2:3*idx2+3])
if (dist <= hbondcutoff):
donorPosition = s1[idx1]
hydrogenPosition = s1[conv_hatom]
acceptorPosition = s2[idx2]
hydrogenPosition = np.array(s1[conv_hatom], dtype=np.float64)
acceptorPosition = np.array(s2[idx2], dtype=np.float64)
v1 = hydrogenPosition - acceptorPosition
v2 = hydrogenPosition - donorPosition
v1norm = np.linalg.norm(v1)
Expand Down Expand Up @@ -194,8 +195,8 @@ def loop_trajectory_grid(sel1c, sel2c, indices1, indices2, config, suppl, selfIn
dist = np.linalg.norm(pos1[0][3*idx1:3*idx1+3] - pos2[0][3*conv_hatom:3*conv_hatom+3])
if (dist <= hbondcutoff):
donorPosition = s2[idx2]
hydrogenPosition = s2[conv_hatom]
acceptorPosition = s1[idx1]
hydrogenPosition = np.array(s2[conv_hatom], dtype=np.float64)
acceptorPosition = np.array(s1[idx1], dtype=np.float64)
v1 = hydrogenPosition - acceptorPosition
v2 = hydrogenPosition - donorPosition
v1norm = np.linalg.norm(v1)
Expand Down
6 changes: 5 additions & 1 deletion PyContact/gui/Canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from PyQt5.QtCore import QSize, QRect
from PyQt5.QtCore import pyqtSignal, QObject
import numpy as np
import math

from ..core.ContactFilters import *
from .LabelView import LabelView
Expand Down Expand Up @@ -195,9 +196,12 @@ def renderContact(self, generator):
alpha = merged_score * self.alphaFactor
if alpha > 255:
alpha = 255
if math.isnan(alpha):
alpha = 255
if self.colorScheme == ColorScheme.bbsc:
# pass
p.setBrush(QColor(bbScColor[0], bbScColor[1], bbScColor[2], alpha))
p.setBrush(QColor(bbScColor[0], bbScColor[1], bbScColor[2],
alpha))
elif self.colorScheme == ColorScheme.custom:
color = QColor(self.customColor)
color.setAlpha(alpha)
Expand Down
4 changes: 2 additions & 2 deletions PyContact/gui/VMDControlPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def initUI(self):
self.fancyPrepared = False
self.setLayout(self.grid)
self.setWindowTitle("VMD Control Panel")
self.resize(640, 144)
self.resize(640, 444)
self.grid.setGeometry(QtCore.QRect(10, 10, 621, 431))

self.startButton = QPushButton("Start VMD")
Expand Down Expand Up @@ -289,7 +289,7 @@ def pushConnectVMD(self):
def pushStartVMD(self):
self.startButton.setEnabled(False)
self.stopButton.setEnabled(True)
# self.commandButton.setEnabled(True)
self.commandButton.setEnabled(True)
response = self.vmd.start()
if response == -1:
self.connectButton.setEnabled(True)
Expand Down