dcatoolkit 0.2.1__tar.gz → 0.2.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: dcatoolkit
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Collection of useful modules and representations for managing DCA output data.
5
5
  Author-email: Raheel Syed Ahmed <raheelsyedahmed@gmail.com>
6
6
  Maintainer-email: Raheel Syed Ahmed <raheelsyedahmed@gmail.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dcatoolkit"
7
- version = "0.2.1"
7
+ version = "0.2.2"
8
8
  description = "Collection of useful modules and representations for managing DCA output data."
9
9
  keywords = ["dca", "toolkit", "DI", "coevolution"]
10
10
 
@@ -1,5 +1,5 @@
1
1
 
2
- __version__ = "0.2.1"
2
+ __version__ = "0.2.2"
3
3
  from .representation import Pairs, DirectInformationData, StructureInformation, ResidueAlignment, MMCIFInformation, PDBInformation
4
4
  from .analytics import MSATools
5
5
 
@@ -546,7 +546,7 @@ class DirectInformationData:
546
546
  return results
547
547
 
548
548
  @staticmethod
549
- def get_dist_commands(model1: str | int, model2: str | int, chain1: str, chain2: str, pairs: npt.NDArray, ca_only: bool=True, auth_res_ids=False) -> list[str]:
549
+ def get_dist_commands(model1: str | int, model2: str | int, chain1: str, chain2: str, pairs: npt.NDArray, ca_only: bool=True, auth_res_ids: bool=False) -> list[str]:
550
550
  """
551
551
  Get UCSF Chimera commands for displaying distance commands for usage in displaying distances between residue pairs. Options are present for alpha-carbon to alpha-carbon distance or for specified atom to specified atom distance.
552
552
 
@@ -787,32 +787,15 @@ class MMCIFInformation(StructureInformation):
787
787
  if len(self.pdbx_file.keys()) > 0:
788
788
  self.first_block = list(self.pdbx_file)[0]
789
789
  self.atom_site_category = self.pdbx_file[self.first_block].get('atom_site')
790
- self.chain_auth_dict = {}
791
- self.auth_chain_dict = {}
792
- self.res_auth_dict = {}
790
+ self.chain_auth_dict: dict[str, str] = {}
791
+ self.auth_chain_dict: dict[str, str] = {}
792
+ self.res_auth_dict: dict[str, tuple[int, int]] = {}
793
+
793
794
  if self.atom_site_category:
794
- group_pdbs = []
795
- seq_ids = []
796
- asym_ids = []
797
- auth_seq_ids = []
798
- auth_asym_ids = []
799
- model_nums = []
800
- for col_name, col in self.atom_site_category.items():
801
- if col_name == 'group_PDB':
802
- group_pdbs = col.as_array()
803
- elif col_name == 'label_seq_id':
804
- seq_ids = col.as_array()
805
- elif col_name == 'label_asym_id':
806
- asym_ids = col.as_array()
807
- elif col_name == 'auth_seq_id':
808
- auth_seq_ids = col.as_array()
809
- elif col_name == 'auth_asym_id':
810
- auth_asym_ids = col.as_array()
811
- elif col_name == 'pdbx_PDB_model_num':
812
- model_nums = col.as_array()
813
-
814
- atom_site_data = np.unique(np.column_stack((group_pdbs, seq_ids, asym_ids, auth_seq_ids, auth_asym_ids, model_nums)), axis=0)
815
- atom_site_data = atom_site_data[atom_site_data[:,5] == str(self.model_num)]
795
+ categories = ['group_PDB', 'label_seq_id', 'label_asym_id', 'auth_seq_id', 'auth_asym_id', 'pdbx_PDB_model_num']
796
+ atom_site_data = np.column_stack([self.atom_site_category[category].as_array() for category in categories])
797
+ _, idx = np.unique(atom_site_data, axis=0, return_index=True)
798
+ atom_site_data = atom_site_data[np.sort(idx)]
816
799
  self.atom_data = atom_site_data[atom_site_data[:,0] == "ATOM"]
817
800
  self.het_atom_data = atom_site_data[atom_site_data[:,0] == "HETATM"]
818
801
  self.unique_chains = np.unique(self.atom_data[:,2])
@@ -824,6 +807,31 @@ class MMCIFInformation(StructureInformation):
824
807
  else:
825
808
  self.atom_site_category = None
826
809
 
810
+ def get_start_res_id(self, chain_id: str, auth_res_ids: bool=False, auth_chain_id_supplied: bool=False) -> int:
811
+ """
812
+ Gets starting residue id of the specified chain excluding heteroatom group entries.
813
+
814
+ Parameters
815
+ ----------
816
+ chain_id : str
817
+ The chain id supplied and selected for from the structure.
818
+ auth_res_ids : bool
819
+ True if you want alt_ids for residues indices, False if cif residue indexing is needed.
820
+ auth_chain_id_supplied : bool
821
+ If True, the chain_id supplied is the auth chain id found on the RCSB website.
822
+
823
+ Returns
824
+ -------
825
+ int
826
+ The residue id of the first atom in the chain provided.
827
+ """
828
+ if auth_chain_id_supplied:
829
+ chain_id = self.auth_chain_dict[chain_id]
830
+ if auth_res_ids:
831
+ return self.res_auth_dict[chain_id][1]
832
+ else:
833
+ return self.res_auth_dict[chain_id][0]
834
+
827
835
  def get_full_sequence(self, chain_id: str, auth_chain_id_supplied: bool=False) -> str:
828
836
  """
829
837
  Get full sequence, including missing residues, from the specified chain off of RCSB.
@@ -1067,6 +1075,26 @@ class PDBInformation(StructureInformation):
1067
1075
  self.non_missing_sequences = {str(chain): str(sequence) for (chain, sequence) in list(zip(struc.get_chains(non_hetero_structure), struc.to_sequence(non_hetero_structure)[0]))}
1068
1076
  self.unique_chains = struc.get_chains(non_hetero_structure)
1069
1077
 
1078
+ def get_start_res_id(self, chain_id: str) -> int:
1079
+ """
1080
+ Gets starting residue id of the specified chain excluding heteroatom group entries.
1081
+
1082
+ Parameters
1083
+ ----------
1084
+ chain_id : str
1085
+ The chain id supplied and selected for from the structure.
1086
+
1087
+ Returns
1088
+ -------
1089
+ int
1090
+ The residue id of the first atom in the chain provided.
1091
+ """
1092
+ non_hetero_structure = self.structure[self.structure.hetero == False]
1093
+ if chain_id in self.unique_chains:
1094
+ return non_hetero_structure[non_hetero_structure.chain_id == chain_id][0].res_id
1095
+ else:
1096
+ raise ValueError("Chain supplied not found in structure.")
1097
+
1070
1098
  def get_non_missing_sequence(self, chain_id: str) -> str:
1071
1099
  """
1072
1100
  Get sequence, including only non-missing residues, from the specified chain.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: dcatoolkit
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Collection of useful modules and representations for managing DCA output data.
5
5
  Author-email: Raheel Syed Ahmed <raheelsyedahmed@gmail.com>
6
6
  Maintainer-email: Raheel Syed Ahmed <raheelsyedahmed@gmail.com>
File without changes
File without changes
File without changes