Skip to content

Commit ed4ca9c

Browse files
benreynwaretal
authored andcommitted
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.
1 parent 0d8299a commit ed4ca9c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Bio/PDB/Entity.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ def add(self, entity):
8484
self.child_list.append(entity)
8585
self.child_dict[entity_id]=entity
8686

87+
def insert(self, pos, entity):
88+
"Add a child to the Entity at a specified position."
89+
entity_id=entity.get_id()
90+
if self.has_id(entity_id):
91+
raise PDBConstructionException( \
92+
"%s defined twice" % str(entity_id))
93+
entity.set_parent(self)
94+
self.child_list[pos:pos] = [entity]
95+
self.child_dict[entity_id]=entity
96+
8797
def get_iterator(self):
8898
"Return iterator over children."
8999
for child in self.child_list:

0 commit comments

Comments
 (0)