Connect with us

Bioinformatics Programming

How to calculate center of mass of a protein structure using Python script?

Published

on

How to calculate center of mass of a protein structure using Python script?

Here is a Python script that helps you calculate the center of mass of a protein using the Pymol [1].

Make sure that you have installed Pymol on your system otherwise, you will get an error stating “No Pymol module found”. If Pymol is not in your path, then run this script from the Pymol directory itself.


import __main__
__main__.pymol_argv = [ 'pymol', '-qc']            #quiet and no GUI
import sys, time, os
import pymol

pymol.finish_launching()

##### Reading user input #####
spath = os.path.abspath(sys.argv[1])
filename = spath.split('/')[-1].split('.')[0]

##### Loading structures #####
pymol.cmd.load(spath, filename)
pymol.cmd.disable("all")
pymol.cmd.enable(filename)
pymol.cmd.centerofmass(filename)

##### Getting output in a file #####
output = pymol.cmd.centerofmass(filename)
sys.stdout = open('output.txt','w')
print ((filename), (output))

##### Quiting #####
pymol.cmd.quit()

If you don’t want to write into a file, then comment out the “Getting output in a file” section. It will display the output on the terminal.

Now, save this file. We are saving it as com.py. Run this file as shown below:

$ python com.py <pdb_file>

OR

$ python3 com.py <pdb_file>

If your input PDB file is in different directory, then provide full path to it.


References

  1. The PyMOL Molecular Graphics System, Version 1.2r3pre, Schrödinger, LLC.

Dr. Muniba is a Bioinformatician based in New Delhi, India. She has completed her PhD in Bioinformatics from South China University of Technology, Guangzhou, China. She has cutting edge knowledge of bioinformatics tools, algorithms, and drug designing. When she is not reading she is found enjoying with the family. Know more about Muniba

Bioinformatics Programming

How to make swarm boxplot?

Published

on

How to make swarm boxplot?

With the new year, we are going to start with a very simple yet complicated topic (for beginners) in bioinformatics. In this tutorial, we provide a simple code to plot swarm boxplot using matplotlib and seaborn. (more…)

Continue Reading

Bioinformatics Programming

How to obtain ligand structures in PDB format from PDB ligand IDs?

Published

on

How to obtain ligand structures in PDB format from PDB ligand IDs?

Previously, we provided a similar script to download ligand SMILES from PDB ligand IDs. In this article, we are downloading PDB ligand structures from their corresponding IDs. (more…)

Continue Reading

Bioinformatics Programming

How to obtain SMILES of ligands using PDB ligand IDs?

Published

on

How to obtain SMILES of ligands using PDB ligand IDs?

Fetching SMILE strings for a given number of SDF files of chemical compounds is not such a trivial task. We can quickly obtain them using RDKit or OpenBabel. But what if you don’t have SDF files of ligands in the first place? All you have is Ligand IDs from PDB. If they are a few then you can think of downloading SDF files manually but still, it seems time-consuming, especially when you have multiple compounds to work with. Therefore, we provide a Python script that will read all Ligand IDs and fetch their SDF files, and will finally convert them into SMILE strings. (more…)

Continue Reading

LATEST ISSUE

ADVERT