Skip to content

SKETCH-2782: get_residue_number_for_new_monomer now uses one residue number per monomer, even for nucleic acids - #372

Merged
KevKeating merged 4 commits into
schrodinger:mainfrom
KevKeating:pr/SKETCH-2782
Jun 29, 2026
Merged

SKETCH-2782: get_residue_number_for_new_monomer now uses one residue number per monomer, even for nucleic acids#372
KevKeating merged 4 commits into
schrodinger:mainfrom
KevKeating:pr/SKETCH-2782

Conversation

@KevKeating

Copy link
Copy Markdown
Collaborator

Description

Based on this discussion, I've modified get_residue_number_for_new_monomer to use one residue number per monomer, even for nucleic acids.

Testing Done

Added unit tests coverage for the new logic.

Comment on lines +757 to +762
if (new_monomer_ap_name ==
ap_model_name_for(NASugarAP::THREE_PRIME)) {
// a new sugar bound to the next phosphate. We skip a number
// since the base is typically given the number immediately
// after the sugar
res_num_offset = -2;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we be worried about this "typically"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not really. This would only be an issue if the user is intentionally leaving an abasic site (i.e. a missing base), and even then, the only result of this would be that the residues aren't numbered sequentially, which shouldn't have any real consequences. If we want a guarantee that we have the ideal residue numbering, i.e. starting at one and continuing sequentially in the correct order, we'll need to renumber the entire strand after it's been built. That's probably not worth worrying about unless we know of something downstream that's requires it.

Comment thread src/schrodinger/sketcher/model/mol_model.cpp Outdated
Comment thread src/schrodinger/sketcher/model/mol_model.cpp Outdated
{
using rdkit_extensions::ChainType;

auto monomer_type = get_monomer_type_from_chain_type(chain_type, res_name);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

General comment but not urgent - I'm not sure whether you will always be able to determine whether something is a base/sugar/phosphate based off residue name. I'm not sure how common it will be but there are customers with modified phosphate linkers and sugars that won't adhere to a certain naming convention - you maybe need to deduce by a substructure match, or just rely completely on the attachment points used

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, agreed. We might want to record information about the monomer type when the monomer is added, since Sketcher and/or the HELM converter would presumably be in the best position to figure that out (and the Sketcher would likely have additional information about the monomer based on the tool being used). I've filed SKETCH-2796 for this.

new_monomer_ap_name ==
ap_model_name_for(NAPhosphateAP::TO_PREV_SUGAR)) {
res_num_offset = -1;
} else if (!((monomer_type == MonomerType::NA_PHOSPHATE &&

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wouldn't these offsets be +1 and +2? Totally possible I am not understanding the MonomerType enum correctly - is this a base connecting to a sugar then a phosphate connecting to the same sugar? if the sugar is 0, I would think that the base is 1 then the phosphate is 2

@KevKeating KevKeating Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it looks like a bunch of the numbers here are off. Good catch! I'll fix that and update the tests, both to check for the correct results and hopefully to make those types of issues more obvious. (I also temporarily tweaked monomer drawing locally so it includes the residue numbers to verify that the current numbering is wrong, since I kept getting myself massively confused trying to reason through the numbering here.)

Comment on lines +4888 to +4896
// check residue numbers for sugars bound to the phosphate
auto prev_sugar_num = get_residue_number_for_new_monomer(
"R", ChainType::RNA, ap_model_name_for(NASugarAP::THREE_PRIME),
phosphate);
auto next_sugar_num = get_residue_number_for_new_monomer(
"R", ChainType::RNA, ap_model_name_for(NASugarAP::FIVE_PRIME),
phosphate);
BOOST_TEST(prev_sugar_num == 8u);
BOOST_TEST(next_sugar_num == 11u);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it would be worth adding comments here (and on the test below) that briefly explain why we should expect these specific residue numbers.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that seems helpful. Added.

@KevKeating
KevKeating added this pull request to the merge queue Jun 29, 2026
Merged via the queue into schrodinger:main with commit 30b2d92 Jun 29, 2026
6 checks passed
@KevKeating
KevKeating deleted the pr/SKETCH-2782 branch June 29, 2026 17:03
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.

3 participants