Bioinformatics ReviewBioinformatics Review
Notification Show More
Font ResizerAa
  •  Home
  • Docking
  • MD Simulation
  • Tools
  • More Topics
    • Softwares
    • Sequence Analysis
    • Algorithms
    • Bioinformatics Programming
    • Bioinformatics Research Updates
    • Drug Discovery
    • Phylogenetics
    • Structural Bioinformatics
    • Editorials
    • Tips & Tricks
    • Bioinformatics News
    • Featured
    • Genomics
    • Bioinformatics Infographics
  • Community
    • BiR-Research Group
    • Community Q&A
    • Ask a question
    • Join Telegram Channel
    • Join Facebook Group
    • Join Reddit Group
    • Subscription Options
    • Become a Patron
    • Write for us
  • About Us
    • About BiR
    • BiR Scope
    • The Team
    • Guidelines for Research Collaboration
    • Feedback
    • Contact Us
    • Recent @ BiR
  • Subscription
  • Account
    • Visit Dashboard
    • Login
Font ResizerAa
Bioinformatics ReviewBioinformatics Review
Search
Have an existing account? Sign In
Follow US
Bioinformatics ProgrammingPython

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

Dr. Muniba Faiza
Last updated: April 24, 2022 5:00 pm
Dr. Muniba Faiza
Share
1 Min Read
How to calculate center of mass of a protein structure using Python script?
SHARE

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.
TAGGED:centerofmassPymolpython script
Share This Article
Facebook Copy Link Print
ByDr. Muniba Faiza
Follow:
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
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

Starting in Bioinformatics? Do This First!
Starting in Bioinformatics? Do This First!
Tips & Tricks
[Editorial] Is it ethical to change the order of authors’ names in a manuscript?
Editorial Opinion
Installing bbtools on Ubuntu
[Tutorial] Installing BBTools on Ubuntu (Linux).
Sequence Analysis Software Tools
wes_data_analysis Whole Exome Sequencing (WES) Data visualization Toolkit
wes_data_analysis: Whole Exome Sequencing (WES) Data visualization Toolkit
Bioinformatics Programming GitHub Python

You Might Also Like

How to commit changes to GitHub repository using vs code?
Bioinformatics ProgrammingGitHub

How to commit changes to GitHub repository using vs code?

February 28, 2024
How to sort binding affinities based on a cutoff using vs_analysis.py script?
Bioinformatics ProgrammingPythonVirtual Screening

How to sort binding affinities based on a cutoff using vs_analysis.py script?

January 10, 2024
SQL queries for complex information retrieval
Bioinformatics ProgrammingSQL

Nested SQL queries and aggregate functions for complex information retrieval from a database

October 1, 2020
python programming
Bioinformatics Programming

How to search for a specific character in a file using Python?

October 27, 2020
Copyright 2024 IQL Technologies
  • Journal
  • Customer Support
  • Contact Us
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Cookie Policy
  • Sitemap
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?

Not a member? Sign Up