<p>have a list of pdbid and I want to separate the dihedral angles of some sequences in protein .</p>
<pre><code>pdbid      st          en
101m    4.A.GLU 15.A.ALA
102m    4.A.GLU 15.A.ALA
103m    4.A.GLU 15.A.ALA
104m    4.A.GLU 15.A.ALA
105m    4.A.GLU 15.A.ALA
106m    4.A.GLU 15.A.ALA
107m    4.A.GLU 15.A.ALA
</code></pre>
<ul>
<li>st is start of sequences   en is end of sequences.</li>
</ul>
<p>And after separating the dihedral angles, I want to write the
corresponding pdbid in front of it.</p>
<p>I wrote the following code:</p>
<pre><code>  library(bio3d)

  # PDB structure object as obtained from function read.pdb.
 pdb=read.pdb(df$pdbid[1])

  #Calculate all torsion angles for a given protein PDB structure object
tor=torsion.pdb(pdb)
 
            phi        psi
1.A.VAL -144.91395  137.473333
2.A.LEU -95.02097   149.7834
3.A.SER -82.68263   166.676942
4.A.GLU -62.53142   -36.263406
5.A.GLY -59.64632   -42.035533
6.A.GLU -68.69144   -40.23538
7.A.TRP -63.52969   -36.769049
8.A.GLN -64.80557   -38.512821
9.A.LEU -64.82472   -42.143097
10.A.VAL    -63.77383   -50.465974
11.A.LEU    -69.74235   -25.698665
12.A.HIS    -70.86863   -41.810178
13.A.VAL    -74.99987   -33.340633
14.A.TRP    -63.20999   -32.690374
15.A.ALA    -61.13164   -30.030673
16.A.LYS    -75.94714   -43.271738
17.A.VAL    -54.76125   -43.181171
18.A.GLU    -64.33161   -12.649873
19.A.ALA    -70.38802   -22.502227

   
    
#separating phi angles from &quot;4.A.GLU&quot; to &quot;15.A.ALA&quot;
phi=tor<span class="math-container">$phi[df$</span>st[1]:df$en[1]]

#separating psi angles
psi=tor<span class="math-container">$psi[df$</span>st[1]:df$en[1]]
print(cbind(phi,psi))

#Put the codes in the loop
for(i in 2:nrow(df))
{
  pdb=read.pdb(df<span class="math-container">$pdbid[i])
  tor=torsion.pdb(pdb)
  psi=tor$</span>psi[df<span class="math-container">$st[i]:df$</span>en[i]]
  phi=tor<span class="math-container">$phi[df$</span>st[i]:df$en[i]]
  print(cbind(phi,psi))
}
</code></pre>
<p>But I get the following error:</p>
<pre><code>Error in df$st[1]:df$en[1] : NA/NaN argument
In addition: Warning messages:
1: NAs introduced by coercion 
2: NAs introduced by coercion
</code></pre>
<pre><code>str(df)
'data.frame':   9 obs. of  3 variables:
 <span class="math-container">$ pdbid: chr  "101m" "102m" "103m" "104m" ...
 $</span> st   : chr  &quot;4.A.GLU&quot; &quot;4.A.GLU&quot; &quot;4.A.GLU&quot; &quot;4.A.GLU&quot; ...
 <span class="math-container">$ en   : chr  "15.A.ALA" "15.A.ALA" "15.A.ALA" "15.A.ALA" ...
str(tor)
List of 11
 $</span> psi   : num [1:295] 158.1 137.5 149.8 166.7 -36.3 ...
 <span class="math-container">$ phi   : num [1:295] NA -144.9 -95 -82.7 -62.5 ...
 $</span> omega : num [1:295] -179 179 177 179 179 ...
 <span class="math-container">$ chi1  : num [1:295] 54.3 175.7 -81 62.3 175.1 ...
 $</span> chi2  : num [1:295] -171.5 NA 72.7 NA 64.4 ...
 <span class="math-container">$ chi3  : num [1:295] -72.1 NA NA NA 17 ...
 $</span> chi4  : num [1:295] NA NA NA NA NA NA NA NA NA NA ...
 <span class="math-container">$ chi5  : logi [1:295] NA NA NA NA NA NA ...
 $</span> alpha : num [1:295] NA -139.4 -123.2 -108.3 58.3 ...
 <span class="math-container">$ coords: num [1:3, 1:17, 1:295] 24.28 8.37 -9.85 24.4 9.86 ...
  ..- attr(*, "dimnames")=List of 3
  .. ..$</span> xyz: chr [1:3] &quot;x&quot; &quot;y&quot; &quot;z&quot;
  .. ..<span class="math-container">$ atm: chr [1:17] "N" "CA" "C" "O" ...
  .. ..$</span> res: chr [1:295] &quot;  0.A.MET&quot; &quot;  1.A.VAL&quot; &quot;  2.A.LEU&quot; &quot;  3.A.SER&quot; ...
 <span class="math-container">$ tbl   : num [1:295, 1:7] NA -144.9 -95 -82.7 -62.5 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$</span> : chr [1:295] &quot;  0.A.MET&quot; &quot;  1.A.VAL&quot; &quot;  2.A.LEU&quot; &quot;  3.A.SER&quot; ...
  .. ..$ : chr [1:7] &quot;phi&quot; &quot;psi&quot; &quot;chi1&quot; &quot;chi2&quot; ...
</code></pre>

