[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [IMP-users] How to : Access chain properties such as chain ID. Access particle properties.



The chain_id is the ascii value for the letter stored in the PDB file. I think the main reason for directly returning an int instead of the char is that 26 is kind of a small limit.


On Mar 22, 2011, at 8:07 AM, Benjamin SCHWARZ wrote:

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]
c0.get_value(chainKey)

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
_______________________________________________
IMP-users mailing list
">
https://salilab.org/mailman/listinfo/imp-users