I'm trying to write a program in R which would take in a .pdb file and give out a .xyz-file.
I'm having problems with erasing some rows that contain useless data. There are around 30-40 thousand rows, from which I would only need about 3000. The rows that contain the useful information start with the word "ATOM".
In unix terminal I would just use the command
grep ATOM < filename.pdb > newfile.xyz
but I have no idea how to achieve the same result with R.
Thank you for your help!
You should be able to use
grep
, and depending on your specific situation, perhapssubstr
.For example
Note that the
substr
part limits the search to only the first three characters of each element of stringVar (e.g., "abc", "def", etc.). This may not be strictly necessary but I've found it to be very useful at times. For example, if you had an element like "defabc" that you didn't want to include, usingsubstr
would ensure it wouldn't be "found" bygrep
.Hope it's helpful.