Skip to content

Commit 3e46c64

Browse files
committed
[contacts.ContactGroup._full_color_list] Handle color in specific situation: one single fragment, self-interface=True, where two colors are needed
1 parent 347e62d commit 3e46c64

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

mdciao/contacts/contacts.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -7894,9 +7894,6 @@ def _full_color_list(top, df, colors=None) -> _DF:
78947894
78957895
The main idea is to incorporate per-residue color values
78967896
7897-
Main ideas:
7898-
* Create
7899-
79007897
Parameters
79017898
----------
79027899
top : :obj:`~mdtraj.Topology`
@@ -7925,13 +7922,21 @@ def _full_color_list(top, df, colors=None) -> _DF:
79257922
if colors is None:
79267923
_colors = list(_mdcplots.color_dict_guesser("tab10", _np.arange(len(frags_from_df))).values())
79277924
jdf["frag_color"] = list(_mdcflare._utils.col_list_from_input_and_fragments(_colors, frags_from_df))
7925+
one_intf_frag = _np.unique(jdf["interface fragment"])
7926+
if len(one_intf_frag)==1:
7927+
assert jdf["self interface residx"].any(), ValueError("If there's only one interface fragment, "
7928+
"then there should be some shared residues between interface members")
7929+
#For the purposes of the flareplot we'll split the shared residxs
7930+
jdf.loc[jdf["self interface residx"], "interface fragment"] = {1 : 0,
7931+
0 : 1}[one_intf_frag[0]]
7932+
79287933
else:
79297934
jdf["frag_color"] = list(_mdcflare._utils.col_list_from_input_and_fragments(colors, frags_from_df))
79307935

79317936
if "interface fragment" in df.keys():
7932-
# TODO do this from self.interface_indices
7933-
intf_from_df = [_np.flatnonzero(df["interface fragment"] == ii) for ii in
7934-
df[~df["interface fragment"].isnull()]["interface fragment"].unique()]
7937+
# TODO do this from self.interface_indices or with groupby
7938+
intf_from_df = [_np.flatnonzero(jdf["interface fragment"] == ii) for ii in
7939+
jdf[~jdf["interface fragment"].isnull()]["interface fragment"].unique()]
79357940
intf_colors = [None] * top.n_residues
79367941
if colors is None:
79377942
if len(frags_from_df)==1: #means no fragments, TODO think about other way of infering this

0 commit comments

Comments
 (0)