pytme 0.1.1__cp311-cp311-macosx_13_0_arm64.whl → 0.1.3__cp311-cp311-macosx_13_0_arm64.whl

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.
tme/structure.py CHANGED
@@ -189,11 +189,11 @@ class Structure:
189
189
 
190
190
  min_atom = np.min(self.atom_serial_number)
191
191
  max_atom = np.max(self.atom_serial_number)
192
- n_atom = max_atom - min_atom + 1
192
+ n_atom = self.atom_serial_number.size
193
193
 
194
194
  min_residue = np.min(self.residue_sequence_number)
195
195
  max_residue = np.max(self.residue_sequence_number)
196
- n_residue = max_residue - min_residue + 1
196
+ n_residue = self.residue_sequence_number.size
197
197
 
198
198
  repr_str = (
199
199
  f"Structure object at {id(self)}\n"
@@ -669,14 +669,16 @@ class Structure:
669
669
  Parameters
670
670
  ----------
671
671
  chain : str, optional
672
- The chain identifier. If None, all chains are returned. Default is None.
672
+ The chain identifier. If multiple chains should be selected they need
673
+ to be a comma separated string, e.g. 'A,B,CE'. If chain None,
674
+ all chains are returned. Default is None.
673
675
 
674
676
  Returns
675
677
  -------
676
678
  Structure
677
679
  A subset of the original structure containing only the specified chain.
678
680
  """
679
- chain = np.unique(self.chain_identifier) if chain is None else chain
681
+ chain = np.unique(self.chain_identifier) if chain is None else chain.split(",")
680
682
  keep = np.in1d(self.chain_identifier, chain)
681
683
  return self[keep]
682
684
 
@@ -698,7 +700,9 @@ class Structure:
698
700
  The ending residue sequence number.
699
701
 
700
702
  chain : str, optional
701
- The chain identifier. If None, all chains are considered. Default is None.
703
+ The chain identifier. If multiple chains should be selected they need
704
+ to be a comma separated string, e.g. 'A,B,CE'. If chain None,
705
+ all chains are returned. Default is None.
702
706
 
703
707
  Returns
704
708
  -------
@@ -789,7 +793,6 @@ class Structure:
789
793
  shape: Tuple[int],
790
794
  sampling_rate: Tuple[float],
791
795
  origin: Tuple[float],
792
- chain: str,
793
796
  ) -> (NDArray, Tuple[str], Tuple[int], float, Tuple[float]):
794
797
  """
795
798
  Converts coordinates to positions.
@@ -804,10 +807,6 @@ class Structure:
804
807
 
805
808
  origin : Tuple[float,]
806
809
  The origin of the coordinate system.
807
-
808
- chain : str
809
- The protein chain that should be considered.
810
-
811
810
  Returns
812
811
  -------
813
812
  Tuple[NDArray, List[str], Tuple[int, ], float, Tuple[float,]]
@@ -819,11 +818,6 @@ class Structure:
819
818
  # positions are in x, y, z map is z, y, x
820
819
  coordinates = coordinates[:, ::-1]
821
820
 
822
- if chain is not None:
823
- idx = np.in1d(self.chain_identifier, chain)
824
- coordinates = coordinates[idx]
825
- atom_types = atom_types[idx]
826
-
827
821
  sampling_rate = 1 if sampling_rate is None else sampling_rate
828
822
  adjust_origin = origin is not None and shape is None
829
823
  origin = coordinates.min(axis=0) if origin is None else origin
@@ -888,7 +882,6 @@ class Structure:
888
882
  ).astype(int)
889
883
 
890
884
  vdw_rad[atom_type] = atom_vdwr
891
- print(atom_vdwr)
892
885
  atom_slice = tuple(slice(-k, k + 1) for k in atom_vdwr)
893
886
  distances = np.linalg.norm(
894
887
  np.divide(
@@ -1039,7 +1032,9 @@ class Structure:
1039
1032
  Origin of the coordinate system. If origin is given its expected to be
1040
1033
  in z, y, x form.
1041
1034
  chain : str, optional
1042
- Protein chain that should be considered. Default None uses all.
1035
+ The chain identifier. If multiple chains should be selected they need
1036
+ to be a comma separated string, e.g. 'A,B,CE'. If chain None,
1037
+ all chains are returned. Default is None.
1043
1038
  weight_type : str, optional
1044
1039
  Which weight should be given to individual atoms.
1045
1040
  scattering_args : dict, optional
@@ -1074,8 +1069,11 @@ class Structure:
1074
1069
  if "source" not in scattering_args:
1075
1070
  scattering_args["source"] = "peng1995"
1076
1071
 
1072
+ temp = self.copy()
1073
+ self = self.subset_by_chain(chain = chain)
1074
+
1077
1075
  positions, atoms, shape, sampling_rate, origin = self._coordinate_to_position(
1078
- shape=shape, sampling_rate=sampling_rate, origin=origin, chain=chain
1076
+ shape=shape, sampling_rate=sampling_rate, origin=origin
1079
1077
  )
1080
1078
  volume = np.zeros(shape, dtype=np.float32)
1081
1079
  if weight_type in ("atomic_weight", "atomic_number"):
@@ -1102,6 +1100,7 @@ class Structure:
1102
1100
  **scattering_args,
1103
1101
  )
1104
1102
 
1103
+ self = temp
1105
1104
  return volume, origin, sampling_rate
1106
1105
 
1107
1106
  @classmethod
@@ -1229,10 +1228,10 @@ class Structure:
1229
1228
  query = structure2.atom_coordinate.copy()
1230
1229
  if sampling_rate is not None:
1231
1230
  reference, atoms1, shape, _, _ = structure1._coordinate_to_position(
1232
- shape=None, sampling_rate=sampling_rate, origin=origin, chain=None
1231
+ shape=None, sampling_rate=sampling_rate, origin=origin
1233
1232
  )
1234
1233
  query, atoms2, shape, _, _ = structure2._coordinate_to_position(
1235
- shape=None, sampling_rate=sampling_rate, origin=origin, chain=None
1234
+ shape=None, sampling_rate=sampling_rate, origin=origin
1236
1235
  )
1237
1236
 
1238
1237
  reference_mean = reference.mean(axis=0)
File without changes
File without changes