There’s actually a bit of code in Rosetta which does something similar already. It’s not encapsulated in an easy-to-use form, but you can potentially crib from it.
This is the code in PoseFromSFRBuilder::build_initial_pose() which handles the `-missing_density_to_jump`. The core of this is as follows:
core::Real bondlength = ( prev_rsd.atom( prev_rsd.upper_connect_atom() ).xyz() -
this_rsd.atom( this_rsd.lower_connect_atom() ).xyz() ).length();
if ( bondlength > 3.0 ) {
// Add TRUNC_VARIANT, as appropriate
}
(Yes, that 3.0 is hard-coded)
Alternatively, you could run with the -missing_density_to_jump option on, and look for residues with the UPPERTERM_TRUNC_VARIANT and LOWERTERM_TRUNC_VARIANT.