Skip to content

Fix: CIF parser wasn't respecting parseCAOnly - #1156

Merged
josemduarte merged 4 commits into
biojava:masterfrom
josemduarte:jd/fixcaonly-cif
Sep 17, 2026
Merged

josemduarte merged 4 commits into
biojava:masterfrom
josemduarte:jd/fixcaonly-cif

Conversation

@josemduarte

Copy link
Copy Markdown
Contributor

Including a new unit test for it.

@sbittrich
sbittrich self-requested a review September 15, 2026 06:01

@sbittrich sbittrich left a comment

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.

LGTM, thanks.
Would consider moving the fixed logic though.

Comment on lines +322 to +323
// keep only C-alpha atoms; requiring element C excludes calcium ions, whose atom name is also CA
if (!(labelAtomId.get(atomIndex).equals(StructureTools.CA_ATOM_NAME) && "C".equals(typeSymbol.get(atomIndex)))) {

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.

Suggested change
// keep only C-alpha atoms; requiring element C excludes calcium ions, whose atom name is also CA
if (!(labelAtomId.get(atomIndex).equals(StructureTools.CA_ATOM_NAME) && "C".equals(typeSymbol.get(atomIndex)))) {
for (int atomIndex = 0; atomIndex < atomSite.getRowCount(); atomIndex++) {
if (params.isParseCAOnly()) {
// keep only C-alpha atoms; requiring element C excludes calcium ions, whose atom name is also CA
if (!(labelAtomId.get(atomIndex).equals(StructureTools.CA_ATOM_NAME) && "C".equals(typeSymbol.get(atomIndex)))) {
continue;
}
}
boolean startOfNewChain = false;

There may be another bug here. Because the check happens this late, lots of empty groups and chains are created.
How about moving it all the way up and making it the first action in the loop?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indeed, good point. The empty chain/groups are actually another bug by itself. Should be fixed in 0b8427a

@sbittrich sbittrich left a comment

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.

Nice, thank you

@josemduarte
josemduarte merged commit a917ec8 into biojava:master Sep 17, 2026
4 of 5 checks passed
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