PyMSDump 0.1.1__cp39-cp39-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
PyMSDump/MSTrj.py ADDED
@@ -0,0 +1,165 @@
1
+ from PyMSDump_ import TrajLoad
2
+ from enum import IntEnum, auto, unique
3
+ from dataclasses import dataclass
4
+ from typing import Iterator, Union
5
+ import numpy as np
6
+ import sys
7
+
8
+ """
9
+ * Materials Studio .trj use below units:
10
+ * All times are in ps.
11
+ * All energies are in kcal mol-1.
12
+ * All pressure and stress values are in GPa.
13
+ * All volumes are in Å3.
14
+ * All coordinates are in Å.
15
+ * All velocities are in Å ps-1.
16
+ * All forces are in kcal mol-1 Å-1.
17
+ * All temperatures are in K.
18
+ * All logical values are stored as integers (0=FALSE, not 0=TRUE).
19
+ """
20
+
21
+ @dataclass
22
+ class Frame:
23
+ """ A frame structure in a trajectory
24
+ Attributes:
25
+ step (int): current step
26
+ time (float): current time, ps
27
+ positions (np.ndarray): Atom positions in Å
28
+ velocities (Union[np.ndarray, None]): Atom velocities in Å ps-1
29
+ forces (Union[np.ndarray, None]): Atoms forces in kcal mol-1 Å-1
30
+ box (np.ndarray): The converted lower triangular simulation box (same as .gro but unit is Angstrom)。
31
+ crystal (np.ndarray): pdb crystal, unit is angle and angstrom
32
+ ener (np.ndarray): energy information
33
+ pvol (np.ndarray): pressure and volume information
34
+ hasV (bool): if has velocity
35
+ hasF (bool): if has force
36
+ """
37
+ step: int
38
+ time: float
39
+ positions: np.ndarray
40
+ velocities: Union[np.ndarray, None]
41
+ forces: Union[np.ndarray, None]
42
+ box: np.ndarray
43
+ crystal: np.ndarray
44
+ ener: np.ndarray
45
+ pvol: np.ndarray
46
+ hasV: bool
47
+ hasF: bool
48
+
49
+ @unique
50
+ class EnergyType(IntEnum):
51
+ Temp=0 # must from 0
52
+ AvgTemp=auto()
53
+ TimeStep=auto()
54
+ InitialTemp=auto()
55
+ FinalTemp=auto()
56
+ TotalPE=auto()
57
+ BondE=auto()
58
+ AngleE=auto()
59
+ TorsionE=auto()
60
+ InversionE=auto()
61
+ vdWE=auto()
62
+ ElectrostaticE=auto()
63
+ HBondE=auto()
64
+ ConstraintE=auto()
65
+ UreyBradleyE=auto()
66
+ ThreeBodyE=auto()
67
+ TotalCrossTermE=auto()
68
+ BendBendE=auto()
69
+ StretchStretchE=auto()
70
+ StretchBendStretchE=auto()
71
+ StretchTorsionStretchE=auto()
72
+ BendTorsionBendE=auto()
73
+ TorsionBendBendE=auto()
74
+ SeperatedStretchStretchE=auto()
75
+ TorsionStretchE=auto()
76
+ InversionInversionE=auto()
77
+ UserE=auto()
78
+ TotalInternalE=auto()
79
+ TotalNonBondE=auto()
80
+ AvgTotalPE=auto()
81
+ AvgBondE=auto()
82
+ AvgAngleE=auto()
83
+ AvgTorsionE=auto()
84
+ AvgInversionE=auto()
85
+ AvgvdWE=auto()
86
+ AvgElectrostaticE=auto()
87
+ AvgHBondE=auto()
88
+ AvgConstraintE=auto()
89
+ AvgUreyBradleyE=auto()
90
+ AvgThreeBodyE=auto()
91
+ AvgTotalCrossTermE=auto()
92
+ AvgBendBendE=auto()
93
+ AvgStretchStretchE=auto()
94
+ AvgStretchBendStretchE=auto()
95
+ AvgStretchTorsionStretchE=auto()
96
+ AvgBendTorsionBendE=auto()
97
+ AvgTorsionBendBendE=auto()
98
+ AvgSeperatedStretchStretchE=auto()
99
+ AvgTorsionStretchE=auto()
100
+ AvgInversionInversionE=auto()
101
+ AvgUserE=auto()
102
+ AvgTotalInternalE=auto()
103
+ AvgTotalNonBondE=auto()
104
+ TotalE=auto()
105
+ TotalKE=auto()
106
+ AvgTotalE=auto()
107
+ AvgTotalKE=auto()
108
+
109
+ @unique
110
+ class PressVolType(IntEnum):
111
+ Press = 0 # must from 0
112
+ Volume=auto()
113
+ TotalPV=auto()
114
+ KineticStrsPV=auto()
115
+ PotentialStrsPV=auto()
116
+ GyrationRadius=auto()
117
+ AvgPress=auto()
118
+ AvgVolume=auto()
119
+ AvgTotalPV=auto()
120
+ AvgKineticStrsPV=auto()
121
+ AvgPotentialStrsPV=auto()
122
+ AvgGyrationRadius=auto()
123
+
124
+ class MSTrjReader:
125
+ def __init__(self, ftrj:str, fpdb:str):
126
+ self.trajectory = TrajLoad(ftrj, fpdb)
127
+ self.natoms_ = self.__natoms()
128
+ self.nframes_ = self.__len__()
129
+
130
+ def __natoms(self):
131
+ nat = 0
132
+ for fr in self:
133
+ nat = len(fr.positions)
134
+ break
135
+ return nat
136
+
137
+ def __iter__(self) -> Iterator[Frame]:
138
+ try:
139
+ for _ in self.trajectory:
140
+ yield _
141
+ finally:
142
+ # always reset pointer to header, such for and break
143
+ self.trajectory.reset()
144
+
145
+ def __len__(self):
146
+ return len([_ for _ in self.trajectory])
147
+
148
+ def __str__(self):
149
+ return f'Total frames: {len(self)}'
150
+
151
+ @property
152
+ def nframes(self):
153
+ """ @brief Total number of frames """
154
+ return self.nframes_
155
+
156
+ @property
157
+ def natoms(self):
158
+ """ @brief Number of atoms in the trajectory """
159
+ return self.natoms_
160
+
161
+
162
+ if __name__ == '__main__':
163
+ trj = MSTrjReader(sys.argv[1], sys.argv[2])
164
+ for ts in trj:
165
+ print(ts)
PyMSDump/__init__.py ADDED
File without changes
Binary file
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyMSDump
3
+ Version: 0.1.1
4
+ Summary: A parser for Materials Studio .trj format
5
+ Author: YujieLiu
6
+ Author-email:
7
+ Classifier: Programming Language :: Python
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: C++
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: numpy
13
+ Dynamic: author
14
+ Dynamic: classifier
15
+ Dynamic: description
16
+ Dynamic: description-content-type
17
+ Dynamic: requires-dist
18
+ Dynamic: requires-python
19
+ Dynamic: summary
20
+
21
+ **<font size=5> A tool to export common trajectory file from Materials Studio</font>**
22
+
23
+
24
+
25
+ # Features
26
+
27
+ * Support full periodic boundary conditions
28
+
29
+ > Please note that this tool has converted the coordinates to match the PDB unit cell and coordinates exported by MS, so there may be differences from the original data output by Perl/Trj2Ascii, especially for the triclinic system.
30
+
31
+ * Support export move + fix atoms if exist `.pdb`
32
+
33
+ * Support export `xyz` trajectory file
34
+
35
+ * Support export `xtc` of gromacs file (includes time and step)
36
+
37
+ * Support export `.trr` format which contains velocities (`nm/ps`) and forces`(kJ/mol/nm)` if it exists
38
+
39
+ > Note that fixed atoms will have zero velocity and force, meaning their coordinates/velocity/force data won't appear in the `.trj` file.
40
+
41
+ * Support export `.txt` format (`Plain text file`) which contains all kinds of energy items and others:
42
+
43
+ ```
44
+ #Time(ps) Temperature(K) Potential(kJ/mol) Kinetic(KJ/mol) TotalEnergy(KJ/mol) Pressure(bar) Volume(A^3)
45
+ ```
46
+ * Support Python API
47
+ ```
48
+ pip install PyMSDump
49
+ ```
50
+ Usage reference: [api_test](https://github.com/liuyujie714/MS_Trajdump/blob/master/PyMSDump/api_test.py)
51
+
52
+
53
+ # Usage
54
+
55
+ First locate molecular dynamics trajectory file created by `Materials Studio`, hidden file `.trj` and `.xtd` are located in same folder.
56
+
57
+
58
+
59
+ Then download program from here: [Download](https://github.com/liuyujie714/MS_Trajdump/releases)
60
+
61
+
62
+
63
+
64
+ * Linux
65
+
66
+ ```
67
+ chmod a+x MS_dump
68
+ ./MS_dump -s system.pdb -f system.trj
69
+ ```
70
+
71
+ * Windows
72
+
73
+ ```
74
+ .\MS_dump.exe -s system.pdb -f system.trj
75
+ ```
76
+
77
+
78
+
79
+ Default output `MS_traj.xyz`, the comment line has box information that can be read by [Ovito](https://www.ovito.org/) software directly.
80
+
81
+ > Lattice="14.408798 0.0 0.0 0.000000 14.408798 0.0 0.000000 0.000000 14.408798" Properties=species:S:1:pos:R:3
82
+
83
+
84
+
85
+
86
+
87
+ **Note:**
88
+
89
+ > The exported xyz will use `C` name for all atoms if not provide pdb file, such as:
90
+ >
91
+ > ```
92
+ > .\MS_dump.exe -f system.trj
93
+ > ```
94
+
95
+
96
+
97
+
98
+
99
+ `-o` option can control output format
100
+
101
+
102
+
103
+ If you want to export `.xtc/.trr` of gromacs, use command:
104
+
105
+ ```
106
+ .\MS_dump.exe -s system.pdb -f system.trj -o system.xtc
107
+ ```
108
+
109
+ ```
110
+ .\MS_dump.exe -s system.pdb -f system.trj -o system.trr
111
+ ```
112
+
113
+
114
+
115
+ Also export energy items:
116
+
117
+ ```
118
+ .\MS_dump.exe -f system.trj -o energy.txt
119
+ ```
120
+
@@ -0,0 +1,7 @@
1
+ PyMSDump_.cp39-win_amd64.pyd,sha256=1VAaHK1DqTmyvy68WaTpXP11DgUiIVtHnp74QsqqeUs,285184
2
+ PyMSDump/MSTrj.py,sha256=Iuw2C38W7S2rVlfBEPiEnlxBPwsbSdnvtZhQYDtZTCQ,4571
3
+ PyMSDump/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ pymsdump-0.1.1.dist-info/METADATA,sha256=Fh0gG5_UUWnc_3LNtUkzhbsI-kOabDfat7BiuPCjfrQ,2919
5
+ pymsdump-0.1.1.dist-info/WHEEL,sha256=zuNlb9Um05hyCt8XRmFaVi795Ee7Bc9lOiOIpwTM7Gs,99
6
+ pymsdump-0.1.1.dist-info/top_level.txt,sha256=0kBKWZ5c4yBR5LA0ZRXz4oo5CqDSVpTyPZ6jiNzuMiY,19
7
+ pymsdump-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp39-cp39-win_amd64
5
+
@@ -0,0 +1,2 @@
1
+ PyMSDump
2
+ PyMSDump_