Skip to content

add chain_id parameter, fix atom name issue, specify torch-fourier-sl… - #9

Open
pcbve1 wants to merge 2 commits into
Lucaslab-Berkeley:mainfrom
pcbve1:specific_chain
Open

add chain_id parameter, fix atom name issue, specify torch-fourier-sl…#9
pcbve1 wants to merge 2 commits into
Lucaslab-Berkeley:mainfrom
pcbve1:specific_chain

Conversation

@pcbve1

@pcbve1 pcbve1 commented Jul 23, 2026

Copy link
Copy Markdown

…ice version

  • Added chain_id as a parameter for ChainTemplateIterator and ResidueTemplateIterator. This allows users to specify which chains to delete and which chains to tile through, reducing the number of tests and decreasing runtime. Chain names must match those in the input PDB file.
  • Fixed a bug where atom scattering potential calculations crashed when atom names contained more than one character (e.g., metal ions).
  • Fixed a common installation issue where MOSAICS could be installed with an incompatible version of torch-fourier-slice. pyproject.toml now explicitly requires torch-fourier-slice>=0.4.0, ensuring a compatible version is installed.

@pcbve1 pcbve1 closed this Jul 23, 2026
@pcbve1 pcbve1 reopened this Jul 23, 2026
Comment thread src/mosaics/template_iterator.py Outdated
unique_chain_ids = self.chain_ids

for chain_id in unique_chain_ids:
print(f"Removing chain {chain_id}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not have print statements within code, especially looped areas of code (design choice)

@pcbve1 pcbve1 Jul 24, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed both print statements. Will open an issue and discuss how best to track deleted residues and chains

Comment thread src/mosaics/template_iterator.py Outdated
for idx in window_iter:
chain_ids = chains[idx]
residue_ids = residues[idx]
print(f"Removing residues {residue_ids[0]} to {residue_ids[-1]}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, no print statements in production code

Comment thread pyproject.toml Outdated
"ttsim3d",
"teamtomo-basemodel",
"Leopard-EM>=v1.0",
"torch-fourier-slice>=v0.4.0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should bump this to ...>=v0.5.2 for all TeamTomo packages as newest release with some minor bug fixes and API updates.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated this line, looks to me like torch-fourier-slice and ttsim3d are the only TeamTomo packages explicitly imported by MOSAICs; the rest are dependencies of Leopard-EM. I'll keep the rest in their current versions, only because if the version of torch-fourier-slice is not defined, MOSAICS crashes. I have not encountered this issue for the other packages.

Comment thread src/mosaics/template_iterator.py Outdated
Comment on lines +519 to +531
chain_ids: list[str] = ["all"]
randomize_chain_order: bool = False

_chain_order: list[str]

def __init__(self, **data: Any):
super().__init__(**data)

# The unique method should retain default order
self._chain_order = self.structure_df["chain"].unique()
# The unique method should retain default order, or an order specified by the user.
if self.chain_ids == ["all"]:
self._chain_order = self.structure_df["chain"].unique()
else:
self._chain_order = self.chain_ids

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicer approach than having a helper function to set an internal parameter for chain ordering. If chain_ids exist, then we should be able to remove _chain_order and use the new list for iteration.

Two things to note:

  • Would prefer a default value of None which then draws the unique chain names from the dataframes upon initialization rather than string "all".
  • Should add assertion / ValueError if any of the strings (chain IDs) are not contained in the DataFrame upon initialization.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented those changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants