In [2]:
%autosave 0
from __future__ import print_function
We will now search for single-stranded motifs within a structure/trajectory. This is performed by using the ss_motif function.
results = bb.ss_motif(query,target,threshold=0.6,out=None,bulges=0)
The function returns a list of hits. Each element in this list is in turn a list containing the following information:
In the following example we search for structures similar to GNRA.pdb
in a crystal structure of the H.Marismortui large ribosomal subunit (PDB 1S72).
In [3]:
import barnaba as bb
# find all GNRA tetraloops in H.Marismortui large ribosomal subunit (PDB 1S72)
query = "../test/data/GNRA.pdb"
target = "../test/data/1S72.pdb"
# call function.
results = bb.ss_motif(query,target,threshold=0.6,out='gnra_loops',bulges=1)
Now we print the fragment residues and their eRMSD distance from the query structure.
In [4]:
for j in range(len(results)):
#seq = "".join([r.split("_")[0] for r in results[j][2]])
print("%2d eRMSD:%5.3f " % (j,results[j][1]))
print(" Sequence: %s" % ",".join(results[j][2]))
print()
We can also calculate RMSD distances for the different hits
In [5]:
import glob
pdbs = glob.glob("gnra_loops*.pdb")
dists = [bb.rmsd(query,f)[0] for f in pdbs]
for j in range(len(results)):
seq = "".join([r.split("_")[0] for r in results[j][2]])
print("%2d eRMSD:%5.3f RMSD: %6.4f" % (j,results[j][1],10.*dists[j]), end="")
print(" Sequence: %s" % seq)
#print "%50s %6.4f AA" % (f,10.*dist[0])
Note that the first hit has a low eRMSD, but no GNRA sequence. Let's have a look at this structure:
In [6]:
import py3Dmol
query_s = open(query,'r').read()
hit_0 = open(pdbs[0],'r').read()
p = py3Dmol.view(width=900,height=600,viewergrid=(1,2))
p.addModel(query_s,'pdb',viewer=(0,0))
p.addModel(hit_0,'pdb',viewer=(0,1))
p.setStyle({'stick':{}})
p.setBackgroundColor('0xeeeeee')
p.zoomTo()
p.show()
Out[6]:
We can also check hit 14, that has low eRMSD but (relatively) high RMSD
In [7]:
hit_14 = open(pdbs[14],'r').read()
p = py3Dmol.view(width=900,height=600,viewergrid=(1,2))
p.addModel(query_s,'pdb',viewer=(0,0))
p.addModel(hit_14,'pdb',viewer=(0,1))
p.setStyle({'stick':{}})
p.setBackgroundColor('0xeeeeee')
p.zoomTo()
p.show()
Out[7]: