There seems to be a few ways to do this. If you have loaded a pose as my_pose - First, you could use len(my_pose.chain_sequence( chain_id ). You could also use the chain_end and chain_begin functions from the conformation object:
start = my_pose.conformation().chain_begin( chain_id )
end = my_pose.conformation().chain_end( chain_id )
and then end - start +1 to get the length.
There are a number of chain utilities for converting to and from chain_id/char/string in core/pose/util. They should be imported with the 'from rosetta import *' command. Here are a few (the core::Size corresponds to the chain id ):
Hey Felipet,
There seems to be a few ways to do this. If you have loaded a pose as my_pose - First, you could use len(my_pose.chain_sequence( chain_id ). You could also use the chain_end and chain_begin functions from the conformation object:
start = my_pose.conformation().chain_begin( chain_id )
end = my_pose.conformation().chain_end( chain_id )
and then end - start +1 to get the length.
There are a number of chain utilities for converting to and from chain_id/char/string in core/pose/util. They should be imported with the 'from rosetta import *' command. Here are a few (the core::Size corresponds to the chain id ):
bool
has_chain(std::string const & chain, core::pose::Pose const & pose);
bool
has_chain(char const & chain, core::pose::Pose const & pose);
bool
has_chain(core::Size chain_id, core::pose::Pose const & pose);
std::set<core::Size>
get_jump_ids_from_chain_ids(std::set<core::Size> const chain_ids, core::pose::Pose const & pose);
core::Size
get_jump_id_from_chain_id(core::Size const & chain_id, core::pose::Pose const & pose);
//std::set<core::Size> get_chain_ids(core::pose::Pose const & pose);
core::Size
get_chain_id_from_chain(std::string const & chain, core::pose::Pose const & pose);
core::Size
get_chain_id_from_chain(char const & chain, core::pose::Pose const & pose);
utility::vector1<core::Size>
get_chain_ids_from_chain(std::string const & chain, core::pose::Pose const & pose);
utility::vector1<core::Size>
get_chain_ids_from_chain(char const & chain, core::pose::Pose const & pose);
utility::vector1<core::Size>
get_chain_ids_from_chains(utility::vector1<std::string> const & chains, core::pose::Pose const & pose);
char
get_chain_from_chain_id(core::Size const & chain_id, core::pose::Pose const & pose);
core::conformation::ResidueCOPs
get_chain_residues(core::pose::Pose const & pose, core::Size chain_id);
Hope this helps!
-Jared