Hello,
with python 2.7.12 and MDAnalysis 0.16.2 I find that I can make a selection with .select_atoms() and that selection is honored during print, but then the RMSD() command seems to ignore it and jump back to a section from the entire structure. The issue is that I have an overall structure with some variable number of proteins and I want to compute the RMSD of each of those sampled proteins to a single reference structure.
here is the relevant code that I used:
<pre>
thisProtein = pdbPatch.select_atoms("resid %d:%d" % (proteinStartResidue, proteinStartResidue + numResPerRas - 1))
print ("sample has %d residues" % len(thisProtein.residues))
print ("reference has %d residues" % len(pdbRef.residues))
R = RMSD(thisProtein, pdbRef, select="name BB", filename="
meow.cat", weights=None, tol_mass=999.99)
R.run()
</pre>
and the output for the printing of number of residues in the initial selection is:
<pre>
sample has 186 residues
reference has 186 residues
</pre>
but then the RMSD() function gives the error:
<pre>
MDAnalysis.exceptions.SelectionError: Reference and trajectory atom selections do not contain the same number of atoms: N_ref=184, N_traj=920
</pre>
Here is the actual complete code snippit:
<pre>
import MDAnalysis as mda
from MDAnalysis.analysis import align
from MDAnalysis.analysis.rms import RMSD
# read in the patch to MDAnalysis
pdbPatch = mda.Universe(fnameTopo, fnameTraj)
fnameRef = "/tmp/reference.pdb"
pdbRef = mda.Universe(fnameRef, fnameRef)
numResPerRas=186 # defined for this system
numAtomPerRas=42 # defined for this system
numProteins=0
analysisFileName = "sim-{}KRAS-{}-ps.rmsdGdomain".format(numKRAS, i)
analysisFileName = os.path.join(self.inpath, analysisFileName)
analysisFileHandle = open(analysisFileName, "w")
for ppr in pdbPatch.residues:
if ppr.resname == "THR":
proteinStartResidue = ppr.resid
break
while pdbPatch.residues[proteinStartResidue].resname == "THR":
numProteins += 1
thisProtein = pdbPatch.select_atoms("resid %d:%d" % (proteinStartResidue, proteinStartResidue + numResPerRas - 1))
print ("sample has %d residues" % len(thisProtein.residues))
print ("reference has %d residues" % len(pdbRef.residues))
R = RMSD(thisProtein, pdbRef, select="name BB", filename="
meow.cat", weights=None, tol_mass=999.99)
R.run()
analysisFileHandle.write("%s" % R.rmsd[0][2])
proteinStartResidue += numResPerRas
analysisFileHandle.close()
</pre>
and the complete output from this code:
<pre>
sample has 186 residues
reference has 186 residues
ERROR:MDAnalysis.analysis.rmsd:Reference and trajectory atom selections do not contain the same number of atoms: N_ref=184, N_traj=920
None
Traceback (most recent call last):
File "cganalysis.py", line 256, in <module>
main()
File "cganalysis.py", line 251, in main
cg.run()
File "cganalysis.py", line 187, in run
R = RMSD(thisProtein, pdbRef, select="name BB", filename="
meow.cat", weights=None, tol_mass=999.99)
File "/home/cneale/.local/lib/python2.7/site-packages/MDAnalysis/analysis/rms.py", line 415, in __init__
raise SelectionError(err)
MDAnalysis.exceptions.SelectionError: Reference and trajectory atom selections do not contain the same number of atoms: N_ref=184, N_traj=920
</pre>
Thank you for your suggestions,
Chris.