Select atom section of pdb object from read.pdb
Hello, I would like to know if it is possible to write a pdb files as output.
I'm doing this
pdb <- read.pdb('1abc.pdb') ## pdb object
pdb <- pdb$atom ## data.frame
##### some code to modify something such as resid, resno and so on
then I'd like to write my modified data.frame as pdb file.
So my question is: how I can do? The write.pdb function returns me this error:
Error in write.pdb(pdb, "1abc_modified.pdb") :
write.pdb: please provide a 'pdb' object or numeric 'xyz' coordinates
Comments (7)
-
-
still the same problem
as.pdb(pdb) Error in as.pdb.default(pdb) : 'pdb' must be of class 'pdb' as obtained from 'read.pdb'
-
What modifications have you made on the pdb? To pass those functions, you need to keep a valid PDB format, such as the data type, length, etc. of each column.
-
I was noticed that even doing any modification the problem persist.
pdb <- read.pdb('1abc.pdb')$atom as.pdb(pdb) Error in as.pdb.default(pdb) : 'pdb' must be of class 'pdb' as obtained from 'read.pdb'
-
Hi,
A valid ‘pdb’ object has multiple components including
$atom
. In your example above, you have extracted the$atom
component and so it becomes invalid. -
ok. How I can modify the $atom components and them save the new pdb file? Thanks
-
Simply modifying the
$atom
without extracting it. For example,pdb$atom$resno[1] <- 100
. To not overwrite the old pdb, you can create a copy first:pdb2 <- pdb
. Then, modify pdb2. - Log in to comment
You can try
as.pdb()
to convert your modified pdb to a “PDB” object.