molutils 0.4.0__tar.gz → 0.5.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.
- {molutils-0.4.0 → molutils-0.5.0}/PKG-INFO +2 -2
- {molutils-0.4.0 → molutils-0.5.0}/molutils/__init__.py +1 -0
- molutils-0.5.0/molutils/_core/count.py +104 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils/_core/extract.py +50 -3
- {molutils-0.4.0 → molutils-0.5.0}/molutils/_core/list_.py +7 -5
- molutils-0.5.0/molutils/_core/remove.py +47 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils/_parsers/parser_pdb.py +25 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils/_ui/app_main.py +1 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils/_ui/fy_help.fyh +36 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils/_ui/fy_rules.fyr +27 -0
- molutils-0.5.0/molutils/_version.py +1 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils.egg-info/PKG-INFO +2 -2
- {molutils-0.4.0 → molutils-0.5.0}/molutils.egg-info/SOURCES.txt +1 -0
- molutils-0.5.0/molutils.egg-info/requires.txt +1 -0
- {molutils-0.4.0 → molutils-0.5.0}/setup.py +1 -1
- molutils-0.4.0/molutils/_core/count.py +0 -38
- molutils-0.4.0/molutils/_version.py +0 -1
- molutils-0.4.0/molutils.egg-info/requires.txt +0 -1
- {molutils-0.4.0 → molutils-0.5.0}/LICENSE.md +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/README.md +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils/__main__.py +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils/_core/__init__.py +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils/_parsers/__init__.py +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils/_parsers/chain_resid.py +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils/_ui/__init__.py +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils/_ui/app_subcommand.py +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils.egg-info/dependency_links.txt +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils.egg-info/entry_points.txt +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/molutils.egg-info/top_level.txt +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/pyproject.toml +0 -0
- {molutils-0.4.0 → molutils-0.5.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: molutils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.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
|
|
@@ -12,7 +12,7 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Requires-Python: >=3.10
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE.md
|
|
15
|
-
Requires-Dist: freyacli==0.4.
|
|
15
|
+
Requires-Dist: freyacli==0.4.1
|
|
16
16
|
Dynamic: author
|
|
17
17
|
Dynamic: author-email
|
|
18
18
|
Dynamic: classifier
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import freyacli as fy
|
|
4
|
+
import molutils as mu
|
|
5
|
+
|
|
6
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
7
|
+
class Count(mu.AppSubcommand):
|
|
8
|
+
# -------------------------------------------------------------------------- UI SECTION
|
|
9
|
+
def run(self):
|
|
10
|
+
command = self.main.subcommands.pop(0)
|
|
11
|
+
|
|
12
|
+
if command == "models" : return self.app_count_models()
|
|
13
|
+
if command == "chains" : return self.app_count_chains()
|
|
14
|
+
if command == "residues": return self.app_count_residues()
|
|
15
|
+
if command == "frames" : return self.app_count_frames()
|
|
16
|
+
if command == "altlocs" : return self.app_count_altlocs()
|
|
17
|
+
|
|
18
|
+
raise ValueError(f"Unknown command: {command}")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# --------------------------------------------------------------------------
|
|
22
|
+
def app_count_models(self):
|
|
23
|
+
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
24
|
+
print(mu.Count.models(path_in))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# --------------------------------------------------------------------------
|
|
28
|
+
def app_count_chains(self):
|
|
29
|
+
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
30
|
+
print(len(mu.List.chains(path_in, do_sort = False)))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# --------------------------------------------------------------------------
|
|
34
|
+
def app_count_residues(self):
|
|
35
|
+
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
36
|
+
print(len(mu.List.residues(path_in, do_sort = False)))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# --------------------------------------------------------------------------
|
|
40
|
+
def app_count_frames(self):
|
|
41
|
+
path_struct = self.main.get_arg_path("path_struct", assertion = fy.PathAssertion.FILE_IN)
|
|
42
|
+
path_traj = self.main.get_arg_path("path_traj",
|
|
43
|
+
assertion = fy.PathAssertion.FILE_IN, allow_none = True
|
|
44
|
+
)
|
|
45
|
+
nframes_valid, nframes_expected = mu.Count.frames(path_struct, path_traj)
|
|
46
|
+
print(f"{nframes_valid}/{nframes_expected}")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# --------------------------------------------------------------------------
|
|
50
|
+
def app_count_altlocs(self):
|
|
51
|
+
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
52
|
+
print(mu.Count.altlocs(path_in))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# -------------------------------------------------------------------------- LOGIC SECTION
|
|
56
|
+
@classmethod
|
|
57
|
+
def models(cls, path_pdb: Path) -> int:
|
|
58
|
+
data = path_pdb.read_text()
|
|
59
|
+
return max(1, cls._count_substring('\n'+data, "\nMODEL"))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# --------------------------------------------------------------------------
|
|
63
|
+
@classmethod
|
|
64
|
+
def frames(cls, path_struct: Path, path_traj: Path | None) -> tuple[int, int]:
|
|
65
|
+
import MDAnalysis as mda
|
|
66
|
+
args_traj = [str(path_traj)] if path_traj is not None else []
|
|
67
|
+
u = mda.Universe(str(path_struct), *args_traj)
|
|
68
|
+
|
|
69
|
+
nframes_expected = u.trajectory.n_frames
|
|
70
|
+
nframes_valid = sum(1 for _ in u.trajectory)
|
|
71
|
+
return nframes_valid, nframes_expected
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# --------------------------------------------------------------------------
|
|
75
|
+
@classmethod
|
|
76
|
+
def altlocs(cls, path_pdb: Path) -> int:
|
|
77
|
+
atoms: dict[str, str] = {}
|
|
78
|
+
pdb = mu.ParserPDB.from_file(path_pdb)
|
|
79
|
+
|
|
80
|
+
### [TODO] adapt for extracting first altloc
|
|
81
|
+
for line in pdb.iter_atoms():
|
|
82
|
+
altloc = mu.ParserPDB.get_altloc(line)
|
|
83
|
+
if altloc == " ": continue
|
|
84
|
+
|
|
85
|
+
resid = mu.ChainResid.from_pdb(line).get_dotstr()
|
|
86
|
+
name = mu.ParserPDB.get_atomname(line)
|
|
87
|
+
|
|
88
|
+
key = f"{resid}.{name}"
|
|
89
|
+
if key in atoms: continue
|
|
90
|
+
|
|
91
|
+
atoms[key] = line
|
|
92
|
+
|
|
93
|
+
return len(atoms)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# --------------------------------------------------------------------------
|
|
97
|
+
@staticmethod
|
|
98
|
+
def _count_substring(string: str, substring: str) -> int:
|
|
99
|
+
"""Counts the number of occurrences of `substring` in `string`."""
|
|
100
|
+
replaced = string.replace(substring, "")
|
|
101
|
+
return (len(string) - len(replaced)) // len(substring)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from pathlib import Path
|
|
1
2
|
from collections import defaultdict
|
|
2
3
|
|
|
3
4
|
import freyacli as fy
|
|
@@ -12,6 +13,7 @@ class Extract(mu.AppSubcommand):
|
|
|
12
13
|
if command == "models" : return self.app_extract_models()
|
|
13
14
|
if command == "chains" : return self.app_extract_chains()
|
|
14
15
|
if command == "residue": return self.app_extract_residue()
|
|
16
|
+
if command == "frames" : return self.app_extract_frames()
|
|
15
17
|
|
|
16
18
|
raise ValueError(f"Unknown command: {command}")
|
|
17
19
|
|
|
@@ -59,6 +61,17 @@ class Extract(mu.AppSubcommand):
|
|
|
59
61
|
path_out.write_text(extracted)
|
|
60
62
|
|
|
61
63
|
|
|
64
|
+
# --------------------------------------------------------------------------
|
|
65
|
+
def app_extract_frames(self):
|
|
66
|
+
path_struct, folder_out = self._io_filein_dirout(key_in = "path_struct")
|
|
67
|
+
path_traj = self.main.get_arg_path("path_traj",
|
|
68
|
+
assertion = fy.PathAssertion.FILE_IN, allow_none = True
|
|
69
|
+
)
|
|
70
|
+
frames = self.main.get_arg_int("frames", is_list = True)
|
|
71
|
+
unpack = self.main.get_arg_bool("unpack")
|
|
72
|
+
mu.Extract.frames(path_struct, path_traj, folder_out, frames, unpack)
|
|
73
|
+
|
|
74
|
+
|
|
62
75
|
# -------------------------------------------------------------------------- LOGIC SECTION
|
|
63
76
|
@classmethod
|
|
64
77
|
def next_model(cls, data: str, start: int = 0) -> tuple[int, str]:
|
|
@@ -98,7 +111,7 @@ class Extract(mu.AppSubcommand):
|
|
|
98
111
|
|
|
99
112
|
# --------------------------------------------------------------------------
|
|
100
113
|
@classmethod
|
|
101
|
-
def residue(cls, data: str, resid: str, chain: str = None):
|
|
114
|
+
def residue(cls, data: str, resid: str, chain: str = None) -> str:
|
|
102
115
|
pdb = mu.ParserPDB(data)
|
|
103
116
|
gen_residue = (
|
|
104
117
|
line for line in pdb.iter_atoms()
|
|
@@ -112,8 +125,42 @@ class Extract(mu.AppSubcommand):
|
|
|
112
125
|
|
|
113
126
|
|
|
114
127
|
# --------------------------------------------------------------------------
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
@classmethod
|
|
129
|
+
def frames(cls,
|
|
130
|
+
path_struct: Path, path_traj: Path | None, folder_out: Path,
|
|
131
|
+
frames: list[int] = None, unpack: bool = False
|
|
132
|
+
) -> None:
|
|
133
|
+
"""Note: This method directly saves the specified frames instead of returning them."""
|
|
134
|
+
import MDAnalysis as mda
|
|
135
|
+
|
|
136
|
+
args_traj = [str(path_traj)] if path_traj is not None else []
|
|
137
|
+
u = mda.Universe(str(path_struct), *args_traj)
|
|
138
|
+
|
|
139
|
+
if frames is not None and len(frames) == 1:
|
|
140
|
+
unpack = True
|
|
141
|
+
|
|
142
|
+
if unpack:
|
|
143
|
+
if frames is None: frames = range(u.trajectory.n_frames)
|
|
144
|
+
for frame in frames:
|
|
145
|
+
u.trajectory[frame]
|
|
146
|
+
path_pdb_out = folder_out / f"{path_struct.stem}.{frame:04}.pdb"
|
|
147
|
+
u.atoms.write(str(path_pdb_out))
|
|
148
|
+
return
|
|
149
|
+
|
|
150
|
+
if path_traj is None:
|
|
151
|
+
### save a struct file separately, useful when the input file
|
|
152
|
+
### had both the struct and traj data inside (e.g. XYZ)
|
|
153
|
+
path_pdb_out = folder_out / f"{path_struct.stem}.sliced.pdb"
|
|
154
|
+
u.atoms.write(str(path_pdb_out))
|
|
155
|
+
|
|
156
|
+
path_xtc_out = folder_out / f"{path_struct.stem}.sliced.xtc"
|
|
157
|
+
u.atoms.write(str(path_xtc_out), frames = "all" if frames is None else frames)
|
|
158
|
+
return
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
# --------------------------------------------------------------------------
|
|
162
|
+
def _io_filein_dirout(self, key_in = "path_in") -> tuple[Path, Path]:
|
|
163
|
+
path_in = self.main.get_arg_path(key_in, assertion = fy.PathAssertion.FILE_IN)
|
|
117
164
|
folder_out = self.main.get_arg_path("folder_out",
|
|
118
165
|
default = path_in.parent, assertion = fy.PathAssertion.DIR_OUT
|
|
119
166
|
)
|
|
@@ -19,7 +19,7 @@ class List(mu.AppSubcommand):
|
|
|
19
19
|
def app_list_chains(self):
|
|
20
20
|
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
21
21
|
first_only = self.main.get_arg_bool("first_only")
|
|
22
|
-
print(*mu.List.chains(path_in, first_only))
|
|
22
|
+
print(*mu.List.chains(path_in, first_only = first_only))
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
# --------------------------------------------------------------------------
|
|
@@ -30,20 +30,22 @@ class List(mu.AppSubcommand):
|
|
|
30
30
|
|
|
31
31
|
# -------------------------------------------------------------------------- LOGIC SECTION
|
|
32
32
|
@classmethod
|
|
33
|
-
def chains(cls, path_pdb: Path, first_only: bool = False) -> list[str]:
|
|
33
|
+
def chains(cls, path_pdb: Path, do_sort: bool = True, first_only: bool = False) -> list[str]:
|
|
34
34
|
pdb = mu.ParserPDB.from_file(path_pdb)
|
|
35
35
|
gen_chain_ids = (mu.ParserPDB.get_chainid(line) for line in pdb.iter_atoms())
|
|
36
36
|
if first_only: return mu.ParserPDB.safe_next(gen_chain_ids)
|
|
37
|
-
return sorted(set(gen_chain_ids))
|
|
37
|
+
if do_sort: return sorted(set(gen_chain_ids))
|
|
38
|
+
return list(set(gen_chain_ids))
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
# --------------------------------------------------------------------------
|
|
41
42
|
@classmethod
|
|
42
|
-
def residues(cls, path_pdb: Path) -> list[str]:
|
|
43
|
+
def residues(cls, path_pdb: Path, do_sort: bool = True) -> list[str]:
|
|
43
44
|
"""Returns list of unique residue identifiers in the format "chainid.resid"."""
|
|
44
45
|
pdb = mu.ParserPDB.from_file(path_pdb)
|
|
45
46
|
gen_residues = (mu.ChainResid.from_pdb(line).get_dotstr() for line in pdb.iter_atoms())
|
|
46
|
-
return sorted(set(gen_residues))
|
|
47
|
+
if do_sort: return sorted(set(gen_residues))
|
|
48
|
+
return list(set(gen_residues))
|
|
47
49
|
|
|
48
50
|
|
|
49
51
|
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import freyacli as fy
|
|
2
|
+
import molutils as mu
|
|
3
|
+
|
|
4
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
class Remove(mu.AppSubcommand):
|
|
6
|
+
# -------------------------------------------------------------------------- UI SECTION
|
|
7
|
+
def run(self):
|
|
8
|
+
command = self.main.subcommands.pop(0)
|
|
9
|
+
|
|
10
|
+
if command == "altlocs" : return self.app_remove_altlocs()
|
|
11
|
+
|
|
12
|
+
raise ValueError(f"Unknown command: {command}")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# --------------------------------------------------------------------------
|
|
16
|
+
def app_remove_altlocs(self):
|
|
17
|
+
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
18
|
+
path_out = self.main.get_arg_path("path_out", assertion = fy.PathAssertion.FILE_OUT)
|
|
19
|
+
out = mu.Remove.altlocs(path_in.read_text())
|
|
20
|
+
path_out.write_text(out)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# --------------------------------------------------------------------------
|
|
24
|
+
@classmethod
|
|
25
|
+
def altlocs(cls, data: str) -> str:
|
|
26
|
+
pdb = mu.ParserPDB(data)
|
|
27
|
+
|
|
28
|
+
out = []
|
|
29
|
+
seen_altlocs = set()
|
|
30
|
+
for line in pdb.iter_atoms():
|
|
31
|
+
altloc = mu.ParserPDB.get_altloc(line)
|
|
32
|
+
if altloc == " ":
|
|
33
|
+
out.append(line)
|
|
34
|
+
continue
|
|
35
|
+
|
|
36
|
+
resid = mu.ChainResid.from_pdb(line).get_dotstr()
|
|
37
|
+
name = mu.ParserPDB.get_atomname(line)
|
|
38
|
+
key = (resid, name)
|
|
39
|
+
if key in seen_altlocs: continue
|
|
40
|
+
|
|
41
|
+
seen_altlocs.add(key)
|
|
42
|
+
out.append(mu.ParserPDB.set_altloc(line, " "))
|
|
43
|
+
|
|
44
|
+
return mu.ParserPDB.join_lines(out)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -3,6 +3,9 @@ from pathlib import Path
|
|
|
3
3
|
# //////////////////////////////////////////////////////////////////////////////
|
|
4
4
|
class ParserPDB:
|
|
5
5
|
LENGTH_RECORD = 80
|
|
6
|
+
IDX0_ATOMNAME = 12
|
|
7
|
+
IDX1_ATOMNAME = 16
|
|
8
|
+
IDX_ALTLOC = 16
|
|
6
9
|
IDX_CHAIN_ID = 21
|
|
7
10
|
IDX0_RESID = 22
|
|
8
11
|
IDX1_RESID = 26
|
|
@@ -39,6 +42,13 @@ class ParserPDB:
|
|
|
39
42
|
except StopIteration: raise ValueError(f"No ATOM records found in PDB file")
|
|
40
43
|
|
|
41
44
|
|
|
45
|
+
# --------------------------------------------------------------------------
|
|
46
|
+
@classmethod
|
|
47
|
+
def get_atomname(cls, line: str) -> str:
|
|
48
|
+
try: return line[cls.IDX0_ATOMNAME:cls.IDX1_ATOMNAME].strip()
|
|
49
|
+
except IndexError: raise ValueError(f"Unexpected format of ATOM records in PDB file")
|
|
50
|
+
|
|
51
|
+
|
|
42
52
|
# --------------------------------------------------------------------------
|
|
43
53
|
@classmethod
|
|
44
54
|
def get_chainid(cls, line: str) -> str:
|
|
@@ -52,4 +62,19 @@ class ParserPDB:
|
|
|
52
62
|
return line[cls.IDX0_RESID:cls.IDX1_RESID].strip()
|
|
53
63
|
|
|
54
64
|
|
|
65
|
+
# --------------------------------------------------------------------------
|
|
66
|
+
@classmethod
|
|
67
|
+
def get_altloc(cls, line: str) -> str:
|
|
68
|
+
try: return line[cls.IDX_ALTLOC]
|
|
69
|
+
except IndexError: raise ValueError(f"Unexpected format of ATOM records in PDB file")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# --------------------------------------------------------------------------
|
|
73
|
+
@classmethod
|
|
74
|
+
def set_altloc(cls, line: str, altloc: str) -> str:
|
|
75
|
+
if len(altloc) != 1: raise ValueError(f"altloc must be a single character")
|
|
76
|
+
try: return line[:cls.IDX_ALTLOC] + altloc + line[cls.IDX_ALTLOC+1:]
|
|
77
|
+
except IndexError: raise ValueError(f"Unexpected format of ATOM records in PDB file")
|
|
78
|
+
|
|
79
|
+
|
|
55
80
|
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -25,6 +25,7 @@ class AppMain(fy.App):
|
|
|
25
25
|
if command == "list" : return mu.List(self).run()
|
|
26
26
|
if command == "count" : return mu.Count(self).run()
|
|
27
27
|
if command == "extract": return mu.Extract(self).run()
|
|
28
|
+
if command == "remove" : return mu.Remove(self).run()
|
|
28
29
|
if command == "select" : return self._run_select()
|
|
29
30
|
if command == "merge" : return self._run_merge()
|
|
30
31
|
raise ValueError(f"Unknown command: {command}")
|
|
@@ -19,6 +19,28 @@
|
|
|
19
19
|
!fyh:_ Counts the number of models in a PDB file.
|
|
20
20
|
!fyh:path_in Path of a PDB file.
|
|
21
21
|
!@
|
|
22
|
+
@chains
|
|
23
|
+
!fyh:_ Counts the number of chains in a PDB file.
|
|
24
|
+
!fyh:path_in Path of a PDB file.
|
|
25
|
+
!@
|
|
26
|
+
@residues
|
|
27
|
+
!fyh:_ Counts the number of residues in a PDB file in the format "chainid.resid".
|
|
28
|
+
!fyh:path_in Path of a PDB file.
|
|
29
|
+
!@
|
|
30
|
+
@frames
|
|
31
|
+
!fyh:_ Counts the number of frames in a trajectory.
|
|
32
|
+
Reports both the expected number of frames (i.e. u.trajectory.n_frames) and the number of actual valid frames.
|
|
33
|
+
These are reported as "valid/expected" and might differ in some formats, like in XYZ.
|
|
34
|
+
Requires MDAnalysis.
|
|
35
|
+
!fyh:path_struct Path of the structure file (e.g. PDB file). Can be anything supported by MDanalysis.
|
|
36
|
+
If the file also contains the trajectory data (e.g. XYZ file), then "path_traj" can be ommitted.
|
|
37
|
+
!fyh:path_traj Path of the trajectory file (e.g. XTC file). Can be anything supported by MDanalysis.
|
|
38
|
+
!@
|
|
39
|
+
@altlocs
|
|
40
|
+
!fyh:_ Counts the number of atoms/heteroatoms in a PDB file that contain alternate locations (altloc).
|
|
41
|
+
Only counts one per atom, disregarding how many alternate locations it has.
|
|
42
|
+
!fyh:path_in Path of a PDB file.
|
|
43
|
+
!@
|
|
22
44
|
!@
|
|
23
45
|
|
|
24
46
|
@extract
|
|
@@ -38,6 +60,20 @@
|
|
|
38
60
|
!use:_io_filein_dirout
|
|
39
61
|
!fyh:residue Residue to extract, in the format "chainid.resid".
|
|
40
62
|
!@
|
|
63
|
+
@frames
|
|
64
|
+
!fyh:_ Extract specific frames from a PDB file into separate file(s).
|
|
65
|
+
Requires MDAnalysis.
|
|
66
|
+
!fyh:path_struct Path of the structure file (e.g. PDB file). Can be anything supported by MDanalysis.
|
|
67
|
+
If the file also contains the trajectory data (e.g. XYZ file), then "path_traj" can be ommitted.
|
|
68
|
+
In this case, an additional structure file (a copy of the first frame) may be exported for convenience.
|
|
69
|
+
!fyh:path_traj Path of the trajectory file (e.g. XTC file). Can be anything supported by MDanalysis.
|
|
70
|
+
!fyh:folder_out Path of the directory where to place the unpacked structure(s).
|
|
71
|
+
If not provided, the parent directory of the input PDB file will be used.
|
|
72
|
+
!fyh:frames Frame indices to extract. If no frames are specified, all frames are extracted.
|
|
73
|
+
If only 1 frame is specified, the frame is exported to PDB (regardless of the "unpack" flag).
|
|
74
|
+
!fyh:unpack When used, the specified frames will be unpacked into single PDB files.
|
|
75
|
+
Otherwise, the frames are exported into a single XTC file.
|
|
76
|
+
!@
|
|
41
77
|
!@
|
|
42
78
|
|
|
43
79
|
@select
|
|
@@ -12,6 +12,19 @@
|
|
|
12
12
|
@models
|
|
13
13
|
path_in[]1.PATH
|
|
14
14
|
!@
|
|
15
|
+
@chains
|
|
16
|
+
path_in[]1.PATH
|
|
17
|
+
!@
|
|
18
|
+
@residues
|
|
19
|
+
path_in[]1.PATH
|
|
20
|
+
!@
|
|
21
|
+
@frames
|
|
22
|
+
path_struct[]1.PATH
|
|
23
|
+
~path_traj[]1.PATH
|
|
24
|
+
!@
|
|
25
|
+
@altlocs
|
|
26
|
+
path_in[]1.PATH
|
|
27
|
+
!@
|
|
15
28
|
!@
|
|
16
29
|
|
|
17
30
|
@extract
|
|
@@ -28,6 +41,20 @@
|
|
|
28
41
|
residue[]1.STR
|
|
29
42
|
~folder_out[o,out]1.PATH
|
|
30
43
|
!@
|
|
44
|
+
@frames
|
|
45
|
+
path_struct[]1.PATH
|
|
46
|
+
~path_traj[]1.PATH
|
|
47
|
+
~folder_out[o,out]1.PATH
|
|
48
|
+
~frames[f,frames]1+.INT
|
|
49
|
+
~unpack[u,unpack]
|
|
50
|
+
!@
|
|
51
|
+
!@
|
|
52
|
+
|
|
53
|
+
@remove
|
|
54
|
+
@altlocs
|
|
55
|
+
path_in[]1.PATH
|
|
56
|
+
path_out[]1.PATH
|
|
57
|
+
!@
|
|
31
58
|
!@
|
|
32
59
|
|
|
33
60
|
@select
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: molutils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.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
|
|
@@ -12,7 +12,7 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Requires-Python: >=3.10
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE.md
|
|
15
|
-
Requires-Dist: freyacli==0.4.
|
|
15
|
+
Requires-Dist: freyacli==0.4.1
|
|
16
16
|
Dynamic: author
|
|
17
17
|
Dynamic: author-email
|
|
18
18
|
Dynamic: classifier
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
freyacli==0.4.1
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
import freyacli as fy
|
|
4
|
-
import molutils as mu
|
|
5
|
-
|
|
6
|
-
# //////////////////////////////////////////////////////////////////////////////
|
|
7
|
-
class Count(mu.AppSubcommand):
|
|
8
|
-
# -------------------------------------------------------------------------- UI SECTION
|
|
9
|
-
def run(self):
|
|
10
|
-
command = self.main.subcommands.pop(0)
|
|
11
|
-
|
|
12
|
-
if command == "models": return self.app_count_models()
|
|
13
|
-
|
|
14
|
-
raise ValueError(f"Unknown command: {command}")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
# --------------------------------------------------------------------------
|
|
18
|
-
def app_count_models(self):
|
|
19
|
-
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
20
|
-
print(mu.Count.models(path_in))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# -------------------------------------------------------------------------- LOGIC SECTION
|
|
24
|
-
@classmethod
|
|
25
|
-
def models(cls, path_pdb: Path) -> int:
|
|
26
|
-
data = path_pdb.read_text()
|
|
27
|
-
return max(1, cls._count_substring('\n'+data, "\nMODEL"))
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# --------------------------------------------------------------------------
|
|
31
|
-
@staticmethod
|
|
32
|
-
def _count_substring(string: str, substring: str) -> int:
|
|
33
|
-
"""Counts the number of occurrences of `substring` in `string`."""
|
|
34
|
-
replaced = string.replace(substring, "")
|
|
35
|
-
return (len(string) - len(replaced)) // len(substring)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.4.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
freyacli==0.4.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|