mirror of
https://github.com/arcan1s/moldyn.git
synced 2025-06-29 15:15:47 +00:00
added get-dipole
This commit is contained in:
70
get_dipole/get-dipole.py
Executable file
70
get_dipole/get-dipole.py
Executable file
@ -0,0 +1,70 @@
|
||||
#!/usr/bin/python2
|
||||
|
||||
import argparse, math
|
||||
|
||||
|
||||
def get_aver_dipole(dipole):
|
||||
"""function to get average dipole moment"""
|
||||
aver_dipole = math.sqrt((dipole[0] * dipole[0] +
|
||||
dipole[1] * dipole[1] +
|
||||
dipole[2] * dipole[2]))
|
||||
aver_dipole = round(aver_dipole, 4)
|
||||
return aver_dipole
|
||||
|
||||
|
||||
def get_charges(file_name):
|
||||
"""function to get charges from GROMACS files"""
|
||||
charges = {}
|
||||
with open(file_name, 'r') as input_file:
|
||||
for line in input_file:
|
||||
try:
|
||||
charges[line.split()[0]] = float(line.split()[2])
|
||||
except:
|
||||
pass
|
||||
return charges
|
||||
|
||||
|
||||
def get_coordinates(file_name):
|
||||
"""function to get coordinates from PDB"""
|
||||
coords = []
|
||||
with open(file_name, 'r') as input_file:
|
||||
for line in input_file:
|
||||
if ((line[0:4] == "ATOM") or (line[0:6] == "HETATM")):
|
||||
coords.append({"type":line.split()[2], "coords":[float(line[30:38]), float(line[38:46]), float(line[46:54])]})
|
||||
return coords
|
||||
|
||||
|
||||
def get_dipole(charges, coords):
|
||||
"""function to get dipole moment"""
|
||||
dipole = [0.0, 0.0, 0.0]
|
||||
for atom in coords:
|
||||
dipole[0] = dipole[0] + charges[atom["type"]] * atom["coords"][0]
|
||||
dipole[1] = dipole[1] + charges[atom["type"]] * atom["coords"][1]
|
||||
dipole[2] = dipole[2] + charges[atom["type"]] * atom["coords"][2]
|
||||
dipole[0] = math.fabs(round(16.0218 * dipole[0] / 3.3356, 4))
|
||||
dipole[1] = math.fabs(round(16.0218 * dipole[1] / 3.3356, 4))
|
||||
dipole[2] = math.fabs(round(16.0218 * dipole[2] / 3.3356, 4))
|
||||
return dipole
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description = 'Calculate dipole moment from PDB')
|
||||
parser.add_argument('-i', '--input', dest = 'input',
|
||||
help = 'File with charges', action = 'store')
|
||||
parser.add_argument('-c', '--coord', dest = 'coord',
|
||||
help = 'File with coordinates', action = 'store')
|
||||
parser.add_argument('-v', '--vector', dest = 'vector',
|
||||
help = 'Return vector', action = 'store_true', default = False)
|
||||
args = parser.parse_args()
|
||||
|
||||
if ((not args.input) or (not args.coord)):
|
||||
print "Input files are not set"
|
||||
exit
|
||||
|
||||
charges = get_charges(args.input)
|
||||
coords = get_coordinates(args.coord)
|
||||
if (args.vector):
|
||||
print get_dipole(charges, coords)
|
||||
else:
|
||||
print get_aver_dipole(get_dipole(charges, coords))
|
||||
|
40
mathmech/PKGBUILD-mingw
Normal file
40
mathmech/PKGBUILD-mingw
Normal file
@ -0,0 +1,40 @@
|
||||
# Author: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgname=mathmech
|
||||
pkgver=1.2.0
|
||||
pkgrel=2
|
||||
pkgdesc="Software package for analysis of molecular dynamics trajectories"
|
||||
arch=('any')
|
||||
url="http://arcan1s.github.io/projects/moldyn"
|
||||
license=('Beerware')
|
||||
depends=('mingw-w64-qwt')
|
||||
makedepends=('mingw-w64-cmake' 'automoc4')
|
||||
source=(https://github.com/arcan1s/moldyn/releases/download/mm-${pkgver}/${pkgname}-${pkgver}-src.zip)
|
||||
md5sums=('46d8e1a3d6bc30d5b0b57ccf485986b1')
|
||||
_cmakekeys="-DCMAKE_INSTALL_PREFIX=/usr
|
||||
-DQWT_INCLUDE_PATH=/usr/x86_64-w64-mingw32/qwt
|
||||
-DQWT_LIBRARY_PATH=/usr/x86_64-w64-mingw32/lib
|
||||
-DMM_PREFIX=mm_
|
||||
-DADD_DOCS:BOOL=1
|
||||
-DADD_INCLUDE:BOOL=1
|
||||
-DCMAKE_BUILD_TYPE=Release"
|
||||
|
||||
prepare() {
|
||||
[[ -d ${srcdir}/build ]] && rm -rf "${srcdir}/build"
|
||||
mkdir "${srcdir}/build"
|
||||
}
|
||||
|
||||
build() {
|
||||
unset LDFLAGS
|
||||
cd "${srcdir}/build"
|
||||
x86_64-w64-mingw32-cmake ${_cmakekeys} ../
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "${srcdir}/build"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
install -Dm644 "${srcdir}/COPYING" "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
|
||||
}
|
||||
|
Reference in New Issue
Block a user