Skip to content

Commit 341f6d6

Browse files
committed
posts
1 parent 3e02ec5 commit 341f6d6

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
File renamed without changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
gt---
2+
layout: post
3+
title: Chain renaming in PyMOL
4+
date: 2024-06-06 10:32:13
5+
description: Renaming chains uniquely
6+
tags:
7+
categories:
8+
tabs: true
9+
---
10+
11+
For some reason, I wanted to rename all the chains in a PyMOL session to be unique once. Here's a script to do so.
12+
13+
```python
14+
from string import ascii_uppercase
15+
16+
i = 0
17+
18+
for model in cmd.get_object_list():\
19+
if i > 25:\
20+
chain_id = "A" + ascii_uppercase[i-26]\
21+
else:\
22+
chain_id = ascii_uppercase[i]\
23+
cmd.alter(model, f"chain=\"{chain_id}\"")\
24+
i = i + 1
25+
```

0 commit comments

Comments
 (0)