00001 /** 00002 * \file Chain.h 00003 * \brief Store the chain ID 00004 * 00005 * Copyright 2007-2010 IMP Inventors. All rights reserved. 00006 */ 00007 00008 #ifndef IMPATOM_CHAIN_H 00009 #define IMPATOM_CHAIN_H 00010 00011 #include "atom_config.h" 00012 #include "Hierarchy.h" 00013 #include <IMP/macros.h> 00014 #include <IMP/Decorator.h> 00015 00016 IMPATOM_BEGIN_NAMESPACE 00017 00018 //! Store info for a chain of a protein 00019 /** \see Hierarchy 00020 */ 00021 class IMPATOMEXPORT Chain: public Hierarchy 00022 { 00023 IMP_DECORATOR(Chain, Hierarchy); 00024 public: 00025 static Chain setup_particle(Particle *p, char id) { 00026 p->add_attribute(get_id_key(), id); 00027 if (!Hierarchy::particle_is_instance(p)) { 00028 Hierarchy::setup_particle(p); 00029 } 00030 return Chain(p); 00031 } 00032 00033 static Chain setup_particle(Particle *p, Chain o) { 00034 p->add_attribute(get_id_key(), o.get_id()); 00035 if (!Hierarchy::particle_is_instance(p)) { 00036 Hierarchy::setup_particle(p); 00037 } 00038 return Chain(p); 00039 } 00040 00041 00042 static bool particle_is_instance(Particle *p) { 00043 return p->has_attribute(get_id_key()) 00044 && Hierarchy::particle_is_instance(p); 00045 } 00046 00047 //! Return the chain id 00048 char get_id() const { 00049 return get_particle()->get_value(get_id_key()); 00050 } 00051 00052 //! Set the chain id 00053 void set_id(char c) { 00054 get_particle()->set_value(get_id_key(), c); 00055 } 00056 00057 //! The key used to store the chain 00058 static IntKey get_id_key(); 00059 }; 00060 00061 IMP_DECORATORS(Chain, Hierarchies); 00062 /** \decorators{Chain} 00063 */ 00064 /** \decoratorstemp{Chain} 00065 */ 00066 00067 IMP_OUTPUT_OPERATOR(Chain); 00068 00069 IMPATOM_END_NAMESPACE 00070 00071 #endif /* IMPATOM_CHAIN_H */