# Using R to import specific records from a PDB file

I'm using R and I'm trying to import specific records from a PDB file (e.g. HETNAM, HETSYN). Unfortunately, it seems the read.pdb function of either biomaRt or Rpdb aren't capable of it.

Any ideas?

Thanks

• Hi, could you show what have you tried? As far as I know it is not so difficult to parse the files, but that depends on the format of the file you downloaded.
– llrs
Jun 8 '18 at 12:07
• Hi, nothing special, I just used the read.pdb function to read in the PDB files. Jun 8 '18 at 14:10

If your file is in PDB format as the one shown here in .pdb format then you can simply extract your desired fields using sed which is a programming language used to parse and transform text. As for this structure i.e 6C4A in .pdb format HETNAM and HETSYN can be extracted using sed as follows:

sed  -n -e '/HETNAM/ p' -e '/HETSYN/ p'  6C4A.pdb

HETNAM     EJA S-[(1Z)-2-CARBOXY-N-HYDROXYETHANIMIDOYL]-L-CYSTEINE
HETNAM     PYR PYRUVIC ACID
HETNAM      MG MAGNESIUM ION
HETNAM     3NP 3-NITROPROPANOIC ACID
HETNAM     PEG DI(HYDROXYETHYL)ETHER
HETNAM     EPE 4-(2-HYDROXYETHYL)-1-PIPERAZINE ETHANESULFONIC ACID
HETSYN     EPE HEPES

• Thanks, seems pretty straightforward. How do I use sed? Is it a way to apply it on R ? Jun 8 '18 at 14:09
• It is straight forward. Write this command on Linux command line/terminal with your input file present in current working directory. Jun 8 '18 at 15:03
• Secondly for using sed in R you should check this Jun 8 '18 at 15:09