CC BY-SA 4.0
2022-01-28T11:42:27.980Z
Welcome to the site. This is a good report that made it easy to spot the error (the only missing piece is what did you try to solve this). There seems to be a problem on `tor$phi[df$st[1]:df$en[1]]` . Looking at the sample data they are characters, but you are using them as numbers, I'm not sure if the packages provides some kind of function to use them like that, but my guess is that it doesn't.
llrs
CC BY-SA 4.0
2022-02-01T17:45:33.770Z
NAN : not a number  ? but NA ? is it null value ?
pippo1980
CC BY-SA 4.0
2022-02-01T17:47:46.840Z
have you tried asking here : https://bitbucket.org/Grantlab/bio3d/issues
pippo1980
<r>
Separation of dihedral angles of the desired sequence in the protein
# Separation of dihedral angles of the desired sequence in the protein

(Asked by: username_0 on 2022-01-27)

have a list of pdbid and I want to separate the dihedral angles of some sequences in protein .
pdbid      st          en
101m    4.A.GLU 15.A.ALA
102m    4.A.GLU 15.A.ALA
103m    4.A.GLU 15.A.ALA
104m    4.A.GLU 15.A.ALA
105m    4.A.GLU 15.A.ALA
106m    4.A.GLU 15.A.ALA
107m    4.A.GLU 15.A.ALA


st is start of sequences   en is end of sequences.

And after separating the dihedral angles, I want to write the
corresponding pdbid in front of it.
I wrote the following code:
  library(bio3d)

  # PDB structure object as obtained from function read.pdb.
 pdb=read.pdb(df$pdbid[1])

  #Calculate all torsion angles for a given protein PDB structure object
tor=torsion.pdb(pdb)
 
            phi        psi
1.A.VAL -144.91395  137.473333
2.A.LEU -95.02097   149.7834
3.A.SER -82.68263   166.676942
4.A.GLU -62.53142   -36.263406
5.A.GLY -59.64632   -42.035533
6.A.GLU -68.69144   -40.23538
7.A.TRP -63.52969   -36.769049
8.A.GLN -64.80557   -38.512821
9.A.LEU -64.82472   -42.143097
10.A.VAL    -63.77383   -50.465974
11.A.LEU    -69.74235   -25.698665
12.A.HIS    -70.86863   -41.810178
13.A.VAL    -74.99987   -33.340633
14.A.TRP    -63.20999   -32.690374
15.A.ALA    -61.13164   -30.030673
16.A.LYS    -75.94714   -43.271738
17.A.VAL    -54.76125   -43.181171
18.A.GLU    -64.33161   -12.649873
19.A.ALA    -70.38802   -22.502227

   
    
#separating phi angles from "4.A.GLU" to "15.A.ALA"
phi=tor$phi[df$st[1]:df$en[1]]

#separating psi angles
psi=tor$psi[df$st[1]:df$en[1]]
print(cbind(phi,psi))

#Put the codes in the loop
for(i in 2:nrow(df))
{
  pdb=read.pdb(df$pdbid[i])
  tor=torsion.pdb(pdb)
  psi=tor$psi[df$st[i]:df$en[i]]
  phi=tor$phi[df$st[i]:df$en[i]]
  print(cbind(phi,psi))
}

But I get the following error:
Error in df$st[1]:df$en[1] : NA/NaN argument
In addition: Warning messages:
1: NAs introduced by coercion 
2: NAs introduced by coercion

str(df)
'data.frame':   9 obs. of  3 variables:
 $ pdbid: chr  "101m" "102m" "103m" "104m" ...
 $ st   : chr  "4.A.GLU" "4.A.GLU" "4.A.GLU" "4.A.GLU" ...
 $ en   : chr  "15.A.ALA" "15.A.ALA" "15.A.ALA" "15.A.ALA" ...
str(tor)
List of 11
 $ psi   : num [1:295] 158.1 137.5 149.8 166.7 -36.3 ...
 $ phi   : num [1:295] NA -144.9 -95 -82.7 -62.5 ...
 $ omega : num [1:295] -179 179 177 179 179 ...
 $ chi1  : num [1:295] 54.3 175.7 -81 62.3 175.1 ...
 $ chi2  : num [1:295] -171.5 NA 72.7 NA 64.4 ...
 $ chi3  : num [1:295] -72.1 NA NA NA 17 ...
 $ chi4  : num [1:295] NA NA NA NA NA NA NA NA NA NA ...
 $ chi5  : logi [1:295] NA NA NA NA NA NA ...
 $ alpha : num [1:295] NA -139.4 -123.2 -108.3 58.3 ...
 $ coords: num [1:3, 1:17, 1:295] 24.28 8.37 -9.85 24.4 9.86 ...
  ..- attr(*, "dimnames")=List of 3
  .. ..$ xyz: chr [1:3] "x" "y" "z"
  .. ..$ atm: chr [1:17] "N" "CA" "C" "O" ...
  .. ..$ res: chr [1:295] "  0.A.MET" "  1.A.VAL" "  2.A.LEU" "  3.A.SER" ...
 $ tbl   : num [1:295, 1:7] NA -144.9 -95 -82.7 -62.5 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:295] "  0.A.MET" "  1.A.VAL" "  2.A.LEU" "  3.A.SER" ...
  .. ..$ : chr [1:7] "phi" "psi" "chi1" "chi2" ...

**Tags:** r
> **Comments:**
> **username_1**: Welcome to the site. This is a good report that made it easy to spot the error (the only missing piece is what did you try to solve this). There seems to be a problem on `tor$phi[df$st[1]:df$en[1]]` . Looking at the sample data they are characters, but you are using them as numbers, I'm not sure if the packages provides some kind of function to use them like that, but my guess is that it doesn't.  
> **username_2**: NAN : not a number  ? but NA ? is it null value ?  
> **username_2**: have you tried asking here : https://bitbucket.org/Grantlab/bio3d/issues  

---

## 0 answers

