Skip to content

Commit

Permalink
added constriction site generation to the registry
Browse files Browse the repository at this point in the history
  • Loading branch information
rtviii committed Nov 24, 2024
1 parent ee917f6 commit b8a900e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
5 changes: 2 additions & 3 deletions kdtree_approach.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def transform_points_to_C0(points: np.ndarray, base_point: np.ndarray, axis_poin

return points_transformed


def transform_points_from_C0(points: np.ndarray, base_point: np.ndarray, axis_point: np.ndarray) -> np.ndarray:
translation, rotation = get_transformation_to_C0(base_point, axis_point)
points_unrotated = points @ rotation
Expand All @@ -63,9 +62,9 @@ def transform_points_from_C0(points: np.ndarray, base_point: np.ndarray, axis_po
return points_untranslated
def main():
# Load your points and transform them as before
RCSB_ID = '4UG0'
RCSB_ID = '8QSJ'
R = 40
H = 120
H = 100
Vsize = 1
ATOM_SIZE = 2
base_point = np.array(PTC_location(RCSB_ID).location)
Expand Down
1 change: 1 addition & 0 deletions ribctl/asset_manager/asset_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def get_asset_path(self, pdb_id: str, asset_type: AssetType) -> Path:
AssetType.MMCIF : "{asset_dir}/{pdb_id}.cif",
AssetType.STRUCTURE_PROFILE : "{asset_dir}/{pdb_id}.json",
AssetType.PTC : "{asset_dir}/{pdb_id}_PTC.json",
AssetType.CONSTRICTION_SITE : "{asset_dir}/{pdb_id}_CONSTRICTION_SITE.json",
# AssetType.THUMBNAIL : "{asset_dir}/{pdb_id}.png",
# AssetType.CLASSIFICATION_REPORT: "{asset_dir}/classification_report_{pdb_id}.json",
# AssetType.NPET_MESH : "{asset_dir}/TUNNELS/{pdb_id}_NPET_MESH.ply",
Expand Down
9 changes: 6 additions & 3 deletions ribctl/asset_manager/asset_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from ribctl import RIBETL_DATA
from ribctl.asset_manager.asset_manager import RibosomeAssetManager
from ribctl.etl.etl_collector import ETLCollector
from ribctl.lib.landmarks.constriction import get_constriction
from ribctl.lib.landmarks.ptc_via_trna import PTC_location
from ribctl.lib.schema.types_ribosome import PTCInfo, RibosomeStructure
from ribctl.lib.schema.types_ribosome import ConstrictionSite, PTCInfo, RibosomeStructure
from .asset_types import AssetType

ModelT = TypeVar("ModelT", bound=BaseModel)
Expand Down Expand Up @@ -83,7 +84,6 @@ async def generate_multiple(
for asset_type in asset_types:
await self.generate_asset(rcsb_id, asset_type, force)


main_registry = AssetRegistry(RibosomeAssetManager(RIBETL_DATA))


Expand All @@ -92,7 +92,10 @@ async def generate_profile(rcsb_id: str) -> RibosomeStructure:
profile = await ETLCollector(rcsb_id).generate_profile()
return profile


@main_registry.register(AssetType.PTC)
async def generate_ptc(rcsb_id: str) -> PTCInfo:
return PTC_location(rcsb_id)

@main_registry.register(AssetType.CONSTRICTION_SITE)
async def generate_constriction(rcsb_id: str) -> ConstrictionSite:
return ConstrictionSite(location=get_constriction(rcsb_id).tolist())
3 changes: 2 additions & 1 deletion ribctl/asset_manager/asset_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import TypeVar, Generic, Optional, Type, Tuple
from pydantic import BaseModel

from ribctl.lib.schema.types_ribosome import PTCInfo, RibosomeStructure
from ribctl.lib.schema.types_ribosome import ConstrictionSite, PTCInfo, RibosomeStructure

# Type for any pydantic model
ModelT = TypeVar('ModelT', bound=BaseModel)
Expand All @@ -33,6 +33,7 @@ class AssetType(Enum):
# Model Based assets
STRUCTURE_PROFILE = AssetInfo("profile", model=RibosomeStructure)
PTC = AssetInfo("ptc", model=PTCInfo, dependencies={"STRUCTURE_PROFILE", "MMCIF"});
CONSTRICTION_SITE = AssetInfo("constriction_site", model=ConstrictionSite, dependencies={"STRUCTURE_PROFILE", "MMCIF"});

@property
def model_type(self) -> Optional[Type[BaseModel]]:
Expand Down
3 changes: 2 additions & 1 deletion ribctl/lib/landmarks/constriction.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def get_constriction(rcsb_id: str)->np.ndarray:
if uL4 is None or uL22 is None:
raise ValueError("Could not find uL4 or uL22 in {}".format(rcsb_id))
structure = ro.assets.biopython_structure()
uL4_c :Chain = structure[0][uL4.auth_asym_id]

uL4_c :Chain = structure[0][uL4.auth_asym_id]
uL22_c :Chain = structure[0][uL22.auth_asym_id]

uL4_coords = [(r.center_of_mass() ) for r in uL4_c.child_list]
Expand Down
Binary file modified ribctl/lib/schema/__pycache__/types_ribosome.cpython-312.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions ribctl/lib/schema/types_ribosome.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ class PTCInfo(BaseModel):
location: list[float]
residues: list[ResidueSummary]

class ConstrictionSite(BaseModel):
location: list[float]

class RibosomeStructureMetadata(BaseModel):

def get_polymers_by_assembly(self)->dict[str,list[str]]:
Expand Down

0 comments on commit b8a900e

Please sign in to comment.