@@ -90,6 +90,7 @@ def reset(self):
90
90
self ._Scc = None
91
91
self ._CC = None
92
92
self ._CCpca = None
93
+ self ._Chi = None
93
94
94
95
return self
95
96
@@ -342,6 +343,19 @@ def chi(self):
342
343
self ._chi = out
343
344
return self ._chi
344
345
346
+ @property
347
+ def Chi (self ):
348
+ """
349
+ Index-able Chi
350
+
351
+ Returns
352
+ -------
353
+ np.array
354
+
355
+ """
356
+ if self ._Chi is None :self ._Chi = Chi (self )
357
+ return self ._Chi
358
+
345
359
@property
346
360
def v_avg (self ):
347
361
"""
@@ -728,6 +742,7 @@ def plotCCpca(self,index=None,states:list=None,ax=None,**kwargs):
728
742
729
743
#%% Plotting
730
744
745
+
731
746
def plotCC (self ,index = None ,ax = None ,CCsum :bool = True ,** kwargs ):
732
747
"""
733
748
Make a CC plot for all residue pairs
@@ -748,10 +763,24 @@ def plotCC(self,index=None,ax=None,CCsum:bool=True,**kwargs):
748
763
749
764
"""
750
765
766
+
767
+
768
+
769
+
751
770
if index is None :index = np .ones (self .N ,dtype = bool )
752
771
if ax is None :
753
772
ax = plt .subplots ()[1 ]
754
773
774
+ index = np .array (index )
775
+ if index .size == 1 and np .issubdtype (index .dtype ,np .integer ):
776
+ ax .plot (self .CC [index ],** kwargs )
777
+ ax .xaxis .set_major_locator (plt .MaxNLocator (30 ,integer = True ))
778
+ ax .xaxis .set_major_formatter (self ._axis_formatter (np .arange (len (self .resids ))))
779
+
780
+ ax .tick_params (axis = 'x' , labelrotation = 90 )
781
+ ax .set_ylabel ('C.C' )
782
+ return ax
783
+
755
784
756
785
if 'cmap' not in kwargs :
757
786
kwargs ['cmap' ]= 'binary'
@@ -852,7 +881,7 @@ def format_func(value,tick_number):
852
881
return plt .FuncFormatter (format_func )
853
882
854
883
855
- def plotChi (self ,index :int ,ax :list = None ,step :int = 1 ):
884
+ def plotChi (self ,index :int ,ax :list = None ,step :int = 1 , cmap = 'tab10' ):
856
885
"""
857
886
Creates one or more Ramachandran histogram plots, depending on the number
858
887
of chi angles, i.e. 1D histogram for Valine, 1 Ramachandran plot for
@@ -868,6 +897,8 @@ def plotChi(self,index:int,ax:list=None,step:int=1):
868
897
fig
869
898
870
899
"""
900
+ chi = self .Chi [index ]
901
+
871
902
index = np .array (index )
872
903
if index .dtype == bool :index = np .argmax (index )
873
904
@@ -878,10 +909,12 @@ def plotChi(self,index:int,ax:list=None,step:int=1):
878
909
ax = np .atleast_1d (ax ).flatten ()
879
910
assert len (ax )== nplots ,f"Residue { self .resid [index ].resname } { self .resid [index ].resid } has { N } chi angles, and therefore requires { nplots } plots"
880
911
881
- chi = [self .chi [k ][self .index [k + 3 ,:index ].sum ()][::step ] for k in range (N - 1 ,- 1 ,- 1 )]
912
+ # chi=[self.chi[k][self.index[k+3,:index].sum()][::step] for k in range(N-1,-1,-1)]
913
+
914
+
882
915
883
916
nstates = self .total_mult [index ]
884
- cmap = plt .get_cmap ('turbo' ). resampled ( nstates )
917
+ if isinstance ( cmap , str ): cmap = plt .get_cmap (cmap )
885
918
886
919
for a ,k in zip (ax ,range (N - 1 )):
887
920
for m in range (nstates ):
@@ -1083,9 +1116,19 @@ def save(self,filename:str,overwrite:bool=False):
1083
1116
with open (filename ,'wb' ) as f :
1084
1117
write_EntropyCC (f ,self )
1085
1118
1119
+
1120
+ class Chi ():
1121
+ def __init__ (self ,ECC ):
1122
+ self .ECC = ECC
1086
1123
1087
-
1088
-
1124
+ def __getitem__ (self ,index ):
1125
+ ECC = self .ECC
1126
+ index = np .array (index )
1127
+ if index .dtype == bool :index = np .argmax (index )
1128
+
1129
+ N = ECC .index [3 :,index ].sum ()
1130
+
1131
+ return np .array ([ECC .chi [k ][ECC .index [k + 3 ,:index ].sum ()] for k in range (N - 1 ,- 1 ,- 1 )])
1089
1132
1090
1133
1091
1134
# Tools for selecting the correct atoms to get rotamers
0 commit comments