Select atom section of pdb object from read.pdb

Issue #894 new
Former user created an issue

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)

  1. NANCY D'ARMINIO

    still the same problem 😞

    as.pdb(pdb)
    Error in as.pdb.default(pdb) :
    'pdb' must be of class 'pdb' as obtained from 'read.pdb'
    

  2. Xinqiu Yao

    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.

  3. NANCY D'ARMINIO

    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'

  4. Xinqiu Yao

    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.

  5. Xinqiu Yao

    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.

  6. Log in to comment