Hi list,
I am wondering what properties are attached to the various levels of a hierarchy and how to retrieve it.
As an example, I would like to know how to get the one-character-code that is attached to a chain.
I have the feeling, this is not strictly feasible, though it is possible to get it as the last character in the particle name of the chain :
import IMP
import IMP.atom
m=IMP.Model()
struct_file_name = "/Users/schwarz/DATA/myPDB/1K8K.pdb"
struct1k8k=IMP.atom.read_pdb(struct_file_name,m)
c0=struct1k8k.get_child(0)
print c0.get_name()
Will result in 'Chain A' being output. Looking at the other properties stored in my c0 chain, I see that everything seems to be integer, including a "chain" attribute that I try to access through
chainKey = c0.get_int_attributes()[2]
which results in the integer 65 being output...
My questions now :
1. Is there a way to get directly the one letter code of a chain ?
2. If not, is there a guaranty that the letter used in the particle name will always reflect the chain ID, or is there a fixed mapping between the value of the chainKey attribute and the chain one letter code ?
3. Is there a nicer way to get a keyType for instance from its string ? In my example, I retrieved chainKey as the third element of the integer keys list returned by get_int_attributes(), this is not very satisfying, and I thought of resorting to a function such as :
def getChainKey( chain ):
for k in chain.get_int_attributes() :
if k.get_string() == 'chain' :
return k
return None
Still, I wonder if there is an IMP mechanism I am not aware of, that I should prefer instead.
--Ben.S
_______________________________________________