Closed murfalo closed 2 weeks ago
I think we can do something much simpler. Remember, writeFile()
will be assigning new chain IDs anyway. So it doesn't really matter much what we assign here. We could do something like this.
lastid = chains[-2].id
if len(lastid) == 1 and 'A' <= lastid < 'Z':
chains[-1].id = chr(ord(lastid)+1)
else:
chains[-1].id = 'A'
We need to make this change both in addSolvent()
and addMembrane()
.
Thanks for the feedback, particularly the much simpler if case and ID assignment. I've implemented that and also taken out the assertions, .upper(), and verbose commentary to better match existing code style.
Before porting code over to addMembrane()
, I have two questions regarding your proposed method:
lastid = chains[-2].id
most often refer to the numeric ID of the newly created solvent chain?Good point. The number of chains added could be either 1 or 2 for addSolvent()
, and either 2 or 3 for addMembrane()
. Maybe write a _renameNewChains()
method that can be called in both cases? You'll pass in the number of chains that previously existed, and it will figure out how many new ones were added and pick appropriate names for them.
Done! Added _renameNewChains()
and updated addSolvent()
and addMembrane()
. How do things look?
Looks good. Thanks!
How does this approach work for fixing #287? This should assign B-Z if the previous chain ID was A-Y, and otherwise leave the ID as a numeric chain ID.
One comment: I noticed PDBFile and PDBxFile simply use
% 26
to map numeric IDs to the alphabet. Should we warn the user somehow that disparate chains may be assigned matching IDs in these cases?