Browse files

Added an insert method to Entity. This allows a child to be inserted …

…into a specified position in the child_list which effects position in the PDB output.
  • Loading branch information...
1 parent 0d8299a commit ed4ca9c68e5654560f2ff55fb128e441bc810b2a @benreynwar benreynwar committed with etal Aug 18, 2011
Showing with 10 additions and 0 deletions.
  1. +10 −0 Bio/PDB/Entity.py
View
10 Bio/PDB/Entity.py
@@ -84,6 +84,16 @@ def add(self, entity):
self.child_list.append(entity)
self.child_dict[entity_id]=entity
+ def insert(self, pos, entity):
+ "Add a child to the Entity at a specified position."
+ entity_id=entity.get_id()
+ if self.has_id(entity_id):
+ raise PDBConstructionException( \
+ "%s defined twice" % str(entity_id))
+ entity.set_parent(self)
+ self.child_list[pos:pos] = [entity]
+ self.child_dict[entity_id]=entity
+
def get_iterator(self):
"Return iterator over children."
for child in self.child_list:

0 comments on commit ed4ca9c

Please sign in to comment.