molutils 0.6.0__tar.gz → 0.7.0__tar.gz

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.
Files changed (29) hide show
  1. {molutils-0.6.0 → molutils-0.7.0}/PKG-INFO +2 -2
  2. {molutils-0.6.0 → molutils-0.7.0}/molutils/__init__.py +3 -0
  3. {molutils-0.6.0 → molutils-0.7.0}/molutils/_core/count.py +26 -21
  4. {molutils-0.6.0 → molutils-0.7.0}/molutils/_core/extract.py +9 -15
  5. {molutils-0.6.0 → molutils-0.7.0}/molutils/_core/list_.py +3 -5
  6. {molutils-0.6.0 → molutils-0.7.0}/molutils/_core/remove.py +3 -3
  7. molutils-0.7.0/molutils/_core/traj.py +78 -0
  8. {molutils-0.6.0 → molutils-0.7.0}/molutils/_ui/app_main.py +10 -12
  9. {molutils-0.6.0 → molutils-0.7.0}/molutils/_ui/fy_help.fyh +47 -6
  10. {molutils-0.6.0 → molutils-0.7.0}/molutils/_ui/fy_rules.fyr +19 -0
  11. molutils-0.7.0/molutils/_utils/__init__.py +0 -0
  12. molutils-0.7.0/molutils/_utils/mda_utils.py +31 -0
  13. molutils-0.7.0/molutils/_version.py +1 -0
  14. {molutils-0.6.0 → molutils-0.7.0}/molutils.egg-info/PKG-INFO +2 -2
  15. {molutils-0.6.0 → molutils-0.7.0}/molutils.egg-info/SOURCES.txt +4 -1
  16. {molutils-0.6.0 → molutils-0.7.0}/molutils.egg-info/requires.txt +1 -1
  17. {molutils-0.6.0 → molutils-0.7.0}/setup.py +1 -1
  18. molutils-0.6.0/molutils/_version.py +0 -1
  19. {molutils-0.6.0 → molutils-0.7.0}/LICENSE.md +0 -0
  20. {molutils-0.6.0 → molutils-0.7.0}/README.md +0 -0
  21. {molutils-0.6.0 → molutils-0.7.0}/molutils/__main__.py +0 -0
  22. {molutils-0.6.0 → molutils-0.7.0}/molutils/_core/__init__.py +0 -0
  23. {molutils-0.6.0 → molutils-0.7.0}/molutils/_ui/__init__.py +0 -0
  24. {molutils-0.6.0 → molutils-0.7.0}/molutils/_ui/app_subcommand.py +0 -0
  25. {molutils-0.6.0 → molutils-0.7.0}/molutils.egg-info/dependency_links.txt +0 -0
  26. {molutils-0.6.0 → molutils-0.7.0}/molutils.egg-info/entry_points.txt +0 -0
  27. {molutils-0.6.0 → molutils-0.7.0}/molutils.egg-info/top_level.txt +0 -0
  28. {molutils-0.6.0 → molutils-0.7.0}/pyproject.toml +0 -0
  29. {molutils-0.6.0 → molutils-0.7.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: molutils
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Collection of tools for preprocessing or summarizing details from biomolecular structure files.
5
5
  Home-page: https://github.com/diegobarmor/molutils
6
6
  Author: DiegoBarMor
@@ -13,7 +13,7 @@ Requires-Python: >=3.10
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE.md
15
15
  Requires-Dist: molsimple==0.1.2
16
- Requires-Dist: freyacli==0.4.5
16
+ Requires-Dist: freyacli==0.5.0
17
17
  Dynamic: author
18
18
  Dynamic: author-email
19
19
  Dynamic: classifier
@@ -1,10 +1,13 @@
1
1
  from ._version import __version__
2
2
 
3
+ from ._utils.mda_utils import MDAUtils
4
+
3
5
  from ._ui.app_subcommand import AppSubcommand
4
6
 
5
7
  from ._core.list_ import List
6
8
  from ._core.count import Count
7
9
  from ._core.extract import Extract
8
10
  from ._core.remove import Remove
11
+ from ._core.traj import Traj
9
12
 
10
13
  from ._ui.app_main import AppMain
@@ -1,5 +1,3 @@
1
- from pathlib import Path
2
-
3
1
  import molsimple as ms
4
2
  import freyacli as fy
5
3
  import molutils as mu
@@ -10,52 +8,53 @@ class Count(mu.AppSubcommand):
10
8
  def run(self):
11
9
  command = self.main.subcommands.pop(0)
12
10
 
13
- if command == "models" : return self.app_count_models()
14
- if command == "chains" : return self.app_count_chains()
15
- if command == "residues": return self.app_count_residues()
16
- if command == "frames" : return self.app_count_frames()
17
- if command == "altlocs" : return self.app_count_altlocs()
11
+ if command == "models" : return self.app_count_models()
12
+ if command == "chains" : return self.app_count_chains()
13
+ if command == "residues" : return self.app_count_residues()
14
+ if command == "particles": return self.app_count_particles()
15
+ if command == "frames" : return self.app_count_frames()
16
+ if command == "altlocs" : return self.app_count_altlocs()
18
17
 
19
18
  raise ValueError(f"Unknown command: {command}")
20
19
 
21
20
 
22
21
  # --------------------------------------------------------------------------
23
22
  def app_count_models(self):
24
- path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
23
+ path_in = self.main.arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
25
24
  print(mu.Count.models(ms.System.read_pdb(path_in)))
26
25
 
27
26
 
28
27
  # --------------------------------------------------------------------------
29
28
  def app_count_chains(self):
30
- path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
29
+ path_in = self.main.arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
31
30
  print(mu.Count.chains(ms.System.read_pdb(path_in)))
32
31
 
33
32
 
34
33
  # --------------------------------------------------------------------------
35
34
  def app_count_residues(self):
36
- path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
35
+ path_in = self.main.arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
37
36
  print(mu.Count.residues(ms.System.read_pdb(path_in)))
38
37
 
39
38
 
40
39
  # --------------------------------------------------------------------------
41
- def app_count_frames(self):
42
- path_struct = self.main.get_arg_path("path_struct", assertion = fy.PathAssertion.FILE_IN)
43
- path_traj = self.main.get_arg_path("path_traj",
44
- assertion = fy.PathAssertion.FILE_IN, allow_none = True
45
- )
40
+ def app_count_particles(self):
41
+ path_in = self.main.arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
42
+ print(mu.Count.particles(ms.System.read_pdb(path_in)))
46
43
 
47
- import MDAnalysis as mda
48
- args_traj = [str(path_traj)] if path_traj is not None else []
49
- u = mda.Universe(str(path_struct), *args_traj)
50
44
 
51
- nframes_valid, _ = mu.Count.frames(u)
45
+ # --------------------------------------------------------------------------
46
+ def app_count_frames(self):
47
+ path_struct = self.main.arg_path("path_struct", assertion = fy.PathAssertion.FILE_IN)
48
+ path_traj = self.main.arg_path("path_traj", assertion = fy.PathAssertion.FILE_IN)
49
+ nframes_valid, _ = mu.Count.frames(
50
+ mu.MDAUtils.create_universe_quiet(path_struct, path_traj)
51
+ )
52
52
  print(f"{nframes_valid}")
53
53
 
54
54
 
55
-
56
55
  # --------------------------------------------------------------------------
57
56
  def app_count_altlocs(self):
58
- path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
57
+ path_in = self.main.arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
59
58
  print(mu.Count.altlocs(ms.System.read_pdb(path_in)))
60
59
 
61
60
 
@@ -77,6 +76,12 @@ class Count(mu.AppSubcommand):
77
76
  return len(mu.List.residues(system, do_sort = False))
78
77
 
79
78
 
79
+ # --------------------------------------------------------------------------
80
+ @classmethod
81
+ def particles(cls, system: ms.System) -> int:
82
+ return len(system.particles)
83
+
84
+
80
85
  # --------------------------------------------------------------------------
81
86
  @classmethod
82
87
  def frames(cls, universe) -> tuple[int, int]:
@@ -1,5 +1,4 @@
1
1
  from pathlib import Path
2
- from collections import defaultdict
3
2
 
4
3
  import molsimple as ms
5
4
  import freyacli as fy
@@ -21,7 +20,7 @@ class Extract(mu.AppSubcommand):
21
20
  # --------------------------------------------------------------------------
22
21
  def app_extract_models(self):
23
22
  path_in, folder_out = self._io_filein_dirout()
24
- first_only = self.main.get_arg_bool("first_only")
23
+ first_only = self.main.arg_toggle("first_only")
25
24
 
26
25
  for i, model in enumerate(ms.System.read_pdb(path_in).models):
27
26
  path_out = folder_out / f"{path_in.stem}.m{i:03}.pdb"
@@ -32,7 +31,7 @@ class Extract(mu.AppSubcommand):
32
31
  # --------------------------------------------------------------------------
33
32
  def app_extract_chains(self):
34
33
  path_in, folder_out = self._io_filein_dirout()
35
- first_only = self.main.get_arg_bool("first_only")
34
+ first_only = self.main.arg_toggle("first_only")
36
35
 
37
36
  system = ms.System.read_pdb(path_in)
38
37
  chain_ids = mu.List.chains(system, do_sort = False)
@@ -46,7 +45,7 @@ class Extract(mu.AppSubcommand):
46
45
  # --------------------------------------------------------------------------
47
46
  def app_extract_residue(self):
48
47
  path_in, folder_out = self._io_filein_dirout()
49
- residue_dotstr = self.main.get_arg_str("residue")
48
+ residue_dotstr = self.main.arg_str("residue")
50
49
 
51
50
  pdb = ms.System.read_pdb(path_in)
52
51
  chres = ms.ChainResid.from_dotstr(residue_dotstr)
@@ -57,11 +56,9 @@ class Extract(mu.AppSubcommand):
57
56
  # --------------------------------------------------------------------------
58
57
  def app_extract_frames(self):
59
58
  path_struct, folder_out = self._io_filein_dirout(key_in = "path_struct")
60
- path_traj = self.main.get_arg_path("path_traj",
61
- assertion = fy.PathAssertion.FILE_IN, allow_none = True
62
- )
63
- frames = self.main.get_arg_int("frames", is_list = True)
64
- unpack = self.main.get_arg_bool("unpack")
59
+ path_traj = self.main.arg_path("path_traj", assertion = fy.PathAssertion.FILE_IN)
60
+ frames = self.main.arg_int_list("frames")
61
+ unpack = self.main.arg_toggle("unpack")
65
62
  mu.Extract.frames(path_struct, path_traj, folder_out, frames, unpack)
66
63
 
67
64
 
@@ -72,10 +69,7 @@ class Extract(mu.AppSubcommand):
72
69
  frames: list[int] = None, unpack: bool = False
73
70
  ) -> None:
