Skip to content

Customized batch exhibition of three-dimensional molecules based on pymol framework

License

Notifications You must be signed in to change notification settings

HaolingZHANG/pymolBE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pymolBE

Customized batch exhibition of three-dimensional molecules based on the pymol framework

Installation

You can use this tool through pymolbe.py. This tool requires a Python version >=3.7, as well as some basic libraries PyMOL 2.5.0, biopython 1.78, matplotlib 3.1.1, Pillow 8.2.0, and numpy.

Repository Structure

The structure of this tool is shown below:

├── examples                // Examples of pymolBE
├── pymolbe.py              // Source code of pymolBE
│    ├── draw_colorfully    // Draw a molecular structure colorfully
│    ├── draw_specially     // Draw a molecular structure with special motifs
│    ├── merge_pictures     // Merge multiple structure pictures into a picture
│    ├── merge_animations   // Merge multiple structure animations into a animation
│    ├── set_initial_state  // Set the initial state of a structure with specific representation
│    ├── set_residue_colors // Set residue color for the structure
│    ├── set_motif_colors   // Set the color of each motif
├── README.md               // Description document of library

Usage & Parameters

Please check each interface annotation for more information.

Exhibition Examples

These examples are successfully run in example folder.

Draw a static picture for a PDB file

run the following statements

from pymolbe import draw_colorfully

draw_colorfully(load_path="./data/p.pdb", 
                save_path="./figures/ps_c.png",
                hides=["(r. HOH)"])

and obtain

ps_c.png

Draw an animation for a PDB file that revolved around the y-axis

run the following statements

from pymolbe import draw_colorfully

draw_colorfully(load_path="./data/p.pdb", 
                save_path="./figures/ps_c.gif",
                hides=["(r. HOH)"], 
                is_movie=True, 
                shafts="y")

and obtain

ps_c.png

Draw an animation for a mmCIF file that revolved around the y-axis

run the following statements

from pymolbe import draw_colorfully

draw_colorfully(load_path="./data/d.cif", 
                save_path="./figures/ds_c.gif",
                hides=["(r. HOH)"], 
                is_movie=True, 
                shafts="y")

and obtain

ds_c.gif

Draw an animation for a mmCIF file that revolved around the y-axis with sticks format

run the following statements

from pymolbe import draw_colorfully

draw_colorfully(load_path="./data/d.cif", 
                save_path="./figures/ds_s.gif",
                representation="sticks",  
                hides=["(r. HOH)"], 
                is_movie=True, 
                shafts="y")

and obtain

ds_s.gif

Draw an animation for a PDB file that revolved around the y-axis with motif "RG"

run the following statements

from pymolbe import draw_specially

draw_specially(load_path="./data/p.pdb", 
               save_path="./figures/ps_s.gif", 
               motif_colors={"RG": "0xff0000"},
               hides=["(r. HOH)"], 
               is_movie=True, 
               shafts="y")

and obtain

ps_s.gif

Draw an animation for a PDB file that revolved around the xyz-axis with motif "RG"

run the following statements

from pymolbe import draw_specially

draw_specially(load_path="./data/p.pdb", 
               save_path="./figures/ps_xyz.gif", 
               motif_colors={"RG": "0xff0000"},
               hides=["(r. HOH)"], 
               is_movie=True, 
               shafts="xyz")

and obtain

ps_xyz.gif

Draw a merged picture for 40 PDB files that contain motif "HHHHH"

run the following statements

from os import listdir, remove
from pymolbe import draw_colorfully, merge_pictures

temp_paths, titles = [], []
for index, child_path in enumerate(listdir("./data/m/")):
    temp_path = "./figures/temp" + str(index + 1).zfill(2) + ".png"
    draw_colorfully(load_path="./data/m/" + child_path, 
                    save_path=temp_path)
    titles.append(child_path[:4])
    temp_paths.append(temp_path)

merge_pictures(load_paths=temp_paths, 
               save_path="./figures/m_p.png", 
               row_number=5, 
               column_number=8,
               figure_size=(10, 6), 
               titles=titles)

for used_path in temp_paths:
    remove(used_path)

and obtain

m_p.png

Draw a merged animation for 40 PDB files simultaneously that contain motif "HHHHH" (emphasizing the location of motif)

run the following statements

from os import listdir, remove
from pymolbe import draw_specially, merge_animations

temp_paths, titles = [], []
for index, child_path in enumerate(listdir("./data/m/")):
    temp_path = "./figures/temp" + str(index + 1).zfill(2) + ".gif"
    draw_specially(load_path="./data/m/" + child_path, 
                   save_path=temp_path, 
                   motif_colors={"HHHHH": "0xff0000"},
                   is_movie=True, 
                   shafts="y")
    titles.append(child_path[:4])
    temp_paths.append(temp_path)

merge_animations(load_paths=temp_paths, 
                 save_path="./figures/m_ps.gif", 
                 row_number=5, 
                 column_number=8,
                 figure_size=(10, 6), 
                 titles=titles, 
                 simultaneous=True)

for used_path in temp_paths:
    remove(used_path)

and obtain

m_ps.gif

Draw a merged animation for 40 PDB files case-by-case that contain motif "HHHHH" (emphasizing the location of motif)

run the following statements

from os import listdir, remove
from pymolbe import draw_specially, merge_animations

temp_paths, titles = [], []
for index, child_path in enumerate(listdir("./data/m/")):
    temp_path = "./figures/temp" + str(index + 1).zfill(2) + ".gif"
    draw_specially(load_path="./data/m/" + child_path, 
                   save_path=temp_path, 
                   motif_colors={"HHHHH": "0xff0000"},
                   is_movie=True, 
                   shafts="y")
    titles.append(child_path[:4])
    temp_paths.append(temp_path)

merge_animations(load_paths=temp_paths, 
                 save_path="./figures/m_pi.gif", 
                 figure_size=(10, 6), 
                 titles=titles, 
                 simultaneous=False,
                 fps=20)

for used_path in temp_paths:
    remove(used_path)

and obtain

m_pi.gif

About

Customized batch exhibition of three-dimensional molecules based on pymol framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages