My main Script
from Bio.PDB import *
import os
import subprocess
pdbl = PDBList()
new1=input("Enter PDB id: ")
file=pdbl.retrieve_pdb_file(new1, pdir = '.', file_format = 'pdb')
records = []
with open(file, "r") as f:
for line in f:
if "HETATM" not in line and "CONECT" not in line :
records.append(line)
if 'ATP' in line:
line = line.replace('ATP', 'LIG')
records.append(line)
with open("new.pdb", "w") as f:
for line in records:
f.write(line)
def vmd():
a = list(("vmd new.pdb -e command.txt").split(" "))
subprocess.Popen(a)
subprocess.run('start' ,shell=True)
vmd()
Script for plotting
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from mpl_toolkits.mplot3d import Axes3D
import sys
data = pd.read_csv("bonds.csv")
print(data.head())
print("\n")
print(" Welcome to Plotter ")
print(" Here you can plot and your desired plot will be save to your directory")
print("\n")
def amino_acid():
head1=np.array(data['LIG'])
head2=np.array(data['Amino_acid'])
bar(head1, head2)
def intrections():
col1=np.array(data['Amino_acid'])
col2=np.array(data['Molecule'])
bar_plot(col1, col2)
def bar(head1,head2):
new=np.arange(len(head1))
sns.barplot(new,list(head2),palette = 'hls',saturation = 10, label='Amino acid')
plt.xlabel('Ligand')
plt.ylabel('amino acid')
plt.title('amino acid')
plt.legend(fontsize=10)
plt.savefig("Amino_acid.png")
plt.show()
def bar_plot(col1,col2):
new=np.arange(len(col1))
sns.barplot(new,list(col2),palette = 'hls',saturation = 10, label='Intrections')
plt.ylabel('No of intrections')
plt.xlabel('Amino acid')
plt.title('Bar Plot')
plt.legend(fontsize=10)
plt.savefig("Intrections.png")
plt.show()
while True:
choice=int(input("To plot number of Amino acids press 1\nTo plot number of Interctions press 2\nTo exit press 0\n"))
if choice==1:
amino_acid()
elif choice==2:
intrections()
elif choice==0:
sys.exit(0)
Script for a simple plot
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
data = pd.read_csv("bonds.csv")
col1=np.array(data['LIG'])
col2=np.array(data['Amino_acid'])
def bar(col1,col2):
new=np.arange(len(col1))
sns.barplot(new,list(col2))
plt.xlabel('Ligand')
plt.ylabel('amino acid')
plt.title('amino acid')
plt.legend(fontsize=10)
plt.savefig("Amino_acid.png")
plt.show()
bar(col1,col2)
Script for bonds: (command.txt)
set filename "bonds.csv"
set fbonds [open $filename "w"]
puts -nonewline $fbonds "col1,LIG,col3,col4,Amino_acid,Molecule,Value"
puts -nonewline $fbonds "\n"
set all [atomselect top "resname LIG"]
set at [$all list]
set mt [molinfo top]
foreach i $at {
set p [atomselect top "within 5 of index $i"]
set pt [$p list]
foreach tl $pt {
set c 0
foreach tt $at {
if { $tt == $tl } {
set c 1
}
}
if { $c == 0} {
lappend tn $tl
}
}
foreach j $tn {
set rj [atomselect top "index $j"]
set mm [measure bond "$j $i"]
if { $mm < 4} {
label add Bonds $mt/$j $mt/$i
label add Atoms $mt/$j
set ri [atomselect top "index $i"]
set pt1a [ $ri get name ]
set pt1r [ $ri get resid ]
set pt1rn [ $ri get resname ]
set pt2a [ $rj get name ]
set pt2r [ $rj get resid ]
set pt2rn [ $rj get resname ]
puts -nonewline $fbonds "$pt1r,$pt1rn,$pt1a,$pt2r,$pt2rn,$pt2a,$mm"
puts -nonewline $fbonds "\n"
unset -nocomplain rj
unset -nocomplain ri
}
}
set tn [lreplace $tn 0 0]
}
label hide Bonds all
label hide Atoms all
close $fbonds
0 Comments