molutils 0.5.0__tar.gz → 0.6.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.5.0 → molutils-0.6.0}/PKG-INFO +3 -3
- {molutils-0.5.0 → molutils-0.6.0}/molutils/__init__.py +0 -3
- {molutils-0.5.0 → molutils-0.6.0}/molutils/_core/count.py +42 -36
- {molutils-0.5.0 → molutils-0.6.0}/molutils/_core/extract.py +14 -73
- {molutils-0.5.0 → molutils-0.6.0}/molutils/_core/list_.py +12 -15
- {molutils-0.5.0 → molutils-0.6.0}/molutils/_core/remove.py +17 -14
- {molutils-0.5.0 → molutils-0.6.0}/molutils/_ui/app_main.py +12 -5
- {molutils-0.5.0 → molutils-0.6.0}/molutils/_ui/fy_help.fyh +2 -1
- {molutils-0.5.0 → molutils-0.6.0}/molutils/_ui/fy_rules.fyr +1 -1
- molutils-0.6.0/molutils/_version.py +1 -0
- {molutils-0.5.0 → molutils-0.6.0}/molutils.egg-info/PKG-INFO +3 -3
- {molutils-0.5.0 → molutils-0.6.0}/molutils.egg-info/SOURCES.txt +0 -3
- molutils-0.6.0/molutils.egg-info/requires.txt +2 -0
- {molutils-0.5.0 → molutils-0.6.0}/setup.py +4 -1
- molutils-0.5.0/molutils/_parsers/chain_resid.py +0 -34
- molutils-0.5.0/molutils/_parsers/parser_pdb.py +0 -80
- molutils-0.5.0/molutils/_ui/__init__.py +0 -0
- molutils-0.5.0/molutils/_version.py +0 -1
- molutils-0.5.0/molutils.egg-info/requires.txt +0 -1
- {molutils-0.5.0 → molutils-0.6.0}/LICENSE.md +0 -0
- {molutils-0.5.0 → molutils-0.6.0}/README.md +0 -0
- {molutils-0.5.0 → molutils-0.6.0}/molutils/__main__.py +0 -0
- {molutils-0.5.0 → molutils-0.6.0}/molutils/_core/__init__.py +0 -0
- {molutils-0.5.0/molutils/_parsers → molutils-0.6.0/molutils/_ui}/__init__.py +0 -0
- {molutils-0.5.0 → molutils-0.6.0}/molutils/_ui/app_subcommand.py +0 -0
- {molutils-0.5.0 → molutils-0.6.0}/molutils.egg-info/dependency_links.txt +0 -0
- {molutils-0.5.0 → molutils-0.6.0}/molutils.egg-info/entry_points.txt +0 -0
- {molutils-0.5.0 → molutils-0.6.0}/molutils.egg-info/top_level.txt +0 -0
- {molutils-0.5.0 → molutils-0.6.0}/pyproject.toml +0 -0
- {molutils-0.5.0 → molutils-0.6.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.6.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,14 +12,14 @@ 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:
|
|
15
|
+
Requires-Dist: molsimple==0.1.2
|
|
16
|
+
Requires-Dist: freyacli==0.4.5
|
|
16
17
|
Dynamic: author
|
|
17
18
|
Dynamic: author-email
|
|
18
19
|
Dynamic: classifier
|
|
19
20
|
Dynamic: description
|
|
20
21
|
Dynamic: description-content-type
|
|
21
22
|
Dynamic: home-page
|
|
22
|
-
Dynamic: keywords
|
|
23
23
|
Dynamic: license
|
|
24
24
|
Dynamic: license-file
|
|
25
25
|
Dynamic: requires-dist
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
|
|
3
|
+
import molsimple as ms
|
|
3
4
|
import freyacli as fy
|
|
4
5
|
import molutils as mu
|
|
5
6
|
|
|
@@ -21,19 +22,19 @@ class Count(mu.AppSubcommand):
|
|
|
21
22
|
# --------------------------------------------------------------------------
|
|
22
23
|
def app_count_models(self):
|
|
23
24
|
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
24
|
-
print(mu.Count.models(path_in))
|
|
25
|
+
print(mu.Count.models(ms.System.read_pdb(path_in)))
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
# --------------------------------------------------------------------------
|
|
28
29
|
def app_count_chains(self):
|
|
29
30
|
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
30
|
-
print(
|
|
31
|
+
print(mu.Count.chains(ms.System.read_pdb(path_in)))
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
# --------------------------------------------------------------------------
|
|
34
35
|
def app_count_residues(self):
|
|
35
36
|
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
36
|
-
print(
|
|
37
|
+
print(mu.Count.residues(ms.System.read_pdb(path_in)))
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
# --------------------------------------------------------------------------
|
|
@@ -42,63 +43,68 @@ class Count(mu.AppSubcommand):
|
|
|
42
43
|
path_traj = self.main.get_arg_path("path_traj",
|
|
43
44
|
assertion = fy.PathAssertion.FILE_IN, allow_none = True
|
|
44
45
|
)
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
|
|
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
|
+
|
|
51
|
+
nframes_valid, _ = mu.Count.frames(u)
|
|
52
|
+
print(f"{nframes_valid}")
|
|
53
|
+
|
|
47
54
|
|
|
48
55
|
|
|
49
56
|
# --------------------------------------------------------------------------
|
|
50
57
|
def app_count_altlocs(self):
|
|
51
58
|
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
52
|
-
print(mu.Count.altlocs(path_in))
|
|
59
|
+
print(mu.Count.altlocs(ms.System.read_pdb(path_in)))
|
|
53
60
|
|
|
54
61
|
|
|
55
62
|
# -------------------------------------------------------------------------- LOGIC SECTION
|
|
56
63
|
@classmethod
|
|
57
|
-
def models(cls,
|
|
58
|
-
|
|
59
|
-
return max(1, cls._count_substring('\n'+data, "\nMODEL"))
|
|
64
|
+
def models(cls, system: ms.System) -> int:
|
|
65
|
+
return len(system.models)
|
|
60
66
|
|
|
61
67
|
|
|
62
68
|
# --------------------------------------------------------------------------
|
|
63
69
|
@classmethod
|
|
64
|
-
def
|
|
65
|
-
|
|
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
|
|
70
|
+
def chains(cls, system: ms.System) -> int:
|
|
71
|
+
return len(mu.List.chains(system, do_sort = False))
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
# --------------------------------------------------------------------------
|
|
75
75
|
@classmethod
|
|
76
|
-
def
|
|
77
|
-
|
|
78
|
-
pdb = mu.ParserPDB.from_file(path_pdb)
|
|
76
|
+
def residues(cls, system: ms.System) -> int:
|
|
77
|
+
return len(mu.List.residues(system, do_sort = False))
|
|
79
78
|
|
|
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
79
|
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
# --------------------------------------------------------------------------
|
|
81
|
+
@classmethod
|
|
82
|
+
def frames(cls, universe) -> tuple[int, int]:
|
|
83
|
+
"""
|
|
84
|
+
Requires MDAnalysis (`universe` should be an instance of `MDAnalysis.Universe`).
|
|
85
|
+
Returns a tuple of `(nframes_valid, nframes_expected)`, where:
|
|
86
|
+
- `nframes_valid`: The number of frames that could be successfully read from the trajectory.
|
|
87
|
+
- `nframes_expected`: The total number of frames expected based on the trajectory metadata.
|
|
88
|
+
"""
|
|
89
|
+
nframes_expected = universe.trajectory.n_frames
|
|
90
|
+
nframes_valid = sum(1 for _ in universe.trajectory)
|
|
91
|
+
return nframes_valid, nframes_expected
|
|
87
92
|
|
|
88
|
-
key = f"{resid}.{name}"
|
|
89
|
-
if key in atoms: continue
|
|
90
93
|
|
|
91
|
-
|
|
94
|
+
# --------------------------------------------------------------------------
|
|
95
|
+
@classmethod
|
|
96
|
+
def altlocs(cls, system: ms.System) -> int:
|
|
97
|
+
parts_with_altloc: set[tuple[str, str]] = set()
|
|
92
98
|
|
|
93
|
-
|
|
99
|
+
for particle in system.particles:
|
|
100
|
+
if not particle.altloc: continue
|
|
94
101
|
|
|
102
|
+
key = (particle.get_chain_resid().get_dotstr(), particle.name)
|
|
103
|
+
if key in parts_with_altloc: continue
|
|
95
104
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"""Counts the number of occurrences of `substring` in `string`."""
|
|
100
|
-
replaced = string.replace(substring, "")
|
|
101
|
-
return (len(string) - len(replaced)) // len(substring)
|
|
105
|
+
parts_with_altloc.add(key)
|
|
106
|
+
|
|
107
|
+
return len(parts_with_altloc)
|
|
102
108
|
|
|
103
109
|
|
|
104
110
|
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
from collections import defaultdict
|
|
3
3
|
|
|
4
|
+
import molsimple as ms
|
|
4
5
|
import freyacli as fy
|
|
5
6
|
import molutils as mu
|
|
6
7
|
|
|
@@ -20,45 +21,37 @@ class Extract(mu.AppSubcommand):
|
|
|
20
21
|
# --------------------------------------------------------------------------
|
|
21
22
|
def app_extract_models(self):
|
|
22
23
|
path_in, folder_out = self._io_filein_dirout()
|
|
23
|
-
|
|
24
|
+
first_only = self.main.get_arg_bool("first_only")
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
_, model = mu.Extract.next_model(data_pdb)
|
|
27
|
-
path_out = folder_out / f"{path_in.stem}.m0.pdb"
|
|
28
|
-
path_out.write_text(model)
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
for i, model in enumerate(mu.Extract.iter_models(data_pdb)):
|
|
26
|
+
for i, model in enumerate(ms.System.read_pdb(path_in).models):
|
|
32
27
|
path_out = folder_out / f"{path_in.stem}.m{i:03}.pdb"
|
|
33
|
-
|
|
28
|
+
model.save(path_out)
|
|
29
|
+
if first_only: break
|
|
34
30
|
|
|
35
31
|
|
|
36
32
|
# --------------------------------------------------------------------------
|
|
37
33
|
def app_extract_chains(self):
|
|
38
34
|
path_in, folder_out = self._io_filein_dirout()
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
chains = mu.Extract.split_chains(data_pdb)
|
|
35
|
+
first_only = self.main.get_arg_bool("first_only")
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
system = ms.System.read_pdb(path_in)
|
|
38
|
+
chain_ids = mu.List.chains(system, do_sort = False)
|
|
45
39
|
|
|
46
40
|
for chain_id in chain_ids:
|
|
47
41
|
path_out = folder_out / f"{path_in.stem}.{chain_id}.pdb"
|
|
48
|
-
|
|
42
|
+
system.particles.select_chainid(chain_id).save(path_out)
|
|
43
|
+
if first_only: break
|
|
49
44
|
|
|
50
45
|
|
|
51
46
|
# --------------------------------------------------------------------------
|
|
52
47
|
def app_extract_residue(self):
|
|
53
48
|
path_in, folder_out = self._io_filein_dirout()
|
|
54
|
-
data_pdb = path_in.read_text()
|
|
55
|
-
|
|
56
49
|
residue_dotstr = self.main.get_arg_str("residue")
|
|
57
|
-
chres = mu.ChainResid.from_dotstr(residue_dotstr)
|
|
58
|
-
extracted = mu.Extract.residue(data_pdb, chres.resid, chres.chain)
|
|
59
50
|
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
pdb = ms.System.read_pdb(path_in)
|
|
52
|
+
chres = ms.ChainResid.from_dotstr(residue_dotstr)
|
|
53
|
+
extracted = pdb.particles.select_chain_resid(chres)
|
|
54
|
+
extracted.save(folder_out / f"{path_in.stem}.{residue_dotstr}.pdb")
|
|
62
55
|
|
|
63
56
|
|
|
64
57
|
# --------------------------------------------------------------------------
|
|
@@ -72,58 +65,6 @@ class Extract(mu.AppSubcommand):
|
|
|
72
65
|
mu.Extract.frames(path_struct, path_traj, folder_out, frames, unpack)
|
|
73
66
|
|
|
74
67
|
|
|
75
|
-
# -------------------------------------------------------------------------- LOGIC SECTION
|
|
76
|
-
@classmethod
|
|
77
|
-
def next_model(cls, data: str, start: int = 0) -> tuple[int, str]:
|
|
78
|
-
idx_0 = data.find("\nMODEL", start)
|
|
79
|
-
if idx_0 == -1: return -1, data
|
|
80
|
-
|
|
81
|
-
idx_1 = data.find("\nENDMDL", idx_0)
|
|
82
|
-
if idx_1 == -1: return -1, data[idx_0:]
|
|
83
|
-
|
|
84
|
-
idx_1 += len("\nENDMDL")
|
|
85
|
-
return idx_1, data[idx_0:idx_1] + "\nEND"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
# --------------------------------------------------------------------------
|
|
89
|
-
@classmethod
|
|
90
|
-
def iter_models(cls, data: str):
|
|
91
|
-
while data:
|
|
92
|
-
idx, model = cls.next_model(data)
|
|
93
|
-
yield model
|
|
94
|
-
if idx == -1: break
|
|
95
|
-
data = data[idx:]
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
# --------------------------------------------------------------------------
|
|
99
|
-
@classmethod
|
|
100
|
-
def split_chains(cls, data: str) -> dict[str, str]:
|
|
101
|
-
pdb = mu.ParserPDB(data)
|
|
102
|
-
chains = defaultdict(list)
|
|
103
|
-
for line in pdb.iter_atoms():
|
|
104
|
-
chain_id = mu.ParserPDB.get_chainid(line)
|
|
105
|
-
chains[chain_id].append(line)
|
|
106
|
-
return {
|
|
107
|
-
chain_id: mu.ParserPDB.join_lines(lines)
|
|
108
|
-
for chain_id, lines in chains.items()
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
# --------------------------------------------------------------------------
|
|
113
|
-
@classmethod
|
|
114
|
-
def residue(cls, data: str, resid: str, chain: str = None) -> str:
|
|
115
|
-
pdb = mu.ParserPDB(data)
|
|
116
|
-
gen_residue = (
|
|
117
|
-
line for line in pdb.iter_atoms()
|
|
118
|
-
if mu.ParserPDB.get_resid(line) == resid
|
|
119
|
-
)
|
|
120
|
-
if chain is not None: gen_residue = (
|
|
121
|
-
line for line in gen_residue
|
|
122
|
-
if mu.ParserPDB.get_chainid(line) == chain
|
|
123
|
-
)
|
|
124
|
-
return mu.ParserPDB.join_lines(gen_residue)
|
|
125
|
-
|
|
126
|
-
|
|
127
68
|
# --------------------------------------------------------------------------
|
|
128
69
|
@classmethod
|
|
129
70
|
def frames(cls,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
|
|
3
|
+
import molsimple as ms
|
|
3
4
|
import freyacli as fy
|
|
4
5
|
import molutils as mu
|
|
5
6
|
|
|
@@ -18,34 +19,30 @@ class List(mu.AppSubcommand):
|
|
|
18
19
|
# --------------------------------------------------------------------------
|
|
19
20
|
def app_list_chains(self):
|
|
20
21
|
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
21
|
-
|
|
22
|
-
print(*mu.List.chains(path_in, first_only = first_only))
|
|
22
|
+
print(*mu.List.chains(ms.System.read_pdb(path_in), do_sort = True))
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
# --------------------------------------------------------------------------
|
|
26
26
|
def app_list_residues(self):
|
|
27
27
|
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
28
|
-
print(*mu.List.residues(path_in))
|
|
28
|
+
print(*mu.List.residues(ms.System.read_pdb(path_in), do_sort = True))
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
# -------------------------------------------------------------------------- LOGIC SECTION
|
|
32
32
|
@classmethod
|
|
33
|
-
def chains(cls,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if do_sort: return sorted(set(gen_chain_ids))
|
|
38
|
-
return list(set(gen_chain_ids))
|
|
33
|
+
def chains(cls, system: ms.System, do_sort: bool = True) -> list[str]:
|
|
34
|
+
unique_chains = set(system.particles.get_chainids())
|
|
35
|
+
if do_sort: return sorted(unique_chains)
|
|
36
|
+
return list(unique_chains)
|
|
39
37
|
|
|
40
38
|
|
|
41
39
|
# --------------------------------------------------------------------------
|
|
42
40
|
@classmethod
|
|
43
|
-
def residues(cls,
|
|
44
|
-
"""Returns list of unique residue identifiers in the format "chainid.resid"."""
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return list(set(gen_residues))
|
|
41
|
+
def residues(cls, system: ms.System, do_sort: bool = True) -> list[str]:
|
|
42
|
+
"""Returns a list of unique residue identifiers in the format "chainid.resid"."""
|
|
43
|
+
unique_residues = set(part.get_chain_resid().get_dotstr() for part in system)
|
|
44
|
+
if do_sort: return sorted(unique_residues)
|
|
45
|
+
return list(unique_residues)
|
|
49
46
|
|
|
50
47
|
|
|
51
48
|
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import molsimple as ms
|
|
1
4
|
import freyacli as fy
|
|
2
5
|
import molutils as mu
|
|
3
6
|
|
|
@@ -16,32 +19,32 @@ class Remove(mu.AppSubcommand):
|
|
|
16
19
|
def app_remove_altlocs(self):
|
|
17
20
|
path_in = self.main.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
18
21
|
path_out = self.main.get_arg_path("path_out", assertion = fy.PathAssertion.FILE_OUT)
|
|
19
|
-
|
|
20
|
-
path_out.write_text(out)
|
|
22
|
+
mu.Remove.altlocs(path_in).save(path_out)
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
# --------------------------------------------------------------------------
|
|
24
26
|
@classmethod
|
|
25
|
-
def altlocs(cls,
|
|
26
|
-
pdb =
|
|
27
|
+
def altlocs(cls, path_pdb: Path) -> ms.ParticleGroup:
|
|
28
|
+
pdb = ms.System.read_pdb(path_pdb)
|
|
27
29
|
|
|
28
|
-
out = []
|
|
30
|
+
out: list[ms.Particle] = []
|
|
29
31
|
seen_altlocs = set()
|
|
30
|
-
for
|
|
31
|
-
altloc
|
|
32
|
-
|
|
33
|
-
out.append(line)
|
|
32
|
+
for particle in pdb.particles:
|
|
33
|
+
if particle.altloc == "":
|
|
34
|
+
out.append(particle)
|
|
34
35
|
continue
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
name
|
|
38
|
-
|
|
37
|
+
chres = particle.get_chain_resid().get_dotstr()
|
|
38
|
+
name = particle.name
|
|
39
|
+
|
|
40
|
+
key = (chres, name)
|
|
39
41
|
if key in seen_altlocs: continue
|
|
40
42
|
|
|
41
43
|
seen_altlocs.add(key)
|
|
42
|
-
|
|
44
|
+
particle.altloc = ""
|
|
45
|
+
out.append(particle)
|
|
43
46
|
|
|
44
|
-
return
|
|
47
|
+
return ms.ParticleGroup(out)
|
|
45
48
|
|
|
46
49
|
|
|
47
50
|
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
|
|
3
|
+
import molsimple as ms
|
|
3
4
|
import freyacli as fy
|
|
4
5
|
import molutils as mu
|
|
5
6
|
|
|
@@ -36,20 +37,26 @@ class AppMain(fy.App):
|
|
|
36
37
|
query = self.get_arg_str("query")
|
|
37
38
|
path_in = self.get_arg_path("path_in", assertion = fy.PathAssertion.FILE_IN)
|
|
38
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
|
+
)
|
|
39
43
|
|
|
40
44
|
import MDAnalysis as mda
|
|
41
45
|
mda.Universe(path_in).select_atoms(query).write(path_out)
|
|
42
46
|
|
|
47
|
+
if paths_traj == [None]: return
|
|
48
|
+
|
|
49
|
+
path_traj_in, path_traj_out = paths_traj
|
|
50
|
+
u = mda.Universe(path_in, path_traj_in)
|
|
51
|
+
u.select_atoms(query).write(str(path_traj_out), frames = "all")
|
|
52
|
+
|
|
43
53
|
|
|
44
54
|
# --------------------------------------------------------------------------
|
|
45
55
|
def _run_merge(self):
|
|
46
56
|
paths_in = self.get_arg_path("paths_in", assertion = fy.PathAssertion.FILE_IN, is_list = True)
|
|
47
57
|
path_out = self.get_arg_path("path_out", assertion = fy.PathAssertion.FILE_OUT)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
for line in mu.ParserPDB.from_file(path_in).iter_atoms()
|
|
51
|
-
)
|
|
52
|
-
path_out.write_text(data)
|
|
58
|
+
pgroups = (ms.System.read_pdb(path_in).particles for path_in in paths_in)
|
|
59
|
+
ms.ParticleGroup((p for pgroup in pgroups for p in pgroup)).save(path_out)
|
|
53
60
|
|
|
54
61
|
|
|
55
62
|
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
@chains
|
|
6
6
|
!fyh:_ Lists the chains in a PDB file.
|
|
7
7
|
!fyh:path_in Path of a PDB file.
|
|
8
|
-
!fyh:first_only Use this flag for displaying only the first chain of the structure.
|
|
9
8
|
!@
|
|
10
9
|
@residues
|
|
11
10
|
!fyh:_ Lists the residues in a PDB file in the format "chainid.resid".
|
|
@@ -81,6 +80,8 @@
|
|
|
81
80
|
!fyh:query Query for selecting the atoms of interest. Must follow MDAnalysis format
|
|
82
81
|
!fyh:path_in Path of the structure file whose atoms will be selected. Can be anything supported by MDanalysis.
|
|
83
82
|
!fyh:path_out Path for the output selected atoms. Can be anything supported by MDanalysis.
|
|
83
|
+
!fyh:paths_traj Input and output paths for an optional trajectory.
|
|
84
|
+
The selection will be applied for all frames of the selection accordingly.
|
|
84
85
|
!@
|
|
85
86
|
|
|
86
87
|
@merge
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.6.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: molutils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.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,14 +12,14 @@ 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:
|
|
15
|
+
Requires-Dist: molsimple==0.1.2
|
|
16
|
+
Requires-Dist: freyacli==0.4.5
|
|
16
17
|
Dynamic: author
|
|
17
18
|
Dynamic: author-email
|
|
18
19
|
Dynamic: classifier
|
|
19
20
|
Dynamic: description
|
|
20
21
|
Dynamic: description-content-type
|
|
21
22
|
Dynamic: home-page
|
|
22
|
-
Dynamic: keywords
|
|
23
23
|
Dynamic: license
|
|
24
24
|
Dynamic: license-file
|
|
25
25
|
Dynamic: requires-dist
|
|
@@ -16,9 +16,6 @@ molutils/_core/count.py
|
|
|
16
16
|
molutils/_core/extract.py
|
|
17
17
|
molutils/_core/list_.py
|
|
18
18
|
molutils/_core/remove.py
|
|
19
|
-
molutils/_parsers/__init__.py
|
|
20
|
-
molutils/_parsers/chain_resid.py
|
|
21
|
-
molutils/_parsers/parser_pdb.py
|
|
22
19
|
molutils/_ui/__init__.py
|
|
23
20
|
molutils/_ui/app_main.py
|
|
24
21
|
molutils/_ui/app_subcommand.py
|
|
@@ -21,7 +21,10 @@ setup(
|
|
|
21
21
|
"_ui/fy_rules.fyr", "_ui/fy_help.fyh",
|
|
22
22
|
],
|
|
23
23
|
},
|
|
24
|
-
install_requires=[
|
|
24
|
+
install_requires=[
|
|
25
|
+
"molsimple==0.1.2",
|
|
26
|
+
"freyacli==0.4.5",
|
|
27
|
+
],
|
|
25
28
|
entry_points={
|
|
26
29
|
"console_scripts": [
|
|
27
30
|
"molutils=molutils.__main__:main",
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import molutils as mu
|
|
2
|
-
|
|
3
|
-
# //////////////////////////////////////////////////////////////////////////////
|
|
4
|
-
class ChainResid:
|
|
5
|
-
def __init__(self, chain: str, resid: str):
|
|
6
|
-
self.chain = chain
|
|
7
|
-
self.resid = resid
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# --------------------------------------------------------------------------
|
|
11
|
-
@classmethod
|
|
12
|
-
def from_pdb(cls, line: str) -> "ChainResid":
|
|
13
|
-
"""Parses an ATOM/HETATM line (PDB format) and returns a ChainResid instance."""
|
|
14
|
-
return cls(mu.ParserPDB.get_chainid(line), mu.ParserPDB.get_resid(line))
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
# --------------------------------------------------------------------------
|
|
18
|
-
@classmethod
|
|
19
|
-
def from_dotstr(cls, dotstr: str) -> "ChainResid":
|
|
20
|
-
"""Parses a string in the format `chainid.resid`."""
|
|
21
|
-
parts = dotstr.split(".")
|
|
22
|
-
if len(parts) != 2:
|
|
23
|
-
raise ValueError(f"Invalid format for ChainResid: {dotstr}. Expected format: `chainid.resid`.")
|
|
24
|
-
chain, resid = parts
|
|
25
|
-
return cls(chain, resid)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
# --------------------------------------------------------------------------
|
|
29
|
-
def get_dotstr(self) -> str:
|
|
30
|
-
"""Returns a string in the format `chainid.resid`."""
|
|
31
|
-
return f"{self.chain}.{self.resid}"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
# //////////////////////////////////////////////////////////////////////////////
|
|
4
|
-
class ParserPDB:
|
|
5
|
-
LENGTH_RECORD = 80
|
|
6
|
-
IDX0_ATOMNAME = 12
|
|
7
|
-
IDX1_ATOMNAME = 16
|
|
8
|
-
IDX_ALTLOC = 16
|
|
9
|
-
IDX_CHAIN_ID = 21
|
|
10
|
-
IDX0_RESID = 22
|
|
11
|
-
IDX1_RESID = 26
|
|
12
|
-
|
|
13
|
-
# --------------------------------------------------------------------------
|
|
14
|
-
def __init__(self, data_pdb: str):
|
|
15
|
-
self.data = data_pdb.splitlines()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# --------------------------------------------------------------------------
|
|
19
|
-
@classmethod
|
|
20
|
-
def from_file(cls, path_pdb: Path):
|
|
21
|
-
return cls(path_pdb.read_text())
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# --------------------------------------------------------------------------
|
|
25
|
-
@classmethod
|
|
26
|
-
def join_lines(cls, lines: list[str]) -> str:
|
|
27
|
-
return '\n'.join(lines) + "\nEND"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# --------------------------------------------------------------------------
|
|
31
|
-
def iter_atoms(self):
|
|
32
|
-
return (
|
|
33
|
-
line for line in self.data
|
|
34
|
-
if line.startswith("ATOM") or line.startswith("HETATM")
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# --------------------------------------------------------------------------
|
|
39
|
-
@classmethod
|
|
40
|
-
def safe_next(cls, gen):
|
|
41
|
-
try: return next(gen)
|
|
42
|
-
except StopIteration: raise ValueError(f"No ATOM records found in PDB file")
|
|
43
|
-
|
|
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
|
-
|
|
52
|
-
# --------------------------------------------------------------------------
|
|
53
|
-
@classmethod
|
|
54
|
-
def get_chainid(cls, line: str) -> str:
|
|
55
|
-
try: return line[cls.IDX_CHAIN_ID]
|
|
56
|
-
except IndexError: raise ValueError(f"Unexpected format of ATOM records in PDB file")
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
# --------------------------------------------------------------------------
|
|
60
|
-
@classmethod
|
|
61
|
-
def get_resid(cls, line: str) -> str:
|
|
62
|
-
return line[cls.IDX0_RESID:cls.IDX1_RESID].strip()
|
|
63
|
-
|
|
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
|
-
|
|
80
|
-
# //////////////////////////////////////////////////////////////////////////////
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.5.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
freyacli==0.4.1
|
|
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
|