Skip to content

Commit 91a6f09

Browse files
committed
[cli.interface] API BREAK frag_idxs_group_1, frag_idxs_group_2 becomes interface_selection_1, interface_selection_2
1 parent 0f6a848 commit 91a6f09

File tree

2 files changed

+67
-49
lines changed

2 files changed

+67
-49
lines changed

mdciao/cli/cli.py

+41-23
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,8 @@ def interface(
11021102
trajectories,
11031103
topology=None,
11041104
fragments='lig_resSeq+',
1105-
frag_idxs_group_1=None,
1106-
frag_idxs_group_2=None,
1105+
interface_selection_1=None,
1106+
interface_selection_2=None,
11071107
AA_selection=None,
11081108
GPCR_UniProt="None",
11091109
CGN_UniProt="None",
@@ -1159,8 +1159,8 @@ def interface(
11591159
are separate, i.e. there might be six chains but
11601160
one can specify to compute the interface between
11611161
chains [0,1] vs [2,3]. Read more in the
1162-
documentation for `fragments`, `frag_idxs_group_1`,
1163-
and `frag_idxs_group_2`.
1162+
documentation for `fragments`, `interface_selection_1`,
1163+
and `interface_selection_2`.
11641164
11651165
One can further refine the fragment selection
11661166
with an aminoacid (AA) selection using
@@ -1253,26 +1253,44 @@ def interface(
12531253
regardless of having passed "consensus" here. I.e., you can
12541254
use `fragments='chains'` to divide the topology for representation
12551255
and residue-tagging purposes but then define the interface as:
1256-
>>> frag_idxs_group_1="TM3"
1257-
>>> frag_idxs_group_2="TM2"
1256+
>>> interface_selection_1="TM3"
1257+
>>> interface_selection_2="TM2"
12581258
to compute the interface of TM3 vs TM2 in a GPCR. For
12591259
this mode of selection to work, the only condition is that the consensus
12601260
labels have been provided via `GPCR_Uniprot`,
12611261
`CGN_UniProt` or `KLIFS_string` (see below).
1262-
frag_idxs_group_1 : NoneType, default is None
1263-
Indices of the fragments that belong to the group_1.
1264-
Strings can be CSVs and include ranges, e.g. '1,3-4',
1265-
or be consensus labels "TM*,-TM6".
1266-
Defaults to None which will prompt the user of
1267-
information, except when only two fragments are
1268-
present. Then it defaults to [0]
1269-
frag_idxs_group_2 : NoneType, default is None
1270-
Indices of the fragments that belong to the group_2.
1271-
Strings can be CSVs and include ranges, e.g. '1,3-4',
1272-
or be consensus labels "TM*,-TM6".
1273-
Defaults to None which will prompt the user of
1274-
information, except when only two fragments are
1275-
present. Then it defaults to [1]
1262+
interface_selection_1 : str or list, default is None
1263+
Selection of the `fragments` that belong to one
1264+
side of the interface. Strings can be CSVs
1265+
and include:
1266+
* ranges, e.g. '1,3-4'
1267+
* wildcards, e.g. "TM*" or "G.H.??"
1268+
* exclusions, e.g. "TM*,-TM6" (all TMs except TM6)
1269+
The default is to prompt the user for
1270+
information, except when:
1271+
* `fragments` yielded only one fragment that
1272+
**doesn't** cover the whole topology. Then
1273+
all othe residues are put into a second
1274+
fragment and then the interface is computed
1275+
between these two fragments.
1276+
* `fragments` yielded just two fragments. Then
1277+
the interface is computed between these two fragments.
1278+
interface_selection_2 : str or list, default is None
1279+
Selection of the `fragments` that belong to the other
1280+
side of the interface. Strings can be CSVs
1281+
and include:
1282+
* ranges, e.g. '1,3-4'
1283+
* wildcards, e.g. "TM*" or "G.H.??"
1284+
* exclusions, e.g. "TM*,-TM6" (all TMs except TM6)
1285+
The default is to prompt the user for
1286+
information, except when:
1287+
* `fragments` yielded only one fragment that
1288+
**doesn't** cover the whole topology. Then
1289+
all othe residues are put into a second
1290+
fragment and then the interface is computed
1291+
between these two fragments.
1292+
* `fragments` yielded just two fragments. Then
1293+
the interface is computed between these two fragments.
12761294
AA_selection : str or list, default is None
12771295
Whatever the fragment definition and fragment selection
12781296
has been, one can further refine the list of
@@ -1515,14 +1533,14 @@ def interface(
15151533
fragments_as_residue_idxs, fragment_names, _, consensus_labelers, consensus_maps, consensus_frags, top2confrag = _parse_fragdefs_fragnames_consensus(
15161534
refgeom.top, fragments, fragment_names, GPCR_UniProt, CGN_UniProt, KLIFS_string, accept_guess, save_nomenclature_files)
15171535
fragments_as_residue_idxs_d = {str(ii) : val for ii, val in enumerate(fragments_as_residue_idxs)}
1518-
if len(fragments_as_residue_idxs)==2 and frag_idxs_group_1 is None and frag_idxs_group_2 is None:
1519-
frag_idxs_group_1, frag_idxs_group_2 =[0], [1]
1536+
if len(fragments_as_residue_idxs)==2 and interface_selection_1 is None and interface_selection_2 is None:
1537+
interface_selection_1, interface_selection_2 =[0], [1]
15201538
else:
15211539
fragments_as_residue_idxs_d.update(consensus_frags)
15221540

15231541
intf_frags_as_residxs, \
15241542
intf_frags_as_str_or_keys = _mdcfrg.frag_dict_2_frag_groups(fragments_as_residue_idxs_d, ng=2,
1525-
answers=[frag_idxs_group_1, frag_idxs_group_2],
1543+
answers=[interface_selection_1, interface_selection_2],
15261544
)
15271545

15281546
intersect = list(set(intf_frags_as_residxs[0]).intersection(intf_frags_as_residxs[1]))

tests/test_cli.py

+26-26
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ def test_interface(self):
473473
with TemporaryDirectory(suffix='_test_mdciao') as tmpdir:
474474
cli.interface([self.traj, self.traj_reverse],
475475
self.geom,
476-
frag_idxs_group_1=[0],
477-
frag_idxs_group_2=[1],
476+
interface_selection_1=[0],
477+
interface_selection_2=[1],
478478
output_dir=tmpdir,
479479
flareplot=True,
480480
no_disk=self.no_disk
@@ -483,13 +483,13 @@ def test_interface(self):
483483
def test_no_top(self):
484484
with TemporaryDirectory(suffix='_test_mdciao') as tmpdir:
485485
cli.interface([self.traj, self.traj_reverse],
486-
frag_idxs_group_1=[0],
487-
frag_idxs_group_2=[1],
486+
interface_selection_1=[0],
487+
interface_selection_2=[1],
488488
output_dir=tmpdir,
489489
flareplot=False,
490490
plot_timedep=False,
491491
no_disk = self.no_disk
492-
)
492+
)
493493

494494
def test_interface_wo_frag_idxs_groups(self):
495495
with TemporaryDirectory(suffix='_test_mdciao') as tmpdir:
@@ -527,8 +527,8 @@ def test_w_just_two_fragments_by_user(self):
527527
with TemporaryDirectory(suffix='_test_mdciao') as tmpdir:
528528
cli.interface([self.traj, self.traj_reverse],
529529
self.geom,
530-
frag_idxs_group_1=[0],
531-
frag_idxs_group_2=[1],
530+
interface_selection_1=[0],
531+
interface_selection_2=[1],
532532
output_dir=tmpdir,
533533
fragments=["0-5",
534534
"6-10"],
@@ -607,8 +607,8 @@ def test_w_nomenclature_CGN_GPCR_fragments_are_consensus_and_flareplot_and_self_
607607
CGN_UniProt="gnas2_human",
608608
GPCR_UniProt="adrb2_human",
609609
accept_guess=True,
610-
frag_idxs_group_1='TM6',
611-
frag_idxs_group_2='TM5,TM6',
610+
interface_selection_1='TM6',
611+
interface_selection_2='TM5,TM6',
612612
self_interface=True,
613613
)
614614

@@ -619,19 +619,19 @@ def test_w_nomenclature_CGN_GPCR_fragments_are_consensus_and_flareplot_and_AA_se
619619
with remember_cwd():
620620
os.chdir(tmpdir)
621621
intf = cli.interface([self.traj, self.traj_reverse],
622-
self.geom,
623-
ctc_cutoff_Ang=5,
624-
n_nearest=4,
625-
output_dir=tmpdir,
626-
fragments=["consensus"],
627-
CGN_UniProt="gnas2_human",
628-
GPCR_UniProt="adrb2_human",
629-
accept_guess=True,
630-
frag_idxs_group_1='TM6',
631-
frag_idxs_group_2='TM5',
632-
self_interface=True,
633-
AA_selection="5.50x50-5.55x55"
634-
)
622+
self.geom,
623+
ctc_cutoff_Ang=5,
624+
n_nearest=4,
625+
output_dir=tmpdir,
626+
fragments=["consensus"],
627+
CGN_UniProt="gnas2_human",
628+
GPCR_UniProt="adrb2_human",
629+
accept_guess=True,
630+
interface_selection_1='TM6',
631+
interface_selection_2='TM5',
632+
self_interface=True,
633+
AA_selection="5.50x50-5.55x55"
634+
)
635635
TM5 = ["5.50x50", "5.51x51", "5.52x52", "5.53x53", "5.54x54", "5.55x55"]
636636
assert all ([lab[1] in TM5 for lab in intf.consensus_labels]), intf.consensus_labels
637637
_plt.close("all")
@@ -650,8 +650,8 @@ def test_w_nomenclature_CGN_GPCR_fragments_are_consensus_and_flareplot_and_AA_se
650650
CGN_UniProt="gnas2_human",
651651
GPCR_UniProt="adrb2_human",
652652
accept_guess=True,
653-
frag_idxs_group_1='TM6',
654-
frag_idxs_group_2='TM5',
653+
interface_selection_1='TM6',
654+
interface_selection_2='TM5',
655655
self_interface=True,
656656
AA_selection=["5.50x50-5.55x55", "6.45x45,6.49x49"]
657657
)
@@ -675,8 +675,8 @@ def test_w_nomenclature_CGN_GPCR_fragments_are_consensus_and_flareplot_and_AA_se
675675
CGN_UniProt="gnas2_human",
676676
GPCR_UniProt="adrb2_human",
677677
accept_guess=True,
678-
frag_idxs_group_1='TM6',
679-
frag_idxs_group_2='TM5',
678+
interface_selection_1='TM6',
679+
interface_selection_2='TM5',
680680
self_interface=True,
681681
AA_selection=["5.50x50-5.55x55,6.45x45,6.49x49"]
682682
)

0 commit comments

Comments
 (0)