74
71
  """Note: This method directly saves the specified frames instead of returning them."""
75
- import MDAnalysis as mda
76
-
77
- args_traj = [str(path_traj)] if path_traj is not None else []
78
- u = mda.Universe(str(path_struct), *args_traj)
72
+ u = mu.MDAUtils.create_universe_quiet(path_struct, path_traj)
79
73
 
80
74
  if frames is not None and len(frames) == 1:
81
75
  unpack = True
@@ -101,8 +95,8 @@ class Extract(mu.AppSubcommand):
101
95
 
102
96
  # --------------------------------------------------------------------------
103
97
  def _io_filein_dirout(self, key_in = "path_in") -> tuple[Path, Path]:
104
- path_in = self.main.get_arg_path(key_in, assertion = fy.PathAssertion.FILE_IN)
105
- folder_out = self.main.get_arg_path("folder_out",
98
+ path_in = self.main.arg_path(key_in, assertion = fy.PathAssertion.FILE_IN)
99
+ folder_out = self.main.arg_path("folder_out",
106
100
  default = path_in.parent, assertion = fy.PathAssertion.DIR_OUT
107
101
  )
108
102
  return path_in, folder_out
@@ -1,5 +1,3 @@
1
- from pathlib import Path
2
-
3
1
  import molsimple as ms
4
2
  import freyacli as fy
5
3
  import molutils as mu
@@ -10,7 +8,7 @@ class List(mu.AppSubcommand):
10
8
  def run(self):
11
9
  command = self.main.subcommands.pop(0)
12
10
 
13
- if command == "chains": return self.app_list_chains()
11
+ if command == "chains" : return self.app_list_chains()
14
12
  if command == "residues": return self.app_list_residues()
15
13
 
16
14
  raise ValueError(f"Unknown command: {command}")
@@ -18,13 +16,13 @@ class List(mu.AppSubcommand):
18
16
 
19
17
  # --------------------------------------------------------------------------
20
18
  def app_list_chains(self):
21
- path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
19
+ path_in = self.main.arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
22
20
  print(*mu.List.chains(ms.System.read_pdb(path_in), do_sort = True))
23
21
 
24
22
 
25
23
  # --------------------------------------------------------------------------
26
24
  def app_list_residues(self):
27
- path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
25
+ path_in = self.main.arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
28
26
  print(*mu.List.residues(ms.System.read_pdb(path_in), do_sort = True))
29
27
 
30
28
 
@@ -10,15 +10,15 @@ class Remove(mu.AppSubcommand):
10
10
  def run(self):
11
11
  command = self.main.subcommands.pop(0)
12
12
 
13
- if command == "altlocs" : return self.app_remove_altlocs()
13
+ if command == "altlocs": return self.app_remove_altlocs()
14
14
 
15
15
  raise ValueError(f"Unknown command: {command}")
16
16
 
17
17
 
18
18
  # --------------------------------------------------------------------------
19
19
  def app_remove_altlocs(self):
20
- path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
21
- path_out = self.main.get_arg_path("path_out", assertion = fy.PathAssertion.FILE_OUT)
20
+ path_in = self.main.arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
21
+ path_out = self.main.arg_path("path_out", assertion = fy.PathAssertion.FILE_OUT)
22
22
  mu.Remove.altlocs(path_in).save(path_out)
23
23
 
24
24
 
@@ -0,0 +1,78 @@
1
+ from pathlib import Path
2
+
3
+ import freyacli as fy
4
+ import molutils as mu
5
+
6
+ # //////////////////////////////////////////////////////////////////////////////
7
+ class Traj(mu.AppSubcommand):
8
+ # -------------------------------------------------------------------------- UI SECTION
9
+ def run(self):
10
+ command = self.main.subcommands.pop(0)
11
+
12
+ if command == "align": return self.app_traj_align()
13
+ if command == "rmsd" : return self.app_traj_rmsd()
14
+
15
+ raise ValueError(f"Unknown command: {command}")
16
+
17
+
18
+ # --------------------------------------------------------------------------
19
+ def app_traj_align(self):
20
+ path_struct = self.main.arg_path("path_struct", assertion = fy.PathAssertion.FILE_IN)
21
+ path_traj = self.main.arg_path("path_traj", assertion = fy.PathAssertion.FILE_IN)
22
+ path_ref = self.main.arg_path("path_ref",
23
+ default = path_struct, assertion = fy.PathAssertion.FILE_IN
24
+ )
25
+ path_out = self.main.arg_path("path_out",
26
+ default = path_struct.with_suffix(".align.xtc"), assertion = fy.PathAssertion.FILE_OUT
27
+ )
28
+ selection = self.main.arg_str("selection")
29
+
30
+ mu.Traj.align(path_struct, path_traj, path_ref, path_out, selection)
31
+
32
+
33
+ # --------------------------------------------------------------------------
34
+ def app_traj_rmsd(self):
35
+ path_struct = self.main.arg_path("path_struct", assertion = fy.PathAssertion.FILE_IN)
36
+ path_traj = self.main.arg_path("path_traj", assertion = fy.PathAssertion.FILE_IN)
37
+ path_ref = self.main.arg_path("path_ref",
38
+ default = path_struct, assertion = fy.PathAssertion.FILE_IN
39
+ )
40
+ selection = self.main.arg_str("selection")
41
+
42
+ print(*mu.Traj.rmsd(path_struct, path_traj, path_ref, selection))
43
+
44
+
45
+ # -------------------------------------------------------------------------- LOGIC SECTION
46
+ @classmethod
47
+ def align(cls,
48
+ path_struct: Path, path_traj: Path | None,
49
+ path_ref: Path, path_out: Path,
50
+ selection: str
51
+ ) -> None:
52
+ """Note: This method directly saves the aligned trajectory instead of returning it."""
53
+ u_to_align = mu.MDAUtils.create_universe_quiet(path_struct, path_traj)
54
+ u_ref = mu.MDAUtils.create_universe_quiet(path_ref)
55
+
56
+ from MDAnalysis.analysis import align
57
+ align.AlignTraj(
58
+ u_to_align, u_ref, select = selection,
59
+ filename = str(path_out), match_atoms = False,
60
+ ).run()
61
+
62
+
63
+ # --------------------------------------------------------------------------
64
+ @classmethod
65
+ def rmsd(cls,
66
+ path_struct: Path, path_traj: Path | None,
67
+ path_ref: Path, selection: str
68
+ ) -> list[float]:
69
+ u_for_rmsd = mu.MDAUtils.create_universe_quiet(path_struct, path_traj)
70
+ u_ref = mu.MDAUtils.create_universe_quiet(path_ref)
71
+
72
+ from MDAnalysis.analysis import rms
73
+ rmsd = rms.RMSD(u_for_rmsd, u_ref, select = selection).run() # shape (n_frames, 3)
74
+ idxs_frame, timesteps, arr_rmsd = rmsd.results.rmsd.T # shape (3, n_frames)
75
+ return [float(r) for r in arr_rmsd] # ensure it's a "normal" float e.g. json serializable
76
+
77
+
78
+ # //////////////////////////////////////////////////////////////////////////////
@@ -27,6 +27,7 @@ class AppMain(fy.App):
27
27
  if command == "count" : return mu.Count(self).run()
28
28
  if command == "extract": return mu.Extract(self).run()
29
29
  if command == "remove" : return mu.Remove(self).run()
30
+ if command == "traj" : return mu.Traj(self).run()
30
31
  if command == "select" : return self._run_select()
31
32
  if command == "merge" : return self._run_merge()
32
33
  raise ValueError(f"Unknown command: {command}")
@@ -34,27 +35,24 @@ class AppMain(fy.App):
34
35
 
35
36
  # --------------------------------------------------------------------------
36
37
  def _run_select(self):
37
- query = self.get_arg_str("query")
38
- path_in = self.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
39
- path_out = self.get_arg_path("path_out", assertion = fy.PathAssertion.FILE_OUT)
40
- paths_traj = self.get_arg_path("paths_traj", assertion = fy.PathAssertion.FILE_OUT,
41
- allow_none = True, is_list = True
42
- )
38
+ query = self.arg_str("query")
39
+ path_in = self.arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
40
+ path_out = self.arg_path("path_out", assertion = fy.PathAssertion.FILE_OUT)
41
+ paths_traj = self.arg_path_list("paths_traj", assertion = fy.PathAssertion.FILE_OUT)
43
42
 
44
- import MDAnalysis as mda
45
- mda.Universe(path_in).select_atoms(query).write(path_out)
43
+ mu.MDAUtils.create_universe_quiet(path_in).select_atoms(query).write(path_out)
46
44
 
47
- if paths_traj == [None]: return
45
+ if not paths_traj: return
48
46
 
49
47
  path_traj_in, path_traj_out = paths_traj
50
- u = mda.Universe(path_in, path_traj_in)
48
+ u = mu.MDAUtils.create_universe_quiet(path_in, path_traj_in)
51
49
  u.select_atoms(query).write(str(path_traj_out), frames = "all")
52
50
 
53
51
 
54
52
  # --------------------------------------------------------------------------
55
53
  def _run_merge(self):
56
- paths_in = self.get_arg_path("paths_in", assertion = fy.PathAssertion.FILE_IN, is_list = True)
57
- path_out = self.get_arg_path("path_out", assertion = fy.PathAssertion.FILE_OUT)
54
+ paths_in = self.arg_path_list("paths_in", assertion = fy.PathAssertion.FILE_IN)
55
+ path_out = self.arg_path("path_out", assertion = fy.PathAssertion.FILE_OUT)
58
56
  pgroups = (ms.System.read_pdb(path_in).particles for path_in in paths_in)
59
57
  ms.ParticleGroup((p for pgroup in pgroups for p in pgroup)).save(path_out)
60
58
 
@@ -20,10 +20,17 @@
20
20
  !@
21
21
  @chains
22
22
  !fyh:_ Counts the number of chains in a PDB file.
23
+ Considers only the first model of the molecular system.
23
24
  !fyh:path_in Path of a PDB file.
24
25
  !@
25
26
  @residues
26
27
  !fyh:_ Counts the number of residues in a PDB file in the format "chainid.resid".
28
+ Considers only the first model of the molecular system.
29
+ !fyh:path_in Path of a PDB file.
30
+ !@
31
+ @particles
32
+ !fyh:_ Counts the number of particles in a PDB file in the format "chainid.resid".
33
+ Considers only the first model of the molecular system.
27
34
  !fyh:path_in Path of a PDB file.
28
35
  !@
29
36
  @frames
@@ -45,12 +52,12 @@
45
52
  @extract
46
53
  !fyh:_ Extract specific sections of data from biomolecular structures.
47
54
  @models
48
- !fyh:_ Extracts the models in a PDB file into separate files.
55
+ !fyh:_ Extract the models in a PDB file into separate files.
49
56
  !use:_io_filein_dirout
50
57
  !fyh:first_only Use this flag for extracting only the first model of the structure and disregard the rest.
51
58
  !@
52
59
  @chains
53
- !fyh:_ Extracts the chains in a PDB file into separate files.
60
+ !fyh:_ Extract the chains in a PDB file into separate files.
54
61
  !use:_io_filein_dirout
55
62
  !fyh:first_only Use this flag for extracting only the first chain of the structure and disregard the rest.
56
63
  !@
@@ -62,10 +69,9 @@
62
69
  @frames
63
70
  !fyh:_ Extract specific frames from a PDB file into separate file(s).
64
71
  Requires MDAnalysis.
65
- !fyh:path_struct Path of the structure file (e.g. PDB file). Can be anything supported by MDanalysis.
66
- If the file also contains the trajectory data (e.g. XYZ file), then "path_traj" can be ommitted.
72
+ !use:mda_struct
67
73
  In this case, an additional structure file (a copy of the first frame) may be exported for convenience.
68
- !fyh:path_traj Path of the trajectory file (e.g. XTC file). Can be anything supported by MDanalysis.
74
+ !use:mda_traj
69
75
  !fyh:folder_out Path of the directory where to place the unpacked structure(s).
70
76
  If not provided, the parent directory of the input PDB file will be used.
71
77
  !fyh:frames Frame indices to extract. If no frames are specified, all frames are extracted.
@@ -75,9 +81,37 @@
75
81
  !@
76
82
  !@
77
83
 
84
+ @remove
85
+ !fyh:_ Remove undesired data from a PDB file.
86
+ @altlocs
87
+ !fyh:_ Keep only the atoms without altloc tags or the first instance encountered of an altloc (usually marked as 'A').
88
+ !fyh:path_in Path of a PDB file.
89
+ !fyh:path_out Path for the output PDB file.
90
+ !@
91
+ !@
92
+
93
+ @traj
94
+ !fyh:_ Common operations related to analysis of trajectories.
95
+ @align
96
+ !fyh:_ Align a trajectory according to its RMSD values against some reference structure. Requires MDAnalysis.
97
+ !use:mda_struct
98
+ !use:mda_traj
99
+ !fyh:path_ref Path of the reference file (e.g. PDB file). Can be anything supported by MDanalysis. If not provided, the first frame of the input trajectory is considered.
100
+ !fyh:path_out Path for the output algined trajectory file (e.g. XTC file). Can be anything supported by MDanalysis.
101
+ !fyh:selection Atom selection query for performing the RMSD. Must follow MDAnalysis format.
102
+ !@
103
+ @rmsd
104
+ !fyh:_ Calculate the RMSD values of a trajectory against some reference structure. Requires MDAnalysis.
105
+ !use:mda_struct
106
+ !use:mda_traj
107
+ !fyh:path_ref Path of the reference file (e.g. PDB file). Can be anything supported by MDanalysis. If not provided, the first frame of the input trajectory is considered.
108
+ !fyh:selection Atom selection query for performing the RMSD. Must follow MDAnalysis format.
109
+ !@
110
+ !@
111
+
78
112
  @select
79
113
  !fyh:_ Select specific atoms with a custom query (MDAnalysis format) and save them into a file. Requires MDAnalysis.
80
- !fyh:query Query for selecting the atoms of interest. Must follow MDAnalysis format
114
+ !fyh:query Query for selecting the atoms of interest. Must follow MDAnalysis format.
81
115
  !fyh:path_in Path of the structure file whose atoms will be selected. Can be anything supported by MDanalysis.
82
116
  !fyh:path_out Path for the output selected atoms. Can be anything supported by MDanalysis.
83
117
  !fyh:paths_traj Input and output paths for an optional trajectory.
@@ -96,3 +130,10 @@
96
130
  !fyh:folder_out Path of the directory where to place the unpacked structure(s).
97
131
  If not provided, the parent directory of the input PDB file will be used.
98
132
  !fed
133
+ !def mda_struct
134
+ !fyh:path_struct Path of the structure file (e.g. PDB file). Can be anything supported by MDanalysis.
135
+ If the file also contains the trajectory data (e.g. XYZ file), then "path_traj" can be ommitted.
136
+ !fed
137
+ !def mda_traj
138
+ !fyh:path_traj Path of the trajectory file (e.g. XTC file). Can be anything supported by MDanalysis.
139
+ !fed
@@ -17,6 +17,9 @@
17
17
  @residues
18
18
  path_in[]1.PATH
19
19
  !@
20
+ @particles
21
+ path_in[]1.PATH
22
+ !@
20
23
  @frames
21
24
  path_struct[]1.PATH
22
25
  ~path_traj[]1.PATH
@@ -56,6 +59,22 @@
56
59
  !@
57
60
  !@
58
61
 
62
+ @traj
63
+ @align
64
+ path_struct[]1.PATH
65
+ ~path_traj[]1.PATH
66
+ ~path_ref[r,ref]1.PATH
67
+ ~path_out[o,out]1.PATH
68
+ ~selection[s,sel]1.STR=all
69
+ !@
70
+ @rmsd
71
+ path_struct[]1.PATH
72
+ ~path_traj[]1.PATH
73
+ ~path_ref[r,ref]1.PATH
74
+ ~selection[s,sel]1.STR=all
75
+ !@
76
+ !@
77
+
59
78
  @select
60
79
  query[]1.STR
61
80
  path_in[]1.PATH
File without changes
@@ -0,0 +1,31 @@
1
+ from pathlib import Path
2
+
3
+ # //////////////////////////////////////////////////////////////////////////////
4
+ class MDAUtils:
5
+ # --------------------------------------------------------------------------
6
+ @staticmethod
7
+ def create_universe_quiet(path_struct: Path, path_traj: Path|None = None):
8
+ import io
9
+ import logging
10
+ import warnings
11
+ import MDAnalysis as mda
12
+ from contextlib import redirect_stdout, redirect_stderr
13
+
14
+ warnings.filterwarnings("ignore", module = "MDAnalysis")
15
+
16
+ buf = io.StringIO()
17
+ logger = logging.getLogger("MDAnalysis")
18
+ old_level = logger.getEffectiveLevel()
19
+ try:
20
+ logger.setLevel(logging.ERROR)
21
+ with warnings.catch_warnings():
22
+ warnings.simplefilter("ignore")
23
+ with redirect_stdout(buf), redirect_stderr(buf):
24
+ args_traj = [str(path_traj)] if path_traj is not None else []
25
+ u = mda.Universe(str(path_struct), *args_traj)
26
+ finally:
27
+ logger.setLevel(old_level)
28
+ return u
29
+
30
+
31
+ # //////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1 @@
1
+ __version__ = "0.7.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: molutils
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Collection of tools for preprocessing or summarizing details from biomolecular structure files.
5
5
  Home-page: https://github.com/diegobarmor/molutils
6
6
  Author: DiegoBarMor
@@ -13,7 +13,7 @@ Requires-Python: >=3.10
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE.md
15
15
  Requires-Dist: molsimple==0.1.2
16
- Requires-Dist: freyacli==0.4.5
16
+ Requires-Dist: freyacli==0.5.0
17
17
  Dynamic: author
18
18
  Dynamic: author-email
19
19
  Dynamic: classifier
@@ -16,8 +16,11 @@ molutils/_core/count.py
16
16
  molutils/_core/extract.py
17
17
  molutils/_core/list_.py
18
18
  molutils/_core/remove.py
19
+ molutils/_core/traj.py
19
20
  molutils/_ui/__init__.py
20
21
  molutils/_ui/app_main.py
21
22
  molutils/_ui/app_subcommand.py
22
23
  molutils/_ui/fy_help.fyh
23
- molutils/_ui/fy_rules.fyr
24
+ molutils/_ui/fy_rules.fyr
25
+ molutils/_utils/__init__.py
26
+ molutils/_utils/mda_utils.py
@@ -1,2 +1,2 @@
1
1
  molsimple==0.1.2
2
- freyacli==0.4.5
2
+ freyacli==0.5.0
@@ -23,7 +23,7 @@ setup(
23
23
  },
24
24
  install_requires=[
25
25
  "molsimple==0.1.2",
26
- "freyacli==0.4.5",
26
+ "freyacli==0.5.0",
27
27
  ],
28
28
  entry_points={
29
29
  "console_scripts": [
@@ -1 +0,0 @@
1
- __version__ = "0.6.0"
File without changes
File without changes
File without changes
File without changes
File without changes